Change
Utilities for handling change outputs in transaction balancing.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Change.type
Members list
Value members
Concrete methods
Handles the diff by adjusting an existing change output at the specified index.
Handles the diff by adjusting an existing change output at the specified index.
This method is intended to be used as a diff handler function with TransactionBuilder.balanceFeeAndChangeWithTokens. It adjusts an existing change output rather than creating a new one.
Value parameters
- changeOutputIdx
-
The index of the change output to modify
- diff
-
The value difference to apply (positive to add, negative to remove)
- protocolParams
-
Protocol parameters for minAda calculations
- tx
-
The transaction to modify
Attributes
- Returns
-
Either a TxBalancingError or the modified transaction
- Throws
-
IllegalArgumentException
if changeOutputIdx is out of bounds
Finds the index of the change output in a transaction.
Finds the index of the change output in a transaction.
Currently uses a simple address match. This may need to be more sophisticated in the future to handle cases with multiple outputs to the same address.
Value parameters
- changeAddress
-
The address to look for
- tx
-
The transaction to search
Attributes
- Returns
-
The index of the first output matching the change address, or -1 if not found
Handles the change output logic for transaction balancing.
Handles the change output logic for transaction balancing.
This is the main entry point for adjusting change outputs during transaction balancing. It decides whether to create, update, or remove change outputs based on the value difference.
- If diff is zero and no tokens, may remove an empty change output
- If diff is positive or has positive tokens, adds to or creates a change output
- If diff is negative, removes from the existing change output
Value parameters
- changeAddress
-
The address to use for the change output
- diff
-
The value difference to handle (inputs - outputs - fee)
- protocolParams
-
Protocol parameters for minAda calculations
- tx
-
The transaction to modify
Attributes
- Returns
-
Either a TxBalancingError or the modified transaction