Post
Topic
Board Bitcoin Technical Support
Merits 6 from 5 users
Topic OP
Withdrawal in HD wallet with very large gap of unused addresses
by
vicknick
on 19/05/2020, 05:30:37 UTC
⭐ Merited by joniboini (2) ,PrimeNumber7 (1) ,HeRetiK (1) ,o_e_l_e_o (1) ,ETFbitcoin (1)
I’m building a site where each signup users will have a permanent bitcoin address assigned to them. I am thinking of using HD wallet with extended private key to generate many bitcoin addresses for those users. Since I already have the extended private key, I don’t need to store the individual private keys for each address, making key management very simple.

However, most users don’t deposit to these addresses. As such, there could be a large unused address before a user finally make a deposit to an address, say at the millionth address. If so, when I’m trying to withdraw using my extended private key, how will the wallet withdraw in this situation. I know that you can increase the ‘gap limit’ so that the wallet keeps on scanning, but is there a better way to withdraw in this case?

Side questions:
1. If there are deposits to addresses where there are multiple large gaps in between these addresses, when I try to query for balance with extended private key, will the gap limit affect the balance shown to me? Because I’m think the wallet will stop at some point, even though there are bitcoin in the addresses subsequent after that.

2. Is it possible to combine bitcoin from different addresses when withdrawing? Say there is one bitcoin in 1st address and there is one bitcoin in the 1,000,000th address. If I want to withdraw 2 BTC, will the wallet able to combine the bitcoin from two addresses in a single transaction?