Last active
February 18, 2019 10:40
-
-
Save shesek/0b4581798890e7280d4de501d7ec76e3 to your computer and use it in GitHub Desktop.
Bitcoin address UTXO extractor based on Blockstream's API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container.py-5 | |
h2 Bitcoin address UTXO query | |
form.mt-3 | |
.form-group | |
label(for='address') Bitcoin address | |
input.form-control#address(type='text', name='address') | |
input.btn.btn-primary(type='submit', value='Get UTXOs') | |
table.table.mt-5 | |
thead: tr #[th txid:vout] #[th value] #[th block height] #[th block time] | |
tbody | |
div.csv.mt-5 | |
h4 CSV | |
p Format: #[em txid,vout,satoshis,block_height] | |
textarea.form-control(rows=6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('form').submit(e => { | |
e.preventDefault() | |
const address = $(e.target).find('[name=address]').val() | |
fetch(`https://blockstream.info/api/address/${address}/utxo`) | |
.then(r => r.json()) | |
.then(utxos => { | |
$('tbody').empty().append(utxos.map(utxo => ` | |
<tr> | |
<td>${utxo.txid}:${utxo.vout}</td> | |
<td>${+utxo.value/100000000}</td> | |
<td>${utxo.status.confirmed ? '#'+utxo.status.block_height : 'unconfirmed'}</td> | |
<td>${utxo.status.confirmed ? new Date(utxo.status.block_time*1000).toLocaleString() : ''}</td> | |
</tr> | |
`)) | |
$('textarea').val(utxos.map(utxo => [utxo.txid, utxo.vout, utxo.value, utxo.status.block_height || '-1'].join(',')).join("\n")) | |
$('table,.csv').show() | |
}) | |
.catch(console.error) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table, .csv { display: none } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Available at https://codepen.io/anon/pen/YBRder