Repository navigation
feat(payments): Internal transfers between own balances in Advanced mode (MO-1125) - #1683
HashEngineering merged 32 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 2
Please check the settings in the CodeRabbit UI or the
|
|
✅ Final review complete — no blockers (commit 966efd5) · triage: critical |
350b289 to
30c360c
Compare
0ac493e to
a4eb20b
Compare
a4eb20b to
d036a9c
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Changes requested: 4 blockers
- Shielding the displayed Identity balance can block later identity-funded shields —
wallet/src/de/schildbach/wallet/service/platform/sdk/InternalTransferServiceImpl.kt:413-418(new)
Impact: A user who enters their full displayed Identity balance can leave later shields blocked even after restarting and trying a smaller amount. - Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:2282-2285(new)
Impact: Someone who has the user’s unpaid Platform receive QR can link a subsequent internal transfer to that user. - Internal top-ups can pay an identity the confirmed wallet does not manage —
wallet/src/de/schildbach/wallet/service/platform/sdk/InternalTransferServiceImpl.kt:329-332(new)
Impact: A user whose restored identity is visible in the app but not attached to the SDK wallet can confirm a Platform or Shielded top-up that spends funds to an identity the wallet has not verified it controls. - The confirmed amount can differ from what reaches the destination balance —
wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt:87-95(new)
Impact: A user can receive less than the confirmation shows on a Core-to-Identity transfer or fee-adjusted Shielded Max, or more across their own addresses on a Core-to-Platform transfer.
This PR adds an Advanced Payments tab for transfers between the wallet’s Core, Shielded, Platform, and Identity balances, reusing the External Send confirmation and result UI. At the reviewed head, GitHub’s check and build jobs passed, CodeRabbit skipped this base branch, and the PastaClaw review was pending.
🔴 4 blocking | 🟡 3 suggestion(s)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate diff that changes funds movement and coin-selection/transaction execution across multiple Core, Shielded, Platform, and Identity transfer routes, including durable in-flight recovery and wallet-pinned SDK operations, notably in InternalTransferServiceImpl.kt and InternalTransferExecutor.kt. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),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 verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/platform/sdk/InternalTransferServiceImpl.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/InternalTransferServiceImpl.kt:413-418: Shielding the displayed Identity balance can block later identity-funded shields
Impact: A user who enters their full displayed Identity balance can leave later shields blocked even after restarting and trying a smaller amount.
The user cannot correct an amount that leaves no room for the Type 21 fee. Identity → Shielded has no Max, so the form accepts the full displayed balance, and the write passes that amount directly to the pinned int39 SDK. In that revision, `shield_from_identity_to` persists the signed debit guard before broadcast without first checking that the proved balance covers the amount plus the admission fee. A rejection leaves the guard in place, and `has_unresolved_identity_shield` refuses later attempts for that identity. Acknowledging the result only clears the app’s in-flight flag. Use an SDK containing Platform commit `0f13797eaa1`, map its preflight refusal to Not sent / insufficient funds, and expose the SDK’s recovery records and informed abandonment for genuinely unresolved debits. Otherwise, leave the pair disabled.
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/InternalTransferServiceImpl.kt:329-332: Internal top-ups can pay an identity the confirmed wallet does not manage
Impact: A user whose restored identity is visible in the app but not attached to the SDK wallet can confirm a Platform or Shielded top-up that spends funds to an identity the wallet has not verified it controls.
The Internal flow can spend into an identity that is not available as a managed balance in the confirmed wallet. `SdkWalletBinder` explicitly handles the restored-but-undiscovered state: the app already has a stored identity ID while the bound wallet does not manage it. The Internal destination branch accepts that stored ID alone. External Send protects Core top-ups, but for Platform it deliberately chooses `platformTopUpExternalIdentity` when the ID is absent from the managed set, and the Shielded route accepts third-party IDs. Pinning the source wallet does not prove ownership of the destination. Require the decoded ID to be in the pinned wallet’s non-watched managed set at submission, as the self-shield does for its source, and return Not sent on an absent or unreadable result rather than falling through to an external top-up.
In `wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:2282-2285: Internal transfers can credit a Platform address already shared with a payer
Impact: Someone who has the user’s unpaid Platform receive QR can link a subsequent internal transfer to that user.
A user can share a Platform QR and then move funds to Platform before the payer uses it. The public `platformReceiveAddress()` and the Internal transfer’s `ownPlatformAddressOrNull()` select the same lowest-index unused row; sharing the QR does not mark it used. The Shielded → Platform route uses the same helper, and its fallback can also reuse a previously advertised row. This violates rule 4.15. Allocate wallet-pinned Platform destinations that Receive cannot advertise, including the Core → Platform remainder if one is used, and refuse the Internal transfer before submission if no such destination can be obtained.
In `wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt:87-95: The confirmed amount can differ from what reaches the destination balance
Impact: A user can receive less than the confirmation shows on a Core-to-Identity transfer or fee-adjusted Shielded Max, or more across their own addresses on a Core-to-Platform transfer.
The confirmation presents a definite destination credit when the write does not guarantee it. Core → Identity locks the entered amount and deducts the metered Platform fee from it; the estimate shown covers only the L1 reserve. Core → Platform locks the amount plus a 62,000-duff margin; the unused margin also credits the user’s Platform balance, so it is not all a network fee. The Shielded → Core Max subtraction handles the fixed Core fee, but the write can reduce the amount again if the pool fee exceeds the single-note estimate. Represent the source debit and destination balance increase separately, distinguish reserves from fees, and label metered or fee-adjustable credits as gross, estimated, or unknown rather than exact.
- [SUGGESTION] wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt:194-197: A typed Shielded-to-Core amount can pass confirmation without covering the Core fee
Impact: A user who types the Max figure instead of tapping Max can authenticate a withdrawal that the wallet then refuses for insufficient funds.
The form accepts an amount that cannot be withdrawn even with an accurate pool-fee estimate. `maxSendable` subtracts the pool fee only, and `limit` and `stillValid()` apply that same bound to typed and Max requests. `sendFromShielded` withdraws that gross amount for Max but adds `WITHDRAWAL_CORE_FEE_DUFFS` to a typed amount. Use a recipient-denominated bound for typed withdrawals and the gross bound for Max, and apply the distinction again using the captured request’s `isMax` at confirmation.
- [SUGGESTION] wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt:410-433: Identity balance polling continues while the Internal tab is hidden
Impact: A user who leaves Identity selected can keep making a Platform balance request on the 15-second polling cadence while another tab is visible or the activity is stopped.
The form keeps doing network work while the user cannot see it. `restartBalance()` collects in `viewModelScope`, which outlives both a tab switch and an activity stop. The UI’s lifecycle-aware collector does not cancel that job, so `ExternalSendServiceImpl.observeBalance(IDENTITY)` continues calling `fetchBalance` while the ViewModel is retained. Scope the form’s balance and Max reads to the selected page’s active lifecycle and refresh when it resumes; keep the authenticated transfer itself in application scope.
In `wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferExecutor.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferExecutor.kt:194-199: A late write from a wiped wallet can erase the next transfer’s restart warning
Impact: If a stale executor resumes after the replacement wallet has marked a new transfer in flight, a later process death can leave the user without the warning that the new transfer may already have completed.
The replacement wallet can lose its duplicate-submission warning even though it recorded the marker before submitting. The marker is a single DataStore boolean, and the executor writes it outside the wipe barrier. `forgetWalletState()` bumps the generation, clears the key, and publishes Idle. If the new wallet then sets the key before the old `marker.set()` continuation runs its stale cleanup, that cleanup clears the new wallet’s marker. Serialize marker mutations with reset and submission, or store a per-operation token and clear only the matching record. The External Send executor already avoids clearing an unowned marker in this branch, preferring a spurious warning to a missing one.
| return mapWrite( | ||
| pair, | ||
| submitUnderWipeBarrier(pair, walletIdHex) { mark -> | ||
| mark.submitting() | ||
| source.shieldFromIdentity(identityId, amount, walletIdHex) | ||
| } |
There was a problem hiding this comment.
✅ Resolved at
4a5139e4; see the replies below.
🔴 Blocking: Shielding the displayed Identity balance can block later identity-funded shields
Impact: A user who enters their full displayed Identity balance can leave later shields blocked even after restarting and trying a smaller amount.
The user cannot correct an amount that leaves no room for the Type 21 fee. Identity → Shielded has no Max, so the form accepts the full displayed balance, and the write passes that amount directly to the pinned int39 SDK. In that revision, shield_from_identity_to persists the signed debit guard before broadcast without first checking that the proved balance covers the amount plus the admission fee. A rejection leaves the guard in place, and has_unresolved_identity_shield refuses later attempts for that identity. Acknowledging the result only clears the app’s in-flight flag. Use an SDK containing Platform commit 0f13797eaa1, map its preflight refusal to Not sent / insufficient funds, and expose the SDK’s recovery records and informed abandonment for genuinely unresolved debits. Otherwise, leave the pair disabled.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Confirmed at the pinned int39 SDK: shield_from_identity_to arms the redrive guard with no proved-balance check, and a refused broadcast keeps it. This is fixed in the SDK itself by Platform commit 0f13797eaa1 (refuse with InsufficientIdentityCredits before the guard is armed), which arrives with the v5.2 SDK update. #1680 (00c8638) already classifies that code-39 refusal as Not sent, so no app change is needed once that SDK lands.
There was a problem hiding this comment.
Needs a tracking issue (re-reviewed at d813e2d0): Deferring this needs a tracking issue for the follow-up, and none is linked in this thread, the PR description or the PR comments. Link one, or ask here and I'll file it; until then the finding stands.
There was a problem hiding this comment.
Update: the base (#1680, ecd430d79) now pins Kotlin SDK 5.2.0-int01 (Platform integration/5.2.0-int01 @ 9fef41a0df), which carries the fix from 0f13797eaa1: the identity shield reads the identity's proved balance before the redrive guard is armed and refuses with InsufficientIdentityCredits (FFI code 39) when it cannot cover amount + fee, so nothing is armed or broadcast. #1680 already classifies that refusal as Not sent. This branch is rebased onto it at 4a5139e4e.
There was a problem hiding this comment.
Resolved (re-reviewed at 4a5139e4): I verified that the pinned integration revision checks the proved balance against the amount plus the admission fee before recording or arming the debit, and the app maps code 39 to Not sent / insufficient funds. That refusal leaves no guard to block a smaller retry.
| override suspend fun ownPlatformAddressOf(walletIdHex: String): String? { | ||
| val walletId = walletIdFromHex(walletIdHex) ?: return null | ||
| return try { | ||
| source.ownPlatformAddressOrNull(walletId) |
There was a problem hiding this comment.
✅ Resolved at
966efd5a; see the replies below.
🔴 Blocking: Internal transfers can credit a Platform address already shared with a payer
Impact: Someone who has the user’s unpaid Platform receive QR can link a subsequent internal transfer to that user.
A user can share a Platform QR and then move funds to Platform before the payer uses it. The public platformReceiveAddress() and the Internal transfer’s ownPlatformAddressOrNull() select the same lowest-index unused row; sharing the QR does not mark it used. The Shielded → Platform route uses the same helper, and its fallback can also reuse a previously advertised row. This violates rule 4.15. Allocate wallet-pinned Platform destinations that Receive cannot advertise, including the Core → Platform remainder if one is used, and refuse the Internal transfer before submission if no such destination can be obtained.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 5029e5d. Self-payments (Core / Identity / Shielded → Platform, the self-unshield and the Core → Platform asset-lock remainder, External Send included) now use unadvertisedOwnRowOrNull, which never returns the row Receive advertises (computed over all the wallet's rows, as Receive does). With no other own row it is Not sent before anything is submitted.
There was a problem hiding this comment.
Still applies (re-reviewed at d813e2d0): The helper now avoids the address Receive currently selects, but its used-row fallback can still choose an address that was advertised and paid previously. Excluding only the current receive row does not establish the required never-advertised privacy boundary.
There was a problem hiding this comment.
Fixed in c321b01: unadvertisedOwnRowOrNull no longer falls back to a used row. It returns only an unused row that Receive does not advertise (and that passes the caller's filter), else null. Every caller refuses on null before anything is submitted: the Internal Core/Identity → Platform route (Not sent), the self-unshield (PreBroadcastRejection → NotBroadcast, no broadcast attempt) and External Send's Platform remainder (Not sent before the funding record is written). New tests cover only-the-advertised-row-unused and every-row-used → null.
There was a problem hiding this comment.
Still applies (re-reviewed at f986270a): Removing the used-row fallback closes the previously paid address case. It doesn't cover what happens after selection: when an earlier receive address is paid during a pending Core-to-Platform transfer, Receive can advance to the stored destination before the sweep credits it.
There was a problem hiding this comment.
Still applies (re-reviewed at dfc1b0f6): The new lock closes the proof-window while a self-payment hold exists, but lines 3193–3195 release that hold after a definitive refusal. If Receive advanced to and displayed row C during the proof, a retry can select C after row B is released, so the latest hold changes do not establish a never-displayed destination boundary.
There was a problem hiding this comment.
Fixed in 5c762e7: a self-payment's held Platform destination is now never released, whatever the outcome (definitive refusal included), for both the self-unshield and Internal Identity/Core → Platform (withHeldOwnPlatformAddress no longer takes a release predicate; releaseSelfPaymentHash is gone). So after Receive advances to C during the proof, B stays held, Receive keeps showing C, and a retry picks D. Tests cover this scenario on both paths. The cost is one skipped unused row per refused attempt until restart; restart-surviving holds remain tracked in #1784.
There was a problem hiding this comment.
Still applies (re-reviewed at 5c762e71): Your new tests establish that B stays held after refusal. Core funding’s remainder C never enters that hold set, so clearing an unbuilt funding record can move Receive back to C and make a QR shared while C was reserved eligible for a later Internal transfer in the same process.
There was a problem hiding this comment.
Addressed in 966efd5: Core funding's remainder C now enters the same never-released hold set as the primary destination (see the reply on the remainder finding), so clearing an unbuilt funding record can no longer move Receive back to C.
There was a problem hiding this comment.
Resolved (re-reviewed at 966efd5a): The remainder now joins the primary destinations and self-unshield target in the same process-lifetime hold set that Receive skips. This closes the remaining same-process case without relying on the funding record to stay present.
| SendBalance.IDENTITY -> { | ||
| val id = ownIdentityId ?: return notSent(pair, NotSentReason.GENERIC, "no own identity") | ||
| delegate(pair, walletIdHex, from, SendDestination.Identity(id), amount, isMax) | ||
| } |
There was a problem hiding this comment.
✅ Resolved at
d813e2d0; see the replies below.
🔴 Blocking: Internal top-ups can pay an identity the confirmed wallet does not manage
Impact: A user whose restored identity is visible in the app but not attached to the SDK wallet can confirm a Platform or Shielded top-up that spends funds to an identity the wallet has not verified it controls.
The Internal flow can spend into an identity that is not available as a managed balance in the confirmed wallet. SdkWalletBinder explicitly handles the restored-but-undiscovered state: the app already has a stored identity ID while the bound wallet does not manage it. The Internal destination branch accepts that stored ID alone. External Send protects Core top-ups, but for Platform it deliberately chooses platformTopUpExternalIdentity when the ID is absent from the managed set, and the Shielded route accepts third-party IDs. Pinning the source wallet does not prove ownership of the destination. Require the decoded ID to be in the pinned wallet’s non-watched managed set at submission, as the self-shield does for its source, and return Not sent on an absent or unreadable result rather than falling through to an external top-up.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 3198679. Core, Shielded and Platform → Identity now require the decoded id to be in the pinned wallet's non-watched managed identity set at submission, the same check the self-shield makes for its source. Absent, malformed or unreadable is Not sent; nothing falls through to the external top-up.
There was a problem hiding this comment.
Resolved (re-reviewed at d813e2d0): The pinned-wallet managed identity check now runs before every internal identity destination route, and unreadable or unmanaged identities return Not sent without falling through to an external top-up.
| /** What the To balance receives: the amount, or for [coreFeeIncluded] the amount minus the Core fee. */ | ||
| val recipientAmount: Dash | ||
| get() = if (coreFeeIncluded) amountAfterWithdrawalCoreFee(request.amount) else request.amount | ||
|
|
||
| /** | ||
| * What leaves the From balance: what the To balance receives plus the fee (for Shielded → Core | ||
| * the estimate includes the Core fee), null while the fee is unknown. | ||
| */ | ||
| val total: Dash? get() = fee?.let { recipientAmount + it.fee } |
There was a problem hiding this comment.
⏭️ Deferred (maintainer decision; not blocking; tracked in #1776) at
d813e2d0; see the replies below.
🔴 Blocking: The confirmed amount can differ from what reaches the destination balance
Impact: A user can receive less than the confirmation shows on a Core-to-Identity transfer or fee-adjusted Shielded Max, or more across their own addresses on a Core-to-Platform transfer.
The confirmation presents a definite destination credit when the write does not guarantee it. Core → Identity locks the entered amount and deducts the metered Platform fee from it; the estimate shown covers only the L1 reserve. Core → Platform locks the amount plus a 62,000-duff margin; the unused margin also credits the user’s Platform balance, so it is not all a network fee. The Shielded → Core Max subtraction handles the fixed Core fee, but the write can reduce the amount again if the pool fee exceeds the single-note estimate. Represent the source debit and destination balance increase separately, distinguish reserves from fees, and label metered or fee-adjustable credits as gross, estimated, or unknown rather than exact.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Not changed in this PR. The confirm sheet follows the Figma design, and marking the amount as estimated, or splitting the Core → Platform reserve from the fee, is a design/copy decision we have not made yet. The fee row already shows ~ where the fee is an estimate; the destination-credit presentation is left for the design follow-up.
There was a problem hiding this comment.
Deferred (re-reviewed at d813e2d0): This moves to a follow-up: I filed #1776 to track it, so it no longer blocks this pull request.
| if (marked && !isCurrent()) { | ||
| // A wipe ran while the marker was written, possibly after it cleared the | ||
| // marker: this one belongs to the wiped wallet. Nothing is sent. | ||
| withContext(NonCancellable) { clearMarker() } | ||
| marked = false | ||
| result = ExternalSendResult.NotSent(NotSentReason.GENERIC) |
There was a problem hiding this comment.
✅ Resolved at
d813e2d0; see the replies below.
🟡 Suggestion: A late write from a wiped wallet can erase the next transfer’s restart warning
Impact: If a stale executor resumes after the replacement wallet has marked a new transfer in flight, a later process death can leave the user without the warning that the new transfer may already have completed.
The replacement wallet can lose its duplicate-submission warning even though it recorded the marker before submitting. The marker is a single DataStore boolean, and the executor writes it outside the wipe barrier. forgetWalletState() bumps the generation, clears the key, and publishes Idle. If the new wallet then sets the key before the old marker.set() continuation runs its stale cleanup, that cleanup clears the new wallet’s marker. Serialize marker mutations with reset and submission, or store a per-operation token and clear only the matching record. The External Send executor already avoids clearing an unowned marker in this branch, preferring a spurious warning to a missing one.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in c726ae7. A stale executor (marked && !isCurrent()) now leaves the marker alone after a wipe, exactly as ExternalSendExecutor does: at worst one spurious restart warning, never a lost one.
There was a problem hiding this comment.
Resolved (re-reviewed at d813e2d0): The stale-generation branch no longer clears the marker after a wallet wipe, so a late old-wallet continuation cannot erase a marker recorded by the replacement wallet.
| val limit: Dash? get() = if (maxBoundsAmount(from, to)) maxSendable else maxSendable ?: balance | ||
|
|
||
| /** AC7: the amount is above Max; shown as "Insufficient balance" and blocks Continue. */ | ||
| val insufficientBalance: Boolean get() = limit?.let { amount.isGreaterThan(it) } == true |
There was a problem hiding this comment.
✅ Resolved at
d813e2d0; see the replies below.
🟡 Suggestion: A typed Shielded-to-Core amount can pass confirmation without covering the Core fee
Impact: A user who types the Max figure instead of tapping Max can authenticate a withdrawal that the wallet then refuses for insufficient funds.
The form accepts an amount that cannot be withdrawn even with an accurate pool-fee estimate. maxSendable subtracts the pool fee only, and limit and stillValid() apply that same bound to typed and Max requests. sendFromShielded withdraws that gross amount for Max but adds WITHDRAWAL_CORE_FEE_DUFFS to a typed amount. Use a recipient-denominated bound for typed withdrawals and the gross bound for Max, and apply the distinction again using the captured request’s isMax at confirmation.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 2bd63bd. A typed Shielded → Core amount is bounded by Max minus the Core fee and a Max by Max itself; the confirm re-check (stillValid) uses the captured request's isMax, and External Send uses the same bound.
There was a problem hiding this comment.
Resolved (re-reviewed at d813e2d0): The current bound distinguishes typed requests from Max requests and subtracts the fixed Core fee for typed Shielded-to-Core amounts. Confirmation applies the same distinction to the captured request.
| balanceJob = service.observeBalance(from) | ||
| .onEach { balance -> | ||
| if (generation == balanceGeneration) _uiState.update { it.copy(balance = balance) } | ||
| } | ||
| .transformLatest { balance -> | ||
| if (balance == null) { | ||
| emit(null) | ||
| return@transformLatest | ||
| } | ||
| var max = service.maxSendable(from, to) | ||
| emit(max) | ||
| // For a pair whose Max is its bound, an unknown Max blocks Continue, and an | ||
| // unchanged balance never re-reads it (as in the External Send). So a failed | ||
| // read is retried on the balance poll cadence until it is known. | ||
| while (max == null && maxBoundsAmount(from, to)) { | ||
| delay(ExternalSendServiceImpl.BALANCE_POLL_MS) | ||
| max = service.maxSendable(from, to) | ||
| if (max != null) emit(max) | ||
| } | ||
| } | ||
| .onEach { max: Dash? -> | ||
| if (generation == balanceGeneration) _uiState.update { it.copy(maxSendable = max) } | ||
| } | ||
| .launchIn(viewModelScope) |
There was a problem hiding this comment.
✅ Resolved at
d813e2d0; see the replies below.
🟡 Suggestion: Identity balance polling continues while the Internal tab is hidden
Impact: A user who leaves Identity selected can keep making a Platform balance request on the 15-second polling cadence while another tab is visible or the activity is stopped.
The form keeps doing network work while the user cannot see it. restartBalance() collects in viewModelScope, which outlives both a tab switch and an activity stop. The UI’s lifecycle-aware collector does not cancel that job, so ExternalSendServiceImpl.observeBalance(IDENTITY) continues calling fetchBalance while the ViewModel is retained. Scope the form’s balance and Max reads to the selected page’s active lifecycle and refresh when it resumes; keep the authenticated transfer itself in application scope.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in d813e2d. The form's balance and Max reads, including the identity poll, run only while the Internal page is resumed (onPageVisible from the fragment's view lifecycle) and re-read when shown; the authenticated transfer itself stays app-scoped.
There was a problem hiding this comment.
Resolved (re-reviewed at d813e2d0): The fragment now reports visibility from its view lifecycle, and the ViewModel cancels the balance job when the page pauses and restarts it when the page resumes. The separate stale-value window is a new issue in the refresh transition, not a continuation of hidden polling.
d036a9c to
d813e2d
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 2 blockers
- Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:617-625(thread, carried)
Impact: A payer who previously received one of the wallet's Platform QR addresses can link a later internal transfer when the address allocator falls back to that used row. - Shielding the displayed Identity balance can block later identity-funded shields —
wallet/src/de/schildbach/wallet/service/platform/sdk/InternalTransferServiceImpl.kt:413-418(thread, carried; accepted as a deferral; lifts when a tracking issue is linked on its thread)
Impact: A user who enters their full displayed Identity balance can leave later shields blocked even after restarting and trying a smaller amount.
New on this head: This head adds fixes for wallet-pinned internal routes, stale transfer markers, typed Shielded-to-Core bounds, unadvertised Platform destinations, and visibility-scoped balance polling. The build and check CI jobs succeeded; the PastaClaw review check remains queued, and the branch currently has a merge conflict with its target branch in the shared External Send confirmation screen.
🔴 2 blocking | 🟡 1 suggestion(s)
Still open from earlier rounds (1)
- 🔴 Blocking: Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:617-625(thread)
⏸️ Awaiting tracking link (1): Shielding the displayed Identity balance can block later identity-funded shields (thread). Link an issue on its thread, or ask there and PastaClaw files it.
Follow-up candidates (optional) (1)
New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.
🟡 Suggestion: This stacked PR no longer merges cleanly with its target branch
Impact: The PR cannot be merged as-is, and resolving the confirmation-screen conflict by taking only one side can drop either the shared confirmation refactor or the target branch's Core Max payment-safety fix.
wallet/src/de/schildbach/wallet/ui/payments/send/ExternalSendScreen.kt:533-559
The target branch now contains commit 501cc705f22a, which changes Core-to-Core Max from an SDK send-all into a fixed-amount payment carrying the confirmed fee through the request, executor, and service. This head refactors ConfirmSheet into SendConfirmComponents.kt, but the current External Send model and service still use the old emptyWallet = isMax drain path and do not carry coreMaxFee; taking the current side while resolving the conflict would therefore reintroduce the target branch's overpayment behavior. Resolve the conflict by retaining the shared component refactor and porting the target branch's exact-amount Core Max semantics through the shared confirmation, ViewModel, executor, and service paths.
source: gpt-6.2-astra (phase2-reviewer: general)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate diff that directly changes funds movement and coin-selection/transaction execution across Core, Shielded, Platform, and Identity balances, including wallet-pinned routing and durable in-flight transfer handling in InternalTransferServiceImpl and InternalTransferExecutor. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),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)
- New since the last final review (
d036a9c5): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 not confirmed (no longer blocking) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt:307-319: Returning to the Internal tab keeps stale balance values enabled during refresh
Impact: A user who returns after another spend can tap Continue using the balance and Max values from before the tab or activity was paused, leading to a confirmation based on stale funds and a likely Not sent result.
The form remains actionable with the previous balance snapshot while the resumed page is asynchronously refreshing. `onPageVisible(false)` cancels the read job but leaves `balance` and `maxSendable` intact, and `canContinue` only checks that those values are non-null; a quick tap after `onPageVisible(true)` can therefore capture stale values before the first new emission arrives. Clear the balance and Max state when hiding the page, or gate Continue until the resumed read has emitted.
In `wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:617-625: Internal transfers can credit a Platform address already shared with a payer
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1683#discussion_r4744880608)
In `wallet/src/de/schildbach/wallet/service/platform/sdk/InternalTransferServiceImpl.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/InternalTransferServiceImpl.kt:413-418: Shielding the displayed Identity balance can block later identity-funded shields
(awaiting a tracking link: link an issue on its thread, or ask there and PastaClaw files it; no code change needed; thread: https://github.com/dashpay/dash-wallet/pull/1683#discussion_r4744880595)
| * Hidden, the balance and Max reads stop (the values last read are kept, and are re-read as | ||
| * soon as the page shows again); the service re-checks every transfer anyway. | ||
| */ | ||
| fun onPageVisible(visible: Boolean) { | ||
| if (pageVisible == visible) return | ||
| pageVisible = visible | ||
| if (visible) { | ||
| restartBalance() | ||
| } else { | ||
| balanceJob?.cancel() | ||
| balanceJob = null | ||
| ++balanceGeneration | ||
| } |
There was a problem hiding this comment.
✅ Resolved at
e43cc6ab; see the replies below.
🟡 Suggestion: Returning to the Internal tab keeps stale balance values enabled during refresh
Impact: A user who returns after another spend can tap Continue using the balance and Max values from before the tab or activity was paused, leading to a confirmation based on stale funds and a likely Not sent result.
The form remains actionable with the previous balance snapshot while the resumed page is asynchronously refreshing. onPageVisible(false) cancels the read job but leaves balance and maxSendable intact, and canContinue only checks that those values are non-null; a quick tap after onPageVisible(true) can therefore capture stale values before the first new emission arrives. Clear the balance and Max state when hiding the page, or gate Continue until the resumed read has emitted.
| * Hidden, the balance and Max reads stop (the values last read are kept, and are re-read as | |
| * soon as the page shows again); the service re-checks every transfer anyway. | |
| */ | |
| fun onPageVisible(visible: Boolean) { | |
| if (pageVisible == visible) return | |
| pageVisible = visible | |
| if (visible) { | |
| restartBalance() | |
| } else { | |
| balanceJob?.cancel() | |
| balanceJob = null | |
| ++balanceGeneration | |
| } | |
| } else { | |
| balanceJob?.cancel() | |
| balanceJob = null | |
| ++balanceGeneration | |
| _uiState.update { it.copy(balance = null, maxSendable = null) } | |
| } |
source: gpt-6.2-astra (phase2-reviewer: general)
There was a problem hiding this comment.
Fixed in f986270: hiding the page now also clears balance and maxSendable, so Continue and Max stay off until the re-read after the page shows again; the typed amount and a chosen Max are kept. One deliberate difference from the suggested snippet: while the confirm sheet is open the values are kept. Visibility follows onResume/onPause, biometric/device-credential authentication can pause the page, and submit re-validates the captured request against these values right after authentication returns, so clearing them would refuse a just-authenticated transfer. They are still re-read on resume, and the service re-checks every transfer against the live balance before submitting. Tests cover hide → null/disabled → re-read → enabled, a chosen Max across a hide, and the open-sheet case.
There was a problem hiding this comment.
Still applies (re-reviewed at f986270a): Clearing the values when no sheet is open fixes the normal return path, and keeping them for the captured authentication request makes sense. The remaining gap is cancellation: onDismissConfirm() drops the sheet but leaves the retained values available to a new Continue or Max action while the refresh is still pending.
There was a problem hiding this comment.
Fixed in e43cc6a. Values kept for an open sheet across a pause are tracked as retained until their first emission after the page shows again. Every path that closes the sheet (Cancel/Back via onDismissConfirm, a refused re-validation, a submit) drops whatever is still retained, so Continue and Max wait for current values; the typed amount and a chosen Max are kept. The authenticated submit still validates against the retained values.
There was a problem hiding this comment.
Resolved (re-reviewed at e43cc6ab): The current head drops every retained balance or Max value that has not received its post-resume emission when the confirmation sheet closes, including cancel, refused revalidation, and submit paths. A new Continue or Max action therefore remains disabled until current values are read.
| return mapWrite( | ||
| pair, | ||
| submitUnderWipeBarrier(pair, walletIdHex) { mark -> | ||
| mark.submitting() | ||
| source.shieldFromIdentity(identityId, amount, walletIdHex) | ||
| } |
There was a problem hiding this comment.
Needs a tracking issue (re-reviewed at d813e2d0): Deferring this needs a tracking issue for the follow-up, and none is linked in this thread, the PR description or the PR comments. Link one, or ask here and I'll file it; until then the finding stands.
| override suspend fun ownPlatformAddressOf(walletIdHex: String): String? { | ||
| val walletId = walletIdFromHex(walletIdHex) ?: return null | ||
| return try { | ||
| source.ownPlatformAddressOrNull(walletId) |
There was a problem hiding this comment.
Still applies (re-reviewed at d813e2d0): The helper now avoids the address Receive currently selects, but its used-row fallback can still choose an address that was advertised and paid previously. Excluding only the current receive row does not establish the required never-advertised privacy boundary.
| SendBalance.IDENTITY -> { | ||
| val id = ownIdentityId ?: return notSent(pair, NotSentReason.GENERIC, "no own identity") | ||
| delegate(pair, walletIdHex, from, SendDestination.Identity(id), amount, isMax) | ||
| } |
There was a problem hiding this comment.
Resolved (re-reviewed at d813e2d0): The pinned-wallet managed identity check now runs before every internal identity destination route, and unreadable or unmanaged identities return Not sent without falling through to an external top-up.
| /** What the To balance receives: the amount, or for [coreFeeIncluded] the amount minus the Core fee. */ | ||
| val recipientAmount: Dash | ||
| get() = if (coreFeeIncluded) amountAfterWithdrawalCoreFee(request.amount) else request.amount | ||
|
|
||
| /** | ||
| * What leaves the From balance: what the To balance receives plus the fee (for Shielded → Core | ||
| * the estimate includes the Core fee), null while the fee is unknown. | ||
| */ | ||
| val total: Dash? get() = fee?.let { recipientAmount + it.fee } |
There was a problem hiding this comment.
Deferred (re-reviewed at d813e2d0): This moves to a follow-up: I filed #1776 to track it, so it no longer blocks this pull request.
| if (marked && !isCurrent()) { | ||
| // A wipe ran while the marker was written, possibly after it cleared the | ||
| // marker: this one belongs to the wiped wallet. Nothing is sent. | ||
| withContext(NonCancellable) { clearMarker() } | ||
| marked = false | ||
| result = ExternalSendResult.NotSent(NotSentReason.GENERIC) |
There was a problem hiding this comment.
Resolved (re-reviewed at d813e2d0): The stale-generation branch no longer clears the marker after a wallet wipe, so a late old-wallet continuation cannot erase a marker recorded by the replacement wallet.
| val limit: Dash? get() = if (maxBoundsAmount(from, to)) maxSendable else maxSendable ?: balance | ||
|
|
||
| /** AC7: the amount is above Max; shown as "Insufficient balance" and blocks Continue. */ | ||
| val insufficientBalance: Boolean get() = limit?.let { amount.isGreaterThan(it) } == true |
There was a problem hiding this comment.
Resolved (re-reviewed at d813e2d0): The current bound distinguishes typed requests from Max requests and subtracts the fixed Core fee for typed Shielded-to-Core amounts. Confirmation applies the same distinction to the captured request.
| balanceJob = service.observeBalance(from) | ||
| .onEach { balance -> | ||
| if (generation == balanceGeneration) _uiState.update { it.copy(balance = balance) } | ||
| } | ||
| .transformLatest { balance -> | ||
| if (balance == null) { | ||
| emit(null) | ||
| return@transformLatest | ||
| } | ||
| var max = service.maxSendable(from, to) | ||
| emit(max) | ||
| // For a pair whose Max is its bound, an unknown Max blocks Continue, and an | ||
| // unchanged balance never re-reads it (as in the External Send). So a failed | ||
| // read is retried on the balance poll cadence until it is known. | ||
| while (max == null && maxBoundsAmount(from, to)) { | ||
| delay(ExternalSendServiceImpl.BALANCE_POLL_MS) | ||
| max = service.maxSendable(from, to) | ||
| if (max != null) emit(max) | ||
| } | ||
| } | ||
| .onEach { max: Dash? -> | ||
| if (generation == balanceGeneration) _uiState.update { it.copy(maxSendable = max) } | ||
| } | ||
| .launchIn(viewModelScope) |
There was a problem hiding this comment.
Resolved (re-reviewed at d813e2d0): The fragment now reports visibility from its view lifecycle, and the ViewModel cancels the balance job when the page pauses and restarts it when the page resumes. The separate stale-value window is a new issue in the refresh transition, not a continuation of hidden polling.
d813e2d to
4a5139e
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 1 blocker
- Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:623-625(thread, carried)
Impact: A payer who receives a Platform address can link a later internal credit at that address to the wallet owner.
New on this head: The PR adds Internal transfers between a user's Core, Shielded, Platform, and Identity balances. This head rebases onto Kotlin SDK 5.2.0-int01, updates comments in the shared confirmation code, and adapts the Internal test fake to External Send's new Core Max fee parameter. The build and check jobs passed; PastaClaw review is pending, and CodeRabbit skipped review for this base branch.
🔴 1 blocking | 🟡 1 suggestion(s)
Still open from earlier rounds (2)
- 🔴 Blocking: Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:623-625(thread) - 🟡 Suggestion: Returning to the Internal tab keeps stale balance values enabled during refresh —
wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt:310-319(thread)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate change that directly implements funds movement across Core, Shielded, Platform, and Identity balances, including transaction construction, wallet-pinned execution, durable in-flight state, and transfer routing in InternalTransferServiceImpl and InternalTransferExecutor. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),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 verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:623-625: Internal transfers can credit a Platform address already shared with a payer
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1683#discussion_r4744880608)
In `wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt:310-319: Returning to the Internal tab keeps stale balance values enabled during refresh
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1683#discussion_r4747805666)
| return mapWrite( | ||
| pair, | ||
| submitUnderWipeBarrier(pair, walletIdHex) { mark -> | ||
| mark.submitting() | ||
| source.shieldFromIdentity(identityId, amount, walletIdHex) | ||
| } |
There was a problem hiding this comment.
Resolved (re-reviewed at 4a5139e4): I verified that the pinned integration revision checks the proved balance against the amount plus the admission fee before recording or arming the debit, and the app maps code 39 to Not sent / insufficient funds. That refusal leaves no guard to block a smaller retry.
4a5139e to
f986270
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 1 blocker
- Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:657-658(thread, carried)
Impact: A payer who receives a Platform QR while the wallet owner's Core-to-Platform transfer is pending can link the later internal credit to that owner.
New on this head: This head removes the used-address fallback for Platform self-payments and clears Internal-tab balance and Max values on pause when no confirmation is open. The build and check jobs passed at f986270; the review check is pending.
🔴 1 blocking | 🟡 1 suggestion(s)
Still open from earlier rounds (2)
- 🔴 Blocking: Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:657-658(thread) - 🟡 Suggestion: Returning to the Internal tab keeps stale balance values enabled during refresh —
wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt:319-324(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — InternalTransferServiceImpl.kt adds intricate SDK routing that directly moves funds among four balance types, while InternalTransferExecutor.kt adds durable tracking for those transfers. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),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 verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:657-658: Internal transfers can credit a Platform address already shared with a payer
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1683#discussion_r4744880608)
In `wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferViewModel.kt:319-324: Returning to the Internal tab keeps stale balance values enabled during refresh
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1683#discussion_r4747805666)
| override suspend fun ownPlatformAddressOf(walletIdHex: String): String? { | ||
| val walletId = walletIdFromHex(walletIdHex) ?: return null | ||
| return try { | ||
| source.ownPlatformAddressOrNull(walletId) |
There was a problem hiding this comment.
Still applies (re-reviewed at f986270a): Removing the used-row fallback closes the previously paid address case. It doesn't cover what happens after selection: when an earlier receive address is paid during a pending Core-to-Platform transfer, Receive can advance to the stored destination before the sweep credits it.
| * Hidden, the balance and Max reads stop (the values last read are kept, and are re-read as | ||
| * soon as the page shows again); the service re-checks every transfer anyway. | ||
| */ | ||
| fun onPageVisible(visible: Boolean) { | ||
| if (pageVisible == visible) return | ||
| pageVisible = visible | ||
| if (visible) { | ||
| restartBalance() | ||
| } else { | ||
| balanceJob?.cancel() | ||
| balanceJob = null | ||
| ++balanceGeneration | ||
| } |
There was a problem hiding this comment.
Still applies (re-reviewed at f986270a): Clearing the values when no sheet is open fixes the normal return path, and keeping them for the captured authentication request makes sense. The remaining gap is cancellation: onDismissConfirm() drops the sheet but leaves the retained values available to a new Continue or Max action while the refresh is still pending.
…ode (MO-1125) The Advanced payments Internal tab is now an internal-transfer screen (Figma DashPay iOS 3333:10699): pick From and To among Core, Shielded, Platform and Identity, enter an amount (DASH or fiat, Max), and confirm through the same confirm/sending/result UI as External Send. No address is entered: the transfer pays the wallet's own destination for the To balance; transfers to Core use an unadvertised internal-chain address. Supported now: Core->Shielded (self-shield), Core->Identity, Shielded->Core/Platform/Identity, Platform->Shielded (self-shield), Platform->Identity, Identity->Core/Platform. Core->Platform, Platform->Core and Identity->Shielded show as not available yet (no app wrapper / SDK support). History entry (AC14) is deferred. - InternalTransferModels/Service/ServiceImpl: pair matrix, own destination resolution (fail closed), wallet-id pinning, routes. - InternalTransferExecutor: application-scoped with its own durable in-flight marker, sibling of ExternalSendExecutor. - Shared confirm components moved out of ExternalSendScreen. - Internal tab always shown in Advanced mode; basic mode unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…125) - Identity -> Platform resolves the wallet's own Platform address through a wallet-pinned SDK address-store read that does not need the shielded runtime, so the pair works with the shielded flag off. - A chosen or restored pair is dropped only on confirmed absence (hasIdentity == false / shielded flag == false); an unreadable shielded flag is now null (unknown), not false. - Focused InternalTransferExecutor tests for the durable in-flight marker. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…125) - Gate the Internal tab's BackHandler on the page being RESUMED, so Back on another Advanced Payments tab no longer closes a hidden sheet. - Confirm validates the captured request (pair, wallet, balance/limit) instead of the live fiat-derived form; a refusal closes the sheet with a visible message, and submit re-checks after authentication. - Re-render the fiat text of a Max or pinned amount when the exchange rate changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Route the Internal Platform → Core pair through the External Send's partial Platform withdrawal (#1680) to the wallet's own unadvertised Core address, pinned to the confirmed wallet, like Shielded → Core and Identity → Core. No pre-send fee or Max, as in External Send. Core → Platform and Identity → Shielded stay unavailable. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…igation (MO-1125) The Internal tab is a pager page of AdvancedPaymentsFragment, whose destination keeps MainActivity's bottom navigation drawn over the bottom of the nav host, so the "Transfer from/to" picker, the confirm sheet and the sending card were partly hidden under it. Host them in their own full-screen window (selected page only), as the app's other sheets over the bottom navigation are. External Send, which has no bottom navigation, is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The overlay window now covers the screen and pads itself by the system bars, so the scrim meets the status bar with no undimmed strip. - The Internal page leaves the bottom navigation's height free, so the keypad's Continue is no longer drawn under it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Basic (non-Advanced) Payments shows only Receive | Send; Internal transfers live in Advanced mode. A saved Internal tab opens Receive. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closing a Sent, "may have gone through" (including the one shown after a process restart) or other terminal outcome now pops back to Home, the way the External Send does since 5610dfc. Not sent stays on the Internal tab so the user can retry. The outcome is read before acknowledging, only the selected pager page navigates, and it falls back to a single pop when Home is not on the back stack. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…appears The From/To picker, the confirm sheet, the sending overlay and the outcome dialog are drawn in their own windows, which stayed above the lock screen (dismissDialogsForLockScreen only dismisses DialogFragments). InternalTransferFragment is now LockScreenAware: on lock the picker and the confirm sheet close (the amount is kept), and the sending overlay and the outcome are withheld, not acknowledged, until LockScreenActivity.walletLocked turns false. A running transfer continues on the app scope. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…place The Advanced payments screen now shows MainActivity's bottom navigation on the Receive tab only; Internal and Send hide it, re-applied after the destination listener when the screen becomes current again. Without the bar, the Internal transfer's picker, confirm sheet and sending overlay are drawn in place in the screen, as the External Send does, and AboveBottomNavigation (a separate dialog window) and the 60dp bottom padding are gone. The lock screen now covers those overlays, so on lock only the outcome dialog (its own window) is withheld until unlock. Verified on a testnet emulator: bar per tab, return from External Send, picker Back, confirm sheet above the system navigation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
InternalTransferExecutor now mirrors ExternalSendExecutor's wipe handling: a wallet-wipe listener plus a generation counter, so a finished, restarted or late-completing transfer of the wiped wallet is never shown to, and never touches the in-flight marker of, the next wallet. InternalTransferServiceImpl's own routes (Core -> Shielded, Shielded -> Platform, Platform -> Shielded) now submit under FundingSelectionLock.withSharedSubmission with the bound-wallet check inside the hold; delegated routes already take it in ExternalSendService.send. Co-Authored-By: Claude Opus 5.5 <[email protected]>
LockScreenActivity registered its Back callback with the activity as LifecycleOwner. Such a callback is removed at ON_STOP and re-added at ON_START, which the activity reaches after its fragments, so after any screen-off it sat above every fragment and Compose BackHandler and took Back from them (Advanced Payments: Back left the screen instead of closing the balance picker or confirm sheet, and skipped acknowledging an outcome). The activity's Back is now added once without a LifecycleOwner, so it stays the lowest priority, and removed in onDestroy. A second callback, enabled only while the lock screen is displayed and re-added on top when it comes up, keeps Back from reaching the screens it covers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
External Send (#1680) now funds a Platform address from Core (fundFromAssetLockExternal), so the Internal pair matrix allows Core -> Platform. The route already delegated to External Send with the wallet's own Platform address; fee (paid on top), Max, pending-funding resume and the wipe barrier all come from External Send. Identity -> Shielded is now the only pair not supported yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
External Send supports Identity -> Shielded (identityShieldTo, Type 21), so the Internal pair matrix now allows every pair of two different balances; NOT_SUPPORTED_YET and internalTransferPairSupported are gone. The Shielded-destination routing used to send every non-Core source to the Platform-credits self-shield. Identity now delegates to External Send with the wallet's own default shielded address, read by the new ShieldedBalanceService.ownShieldedAddressOf, which is pinned to the confirmed wallet and fails closed (Not sent, nothing called). Platform -> Shielded keeps its self route. As in External Send, an identity source has no fee estimate and no Max. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hield
The SDK refuses shieldedShieldFromIdentityToRecipient when the recipient
belongs to the wallet's own shielded account ("use the self-shield entry
point"), so the External Send delegate added in the previous commit was
Not sent on a device. Wrap shieldedShieldFromIdentity (Type 21, no
recipient) as ShieldedBalanceService.shieldFromIdentity, mirroring
shieldFromIdentityToAddress through runShieldedWrite, and route Internal
Identity -> Shielded to it as a self route under the wipe barrier, with the
own identity checked as SDK-managed first. ownShieldedAddressOf is removed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
As d4a6e58 did for External Send: every Throwable-passing log in InternalTransferExecutor and InternalTransferServiceImpl now logs only safeErrorSummary (error class names and a native code), never an exception message or stack trace, which can name a recipient or identity. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Shielded -> Core Max withdraws the Max itself and the asset unlock's Core fee comes out of it, so the own Core balance receives the Max minus WITHDRAWAL_CORE_FEE_DUFFS. Internal's confirm sheet showed the full Max as received and a total of Max + fee (the Core fee counted twice). It now uses External Send's rule, shared as withdrawalCoreFeeIncluded / amountAfterWithdrawalCoreFee: amount shown = Max - Core fee, total = that + fee. The send was already right and is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…address Internal transfers to Platform (Core, Identity and Shielded -> Platform), the self-unshield and the Core -> Platform asset-lock remainder picked the lowest-index unused Platform address: the one Receive shows to payers. They now use unadvertisedOwnRowOrNull, which never returns the row Receive advertises (computed over all the wallet's rows, as Receive does): the next unused row, else an own used one. None is still Not sent before anything is submitted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… manages Core, Shielded and Platform -> Identity trusted the stored identity id alone. In the restored-but-undiscovered state the bound SDK wallet does not manage it, and Platform -> Identity then fell through to the External Send's top-up of someone else's identity. The id must now be in the pinned wallet's non-watched managed set (the check the Identity -> Shielded self-shield already made, now shared); absent, malformed or unreadable is Not sent, and nothing reaches the External Send. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…'s marker When Reset Wallet ran while a transfer's in-flight marker was being written, the stale transfer cleared the marker afterwards, which by then could be the replacement wallet's own transfer's. It now leaves the marker alone, as the External Send's executor does: at worst one spurious "interrupted" warning, never a dropped restart protection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… Core fee The Shielded -> Core Max is the gross withdrawal (the Core fee comes out of it), but a typed amount has the Core fee withdrawn on top. A typed amount equal to Max passed Continue and confirm, and then the write refused it. maxAmountBound gives a typed amount Max minus the Core fee and a Max the Max itself; the Internal Transfer's confirm re-check uses the captured request's isMax. The External Send's amount page had the same bound and uses it too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on show The From balance and Max reads (the identity and Platform balances poll every 15 s) ran in viewModelScope while the Internal tab was offscreen or the activity stopped. The fragment now reports the page's RESUMED state (ViewPager2 resumes only the selected page) and the reads run only while it is visible; the last values are kept while hidden and re-read when the page shows again. The transfer itself stays app-scoped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The base no longer pays a Core -> Core Max as a drain (501cc70), so the moved confirm sheet's comments follow its wording. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ternal fake Co-Authored-By: Claude Opus 5.5 <[email protected]>
A used address was advertised and paid before, so a payer who had it could link the self-payment to the wallet. unadvertisedOwnRowOrNull now returns only an unused row Receive does not advertise; with none, every caller is Not sent before anything is submitted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s hidden Continue and Max wait for the re-read when the page shows again, so a value read before the page was hidden is never acted on. An open confirm sheet keeps them: authentication can pause the page and submit re-validates on return. Co-Authored-By: Claude Opus 5.5 <[email protected]>
f986270 to
b6ce091
Compare
…redit While a Core -> Platform funding is pending (or its completion unconfirmed), paying the advertised address could move Receive onto the stored destination or remainder before the sweep credits it. Receive and the self-payment picker now share one rule that skips those reserved addresses; an unreadable funding store shows no address and refuses the self-payment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…closes Values kept for an authenticated submit are dropped when the sheet closes before the re-read lands, so Continue and Max wait for current values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 1 blocker
- Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:3153-3158(thread, carried)
Impact: A user who receives or shares a Platform address can have an overlapping Shielded-to-Platform transfer credit that same address, allowing the payer to link the internal payment to the user.
New on this head: This head adds durable reservations for Core → Platform funding addresses and completes the retained Internal balance/Max cleanup when the confirmation sheet closes. Build, check, and CodeRabbit checks passed; the PastaClaw review check remains queued.
🔴 1 blocking
Still open from earlier rounds (1)
- 🔴 Blocking: Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:3153-3158(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate diff that changes funds-movement code in InternalTransferServiceImpl and InternalTransferExecutor, including routing, wallet-pinned SDK operations, durable in-flight recovery, and balance transfers. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),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 verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:3153-3158: Internal transfers can credit a Platform address already shared with a payer
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1683#discussion_r4744880608)
| override suspend fun ownPlatformAddressOf(walletIdHex: String): String? { | ||
| val walletId = walletIdFromHex(walletIdHex) ?: return null | ||
| return try { | ||
| source.ownPlatformAddressOrNull(walletId) |
There was a problem hiding this comment.
Still applies (re-reviewed at e43cc6ab): The new pending and completion-unconfirmed records close the ordinary Core-funding reuse cases, but they do not represent a Shielded-to-Platform transfer's selected destination and are read only as a snapshot. Receive can still advance onto that destination during the proof, and concurrent Core funding can select the same remainder before its record is written because the two selections are not coordinated.
| * Hidden, the balance and Max reads stop (the values last read are kept, and are re-read as | ||
| * soon as the page shows again); the service re-checks every transfer anyway. | ||
| */ | ||
| fun onPageVisible(visible: Boolean) { | ||
| if (pageVisible == visible) return | ||
| pageVisible = visible | ||
| if (visible) { | ||
| restartBalance() | ||
| } else { | ||
| balanceJob?.cancel() | ||
| balanceJob = null | ||
| ++balanceGeneration | ||
| } |
There was a problem hiding this comment.
Resolved (re-reviewed at e43cc6ab): The current head drops every retained balance or Max value that has not received its post-resume emission when the confirmation sheet closes, including cancel, refused revalidation, and submit paths. A new Continue or Max action therefore remains disabled until current values are read.
…roves The user can leave a Shielded -> Platform transfer during its ~30 s proof and open Receive; if a payment marks the advertised address used meanwhile, Receive could advance onto the unshield's destination. The destination is now picked and held in memory in one locked step, and Receive and every own-row pick skip held rows. It is released only when nothing was submitted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… it runs Identity -> Platform and Core -> Platform now pick and hold their destination the way the self-unshield does, so Receive cannot advance onto it while the transfer is in flight. The hold is released only when the transfer was Not sent; ownPlatformAddressOf (a pick without a hold) is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 1 blocker
- Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:3193-3195(thread, carried)
Impact: A payer who receives a Platform QR while a self-unshield is proving can link a later retried unshield to that user, even if the payer never uses the QR.
New on this head: This head adds wallet-process reservations for Platform destinations selected by self-unshields and Internal transfers, and makes Receive and related address pickers observe those holds. The build and check CI jobs succeeded; the PastaClaw review check remains in progress.
🔴 1 blocking
Still open from earlier rounds (1)
- 🔴 Blocking: Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:3193-3195(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate diff that directly changes funds movement and coin-selection/transaction execution across Core, Shielded, Platform, and Identity balances, including InternalTransferServiceImpl and InternalTransferExecutor. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),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 verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:3193-3195: Internal transfers can credit a Platform address already shared with a payer
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1683#discussion_r4744880608)
| override suspend fun ownPlatformAddressOf(walletIdHex: String): String? { | ||
| val walletId = walletIdFromHex(walletIdHex) ?: return null | ||
| return try { | ||
| source.ownPlatformAddressOrNull(walletId) |
There was a problem hiding this comment.
Still applies (re-reviewed at dfc1b0f6): The new lock closes the proof-window while a self-payment hold exists, but lines 3193–3195 release that hold after a definitive refusal. If Receive advanced to and displayed row C during the proof, a retry can select C after row B is released, so the latest hold changes do not establish a never-displayed destination boundary.
A self-unshield or an Internal Identity/Core -> Platform transfer holds its own Platform destination from Receive while it runs. Releasing that hold after a refusal that submitted nothing let Receive fall back to the held row, so a retry could pick the next row, which Receive may have shown to a payer during the proof. Keep every hold for the process lifetime, whatever the outcome; the cost is one skipped unused row per refused attempt, until restart. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 1 blocker
- Internal transfers can credit a Platform address already shared with a payer —
wallet/src/de/schildbach/wallet/service/platform/sdk/ExternalSendServiceImpl.kt:924-937(carried)
Impact: A payer who gets a Platform QR while Core-to-Platform funding is pending can link a later Internal transfer to that QR after the funding record is cleared, without an app restart.
New on this head: This head keeps the primary Platform destination of a self-payment reserved for the life of the process, even when nothing was submitted, and adds tests for Receive advancing during the hold. GitHub’s build and check jobs passed at the reviewed SHA; the review check is still pending.
🔴 1 blocking | 🟡 1 suggestion(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — The large diff directly changes funds movement and coin-selection/payment execution across Core, Shielded, Platform, and Identity balances, including transaction construction, durable in-flight state, wallet pinning, and shielding/unshielding methods in InternalTransferServiceImpl and InternalTransferExecutor. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),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 verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/platform/sdk/ExternalSendServiceImpl.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/sdk/ExternalSendServiceImpl.kt:924-937: Internal transfers can credit a Platform address already shared with a payer
Impact: A payer who gets a Platform QR while Core-to-Platform funding is pending can link a later Internal transfer to that QR after the funding record is cleared, without an app restart.
Keeping the primary destination held fixes the refusal case in the new tests, but a later transfer can still credit a QR shared while the remainder was reserved. With A advertised, Internal Core → Platform holds B and records C as its remainder; the remainder picker reads the held set but never adds C to it. A wallet with many small Core outputs can hit the SDK’s asset-lock input cap before the outpoint callback. The app classifies that failure as ambiguous and keeps the no-outpoint record. If an incoming payment marks A used and the user opens Receive while that record remains, Receive skips B and C and can share D. The sweep then clears the record once it sees no open lock. B stays held, but unused C becomes the row the picker treats as advertised, making the still-unpaid D eligible for the next Internal transfer. This violates rule 4.15 without two simultaneous sends. Allocate the remainder through the same wallet-pinned hold mechanism as the primary destination, so clearing a funding record cannot make a previously shared row eligible.
In `wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/service/platform/sdk/ShieldedBalanceServiceImpl.kt:3178-3182: Shielded-to-Platform Max can fail on the fee retry despite having enough funds
Impact: A user with one private Platform address left gets Not sent if the first Max attempt is rejected for a pool-fee shortfall, even when the adjusted amount fits.
`InternalTransferServiceImpl.unshieldToOwnPlatform()` retries once when the SDK rejects the first Max attempt before broadcast because the exact note-selection fee exceeds the estimate. Both attempts call `unshieldToCredits()` and pick a destination independently. Before this commit, that refusal released the first hold; now it keeps the last eligible row without crediting it, so the adjusted attempt returns Not sent at address lookup without reaching the SDK. Reuse the held, wallet-pinned destination for the single fee-adjusted retry of the same confirmed transfer, without releasing it back to Receive.
| val held = reservedHashes + shieldedBalanceService.heldSelfPaymentAddressHashes() | ||
| val rows = database().platformAddressDao().observeByWallet(walletIdBytes(walletIdHex)).first() | ||
| .filter { | ||
| it.accountIndex == EXTERNAL_FUNDING_PLATFORM_ACCOUNT_INDEX && | ||
| it.addressType == 0 && | ||
| it.addressHash.size == 20 && | ||
| !it.addressHash.contentEquals(excludeHash) | ||
| } | ||
| val row = rows.filter { !it.isUsed }.minByOrNull { it.addressIndex } ?: rows.minByOrNull { it.addressIndex } | ||
| val row = unadvertisedOwnRowOrNull( | ||
| rows, | ||
| isUsed = { it.isUsed }, | ||
| isReserved = { isReservedPlatformRow(held, it.addressType, it.addressHash) }, | ||
| index = { it.addressIndex } | ||
| ) { | ||
| it.accountIndex == EXTERNAL_FUNDING_PLATFORM_ACCOUNT_INDEX && | ||
| it.addressType == 0 && | ||
| it.addressHash.size == 20 && | ||
| !it.addressHash.contentEquals(excludeHash) | ||
| } | ||
| return row?.let { PlatformAddressBytes(0, it.addressHash.copyOf()) } |
There was a problem hiding this comment.
✅ Resolved at
966efd5a; see the replies below.
🔴 Blocking: Internal transfers can credit a Platform address already shared with a payer
Impact: A payer who gets a Platform QR while Core-to-Platform funding is pending can link a later Internal transfer to that QR after the funding record is cleared, without an app restart.
Keeping the primary destination held fixes the refusal case in the new tests, but a later transfer can still credit a QR shared while the remainder was reserved. With A advertised, Internal Core → Platform holds B and records C as its remainder; the remainder picker reads the held set but never adds C to it. A wallet with many small Core outputs can hit the SDK’s asset-lock input cap before the outpoint callback. The app classifies that failure as ambiguous and keeps the no-outpoint record. If an incoming payment marks A used and the user opens Receive while that record remains, Receive skips B and C and can share D. The sweep then clears the record once it sees no open lock. B stays held, but unused C becomes the row the picker treats as advertised, making the still-unpaid D eligible for the next Internal transfer. This violates rule 4.15 without two simultaneous sends. Allocate the remainder through the same wallet-pinned hold mechanism as the primary destination, so clearing a funding record cannot make a previously shared row eligible.
source: gpt-6.2-astra (phase2-reviewer: general)
There was a problem hiding this comment.
Fixed in 966efd5: the Core → Platform remainder is now picked and held in one step under the self-payment selection lock (ShieldedBalanceService.pickAndHoldOwnPlatformRow), and like the primary destination it is never released for the process lifetime. Clearing the funding record therefore no longer returns C to Receive. In your scenario Receive keeps showing D, and the next Internal pick goes to E (remainderHeld_afterTheFundingRecordClears_…). This covers External Send's own Core → Platform remainder too, which uses the same picker.
There was a problem hiding this comment.
Resolved (re-reviewed at 966efd5a): The production remainder picker now records C in the held set before releasing the selection lock. Clearing the funding record leaves C excluded, so Receive still shows D and the next Internal transfer skips D.
| private suspend fun unshieldToCreditsInternal(amount: Dash, expectedWalletIdHex: String?): SdkWriteResult<Unit> = | ||
| runShieldedWrite("unshieldToCredits", amount, expectedWalletIdHex) { walletId, credits -> | ||
| // Held for the process lifetime, whatever the outcome (see [heldSelfPaymentHashes]). | ||
| val (target, _) = reserveSelfUnshieldDestination(walletId) | ||
| source.unshield(walletId, target, credits) |
There was a problem hiding this comment.
✅ Resolved at
966efd5a; see the replies below.
🟡 Suggestion: Shielded-to-Platform Max can fail on the fee retry despite having enough funds
Impact: A user with one private Platform address left gets Not sent if the first Max attempt is rejected for a pool-fee shortfall, even when the adjusted amount fits.
InternalTransferServiceImpl.unshieldToOwnPlatform() retries once when the SDK rejects the first Max attempt before broadcast because the exact note-selection fee exceeds the estimate. Both attempts call unshieldToCredits() and pick a destination independently. Before this commit, that refusal released the first hold; now it keeps the last eligible row without crediting it, so the adjusted attempt returns Not sent at address lookup without reaching the SDK. Reuse the held, wallet-pinned destination for the single fee-adjusted retry of the same confirmed transfer, without releasing it back to Receive.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 966efd5: withSelfUnshieldDestination runs both attempts of a shielded Max in one scope, so the fee-adjusted retry reuses the first attempt's held, wallet-pinned destination instead of holding a second row. It refuses if the wallet changed, and a call after a non-NotBroadcast result is refused. InternalTransferServiceImpl.unshieldToOwnPlatform and the invite overage top-up (ShieldedInviteOverageTopUp, which always takes the fee retry) both use it. A test covers the one-eligible-row case reaching the SDK.
There was a problem hiding this comment.
Resolved (re-reviewed at 966efd5a): Both callers now keep the fee-adjusted attempt in the original destination scope, which checks the wallet ID before reusing the held address. Your one-eligible-row test confirms both attempts reach the SDK-call seam with the same target.
| override suspend fun ownPlatformAddressOf(walletIdHex: String): String? { | ||
| val walletId = walletIdFromHex(walletIdHex) ?: return null | ||
| return try { | ||
| source.ownPlatformAddressOrNull(walletId) |
There was a problem hiding this comment.
Still applies (re-reviewed at 5c762e71): Your new tests establish that B stays held after refusal. Core funding’s remainder C never enters that hold set, so clearing an unbuilt funding record can move Receive back to C and make a QR shared while C was reserved eligible for a later Internal transfer in the same process.
…ld destination on retry The Core -> Platform funding's remainder row was protected only by its durable record. Once a sweep cleared that record, Receive could fall back to it, making a row already shown to a payer eligible for the next self-payment. Pick and hold the remainder under the self-payment selection lock, for the process lifetime, like the payment's own destination. Now that holds are never released, a fee-adjusted retry of a shielded Max (Internal Shielded -> Platform, the invite overage top-up) would hold a second row, or fail when only one eligible row is left. Run both attempts in one withSelfUnshieldDestination scope so the retry reuses the first attempt's held, wallet-pinned destination. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: The latest commit holds Core → Platform remainder addresses for the life of the process under the same lock Receive uses, so clearing a funding record no longer makes its remainder available. Shielded → Platform Max and invite-overage fee retries now reuse the first attempt’s wallet-pinned destination. GitHub’s build and check jobs passed; the PastaClaw review check is pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate change that directly modifies funds movement and coin-selection paths across InternalTransferServiceImpl, InternalTransferExecutor, ShieldedBalanceServiceImpl, and related wallet-pinned shielding, unshielding, and withdrawal operations. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),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 verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
| override suspend fun ownPlatformAddressOf(walletIdHex: String): String? { | ||
| val walletId = walletIdFromHex(walletIdHex) ?: return null | ||
| return try { | ||
| source.ownPlatformAddressOrNull(walletId) |
There was a problem hiding this comment.
Resolved (re-reviewed at 966efd5a): The remainder now joins the primary destinations and self-unshield target in the same process-lifetime hold set that Receive skips. This closes the remaining same-process case without relying on the funding record to stay present.
| val held = reservedHashes + shieldedBalanceService.heldSelfPaymentAddressHashes() | ||
| val rows = database().platformAddressDao().observeByWallet(walletIdBytes(walletIdHex)).first() | ||
| .filter { | ||
| it.accountIndex == EXTERNAL_FUNDING_PLATFORM_ACCOUNT_INDEX && | ||
| it.addressType == 0 && | ||
| it.addressHash.size == 20 && | ||
| !it.addressHash.contentEquals(excludeHash) | ||
| } | ||
| val row = rows.filter { !it.isUsed }.minByOrNull { it.addressIndex } ?: rows.minByOrNull { it.addressIndex } | ||
| val row = unadvertisedOwnRowOrNull( | ||
| rows, | ||
| isUsed = { it.isUsed }, | ||
| isReserved = { isReservedPlatformRow(held, it.addressType, it.addressHash) }, | ||
| index = { it.addressIndex } | ||
| ) { | ||
| it.accountIndex == EXTERNAL_FUNDING_PLATFORM_ACCOUNT_INDEX && | ||
| it.addressType == 0 && | ||
| it.addressHash.size == 20 && | ||
| !it.addressHash.contentEquals(excludeHash) | ||
| } | ||
| return row?.let { PlatformAddressBytes(0, it.addressHash.copyOf()) } |
There was a problem hiding this comment.
Resolved (re-reviewed at 966efd5a): The production remainder picker now records C in the held set before releasing the selection lock. Clearing the funding record leaves C excluded, so Receive still shows D and the next Internal transfer skips D.
| private suspend fun unshieldToCreditsInternal(amount: Dash, expectedWalletIdHex: String?): SdkWriteResult<Unit> = | ||
| runShieldedWrite("unshieldToCredits", amount, expectedWalletIdHex) { walletId, credits -> | ||
| // Held for the process lifetime, whatever the outcome (see [heldSelfPaymentHashes]). | ||
| val (target, _) = reserveSelfUnshieldDestination(walletId) | ||
| source.unshield(walletId, target, credits) |
There was a problem hiding this comment.
Resolved (re-reviewed at 966efd5a): Both callers now keep the fee-adjusted attempt in the original destination scope, which checks the wallet ID before reusing the held address. Your one-eligible-row test confirms both attempts reach the SDK-call seam with the same target.
Issue being fixed or feature implemented
MO-1125 Internal Transfers. In Advanced mode, the Internal tab of Advanced Payments moves Dash between the user's own balances: Core, Shielded, Platform and Identity. The design is Figma
DashPay - iOSnode 3333:10699, adapted to Android Compose.This PR is stacked on #1680 (External Send) and targets
feat/advanced-external-send. Basic mode (Advanced off): the Payments screen now shows only Receive | Send; the Internal tab is hidden (a saved Internal tab opens Receive).PaymentsInternalFragmentandShieldedBalanceActivitystay in the code; the invite and username "Shield first" options still openShieldedBalanceActivity.What was done?
ui/payments/internal/):InternalTransferFragment,InternalTransferScreenandInternalTransferViewModel(singleUIState, Hilt).ExternalSendScreenintoSendConfirmComponents.kt.InternalTransferServiceresolves the transfer route for each pair:InternalTransferExecutorkeeps a durable in-flight marker (DashPayConfig.INTERNAL_TRANSFER_IN_FLIGHT). It works the same way asExternalSendExecutor, whose marker key is now a parameter.ShieldedBalanceService:shieldFromWalletPinned,shieldFromCreditsPinned,unshieldToCreditsPinnedandownPlatformAddressOf. The last one doesn't need the shielded runtime.Pairs
The two ⛔ pairs show as "not available yet", because the SDK has no usable route for them yet:
fundFromAssetLockwith resume.Deferred
How Has This Been Tested?
Unit tests:
InternalTransferViewModelTestInternalTransferServiceImplTestInternalTransferExecutorTestInternalTransferModelsTestAdvancedPaymentsTabsTestThe External Send suites (
ExternalSendViewModelTest,ExternalSendServiceImplTestandExternalSendModelsTest) still pass.ktlintFormatis clean.Not yet tested on a device.
Two local pre-review rounds were run with GPT-6.1 Sol:
Round 1: 2 blocking findings and 1 suggestion, fixed in a87dc22.
Round 2: 3 blocking findings, fixed in 350b289:
These fixes have not been reviewed again locally.
Known sibling issue:
ExternalSendViewModelin #1680 has the same two problems as the round-2 confirm and fiat-rate findings. They are left for that PR.Breaking Changes
None.
Checklist:
🤖 Generated with Claude Code