nbd-wtf / bitcoin_signet

Generic Signet Dockerfiles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix for descriptors in setup_signet.sh

benthecarman opened this issue · comments

In setup_signet.sh it says that it is not working for descriptors. This is because when putting a private key in a descriptor it needs to be WIF encoded.

here is a bash script for converting

  # Descriptors take private keys in WIF format

  # Add the testnet prefix 'ef'
  prefix_key="ef$PRIVKEY"
  # Double sha256 hash of prefix key
  double_hash=$(echo -n $prefix_key | xxd -r -p | openssl sha256 | awk '{print $2}' | xxd -r -p | openssl sha256 | awk '{print $2}')
  # Take first 4 bytes of double hash as checksum
  checksum=${double_hash:0:8}
  # Append checksum to prefix key
  checksum_key="$prefix_key$checksum"
  # Convert the final key into base58 encoding
  WIF_KEY=$(echo -n $checksum_key | xxd -r -p | base58)