Skip to content

feat(platform-wallet): reserve DashPay payout addresses without Core funding - #4623

Merged
PastaPastaPasta merged 6 commits into
v5.1-devfrom
feat/dashpay-payout-address
Oct 6, 2026
Merged

PastaPastaPasta merged 6 commits into
v5.1-devfrom
feat/dashpay-payout-address

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Supersedes #4614 (re-opened from the main repo so the Rust/Swift CI jobs run on it).

Issue being fixed or feature implemented

DashPay contact payments currently expose a combined address-resolution and Core-funded send operation. Wallets with Platform or shielded funds cannot obtain a fresh DIP-15 contact destination without selecting transparent Core inputs.

What was done?

Add DashPayView::reserve_payment_address and the Swift ManagedPlatformWallet.reserveDashPayPaymentAddress(fromIdentityId:toContactIdentityId:) wrapper through the C FFI. The operation completes the seed-verified deferred contact-crypto drain, consumes an address from the authoritative wallet/owner/contact external account pool, and persists and flushes its used flag before returning it.

Core sends and external payout reservations share the derivation helper and a per-wallet gate that keeps their pool snapshots ordered. Core broadcasts release the gate while awaiting the network, then reacquire it before a definitive rejection's address rollback. The Swift wrapper retains its mnemonic resolver throughout the FFI call and frees the returned string.

Callers reserve only when submitting a confirmed payment. Exposed addresses stay consumed after cancellation, rejected withdrawal, or an unknown outcome; this API does not submit the withdrawal or record payment history. The companion iOS change owns the submitted-withdrawal history.

How Has This Been Tested?

  • Rust DashPay payments unit suite: 64 passed, including zero-Core-balance reservations, wallet/identity/contact scoping, persisted rotation shared with a subsequent Core send, store/flush failure, wrong-seed rejection, deferred contact setup, preservation across a concurrent Core rejection, and a multithreaded test that parks one reservation inside the host store and proves a competing reservation cannot snapshot or persist ahead of it (fails when the gate acquisition is removed).
  • cargo clippy -p platform-wallet -p platform-wallet-ffi --lib (only pre-existing upstream warnings).
  • cargo fmt -p platform-wallet -p platform-wallet-ffi --check and git diff --check.
  • iOS simulator release FFI build and SwiftExampleApp Xcode build.

Real testnet validation used two registered DashPay contacts: a 0.02 DASH Platform withdrawal with zero Transparent balance and a user-submitted 0.1 DASH Shielded withdrawal paid the reserved addresses. Recipient receipt verification used a combined test build with the separate AssetUnlock discovery fix in dashpay/rust-dashcore#1004. Screenshots and exact build provenance.

The receipt fix needs a separate upstream SDK dependency update. This PR only adds address reservation and leaves the existing rust-dashcore dependencies unchanged.

Breaking Changes

None. The existing Core-funded send API remains available.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

This pull request was created by Codex.

Summary by CodeRabbit

  • New Features

    • Added the ability to reserve a fresh DashPay contact payment address without sending a payment.
    • Exposed contact payment address reservation through the Swift SDK.
    • Reserved addresses are persisted and returned for use in Platform or shielded withdrawals.
  • Bug Fixes

    • Improved reliability when multiple contact payments or withdrawals are processed concurrently.
    • Enhanced handling of rejected payment broadcasts to maintain address-pool consistency.

PR Hygiene · 5850e7c

  • Bots — coderabbitai skipped after the window · thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Build green
  • Approvals
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/src/dashpay.rs) — approved by llbartekll
    • rs-platform-wallet (packages/rs-platform-wallet/src/wallet/identity/network/payment_handler.rs, packages/rs-platform-wallet/src/wallet/identity/network/payments.rs, packages/rs-platform-wallet/src/wallet/persister.rs) — approved by llbartekll
    • swift-sdk (packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift) — approved by llbartekll

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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: Repository: dashpay/platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f4916f5d-c46e-4574-a340-e5488c42e576

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: b8603ace-3a5e-460b-9dc2-17d1dd9151c0

📥 Commits

Reviewing files that changed from the base of the PR and between 34fa594 and 19e0b60.

📒 Files selected for processing (4)
  • packages/rs-platform-wallet-ffi/src/dashpay.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/payments.rs
  • packages/rs-platform-wallet/src/wallet/persister.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds DashPay contact payment address reservation across wallet logic, FFI, and Swift SDK layers. It serializes contact-payment persistence, updates payment sending and rollback paths, and adds coverage for persistence and concurrency behavior.

Changes

DashPay payment address reservation

Layer / File(s) Summary
Wallet reservation and serialization
packages/rs-platform-wallet/src/wallet/identity/network/payments.rs, packages/rs-platform-wallet/src/wallet/persister.rs
The wallet derives and consumes contact addresses, persists and flushes pool changes, and serializes contact-payment operations. send_payment reuses the reservation helper and reacquires the gate for rejected-broadcast rollback. Tests cover persistence failures, concurrency ordering, address rotation, and deferred contact-crypto draining.
FFI reservation entry point
packages/rs-platform-wallet-ffi/src/dashpay.rs
The FFI function validates pointers and identity IDs, calls wallet reservation, maps SeedMismatch, and returns an owned C string.
Swift SDK wrapper
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift
The Swift method marshals identity IDs, keeps the mnemonic resolver alive during the FFI call, frees the returned string, and throws on failure or a missing address.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ManagedPlatformWallet
  participant DashPayFFI
  participant DashPayView
  participant WalletPersister
  ManagedPlatformWallet->>DashPayFFI: reserveDashPayPaymentAddress
  DashPayFFI->>DashPayView: reserve_payment_address
  DashPayView->>WalletPersister: persist and flush consumed address
  WalletPersister-->>DashPayView: persistence result
  DashPayView-->>DashPayFFI: reserved address or error
  DashPayFFI-->>ManagedPlatformWallet: address string or FFI error
Loading

Merge Risk: ⚪ Minimal · up to 19e0b

The reservation flow is mergeable based on the supplied evidence, with no actionable risk remaining.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.17% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: reserving DashPay payout addresses without requiring Core funding.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@thepastaclaw

thepastaclaw commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 5850e7c)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 2 only (queue backlog)

Verified the supplied findings against the exact head and confirmed one nonblocking coverage gap: the new concurrency test checks progress during broadcast, but does not exercise overlapping pool persistence protected by the payment gate. No in-scope blocking defect was confirmed. The existing Swift persistence acknowledgement behavior is retained as a separate follow-up; independent validation here was source inspection and a passing diff whitespace check, not a rerun of the reported test suites.

Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

Review provenance

  • Triage: critical by gpt-6-astra (effort low) — The change touches funds-related address derivation, durable address-consumption state, concurrent Core-send rollback ordering, seed verification, and Rust/Swift FFI ownership, where errors could cause address reuse, incorrect payment destinations, or wallet-state corruption.
  • Phase 1 reviewers: not run (skipped for throughput: 63 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer

🟡 1 suggestion(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-platform-wallet/src/wallet/identity/network/payments.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:6194-6201: Exercise overlapping persistence to protect the new payment gate
  The reservation completes its store and flush before this test releases the rejecting broadcaster. This verifies that reservation can proceed during broadcast and that the subsequent rollback preserves it, but does not exercise the stale-snapshot ordering that the new payment gate prevents. The default current-thread Tokio test and synchronous persistence callbacks do not overlap these snapshot/store sequences. Add a deterministic multithreaded test that pauses a pool store after snapshot capture, starts a competing reservation or rejection rollback, and verifies that the competing operation cannot persist ahead of the paused operation. Ensure the test fails when the corresponding gate acquisition is removed, so an older whole-pool snapshot cannot silently overwrite a newer reservation's used flag.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Make required address-pool persistence acknowledgements fail closed — PlatformWalletPersistenceHandler.swift:3559–3560 acknowledges a missing parent account for every account type except IdentityInvitation, and fetchAccount at lines 3763–3783 converts fetch failures into lookup misses. The address-pool callback consequently can return zero without staging a DashPay pool update, which the Rust persister treats as success. This deliberate tolerance for ordinary address sync predates the PR and already applies to Core-funded contact sends, but it can leave a payment-address used flag unpersisted and permit reuse after reload.
    • Follow-up: Track a separate persistence-contract change that distinguishes required payment reservation writes from tolerant background synchronization, with Swift-backed failure-injection coverage for DashPay account lookup failures.

@llbartekll llbartekll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The design looks right to me: one shared derivation helper for Core sends and external payouts, a per-wallet gate that keeps pool snapshots ordered (released across the broadcast, re-taken for the rejection rollback), and store + flush before the address is ever exposed. Lock order is gate -> wallet-manager write lock at all three sites, the gate is a shared Arc on the once-per-wallet WalletPersister, and host persistence never runs under the manager guard. The Swift wrapper mirrors sendDashPayPayment including the extended-lifetime resolver and the string free.

Requesting changes for one thing only: the branch no longer compiles once merged into current v4.2-dev. The base bumped rust-dashcore (393b612 -> e4208c9) and Mnemonic::from_phrase now takes a single argument. Git merges this PR cleanly, but the three new tests still use the old two-argument form, so cargo test -p platform-wallet fails with 6 errors on the merge result (E0433 + E0061 at each site). PR CI is green only because it ran before the bump landed. With those three lines fixed the merged tree passes 63/63 payments tests, and clippy on both crates is clean for the touched files. Details inline. A rebase so CI runs on the current base would be good too.

Two non-blocking suggestions:

  1. FFI wait pattern. Since this branch forked, platform_wallet_pending_contact_crypto_count and platform_wallet_drainable_contact_crypto_count were changed to look the identity up under the registry guard and block_on_worker outside it, because waiting on wallet_manager inside the guard stalls platform_wallet_destroy and every other registry reader. The new platform_wallet_reserve_dashpay_payment_address uses the older inside-the-guard shape. It is consistent with its sibling platform_wallet_send_dashpay_payment, so not blocking, but this call also waits on the new payment gate and on host persistence, so it is a good candidate for the newer pattern while you are rebasing.

  2. The concurrent test does not exercise the gate. reserve_payment_address_survives_concurrent_core_rejection proves the reservation does not wait for the network broadcast and that the rollback snapshot preserves it, but on a current-thread runtime with synchronous persistence the snapshot-then-store sequences never interleave, so the test still passes with lock_contact_payments removed. A multi-thread test that pauses a store after snapshot capture (e.g. a barrier inside the persister) and then starts a competing reservation would make the gate load-bearing in CI. Same point as the existing bot comment; happy for this to be a follow-up.

One pre-existing note, not caused by this PR: dashpay_account_registration_changeset in contacts.rs also persists a whole-pool snapshot of the external account and runs in the pre-gate drain. The window is tiny and only exists on first contact setup, so I would not hold this PR on it.

@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Rebased onto d8b7944ef and pushed; all inline threads addressed and resolved:

  • cadb566aa fixes the three Mnemonic::from_phrase sites (the blocking item) and adds reserve_payment_address_cannot_persist_ahead_of_a_paused_reservation, the multi-thread gate test from suggestion 2. It parks the first reservation inside the host store after snapshot capture and asserts a competing reservation neither completes nor persists ahead of it. Mutation-checked: removing the gate acquisition in reserve_payment_address fails it.
  • 19e0b600c moves the FFI wait outside the registry guard (suggestion 1).

Local: platform-wallet payments module 64/64, platform-wallet-ffi lib 371/371, clippy and fmt clean on the touched crates. Agree the dashpay_account_registration_changeset window is pre-existing and first-setup only; leaving it for a follow-up.


🤖 Posted autonomously by Codex on behalf of pasta.

@github-actions

Copy link
Copy Markdown
Contributor

@thepastaclaw review

No review for 19e0b600 yet, so PR Hygiene is asking once. If nothing arrives, the requirement is dropped for this commit and the pull request is labelled bot-review-missed.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ DEGRADED — Re-review — Final validation — Phase 1 + Phase 2

⚠️ DEGRADED review. The primary review models were unavailable (gpt-6-astra unavailable: All credentials for model gpt-6-astra are cooling down (last error: usage_limit_reached: The usage limit has been reache), so this review ran on stand-in models: gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped at high effort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.

Reserve-only DashPay payout reservation shares the Core-send pool behind a per-wallet gate with mutation-checked multithreaded coverage, and the FFI wait now runs outside the registry guard. Two in-scope suggestions remain: the gate is minted per persister handle rather than per wallet, and the new FFI entry nulls its out-param after the first null check.

🟡 2 suggestion(s)

Review provenance

Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gemini-3.8-flash-high (agent: phase1-reviewer, role: architecture-layering); reviewer 3: gemini-3.8-flash-high (agent: phase1-reviewer, role: ffi-engineer); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: architecture-layering); reviewer 8: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: ffi-engineer); reviewer 9: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: rust-quality); reviewer 10: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: security-auditor); reviewer 11: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: general); reviewer 12: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: architecture-layering); reviewer 13: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: ffi-engineer); reviewer 14: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: rust-quality); reviewer 15: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: security-auditor); final verifier: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: astra-verifier, role: final-verifier)

  • Degraded mode: gpt-6-astra unavailable: All credentials for model gpt-6-astra are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-09-18T05:22:01Z); stand-ins gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor; Phase 1 effort capped at high
  • Triage: critical by muse-spark-1.3-contributor (standing in for gpt-6-astra) (effort low) — Large intricate diff (+651/-98) adds DashPayView::reserve_payment_address in payments.rs changing HD address-pool derivation/consumption and used-flag persistence that directs where withdrawn funds go.
  • Phase 1 reviewers: gemini-3.8-flash-high — general (completed, effort high); agent phase1-reviewer, gemini-3.8-flash-high — architecture-layering (completed, effort high); agent phase1-reviewer, gemini-3.8-flash-high — ffi-engineer (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort high); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (zai below 15% reserve: 5h 99% left, weekly 14% left)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: muse-spark-1.3-contributor (standing in for gpt-6-astra) — final-verifier; agent astra-verifier
  • Phase 2 reviewers: muse-spark-1.3-contributor (standing in for gpt-6-astra) — general (completed, effort xhigh); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6-astra) — architecture-layering (completed, effort xhigh); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6-astra) — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6-astra) — rust-quality (completed, effort xhigh); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6-astra) — security-auditor (completed, effort xhigh); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6-astra) — general (completed, effort xhigh); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6-astra) — architecture-layering (completed, effort xhigh); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6-astra) — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6-astra) — rust-quality (completed, effort xhigh); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6-astra) — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-platform-wallet/src/wallet/persister.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/persister.rs:55-74: Contact-payment gate is per-persister-instance, not per-wallet
  WalletPersister::new mints a fresh contact_payment_gate, so ordering holds only when every locker clones the same handle. Production PlatformWallet::new builds one handle and clones it, but payment_handler.rs:235 builds a second WalletPersister::new for the same wallet_id for event hooks, and tests do the same. Those instances never call lock_contact_payments today so there is no active race, but the per-wallet ordering this PR promises holds by accident of handle sharing rather than by construction: a future pool writer through a second handle would silently bypass reservation ordering. Centralize the gate with the per-wallet shared state that owns the pool (e.g. in the manager) or document that lockers must clone the wallet persister and never new() one.

In `packages/rs-platform-wallet-ffi/src/dashpay.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/dashpay.rs:609-611: Null the string out-param before the signer null-check
  platform_wallet_reserve_dashpay_payment_address nulls *out_address only after check_ptr!(core_signer_handle), so a null-signer call returns ErrorNullPointer leaving *out_address untouched. The documented contract (free only on success) and the Swift caller (nil-initialized) are safe, but a C cleanup-on-error caller that did not pre-initialize would free garbage. The file's own convention in platform_wallet_fetch_sent_contact_requests publishes the empty sentinel before any fallible work. Match it here.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Registration/teardown pool snapshots sit outside the new gate — dashpay_account_registration_changeset and the contact-rotation teardown/rebuild persist the same external-account pools without lock_contact_payments. Pre-existing first-setup/rotation-only window with privacy-only impact; author already scoped it as a follow-up.
    • Follow-up: Track separately: route external-account registration/teardown persistence through the same per-wallet ordering primitive.

@llbartekll llbartekll modified the milestones: v4.2.0, v4.3.0 Sep 18, 2026
@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Sep 20, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: address llbartekll requested changes, then post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Sep 23, 2026
PastaPastaPasta and others added 5 commits October 4, 2026 22:15
Pool snapshots are whole-pool and last-write-wins on the host, so two
reservations interleaving as A: snapshot, B: snapshot, B: store,
A: store would leave B's address unused in the persisted truth and a
relaunch would re-hand it. The contact-payment gate holds each
reservation from snapshot through store to forbid that ordering, but
the existing tests ran on a current-thread runtime with synchronous
persistence callbacks, so the snapshot/store sequences never overlapped
and removing the gate acquisition left every test green.

Add a multithreaded test whose persister parks the first external-pool
store inside the host callback, after the snapshot is captured. A
competing reservation must not complete while that store is parked,
nothing may reach the host in the meantime, and the last persisted
snapshot must carry both addresses. Waits are bounded so a regression
fails instead of wedging the runtime. Dropping the gate acquisition in
reserve_payment_address makes the competing reservation complete while
the first is parked and fails the first assertion.

Also adopt the one-argument Mnemonic::from_phrase from the rebase base.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… registry guard

Look the identity up under the wallet registry guard and run the
reservation on the worker outside it, the shape the base adopted for
platform_wallet_pending_contact_crypto_count. The reservation waits on
the wallet-manager write lock, the contact-payment gate, and the host
store and flush, and a registry read guard held across those stalls
platform_wallet_destroy and, through parking_lot's writer preference,
every other registry reader.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e signer check

`platform_wallet_reserve_dashpay_payment_address` nulled `*out_address`
only after `check_ptr!(core_signer_handle)`, so a null signer returned
`ErrorNullPointer` with the slot untouched. Publish the null sentinel
first, matching the file's other out-param entry points, and pin it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…g contract

The gate lives on the `WalletPersister` handle, so ordering holds only
for clones of the handle `PlatformWallet::new` builds. Say so on
`lock_contact_payments`, and mark the incoming-payment hook's separately
constructed handle as history-only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@PastaPastaPasta
PastaPastaPasta changed the base branch from v5.0-dev to v5.1-dev October 5, 2026 07:03
@PastaPastaPasta
PastaPastaPasta force-pushed the feat/dashpay-payout-address branch from 19e0b60 to f689cd6 Compare October 5, 2026 07:03
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

@thepastaclaw review

No review for f689cd6f yet, so PR Hygiene is asking once. If nothing arrives, the requirement is dropped for this commit and the pull request is labelled bot-review-skipped.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Verified the complete diff at f689cd6 and confirmed that all three prior findings are fixed. Two in-scope persistence issues remain: unsupported backends can report successful durable reservation, and store failures lose their typed classification; both are suggestions under the project's non-consensus severity policy. This was a static review: current CI reports Rust wallet tests passing, with Swift build/tests still pending.

🟡 2 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate changes in payments.rs to reserve_contact_payment_address, reserve_payment_address, and the existing Core send path alter payment destination derivation, durable address consumption, and concurrent broadcast-rejection rollback on a funds-movement surface.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-platform-wallet/src/wallet/identity/network/payments.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:1163-1165: Require durable contact-pool support before reserving an address
  The new API promises that an exposed address remains consumed, but successful store/flush calls do not establish that guarantee for all supported backends. NoPlatformPersistence returns success while discarding the changeset, and FFIPersister silently skips account_address_pools when on_persist_account_address_pools_fn is absent; its flush also succeeds without a callback. Manager creation accepts these incomplete callback tables. With an external contact account already resident, reservation therefore returns an address whose used flag was never persisted. After restart and deterministic contact-account reconstruction, that destination can be issued again, including after cancellation or an unknown withdrawal outcome. Add a fail-closed preflight in this owning Rust method before the drain or pool mutation, requiring an attested contract for DashPay external-account/pool persistence and restart hydration. The existing ACCOUNT_ADDRESS_POOLS alias documents asset-lock funding semantics, so extend the capability contract if necessary rather than assuming it covers DashPay. Add native and incomplete-FFI-backend refusal coverage, including a null output address on the FFI error path.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:1177-1181: Preserve the typed cause of reservation store failures
  Formatting the PersistenceError into PlatformWalletError::Persistence(String) discards its failure kind and source chain. The FFI conversion consequently reports these failures as ErrorUnknown instead of the existing transient, constraint, or fatal store codes, preventing native and host callers from distinguishing recovery paths without parsing text. Use WalletPersister::classify_store_failure to preserve the typed cause while enforcing the backend's retry-safety attestation, and update the injected-store-failure assertion to expect PersisterStore.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Serialize first-time external-account publication with pool snapshots — The unchanged register_external_contact_account path checks account absence, persists an initial unused pool, and only then acquires the manager write lock for insertion. Concurrent first-time registrations can both pass the check; a delayed initial snapshot can overwrite a used flag persisted after the competing registration completed. Swift's pool consumer assigns row.isUsed from each arriving snapshot, making restart address reuse a concrete risk. This sequence and its reachability through concurrent Core sends predate this PR.
    • Follow-up: Track a separate issue or maintainer-requested PR for single-flight contact-account registration ordered with payment-pool persistence, with a deterministic overlapping-registration regression.

…ore failure

`reserve_payment_address` formatted the store's `PersistenceError` into
`PlatformWalletError::Persistence(String)`, dropping its kind and source
chain, so the FFI reported every store failure as `ErrorUnknown`. Route
it through `WalletPersister::classify_store_failure`, as
`retry_pending_balance` does, so hosts get the transient / constraint /
fatal store codes under the backend's retry attestation. The flush
mapping stays a string, matching that same call site.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The shared allocator, payment gate, typed store-error propagation, and FFI ownership handling are consistent with the wallet architecture, and four prior findings are fixed. Two non-consensus correctness concerns remain: unpaid reservations can exceed the recipient's discovery window, and supported persistence backends can acknowledge reservations without preserving them across restart. This was a static review of the complete diff; the supplied exact-head CI snapshot still had build/test prerequisites queued or pending.

🟡 2 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 10: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 11: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 12: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 15: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 16: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 17: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate changes in payments.rs to reserve_contact_payment_address, reserve_payment_address, and the Core send path alter payment destination allocation and its persistence and concurrent rejection rollback, directly affecting funds movement.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-platform-wallet/src/wallet/identity/network/payments.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:1165-1173: Keep unpaid reservations within the recipient's discovery window
  Reservation permanently advances the shared sender pool without requiring an on-chain payment or bounding the unpaid gap. I checked the exact pinned rust-dashcore commit, e4208c90786a6854bd498315bcb571ef24182c15: managed_account_type.rs initializes DashpayReceivingFunds with 20 addresses, account_checker.rs matches outputs against materialized scripts, and wallet_checker.rs maintains lookahead only after a matching transaction. For a fresh contact, 20 confirmed withdrawals that are subsequently canceled or rejected consume sender indices 0–19 without advancing the receiver. The next reservation, or a Core send through the shared allocator, selects index 20, which ordinary recipient synchronization does not discover. The prohibition on previews does not prevent this supported cancellation/rejection sequence, and persisting or extending the sender's pool cannot extend the receiver's pool. Preserve exposed-address consumption, but track observed-payment progress separately and prevent issuance beyond the receiver's discoverable window unless coordinated receiver advancement establishes safety. Add coverage with separate sender and receiver pools, unpaid reservations exhausting the initial window, and a subsequent payment. This is a client-wallet correctness suggestion under the project's non-consensus severity policy.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:1177-1185: Require durable contact-pool support before reserving an address
  (existing thread: https://github.com/dashpay/platform/pull/4623#discussion_r4181960588)
  The new endpoint still returns success without establishing its documented restart-safe consumption guarantee. NoPlatformPersistence explicitly discards changesets while acknowledging store and flush; FFIPersister skips account_address_pools when its callback is absent and also acknowledges a callback-free flush. With an external account already resident, reservation therefore succeeds without saving its used flag, and deterministic reconstruction can reissue the same exposed destination after restart. Swift also acknowledges missing DashPay parent accounts in persistAccountAddresses. Your explanation correctly rules out reusing ASSET_LOCK_FUNDING_INDICES: its contract is asset-lock-scoped, and existing host attestations do not establish DashPay durability. That establishes the need for a dedicated contract, not the correctness of unconditional durable success here. A reissued address still belongs to the same contact, but it breaks one-time destination privacy, particularly when a canceled or rejected withdrawal leaves no on-chain evidence of exposure. Before draining or mutating, require a truthful contact-account/pool persistence and restoration contract with fail-closed host callbacks; alternatively, explicitly distinguish session-only reservations rather than presenting them as durable. Cover native no-op and incomplete-FFI refusal, including a null output address. Coordinating the legacy Core-send contract can remain separate work; its existing limitation does not satisfy the new endpoint's guarantee.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Serialize initial external-account registration with contact-pool consumption — register_external_contact_account checks account absence under a read guard, then persists an initial unused pool before acquiring the insertion write guard. Concurrent first-time registrations can both pass the check, allowing a delayed initial snapshot to overwrite a subsequently persisted reservation's used flag. contacts.rs is unchanged by this PR, and this window already affects Core sends, so it is a separate restart-privacy follow-up rather than an in-scope finding.
    • Follow-up: Track a separate issue or maintainer-requested PR ordering first-time external-account registration against pool mutation and persistence, with an overlapping-registration/store regression test.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai review

No review for 5850e7c7 yet, so PR Hygiene is asking once. If nothing arrives, the requirement is dropped for this commit and the pull request is labelled bot-review-skipped.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 6, 2026

@llbartekll llbartekll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at 5850e7c, merged locally onto current v5.1-dev (723b09e).

The blocking item from my last review is fixed: the three new tests use the one-argument Mnemonic::from_phrase, and the merged tree builds. Both non-blocking suggestions landed as well: the FFI entry point now looks the identity up under the registry guard and waits outside it, and reserve_payment_address_cannot_persist_ahead_of_a_paused_reservation makes the gate load-bearing on a real multi-thread runtime (first store parked inside the host callback, competing reservation proven unable to finish or reach the host until release).

What I checked on the merge result:

  • Lock order is gate -> wallet-manager write lock at all three lockers (reserve_payment_address, send_payment, the rejected-broadcast rollback); the drain runs before the gate; host store/flush never run under the manager guard.
  • The gate's handle-sharing contract holds: PlatformWallet::new builds one WalletPersister and clones it, the hook's second handle only writes payment history, and the only other external-pool snapshot writer is the pre-existing first-setup registration in contacts.rs that we already agreed to leave for a follow-up.
  • Store failures surface as PersisterStore via classify_store_failure, so the FFI maps them to the typed transient/fatal/constraint codes; flush keeps the Persistence(String) shape retry_pending_balance uses.
  • *out_address is nulled before the signer null-check, and the Swift wrapper mirrors sendDashPayPayment (extended-lifetime resolver, platform_wallet_string_free on the success path).
  • Locally on the merge result: cargo fmt --check and git diff --check clean; the full platform-wallet unit suite passes (1194/1194). The FFI crate on base only changed a doc comment in error.rs since your merge-base, so the green head CI (clippy -D warnings + tests over the three wallet crates) covers it.

On the two findings deferred to a follow-up (backends that acknowledge a reservation they never persisted, and unpaid reservations outrunning the recipient's 20-address discovery window): I agree these are follow-ups, not blockers. The persistence gap already applies to the Core send path, and the discovery-window bound needs a paid-index watermark the sender does not track today. If you want a cheap interim for the latter in that follow-up: an explicit release call for a withdrawal that definitively failed before anything reached the network, mirroring what send_payment already does for a rejected broadcast.

Non-blocking: no Kotlin counterpart for reserveDashPayPaymentAddress yet; fine to add when Android needs it.

@PastaPastaPasta
PastaPastaPasta merged commit 6499c68 into v5.1-dev Oct 6, 2026
41 of 43 checks passed
@PastaPastaPasta
PastaPastaPasta deleted the feat/dashpay-payout-address branch October 6, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. Client Only waiting-self-review Waiting for the author to post /self-reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants