citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

btc-fetchtxs (645B)


      1 #!/usr/bin/env bash
      2 
      3 BITCOIN_RPCUSER=rpcuser
      4 BITCOIN_RPCPASS=rpcpass
      5 BITCOIN_RPCPORT=${BITCOIN_RPCPORT:-8332}
      6 BITCOIN_HOST=${BITCOIN_HOST:-127.0.0.1}
      7 
      8 mkreq () {
      9     (
     10         printf '['
     11         echo ${1#","}
     12         printf ']'
     13     )
     14 }
     15 
     16 doreq() {
     17     local host="http://${BITCOIN_HOST}:${BITCOIN_RPCPORT}"
     18     mkreq "$1" |
     19     curl -s -u $BITCOIN_RPCUSER:$BITCOIN_RPCPASS \
     20         --data-binary @- \
     21         -H 'content-type: text/plain;' "$host"
     22 }
     23 
     24 make_reqs() {
     25         xargs printf ',{"jsonrpc": "1.0", "id":"get_txids", "method": "getrawtransaction", "params": ["%s", 1] }\n'
     26 }
     27 
     28 txid_reqs=$(make_reqs)
     29 
     30 doreq "$txid_reqs" | jq '.[].result'