1

I want to use a mnemonic phrase and BIP 39 to store the keys, and use bitcoin-core, I understand that master private keys cannot be imported at least directly and that mnemonic phrase is not supported.

Also, I know that there is the idea of re-think the wallet format of bitcoin core to use descriptors, that support key derivation using BIP32.

My idea was to use importmulti to generate a basic usable wallet with some addresses generated from the master account key.

Using https://iancoleman.io/bip39/ , I've generated a seed and mnemonic:

rebel image use energy write boil throw okay claw
umbrella advice together clarify water actress

From there I can get the account extended private key (44'/1'/0'):

tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o

From there I can build some descriptors to build usable wallet:

External

deriveaddresses "combo(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/0h/*)#quvrmfad" 0
# => ["myeHNHuNnbk1aG4WcJNkWw6foM2G64AXGF", "myeHNHuNnbk1aG4WcJNkWw6foM2G64AXGF", "tb1qcm233e9h79ntuv4c5mhsvmfhe2umvm0hsgafsf", "2N56BvNBqmkTh1Jic4GbpXSYpbtTNHUdQFw"]

Internal

deriveaddresses "wpkh(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/1h/*)#6gdaynzv" 0
# => ["tb1q5vgxy6ntsugpdde9ryhst66cz8z4c8ztp4k7qv"]

To generate the wallet, I've created an empty wallet (as I don't want to depend on backups, just the mnemonic I generated earlier), and import some addresses with importmulti:

createwallet "mnemonic-test" false true
importmulti '[{"desc": "combo(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/0h/*)#quvrmfad", "range": 10, "timestamp": "now"}, {"desc": "wpkh(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/1h/*)#6gdaynzv", "range": 10, "internal": true, "timestamp": "now"}]' '{"rescan": false}'

It seems to work, all the generated addresses are generated, there is no HD seed enabled (so the addresses are always derived from the mnemonic seed).

The problems I found is that, those addresses, are never used by bitcoin-wallet, when trying to receive bitcoin it says it cannot generate an address (does not try to use one of the already generated addresses) and when spending it says it does not have any internal address available.

Do you know how to enable those coins?

1 Answer 1

1

You cannot import private keys to the keypool. This is currently not allowed because it is generally regarded as unsafe, at least with the way that the wallet works today. There is ongoing work to change this in the future.

You could do a split wallet setup where you have a watch only wallet with the pubkeys imported into the keypool and use that for address generation and transaction creation. Then you have a wallet with just the private keys imported and you use that for signing. But that's not what you want.

If you aren't tied to using a BIP 39 seed, you could generate a 256 bit seed and use sethdseed to set the HD seed of a wallet. That would do what you want, but BIP 39 uses 512 bit seeds and not 256, so it won't work there.


Imported addresses are never automatically used when you do getnewaddress. When you import them, you need to set keypool: "true" for each imported object for that to work.

4
  • The problem is that keypool: true is only allowed when wallet private keys are disabled. but I want to use them, so I don't know how to do that.
    – eloyesp
    Commented Jan 31, 2020 at 17:31
  • Oh right. You can't then. The reason that keypool is not allowed for wallets with private keys is that we don't want users to use keys that have been exposed. Imported private keys are considered to be exposed. Importing private keys to the keypool also means that you may be reusing addresses, and we want to avoid that as well.
    – Ava Chow
    Commented Feb 1, 2020 at 1:32
  • Could I generate a mnemonic, use it to generate the 512 bit seed, split that seed in two and use the first one on bitcoin core? If I ever lost access to bitcoin core backups, I can use the same procedure to get the same seed, is that correct? does it makes sense?
    – eloyesp
    Commented Feb 3, 2020 at 14:40
  • You could do that, but the seed would be useless in any other software.
    – Ava Chow
    Commented Feb 3, 2020 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.