View UTXO
Overview
You can view the unspent transaction output (UTXO) for any wallet containing UTXO-based coins. This is helpful, because a certain amount of UTXO is included on every outgoing transaction to cover blockchain fees. Therefore, the available UTXO in your wallet is impacted by the UTXO locked to transactions pending approval.
Prerequisites
Steps
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
import * as dotenv from "dotenv"; import {EnvironmentName} from "bitgo"; import {BitGoAPI} from "@bitgo/sdk-api"; import {Tbtc4} from "@bitgo/sdk-coin-btc"; dotenv.config(); const bitgo = new BitGoAPI({ env: process.env.ENV as EnvironmentName, accessToken: process.env.TESTNET_ACCESS_TOKEN }); const coin = 'tbtc4'; bitgo.register(coin, Tbtc4.createInstance); const walletId = process.env.WALLET_ID; async function main() { const walletInstance = await bitgo.coin(coin).wallets().get({id: walletId}); walletInstance.unspents().then(function (unspents) { // print unspents console.dir(unspents); }); } main().catch((err) => console.error(err));
Step Result
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
{ "coin": "tbtc4", "unspents": [ { "id": "003f688cc349f1fca8ac5ffa21671ca911b6ef351085c60733ed8c2ebf162cb8:2", "address": "2MsKxhhkDo5WaLaYRGA9Cr3iSQPyXsu6Fi2", "value": 0, "valueString": "2000000", "blockHeight": 0, "date": "2017-03-25T23:01:40.248Z", "coinbase": true, "wallet": "59cd72485007a239fb00282ed480da1f", "fromWallet": "59cd72485007a239fb00282ed480da1f", "chain": 0, "index": 0, "redeemScript": "522102f1e990044d2a8be43d5b500bbdcb36277b97a4b07e01c5101ae8ec1568bfd6532103dab7dc82f2fc8c28200c1bdeca9c4cf181e0ca257395829cbd599395048afb57210205422e711827d8356f2fb75334d863941dd7eb45bd5788fa231dc5fa755135b653ae", "witnessScript": "52210351311cd81144e6cbdba561d24dfc22644cb02d053339d4beace03231b3be4f372103a8d0c1a375b9ee1a2411f9f8e18373be7f228b18260f63bbfca48809170ed08b2103c3bd8bd074657bbe9ee6714b31a4a54b6fd5b5cda0e1030122f9bf46b5034f6b53ae", "isSegwit": true } ] }