Skip to content

Instantly share code, notes, and snippets.

Last active December 8, 2021 12:20
What would you like to do?
Bitcoin address UTXO extractor based on Blockstream's API
<!DOCTYPE html>
<meta charset="utf-8">
<title>Bitcoin address UTXO extractor</title>
table, .csv { display: none }
<div class="container py-5">
<h2>Bitcoin address UTXO query</h2>
<form class="mt-3">
<div class="form-group">
<label for="address">Bitcoin address</label>
<input class="form-control" id="address" type="text" name="address">
<input class="btn btn-primary" type="submit" value="Get UTXOs">
<table class="table mt-5">
<th>block height</th>
<th>block time</th>
<div class="csv mt-5">
<p>Format: <em>txid,vout,satoshis,block_height</em></p>
<textarea class="form-control" rows="6"></textarea>
document.querySelector('form').addEventListener('submit', e => {
const address ='[name=address]').value
.then(r => r.json())
.then(utxos => {
document.querySelector('tbody').innerHTML = => `
<td><a href="${utxo.txid}/hex" target="_blank">rawtx</a></td>
<td>${utxo.status.confirmed ? '#'+utxo.status.block_height : 'unconfirmed'}</td>
<td>${utxo.status.confirmed ? new Date(utxo.status.block_time*1000).toLocaleString() : ''}</td>
document.querySelector('textarea').value = => [utxo.txid, utxo.vout, utxo.value, utxo.status.block_height || '-1'].join(',')).join("\n")
document.querySelector('table').style.display = document.querySelector('.csv').style.display = 'block'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment