<p>Firstly, you need to know both all the public keys, and at least the threshold (<code>M</code> for a <code>M of N</code> multisig) number of private keys.</p>
<p>You can then import the public keys, private keys, and script to <code>bitcoind</code> by using the <code>importmulti</code> RPC command and either providing an <a href="https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md" rel="nofollow noreferrer">output descriptor</a> or a a raw address / scriptPubkey (+ redeemScript / witnessScript if using a P2(W)SH).</p>
<p>To quote the help:</p>
<pre><code>$ bitcoin-cli help importmulti
importmulti &quot;requests&quot; ( &quot;options&quot; )

Import addresses/scripts (with private or public keys, redeem script (P2SH)), optionally rescanning the blockchain from the earliest creation time of the imported scripts. Requires a new wallet backup.
If an address/script is imported without all of the private keys required to spend from that address, it will be watchonly. The 'watchonly' option must be set to true in this case or a warning will be returned.
Conversely, if all the private keys are provided and the address/script is spendable, the watchonly option must be set to false, or a warning will be returned.

Note: This call can take over an hour to complete if rescan is true, during that time, other rpc calls
may report that the imported keys, addresses or scripts exist but related transactions are still missing.
Note: Use &quot;getwalletinfo&quot; to query the scanning progress.
</code></pre>

CC BY-SA 4.0
2020-08-24T21:58:05.043Z
I have the required threshold number of private keys, but none of the public keys. However, as noted above, I do have a redeem script. Also, I have spent funds from the address previously. Is it possible to extract the public keys from the redeem script or a block explorer?
user738676
CC BY-SA 4.0
2020-08-24T22:22:57.957Z
Yes, if you have the redeem script or already spent funds you are fine. You can use the `decodescript` RPC command to get pubkeys out of the redeemscript.
Antoine Poinsot
CC BY-SA 4.0
2020-08-25T11:03:02.340Z
I've executed importmulti and waited for the rescan to complete, but the wallet balance is still shown as zero. Also, ```bitcoin-cli dumpprivkey <addr>``` says 'address does not refer to a key'. I provided the following parameters to importmulti: scriptPubKey (obtained via ```bitcoin-cli getaddressinfo <addr>```), timestamp, redeemscript, pubkeys (obtained via ```bitcoin-cli decodescript <redeemscript>```, keys. Are there any other parameters that I should have provided, or where else could this have gone wrong? Didn't get an error message or warning.
user738676
CC BY-SA 4.0
2020-08-25T11:24:44.543Z
This looks correct, if the pubkeys are in the right order. Regarding the wallet balance: it's expected that's specifically the point of the rescan. Let's wait for it to finish and see if it got some utxos
Antoine Poinsot
CC BY-SA 4.0
2020-08-25T12:29:37.387Z
The rescan was already finished. I left the pubkeys in the same order as returned by ```decodescript```. Do the private keys need to be in any particular order? Note that I only have M private keys, not all N of them.
user738676
CC BY-SA 4.0
2020-08-25T12:33:17.403Z
Arf, to check that your redeemScript was correct does `decodescript` output your initial address ? Checking again the documentation of `importmulti`, i don't think you need to specify the public keys. Finally, are you sure there are funds on the address ?
Antoine Poinsot
CC BY-SA 4.0
2020-08-25T12:34:08.187Z
Also, maybe better to come to #bitcoin on freenode (IRC) for this kind of support
Antoine Poinsot
CC BY-SA 4.0
2020-08-21T10:45:07.603Z
2020-08-21T10:45:07.603Z
Antoine Poinsot
<p>I would like to import the private keys from a multisig paper wallet to Bitcoin Core. My aim is to convert the paper wallet to an electronic wallet and to be able to export the corresponding wallet.dat. What's the recommended way of doing this via the command line?</p>

CC BY-SA 4.0
2020-08-20T14:14:14.643Z
What is the format of the private key ? Raw hexadecimal or WIF ?
Antoine Poinsot
CC BY-SA 4.0
2020-08-21T10:12:51.510Z
It's WIF uncompressed.
user738676
CC BY-SA 4.0
2020-08-21T10:45:29.797Z
Do you know the script ? Did you use a P2SH or a bare multisig ?
Antoine Poinsot
CC BY-SA 4.0
2020-08-24T21:53:45.777Z
I do have a P2SH redeem script.
user738676
<bitcoin-core><multi-signature><bitcoin-cli><paper-wallet><private-key-import>
Bitcoin Core private key import
user738676
# Bitcoin Core private key import

(Asked by: username_0 on 2020-08-20)

I would like to import the private keys from a multisig paper wallet to Bitcoin Core. My aim is to convert the paper wallet to an electronic wallet and to be able to export the corresponding wallet.dat. What's the recommended way of doing this via the command line?

**Tags:** bitcoin-core, multi-signature, bitcoin-cli, paper-wallet, private-key-import

> **Comments:**
> **username_1**: What is the format of the private key ? Raw hexadecimal or WIF ?  
> **username_0**: It's WIF uncompressed.  
> **username_1**: Do you know the script ? Did you use a P2SH or a bare multisig ?  
> **username_0**: I do have a P2SH redeem script.  

---

## 1 answers

### Answer by username_1 on 2020-08-21. Score: 1

Firstly, you need to know both all the public keys, and at least the threshold (`M` for a `M of N` multisig) number of private keys.

You can then import the public keys, private keys, and script to `bitcoind` by using the `importmulti` RPC command and either providing an [output descriptor](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md) or a a raw address / scriptPubkey (+ redeemScript / witnessScript if using a P2(W)SH).

To quote the help:

```
$ bitcoin-cli help importmulti
importmulti "requests" ( "options" )

Import addresses/scripts (with private or public keys, redeem script (P2SH)), optionally rescanning the blockchain from the earliest creation time of the imported scripts. Requires a new wallet backup.
If an address/script is imported without all of the private keys required to spend from that address, it will be watchonly. The 'watchonly' option must be set to true in this case or a warning will be returned.
Conversely, if all the private keys are provided and the address/script is spendable, the watchonly option must be set to false, or a warning will be returned.

Note: This call can take over an hour to complete if rescan is true, during that time, other rpc calls
may report that the imported keys, addresses or scripts exist but related transactions are still missing.
Note: Use "getwalletinfo" to query the scanning progress.

```

> **Comments:**
> **username_0**: I have the required threshold number of private keys, but none of the public keys. However, as noted above, I do have a redeem script. Also, I have spent funds from the address previously. Is it possible to extract the public keys from the redeem script or a block explorer?  
> **username_1**: Yes, if you have the redeem script or already spent funds you are fine. You can use the `decodescript` RPC command to get pubkeys out of the redeemscript.  
> **username_0**: I've executed importmulti and waited for the rescan to complete, but the wallet balance is still shown as zero. Also, ```bitcoin-cli dumpprivkey <addr>``` says 'address does not refer to a key'. I provided the following parameters to importmulti: scriptPubKey (obtained via ```bitcoin-cli getaddressinfo <addr>```), timestamp, redeemscript, pubkeys (obtained via ```bitcoin-cli decodescript <redeemscript>```, keys. Are there any other parameters that I should have provided, or where else could this have gone wrong? Didn't get an error message or warning.  
> **username_1**: This looks correct, if the pubkeys are in the right order. Regarding the wallet balance: it's expected that's specifically the point of the rescan. Let's wait for it to finish and see if it got some utxos  
> **username_0**: The rescan was already finished. I left the pubkeys in the same order as returned by ```decodescript```. Do the private keys need to be in any particular order? Note that I only have M private keys, not all N of them.  
> **username_1**: Arf, to check that your redeemScript was correct does `decodescript` output your initial address ? Checking again the documentation of `importmulti`, i don't think you need to specify the public keys. Finally, are you sure there are funds on the address ?  
> **username_1**: Also, maybe better to come to #bitcoin on freenode (IRC) for this kind of support  

---

