Skip to content

feat: expose the next unused on-chain address - #134

Merged
rolznz merged 1 commit into
getAlby:mainfrom
rolandgx:feat/next-unused-onchain-address
Nov 18, 2026
Merged

rolznz merged 1 commit into
getAlby:mainfrom
rolandgx:feat/next-unused-onchain-address

Conversation

@rolandgx

Copy link
Copy Markdown

Problem

OnchainPayment::new_address derives 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

  • Add 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's next_unused_address(KeychainKind::External), which is already used for change addresses.
  • Expose it in the bindings (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_address is returned before a new one is derived.

Testing

New integration tests onchain_next_unused_address_esplora and onchain_next_unused_address_bitcoind_rpc_sync:

  • the same address is returned until it receives funds
  • an unconfirmed payment rotates it
  • an unused address from new_address is returned before a new one is derived
  • used addresses stay used across a stop/start

Both pass locally, and cargo check --features uniffi builds.

🤖 Generated with Claude Code

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]>
@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 51f434c3-049d-4fac-b4ae-26ed075bab8a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@rolznz
rolznz merged commit 561ba34 into getAlby:main Nov 18, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants