How to generate p2wpkh addresses (bc1) using Xpriv (dumpprivkey fails for non-legacy)

6 replies 35 views
sage_moonSenior Member
Posts: 273 · Reputation: 1371
#1Nov 3, 2018, 12:18 AM
Every now and then, we need to back up our private keys from Bitcoin Core using the dumpprivkey command, but it doesn't work since it's only for legacy wallets and doesn't handle descriptor wallets. Here’s how to get around that: First, grab your xpriv using this command in the Bitcoin Core console: After you've got your xpriv, just plug it into the Python code below and decide how many addresses you want to create: This will give you a text file with your private keys in WIF format.
4 Reply Quote Share
Posts: 5 · Reputation: 141
#2Nov 3, 2018, 04:53 AM
How to import an existing private key or address into the core wallet?
3 Reply Quote Share
sage_moonSenior Member
Posts: 273 · Reputation: 1371
#3Nov 3, 2018, 07:42 AM
This post might help you: https://bitcoin.stackexchange.com/questions/113846/how-can-a-private-key-be-imported-to-a-descriptor-wallet
1 Reply Quote Share
yield_forkFull Member
Posts: 162 · Reputation: 728
#4Nov 3, 2018, 01:42 PM
From what I've tested, this script dumps private keys for bech32 addresses, only receiving addresses. To dump change addresses and other scripts addresses (legacy, p2sh-segwit and bech32m) you should add more functions to this script as I described. I have a similar script, you can base it on it, at the moment it only accepts mnemonics and bip39 passphrases, but you can make changes to allow for the inclusion of extended private keys. Do you mean importing a single private key or an extended private key (xpriv)? If you want to import single private keys from one or more addresses, I have a guide, you can access it through the link: [HOW-TO] Import privkeys into a Bitcoin Core descriptor wallet To import all addresses from a wallet derived from an xpriv, follow this thread: How to import an xpriv to a descriptor wallet in bitcoin core?
6 Reply Quote Share
sage_moonSenior Member
Posts: 273 · Reputation: 1371
#5Nov 3, 2018, 06:43 PM
thanks for the suggestions, i know this topic can be a pain for many users, the existing tools are discontinued, and are not friendly for the average non-programmer, so in my spare time i'm making an easy to use open source software to: derive address from xprivderive address from wallet.dat(descriptor, sqlite)extract address from wallet.dat(legacy, berkeleydb)(old)fix wallet.dat (corrupt) both descriptor and legacy. maybe next month i'll finish it (if my streak of bad luck ends)
1 Reply Quote Share
0xMaxiFull Member
Posts: 87 · Reputation: 378
#6Nov 3, 2018, 11:24 PM
Thank you for posting this here. I think there is a lack of software that calculates keys independently of the core client. There is the Ian Coleman tool. See: https://github.com/iancoleman/bip39 But the tool does not support taproot, for example. It would be fantastic if there was an easy-to-use tool for this too. I absolutely understand that you want to check the calculations twice. But let's assume we trust the core client and the math. Why don't you simply save the output of I have already used it to completely restore wallets (as a test). It can also be encrypted. Linux command line: And it fits easily into a QR code. You can of course also print out the QR code. That's just an idea. And quite independently of that, I find your project very useful.
2 Reply Quote Share
sage_moonSenior Member
Posts: 273 · Reputation: 1371
#7Nov 4, 2018, 12:47 AM
Thank you,  I'm doing this with users with little computer knowledge in mind. There are people who don't even know that the console exists. If we want a larger adoption of Bitcoin, we need to create user-friendly tools.
2 Reply Quote Share

Related topics