Skip to content

Instantly share code, notes, and snippets.

@vindard
vindard / taproot.sh
Last active May 14, 2021 16:52 — forked from mutatrum/taproot.sh
Print a taproot signalling block diagram
#!/bin/bash
BLOCKCHAININFO=$(bitcoin-cli getblockchaininfo)
BLOCKS=$(echo "$BLOCKCHAININFO" | jq .blocks)
TAPROOT=$(echo "$BLOCKCHAININFO" | jq .softforks.taproot.bip9)
SINCE=$(echo "$TAPROOT" | jq .since)
PERIOD=$(echo "$TAPROOT" | jq .statistics.period)
BLOCKS=$(echo "$BLOCKCHAININFO" | jq .blocks)
PERIOD_COUNT=$(((BLOCKS - SINCE) / PERIOD))
SINCE=$((SINCE + (PERIOD * PERIOD_COUNT)))
ELAPSED=$(echo "$TAPROOT" | jq .statistics.elapsed)
@vindard
vindard / xpub_zpub_convert.py
Created May 8, 2021 17:34 — forked from freenancial/xpub_zpub_convert.py
Convert xpub/xprv to zpub/zprv
import base58
x = 'xprv9s21ZrQH143K2f55zo5GiXiX16MiPzBgc2bEXNd77e1ooGsjxAyXjozyuniqiSB76VESjTW8s7vdsK3NFboha6tZgF9BzcDdNtUT6Aw99P2'
zp = b'\x04\xb2\x43\x0c'
base58.b58encode_check(zp + base58.b58decode_check(x)[4:]).decode('ascii')
# output: 'zprvAWgYBBk7JR8GjFTKfWeX8huXM2ecHEAgSFdg6AQssemZuUWCTVJeywKFxCe1iFUwumU4EQhFnSdjdtGVgzdjAaFmQvY3ARrbvLbjsLf6oNE'
# xprv = b'\x04\x88\xad\xe4'
# yprv = b'\x04\x9d\x78\x78'
# zprv = b'\x04\xb2\x43\x0c'