Bitcoin Outputs
Watch a Bitcoin output, such as a peg or bond UTXO, and learn when it moves and which transaction moved it.
$curl "$SECONDLAYER_API_URL/v1/bitcoin/outspend/$TXID/0" \
-H "Authorization: Bearer $SECONDLAYER_API_KEY"
const out = await sl.index.bitcoin.outspend(txid, 0);
if (out?.spent) console.log(out.spending_txid, out.mempool ? "mempool" : out.block_height);
| Answer | Means |
|---|---|
spent: false | Still unspent, including in the mempool |
mempool: true | Spent by spending_txid, not yet in a block |
confirmed: true | Spent in block_height |
spending_txid: null | Spent more than 144 blocks below the tip; note says so |
The SDK returns null on 404. Fields and errors: Output spend.
One answer is one row, read live from your Bitcoin node: Bitcoin Core 24 or later with txindex=1. Poll once per block, or more often to catch a mempool spend.