Skip to content

fix(rs-platform-wallet): reserve platform receive address on hand-out (Found-026) [backport]#3658

Draft
lklimek wants to merge 1 commit into
v3.1-devfrom
fix/found-026-v3.1-dev
Draft

fix(rs-platform-wallet): reserve platform receive address on hand-out (Found-026) [backport]#3658
lklimek wants to merge 1 commit into
v3.1-devfrom
fix/found-026-v3.1-dev

Conversation

@lklimek
Copy link
Copy Markdown
Contributor

@lklimek lklimek commented May 18, 2026

Semantic backport to v3.1-dev of the Found-026 reserve-on-hand-out fix already proven on #3549 (3/3 focused 14-thread + R2-clean + adjudicated).

Problem

key-wallet AddressPool::next_unused returns the first used==false index WITHOUT marking it; used only flips on a positive synced balance. Two concurrent callers of PlatformAddressWallet::next_unused_receive_address therefore receive the SAME address before the sync pass — duplicate-address race.

Fix

Reserve the handed-out index under the already-held wallet_manager.write() guard: swap next_unused(...) for next_unused_with_info(...), then call mark_index_used(info.index) before releasing the guard. mark_index_used is idempotent, so a later real sync hit on the index is a no-op (no gap-limit / highest_used double-counting).

Why hand-applied (not cherry-picked)

The next_unused_receive_address region diverged on v3.1-dev (different rust-dashcore pin, no Found-026 doc block, direct-Address return) so a textual cherry-pick of the #3549 commit does NOT apply. Same SEMANTIC transform re-applied by hand to v3.1-dev's own structure; verified the v3.1-dev key-wallet pin (53130869e5b...) exposes byte-identical AddressPool (next_unused_with_info, mark_index_used, AddressInfo) to the proven pin (5297d61...).

Validation

cargo check (lib + --tests), cargo clippy --lib -D warnings, cargo test --lib (121 passed, 0 failed), rustfmt — all clean. Behavioural correctness proven on #3549; v3.1-dev has no e2e harness / found_026 guards (those are #3549-only) so this PR confirms compile + no lib-test regression.

Backport sibling of #3549 / Found-026.

🤖 Generated with Claude Code

… (Found-026) [backport]

Semantic backport of the #3549-proven Found-026 reserve-on-hand-out fix.
Region diverged on v3.1-dev so re-applied by hand, not cherry-picked.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c5f94435-b41a-44ad-ad46-205bd0d191eb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/found-026-v3.1-dev

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant