Repository navigation
feat: expose the next unused on-chain address - #134
Merged
Merged
Conversation
Add OnchainPayment::next_unused_address, which returns the first revealed receive address that has not received funds yet and only derives a new one if all of them have. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
OnchainPayment::new_addressderives a new receive address on every call. Alby Hub wants to show the same receive address until it has been paid. To do that today, it looks up the address history on an Esplora or Electrum server. With a bitcoind chain source there is no address index, so that lookup cannot be answered by the user's own node (see getAlby/hub#2712).The on-chain wallet already knows which of its addresses have received funds.
Change
OnchainPayment::next_unused_address. It returns the first revealed receive address that has not received funds yet, and only derives a new one if all of them have. It uses BDK'snext_unused_address(KeychainKind::External), which is already used for change addresses.ldk_node.udl).Whether an address is used is based on the transactions the wallet knows about, so the result is only as current as the last wallet sync. An unconfirmed payment counts as used.
An unused address handed out earlier by
new_addressis returned before a new one is derived.Testing
New integration tests
onchain_next_unused_address_esploraandonchain_next_unused_address_bitcoind_rpc_sync:new_addressis returned before a new one is derivedBoth pass locally, and
cargo check --features uniffibuilds.🤖 Generated with Claude Code