New RPC command suggestion for Bitcoin Core: next_index

1 reply 22 views
yield_forkFull Member
Posts: 162 · Reputation: 728
#1Jul 16, 2024, 11:58 AM
Right now in Bitcoin Core, we can import descriptors and choose the index from which the wallet will give us a new address using "getnewaddress" or in the receiving tab. So, next_index is currently just an argument, but wouldn’t it be smarter to create a new RPC command for this, like with keypoolrefill? What’s driving this suggestion? Every time we create a new address, Bitcoin Core shows that address just once, then it gets stored in the address list. This is all about privacy, so users don’t have to use the same address repeatedly. The issue here is that if someone hits get new address 100 or 1000 times, the next index would be, say, 1001. But the wallet might not instantly reflect the funds sent to that address, which can freak people out. They then have to use the newkeypool or keypoolrefill command. Maybe it would be better if Bitcoin Core only made new addresses when it sees the previous one has been used, which would solve the problem of skipping addresses. I really think this kind of fix would make managing our finances a lot easier. Is anyone else feeling this way? Or maybe an RPC command could be added to the options window, so Bitcoin Core could generate new addresses whenever we ask for them, or only create new ones when they get used, like a lot of other wallets do.
5 Reply Quote Share
ryan_nodeSenior Member
Posts: 204 · Reputation: 859
#2Jul 17, 2024, 07:26 PM
I don't understand at all what you are asking for. You can still use keypoolrefill. Why would they have to? The wallet updates next_index every time a new address is produced to the user, so they never need to use newkeypool or keypoolrefil. If the descriptor is being imported, the point of having next_index in importdescriptors is to set it from the start. There's also the range option to set the initial keypool size. That doesn't work. There are a number of common cases where you may request and give out an address, but not expect payment to that address before the next address needs to be given out. A simple example is a donation address. You may get an address to use for donations and put that up somewhere, That address may not get any payments for a very long time. In that time, someone may want to pay you, and you would want to get a new address for them. What wallet does that? I don't think any wallet actually generates addresses on the fly, rather they all do something like Core with a pregenerated lookahead. It's usually called the gap limit. Without such a lookahead, rescans are likely to fail unless you can be sure that no addresses went unused. Even in that case though, reorgs can cause an address to become "unused", so you'd still need some gap limit.
0 Reply Quote Share

Related topics