ShelleyTransactionBodyLogic extension

Handle balance checks and generating/modifying the correct change output so that the sum of inputs and output is zero (i.e. is balanced).

on

Methods

balancedOutputsWithChange({required ShelleyAddress changeAddress, required BlockchainCache cache, Coin fee = 0}) → Result<List<ShelleyTransactionOutput>, String>
Balance transaction by adding/modifying change outputs to match inputs and fee. If no change adjustments are needed, returns input list. All native tokens must have a CurrencyAsset in the cache. To avoid adding multiple change outputs, changeAddress should be the same for a given tx.
firstWhere(List<ShelleyTransactionOutput> list, String address) ShelleyTransactionOutput?
sumCurrencyIO({required BlockchainCache cache, Coin fee = 0, Logger? logger}) → Result<Map<AssetId, Coin>, String>
Sum currency amounts accross transaction. The sums should all be zero if the transaction is balanced. All transactions referenced by the inputs must be in the cache.
transactionIsBalanced({required BlockchainCache cache, Coin fee = 0}) → Result<bool, String>
just return true or false if the transaction is balanced.