Skip to content

Instantly share code, notes, and snippets.

@kevinho
Forked from shesek/bitcoin-address-utxo.html
Created July 12, 2023 02:36
Show Gist options
  • Select an option

  • Save kevinho/1168f490f9e7943dbf608739e44b7a0b to your computer and use it in GitHub Desktop.

Select an option

Save kevinho/1168f490f9e7943dbf608739e44b7a0b to your computer and use it in GitHub Desktop.

Revisions

  1. @shesek shesek revised this gist Feb 18, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bitcoin-address-utxo.html
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,7 @@ <h4>CSV</h4>
    .then(utxos => {
    document.querySelector('tbody').innerHTML = utxos.map(utxo => `
    <tr>
    <td><a href="https://blockstream.info/api/tx/${utxo.txid}/hex">rawtx</a></td>
    <td><a href="https://blockstream.info/api/tx/${utxo.txid}/hex" target="_blank">rawtx</a></td>
    <td>${utxo.txid}:${utxo.vout}</td>
    <td>${+utxo.value/100000000}</td>
    <td>${utxo.status.confirmed ? '#'+utxo.status.block_height : 'unconfirmed'}</td>
  2. @shesek shesek revised this gist Feb 18, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions bitcoin-address-utxo.html
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,7 @@ <h2>Bitcoin address UTXO query</h2>
    <table class="table mt-5">
    <thead>
    <tr>
    <th></th>
    <th>txid:vout</th>
    <th>value</th>
    <th>block height</th>
    @@ -40,6 +41,7 @@ <h4>CSV</h4>
    .then(utxos => {
    document.querySelector('tbody').innerHTML = utxos.map(utxo => `
    <tr>
    <td><a href="https://blockstream.info/api/tx/${utxo.txid}/hex">rawtx</a></td>
    <td>${utxo.txid}:${utxo.vout}</td>
    <td>${+utxo.value/100000000}</td>
    <td>${utxo.status.confirmed ? '#'+utxo.status.block_height : 'unconfirmed'}</td>
  3. @shesek shesek revised this gist Feb 18, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bitcoin-address-utxo.html
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <!DOCTYPE html>
    <meta charset="utf-8">
    <title>BItcoin address UTXO extractor</title>
    <title>Bitcoin address UTXO extractor</title>
    <style>
    table, .csv { display: none }
    </style>
  4. @shesek shesek revised this gist Feb 18, 2019. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions bitcoin-address-utxo.html
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,12 @@
    <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"></div><input class="btn btn-primary" type="submit" value="Get UTXOs"></form>
    <div class="form-group">
    <label for="address">Bitcoin address</label>
    <input class="form-control" id="address" type="text" name="address">
    </div>
    <input class="btn btn-primary" type="submit" value="Get UTXOs">
    </form>
    <table class="table mt-5">
    <thead>
    <tr>
    @@ -21,7 +26,8 @@ <h2>Bitcoin address UTXO query</h2>
    </table>
    <div class="csv mt-5">
    <h4>CSV</h4>
    <p>Format: <em>txid,vout,satoshis,block_height</em></p><textarea class="form-control" rows="6"></textarea>
    <p>Format: <em>txid,vout,satoshis,block_height</em></p>
    <textarea class="form-control" rows="6"></textarea>
    </div>
    </div>

  5. @shesek shesek created this gist Feb 18, 2019.
    48 changes: 48 additions & 0 deletions bitcoin-address-utxo.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    <!DOCTYPE html>
    <meta charset="utf-8">
    <title>BItcoin address UTXO extractor</title>
    <style>
    table, .csv { display: none }
    </style>
    <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"></div><input class="btn btn-primary" type="submit" value="Get UTXOs"></form>
    <table class="table mt-5">
    <thead>
    <tr>
    <th>txid:vout</th>
    <th>value</th>
    <th>block height</th>
    <th>block time</th>
    </tr>
    </thead>
    <tbody></tbody>
    </table>
    <div class="csv mt-5">
    <h4>CSV</h4>
    <p>Format: <em>txid,vout,satoshis,block_height</em></p><textarea class="form-control" rows="6"></textarea>
    </div>
    </div>

    <script>
    document.querySelector('form').addEventListener('submit', e => {
    e.preventDefault()
    const address = e.target.querySelector('[name=address]').value
    fetch(`https://blockstream.info/api/address/${address}/utxo`)
    .then(r => r.json())
    .then(utxos => {
    document.querySelector('tbody').innerHTML = 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>
    `).join('')
    document.querySelector('textarea').value = utxos.map(utxo => [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'
    })
    .catch(console.error)
    })
    </script>