getBalanceFromUtxos()
getBalanceFromUtxos() is a utility function from privacycash/utils used to calculate the total balance from a set of SOL UTXOs (Unspent Transaction Outputs).
Parameters
| Parameter | Type | Description |
|---|---|---|
utxos | Utxo[] | An array of UTXO objects, typically retrieved using getUtxos(). |
Return Value
The function returns an object containing the balance information:| Property | Type | Description |
|---|---|---|
lamports | number | The total balance in lamports. |
Example Usage
getUtxos()
getUtxos() is used to fetch all valid private UTXOs for a given user.
Parameters
| Parameter | Type | Description |
|---|---|---|
connection | Connection | Solana web3 connection object. |
publicKey | PublicKey | The user’s Solana public key. |
storage | Storage | A storage object (e.g., localStorage). |
encryptionService | EncryptionService | The encryption service to decrypt UTXO data. |
offset | number | (optional) utxo fetch offset |
Example Usage
getBalanceFromUtxosSPL()
getBalanceFromUtxosSPL() calculates the total balance from a set of SPL token UTXOs.
Parameters
| Parameter | Type | Description |
|---|---|---|
utxos | Utxo[] | An array of UTXO objects, retrieved using getUtxosSPL(). |
Return Value
| Property | Type | Description |
|---|---|---|
base_units | number | The total balance in base units. |
getUtxosSPL()
getUtxosSPL() is used to fetch all valid private SPL token UTXOs for a given user and specific token mint.
Parameters
| Parameter | Type | Description |
|---|---|---|
connection | Connection | Solana web3 connection object. |
publicKey | PublicKey | The user’s Solana public key. |
storage | Storage | A storage object (e.g., localStorage). |
encryptionService | EncryptionService | The encryption service. |
mintAddress | PublicKey or string | The mint address of the SPL token. |
offset | number | (optional) utxo fetch offset |
