Help with Bitcoin Address Generation Process

4 replies 152 views
mr_hawkMember
Posts: 2 · Reputation: 242
#1Nov 8, 2019, 07:46 AM
Hey everyone, I'm back to a project I paused, and it involves users getting unique Bitcoin deposit addresses. Big thing on my mind is backing up private keys so I don't lose them if my bitcoin node goes down. A while back, I created a bunch of addresses using 'getnewaddress', tagged half as 'change', then dumped the private keys, encrypted the file, and stored it safely. So if disaster strikes, I can just import those keys on a new setup.
4 Reply Quote Share
0xChadNewbie
Posts: 513 · Reputation: 3
#2Nov 9, 2019, 05:08 AM
That makes sense. When you use descriptors, the ones where "internal: true" are for change addresses, right? Those don't show up when using 'getnewaddress'. And remember the "range" values? They decide how many keys Bitcoin Core checks for transactions. The default is 1000 keys from the last used one, so you might want to tweak that when importing descriptors.
4 Reply Quote Share
diamondhandsHero Member
Posts: 200 · Reputation: 2112
#3Nov 9, 2019, 07:47 AM
Yep, exactly. The descriptors are slightly different, but you import similarly. Just change the derivation path, like replacing "0" with "1" for change addresses. With descriptor wallets, you skip all the pre-generating stuff. Just need a non-hardened derivation and the master public key to derive public keys from it.
5 Reply Quote Share
mr_hawkMember
Posts: 2 · Reputation: 242
#4Nov 9, 2019, 09:17 AM
Thanks for the info, guys! I think my descriptors are hardened since they have single quotes. So if I save the output of "listdescriptors true", can I retrieve all my coins later, whether they're change or not? And is "fundrawtransaction" really the best way to handle UTXOs? Should I just forget about "sendtoaddress"?
0 Reply Quote Share
diamondhandsHero Member
Posts: 200 · Reputation: 2112
#5Nov 9, 2019, 12:22 PM
Yeah, but be careful. Using defaults might not make all keys hardened. You can check against my example to see if yours match up. For deriving, you only need the "tpub" keys. "tprv" is only for spending. I usually handpick inputs and outputs because the Core wallet tends to estimate fees too high.
3 Reply Quote Share

Related topics