how to dump private key from multisig address

1

how to dump private key from multisig address ? I tried with dumpprivkey RPC function but return error : Address does not refer to a key

Billy Adelphia

Posted 2018-11-26T10:24:21.887

Reputation: 165

Answers

1

You can't dump the private key for a multisig address because there are multiple key pairs (thus multiple possible private keys) assigned to the address. You need to specify which key pair you want. First, get the public keys belonging to that address by using:

$ bitcoin-cli getaddressinfo <your address>

{
  "address": "<your address>",
  ...
  "embedded": {
    ...
    "pubkeys": [
      "<pubkey 1>",
      "<pubkey n>",
      "..."
    ],
   ...
}

Assuming you want the private key corresponding to <pubkey 1>, you can convert it to a simple P2PKH address and then use dumpprivkey, for example:

$ hash160 <pubkey 1>
  <pubkey 1 hash>
$ echo 00<pubkey 1 hash> | xxd -r -p | base58 -c
  <P2PKH address>
$ bitcoin-cli dumpprivkey <P2PKH address>
  <privkey>

Where hash160 is just a bash script that uses openssl:

#!/bin/bash
## Command Line parsing
#######################

if [[ $# -lt 1 ]]; then
    echo "Usage: $ hash160 <input-hex>"
    exit 1
fi

inputHex=$1

hash1="$(printf $inputHex | xxd -r -p | openssl sha256 | cut -c 10-)"
printf $hash1 | xxd -r -p | openssl ripemd160 | cut -c 10-

JBaczuk

Posted 2018-11-26T10:24:21.887

Reputation: 6 172

very usefull, work on my caseBilly Adelphia 2018-11-27T01:06:35.527