Class BalanceChanges
Utilities for computing balance changes (XRP and issued currencies) from transaction metadata's affected nodes.
Inheritance
Namespace: Xrpl.Utils
Assembly: Xrpl.dll
Syntax
public static class BalanceChanges
Methods
| Edit this page View SourceGetBalanceChanges(ITransactionMetadata)
Computes balance changes per account from transaction metadata.
Declaration
public static Dictionary<string, List<Currency>> GetBalanceChanges(ITransactionMetadata metadata)
Parameters
| Type | Name | Description |
|---|---|---|
| ITransactionMetadata | metadata | Transaction metadata including affected nodes. |
Returns
| Type | Description |
|---|---|
| Dictionary<string, List<Currency>> | Dictionary mapping account addresses to balance changes (XRP string or IssuedCurrencyAmount). |
Remarks
This walks every affected node and computes a delta for every account on the payment path, not only the one the caller has in mind. The amounts it reads are therefore untrusted: it is enough for a payment to route through an offer in somebody's own token for a value beyond decimal to reach this code, and then AmountOutOfRangeException comes out - see issue #148.
That matters most to anything that re-reads history. A monitor catching up over a ledger range, an indexer or a reconciler meets the same transaction on every pass, so an unguarded call does not fail once, it stops there permanently. Catch it and decide what an unrepresentable balance means for you; issue #150 tracks representing it instead.
Exceptions
| Type | Condition |
|---|---|
| AmountOutOfRangeException | An amount in the metadata exceeds what decimal can hold. |