6

I'm using Bitcoin Core 0.17, and using bitcoin-cli getaddressinfo method to extract xpub for a given address.

This xpub is 66 characters long, and I'm using BTCPayServer which needs this xpub and I've to select one of the following address type corresponding to this:

  • P2WPKH
  • P2SH-P2WPKH
  • P2PKH

What I'm trying to do : I'm trying to link my wallet to BTCPayServer, in order to do so their admin panel needs an input for xpub and it also asks to specify the exact format of that xpub/derivation scheme. I don't want to use a wallet like electrum so I'm creating my own private keys through bitcoin-cli

enter image description here

2
  • 1
    Maybe first explain what you're trying to do. Sep 1, 2019 at 6:25
  • I've edited my question, added screenshot where this information is to be input
    – WhoIsNinja
    Sep 1, 2019 at 6:51

1 Answer 1

15

This is not currently possible, as Bitcoin Core uses hardened BIP32 derivation to compute keys and addresses. This derivation scheme does not have a usable xpub that lets you derive the same keys publicly.

For more background, an xpub (or extended public key) is a string defined by BIP32. Every xpub has a corresponding xprv (extended private key). From the xpub one can derive a large number of child public keys, whose private keys can be derived from the corresponding xprv. This permits watching a large number of addresses without explicitly transferring all public keys.

The downside is that the xpub derivation scheme has a weakness: if an attacker knows the private key of any of the child keys and the xpub, he can compute the private key of all child keys. Because of this corcern, Bitcoin Core does not currently support xpub-compatible key derivation.

This will likely change in a future version with the introduction of descriptor wallets, which are far more flexible in specifying what keys and addresses belong to the wallet.

3
  • understood, that makes sense. so now, if I still want to link it to my bitcoin-cli generated xpub. What's the best way to convert that 66 char xpub to one of the desired formats using a tool or wallet ? (I understand it will be less secure)
    – WhoIsNinja
    Sep 2, 2019 at 2:59
  • 5
    You can't convert it. This functionality is simply not possible; the keys generated by Bitcoin Core cannot be predicted by an xpub. You can use other wallet software, however. Sep 2, 2019 at 3:10
  • 1
    Time to update this answer? I think with listdescriptors RPC it's possible.
    – rustyx
    Aug 13, 2022 at 21:45

Your Answer

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

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