bitcoindevkit / bdk

A modern, lightweight, descriptor-based wallet library written in Rust!
Other
873 stars 314 forks source link

Address gap limit? #1577

Open evanlinjin opened 3 months ago

evanlinjin commented 3 months ago

Describe the situation

An undisclosed user of ours ran into an issue where creating multiple unbroadcasted transactions resulted in incrementing the revealed index for the internal keychain too rapidly. Eventually, the gap of unused addresses surpassed the stop_gap set for the spk-based chain source, thus some transactions were not caught by the syncing process.

This is caused by Wallet::create_tx which marks change addresses as used. https://github.com/bitcoindevkit/bdk/blob/775e4aee3a9ec2d99adb129f7a9367a3a15c7032/crates/wallet/src/wallet/mod.rs#L1460

The correct use of the current API would be to call Wallet::cancel_tx. However, I would argue that this is unwieldy and not immediately apparent. https://github.com/bitcoindevkit/bdk/blob/775e4aee3a9ec2d99adb129f7a9367a3a15c7032/crates/wallet/src/wallet/mod.rs#L1963

Also, recently another user mentioned trying to implement some sort of address-recycling logic on Discord @ #bdk-users.

What to do

Not sure, let's discuss.

notmandatory commented 2 months ago

Is this fixed by #1579 ?

LLFourn commented 2 months ago

This is an issue about a new feature that would stop revealing new addresses passed the stop gap. It's related to #1579 as it would have softened the problem for the user who doesn't called cancel_tx but it is not fixed by resolving that.

notmandatory commented 2 months ago

If this a new feature request can we move it out of the 1.0 beta milestone?