View UTXO
List unspent transaction outputs for a UTXO-based wallet. See the Guide.
-
You view the unspent transaction outputs (UTXOs) for any wallet containing UTXO-based coins. This is helpful because every outgoing transaction includes a certain amount of UTXO to cover blockchain fees. The UTXO locked to transactions pending approval impacts the available UTXO in your wallet.
Prerequisites: You must have completed Get Started and Create Wallets.
// 1. List Unspents
export COIN="tbtc4"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X GET \
https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/unspents \
-H "Authorization: Bearer $ACCESS_TOKEN"
// 1. List Unspents
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));
Response
// 1. List Unspents Response
{
"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
}
]
}