Add get unspent tokens function to base wallet

This commit is contained in:
devperate
2025-08-09 22:08:46 +00:00
committed by Jim Hamill
parent be0bea5a20
commit f2d4a811f4
+15
View File
@@ -146,6 +146,21 @@ export abstract class BaseWallet<
*/
abstract getUnspents(): Promise<BlockchainUTXOs>;
/**
* Fetch all unspents tokens from the blockchain belonging to this wallet.
*/
async getUnspentTokens(): Promise<BlockchainUTXOs> {
// Get the unspents.
const unspents = await this.getUnspents();
// Filter to get only the utxos that contain tokens
const unspentTokens = unspents.filter((utxo) => {
return Boolean(utxo.utxo.output.token);
});
return unspentTokens;
};
/**
* Fetch all unspents from the blockchain belonging to this wallet.
*