Skip to content

feat(payments): External Send from any balance in Advanced mode - #1680

Draft
HashEngineering wants to merge 36 commits into
feat/shared-amount-entry-pagefrom
feat/advanced-external-send
Draft

HashEngineering wants to merge 36 commits into
feat/shared-amount-entry-pagefrom
feat/advanced-external-send

Conversation

@HashEngineering

@HashEngineering HashEngineering commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

MO-1121: External Send in Advanced mode. The Advanced Payments Send tab now opens a new Compose flow that sends from any of the wallet's balances (Core, Shielded, Platform or Identity) to a Dash address, a shielded address, a Platform address or an identity. Basic mode is unchanged.

Stacked on #1678 (AmountEntryPage); the amount step reuses that page.

What was done?

Flow (ui/payments/send/): Send menu (username, Dash address, Scan QR), then the address page (empty, clipboard and filled states), then the amount page with From/To cards, Max and the source sheet, then the confirm sheet, then PIN/biometric, then the send.

  • AdvancedSendFragment is the tab page. ExternalSendFragment, ExternalSendScreen and ExternalSendViewModel hold the flow, with a single UIState StateFlow and Hilt.
  • ExternalSendExecutor is an @Singleton that runs the send on the application scope, so leaving the screen doesn't cancel it.
    • A durable in-flight marker (DashPayConfig.EXTERNAL_SEND_IN_FLIGHT) means that, after process death, the next launch shows "may have gone through" instead of the editable form.
    • The marker is cleared only for Not sent, or when the user acknowledges the result. The acknowledgement is claimed atomically before the clear.
  • After a send that went out (or may have), closing the result returns to Home. After Not sent, the form stays open for editing.

Service (service/platform/sdk/ExternalSendService*, ExternalSendModels):

  • Detects the destination: Core P2PKH/P2SH, Orchard dash1z…, Platform dash1k…/dash1s…, a Base58 identity ID, and dash: URIs.
  • Reads the balance for each source, fee estimates and Max.
  • Sends exactly once, returning SdkWriteResult as Sent, Not sent, or "may have gone through", which is never retried.

ShieldedBalanceService gains external-recipient writes: transfer, withdraw to Core, unshield to a Platform address, identity top-up, shield from the wallet to an address, and (SDK int37) shield from Platform addresses or an identity to a third-party Orchard address. Each write takes the expected wallet ID.

SDK: 5.1.0-int37-20261108.041023-1, pinned to the timestamped build.

  • int36 added ManagedPlatformWallet.fundFromAssetLockExternal (Core → third-party Platform address).
  • int37 added withdrawCredits (partial Platform-address withdrawal), shieldedShieldToRecipient and shieldedShieldFromIdentityToRecipient.

Core → Platform address (ExternalPlatformFunding.kt):

  • One asset lock of amount + 62 000 duffs pays the payee exactly amount; the rest goes to the wallet's own Platform address, which pays the Platform fee. 62 000 duffs is the DPP admission floor for this transition, not a measured fee; what the fee doesn't use stays on the wallet's address.
  • The SDK's tracked lock stores no recipients, so the wallet persists them before the call and records the outpoint in onAssetLockBuilt. At app start (and when the flow opens) a sweep resumes an interrupted lock with exactly those recipients. Once a lock is built, a failure is "may have gone through", never Not sent.
  • The SDK takes P2PKH recipients only, so a dash1s… (P2SH) destination is refused before anything is built.

Platform → Core: the wallet selects the Platform addresses to draw from: never more than an address's balance, at most 16, fewest first, and the first-sorting address (which the SDK charges the fee to) keeps the fee reserve. Amounts below 0.0119 DASH (min_withdrawal_amount plus the Core fee) or above 500 DASH are refused before signing. The recipient receives the amount minus the Core fee (190 duffs), as with Identity → Core.

Platform address sync: PlatformAddressSyncService starts the SDK's Platform-address balance sync once the cutover is committed and the SDK wallet is bound, and stops it with the other SDK engines, so Platform credits received from another wallet show up.

History: a Core → Platform lock reads "Platform" with the sent arrow. A received withdrawal that the wallet's own shielded pool did not make reads "Withdrawal" (was "Unshielded Withdrawal"): the Core transaction does not say whether it came from a Platform address, an identity or someone's shielded pool. The shielded identity-debit-pending error and a send to the wallet's own shielded address are classified as Not sent, since Rust builds nothing.

Supported pairs

From \ To Core Shielded Platform Identity
Core ✓ ✓ ✓ (P2PKH) own identity only
Shielded ✓ ✓ ✓ ✓
Platform ✓ ✓ ✓ ✓
Identity ✓ ✓ ✓ ✓ (not to itself)

Still unavailable, shown as disabled in the source sheet:

  • Core → someone else's identity: the SDK's top-up resume is keyed on a managed identity, so an interrupted send could not be resumed safely.
  • Core → a P2SH Platform address: the SDK rejects P2SH recipients.
  • Identity → the same identity: it moves nothing and costs a fee.

Fees:

  • Platform and Identity sources, and Core → Identity, have no pre-send fee estimate, so the fee shows "—" and Max is off.
  • Shielded fees and Core → Platform are estimates and show with "~".

Figma (section 6860:47472):

  • Built: the Send menu, the three address states, the amount page with From/To and Max, the source sheet, and both confirm variants with the Shielded notes.
  • Sending progress and the result dialogs have no frames; they reuse the existing shielded progress overlay and ModalDialog.
  • Deferred, still needing design: the withdrawal-delay notice, Core lock progress, and pending/failed history (ACs 10, 11, 13).
  • Known differences from Figma in shared components, left as they are rather than changed:
    • The nav bar is 64dp (74 in Figma) and the amount bar 110dp (97 in Figma).
    • The currency picker shows only the other currency.
    • The "becomes public" eye icon doesn't exist in the app.
    • The Core icon is round, not the rounded square.

How Has This Been Tested?

  • Unit tests:

    Suite Tests
    ExternalSendModelsTest 31
    ExternalSendServiceImplTest 66
    ExternalSendViewModelTest 41
    ShieldedBalanceServiceTest 160
    SdkDashPayWritesTest 35
    CutoverUiDataServiceTest 158
    PlatformAddressSyncServiceTest 9
    PlatformSyncEngineRestartTest / TeardownTest 12 / 4
    common AddressParserTest, WifKeyTest —
  • Testnet emulators, between two wallets:

    Pair Result
    Core → Shielded New shielded note on the receiver about 8 s after Sent
    Core → Platform 0.05 DASH arrived exactly, twice; with the address sync it showed about 10 s later
    Platform → Platform 0.02 DASH arrived
    Platform → Shielded 0.01 DASH note on the receiver 49 s after Sent
    Platform → Core 0.012 DASH sent from 4 funded addresses; 0.01199810 received (less the 190-duff Core fee). The Platform side paid about 0.00104 DASH in fees
    Identity → Shielded 0.012 DASH note on the receiver 12 s after Sent; the identity paid about 0.00014 DASH in fees
  • Returning Home after a finished send was checked on device.

  • Not yet run on a device: the other pairs, the resume sweep after a killed Core → Platform send, and the refusal paths.

Open items

  • Local pre-review, last round on 4440881 (two new findings from that round are fixed in 7c232ff: the wallet-wipe barrier on every External Send submission, and the executor forgetting its state on wipe). Still listed:
    • Core Max drain: a Core Max uses the SDK send-all, whose amount is only a floor. Funds that arrive between the final balance re-check and the send-all go out too. Deferred.
    • Resume on an unproven Platform answer — addressed in 91ff74a on the int38 SDK (e7bda1e, includes platform#5556): typed *Unconfirmed errors are "may have gone through" and keep the record for the next sweep; an unauthenticated AssetLockAlreadyConsumed moves the record to a "completion unconfirmed" set (as dashwallet-ios does) so it no longer auto-resumes or blocks new Core → Platform sends. There is no manual-retry screen for it yet, and platform#5823's proven outcome does not cover address funding.
    • An outpoint write failure doesn't stop the broadcast, leaving a record without an outpoint that blocks later Core → Platform sends. Needs an SDK funding checkpoint.
    • The Core → someone else's Shielded "Shielded" send label is in-memory only; after a restart such a row shows as an own shield again (same limit as Core → Platform's "Platform" label).
  • Platform → Identity is limited to the wallet's own identity (d4a6e58). The SDK's topUpFromAddresses only finds managed identities; paying someone else's identity from Platform addresses needs a Kotlin binding of feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses platform#5860.
  • A stale cached Platform balance can make a Platform → Core, Platform → Platform or Platform → Identity send report "may have gone through" when the SDK refused before signing: the SDK's AddressNotEnoughFundsError is not yet classified as Not sent.
  • AddressUtils.decode and WifKey in common now reject an empty payload instead of throwing.

Breaking Changes

None. Advanced mode only; Basic mode's send screen is unchanged.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

🤖 Generated with Claude Code

HashEngineering and others added 5 commits November 4, 2026 13:27
…enter-amount screen onto it

AmountEntryPage (common) combines the EnterAmount bar, NumericKeyboardCompose and the
locale display boundary, with header/belowAmount/primaryButton slots and optional
Max/balance buttons, Dash/fiat picker or tap-to-toggle secondary amount. State stays
hoisted: keys go to the owner, which applies processAmountKeyInput.

DEXEnterAmountScreen now uses it with no change in layout or behaviour.
PurchaseGiftCardScreenV2 is left as is: only one of its three modes shows the keypad,
inside a scrolling column, with different button spacing.

Adds unit tests for processAmountKeyInput and the display-separator helpers, and
moves the processAmountKeyInput KDoc back above its function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…121)

The Advanced payments Send tab gets its own Compose page: send to a
username (Core, as today), to a typed/pasted/scanned destination, or by
scanning a Dash QR. The external send flow detects the destination type
from the whole address (Core, Platform dash1k/dash1s, Shielded dash1z,
identity ID) and rejects wrong-network or malformed input, then reuses
AmountEntryPage with From/To cards, a source picker, a confirm sheet and
PIN before every send.

ExternalSendService routes each source/destination pair to the SDK with
the SdkWriteResult rules (only provably pre-broadcast failures are
retryable, the bound wallet is captured and re-checked before submit).
Supported: Core->Core/Shielded/own Identity, Shielded->all,
Platform->Platform/Identity, Identity->Core/Platform/Identity. The rest
need SDK changes and are shown as not available yet. Basic mode is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Core->Shielded locks amount + pool fee so the recipient gets the
  confirmed amount; fee, Max and Total agree.
- Core Max refuses when the balance changed since confirm; the confirm
  sheet shows a Max send as fee-inclusive, like Basic send-all.
- The SDK wallet is captured at confirm and checked before every write.
- An in-flight marker survives process death and restores the terminal
  "may have gone through" state instead of the editable form.
- dash: URIs for Shielded/Platform/Identity amount requests parse.
- The exact amount is pinned across a currency switch.
- AddressUtils/WifKey reject an empty Base58Check payload instead of
  crashing; destination detection never throws.
- Advanced scan keeps BIP70, AnyPay and serialized requests on the
  Basic invoice path.
- Live identity/shielded reads recover after a transient error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Keep the in-flight marker after a Sent until the user acknowledges it,
  so a process kill before the result is seen warns instead of
  reopening the form.
- Claim an acknowledgement atomically (new Acknowledging state) before
  clearing the marker, so a duplicate acknowledgement cannot clear a
  later send's marker.
- Core→Core: size the fee reserve by UTXO count and turn Max off when
  the balance does not exceed it, so the recipient amount is always
  positive.
- Core→Shielded Max now comes from the confirmed balance an asset lock
  can spend, with the L1 fee reserved up front; the Max retry is gone.

The Core Max drain is still uncapped by the confirmed amount (finding 1);
it is left for device testing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inished

After the user closed the result of a send that went out (or may have),
the executor returned to Idle while the screen was leaving, and the
amount form, still holding the sent amount, became enabled again. A
`finished` flag, set before the executor is released and kept in saved
state, now keeps Continue, the keypad, Max and the source picker inert.
A not-sent result still returns to an editable amount.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
Pre-merge checks: Passed 1 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Passed Passed checks: 1 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Share

@thepastaclaw

thepastaclaw commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🕓 Review not started yet because this PR is a draft.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit ddbf90a. Normal review starts when eligible; priority review starts as soon as a slot is available.

HashEngineering and others added 5 commits November 6, 2026 09:40
…orm address

Bump the Kotlin SDK to 5.1.0-int36 (HashEngineering/platform
feat/kotlin-sdk-fund-from-asset-lock-external @ 760d00f559), which binds
fundFromAssetLockExternal, and use it for Core → Platform (P2PKH only).

- The payee gets exactly the amount; the lock carries a 62 000-duff margin
  (the DPP address-funding admission floor) whose remainder, after the
  Platform fee, lands on the wallet's own Platform address.
- Per the SDK contract the recipients are persisted before the call and the
  lock outpoint inside onAssetLockBuilt; once a lock is built a failure is
  "may have gone through", never Not sent.
- A resume sweep (executor start and screen open) completes an interrupted
  funding with exactly the persisted recipients, capped per process.
- A pending record blocks a second Core → Platform send.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the External Send Platform-funding resume sweep from
PlatformSynchronizationService.kickSdkEngines, right after the pending
wallet-shield sweep: every kick (app start and each blockchain-service
start), after the SDK bind pass. A stuck payee is now paid without the
user reopening External Send. The executor is injected as dagger.Lazy so
its service graph is built off the main thread and can't form a cycle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app never started the Kotlin SDK's Platform-address (BLAST) sync, so
credits other wallets sent to our Platform addresses never appeared: the
wallet only knew balances it wrote itself.

PlatformAddressSyncService starts the SDK loop once the cutover is
committed, the SDK wallet is bound and exactly one SDK wallet is loaded.
PlatformSynchronizationService starts it with the L1 engine (foreground
blockchain-service lifetime, after the bind pass, and on bind heal) and
stops it last in stopSdkEngines (shutdown and wallet wipe). A stop
generation refuses a start decided before a stop. The SDK's 15 s interval
is used; External Send's 15 s Platform balance poll picks up each pass.

Verified on testnet emulators: a 0.05 DASH Core → Platform send from one
wallet appeared on the receiver's Platform address ten seconds later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closing a Sent or "may have gone through" result (including the one shown
after a process restart) now pops back to Home instead of only closing
the External Send screen, which left the user on Payments. The back
button, Not sent and leaving mid-send still return to Payments; if Home
is not on the back stack it falls back to the single pop.

Verified on a testnet emulator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Core → Platform-address External Send is an asset lock the SDK tracks
with funding type 4, which AssetLockKindResolver did not map, so its row
fell back to "Internal" with the internal-transfer icon.

Add AssetLockKind.PLATFORM for funding type 4: the row and detail sheet
read "Platform" with the sent arrow, count under the Sent filter and never
notify as received. The send seeds the kind from onAssetLockBuilt so the
row is right before the SDK's asset_locks row lands. A restored wallet's
own Platform top-up (also type 4) reads the same, since the funding type
cannot tell own from third-party.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HashEngineering and others added 2 commits November 8, 2026 18:18
…ernal Send

Adopt Dash SDK 5.1.0-int37, which adds a partial Platform-address
withdrawal and recipient-taking shield calls, and turn on three
Advanced-mode External Send pairs:

- Platform → Core: ManagedPlatformWallet.withdrawCredits with
  wallet-selected inputs (never above an address's balance, at most 16,
  the first-sorting fee payer keeps the fee reserve). Amounts below the
  withdrawal minimum or above the maximum are refused before signing.
- Platform → Shielded: PlatformWalletManager.shieldedShieldToRecipient.
- Identity → Shielded: shieldedShieldFromIdentityToRecipient.

The three pairs show no fee estimate and keep Max off. Results stay
exactly-once (Sent / Not sent / may have gone through, never retried).
The shielded identity-debit-pending error and the own-shielded-recipient
refusal are now classified as NotBroadcast, as Rust builds nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A received AssetUnlock this wallet's shielded pool did not author can be
a Platform-address withdrawal (now sendable via Platform → Core), an
identity credit withdrawal or a foreign pool's unshield; the Core
transaction does not say which. "Unshielded Withdrawal" mislabelled the
first two, so the row now reads "Withdrawal". Own-pool unshields keep
"Unshielded"; receive semantics are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HashEngineering added a commit that referenced this pull request Nov 9, 2026
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 <noreply@anthropic.com>
HashEngineering and others added 2 commits November 9, 2026 09:26
Switching the source after pressing Max kept the old source's Max as a
plain amount, so a Core Max could be confirmed as a Shielded send. Max
now follows the source: the amount is 0 and Continue disabled until the
new source's Max is read, then it is applied as if Max were pressed. A
source with no Max (unknown fee, empty balance) leaves the amount at 0.
Typing cancels a pending Max, and it survives process death.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HashEngineering added a commit that referenced this pull request Nov 10, 2026
…ry-rows

Picks up cac4f5c (phase-1 through #1675, #1677/#1678/#1680, int37 pin).

Conflicts resolved by keeping both sides:
- AppDatabaseMigrations: our 22->23 tx_display_cache.source migration plus
  the base's data-only removeCrowdNodeCacheRows callback (base stays at v22,
  so AppDatabase is v23 with 23.json unchanged).
- PlatformSyncService: both shieldedHistoryRowSync and
  transparentUsernameCreation constructor params; the six platform tests and
  IdentityConditionalWriteTest pass both.
- DatabaseMigrationTest: our migrate22to23 plus the base's crowdnode cache
  tests; its migrations array now includes migration22to23.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HashEngineering and others added 2 commits November 10, 2026 11:26
- estimateFee drops its unused amount; estimateFee and maxSendable take
  the source and destination balance kinds (balanceKindOf, now shared).
- The shielded flag and own-identity flows are deduplicated before
  flatMapLatest, so an unrelated config write no longer restarts the
  balance flows or re-fetches the Identity balance.
- sendFromShielded and nativeWrite return mapWrite's mapping.
- The private retryReadErrors copy is replaced by the common helper.
- PlatformAddressSyncService shares SdkL1SendService's cutover check.
- ExternalSendFragment remembers its actions; the currency codes list is
  remembered per fiat code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HashEngineering and others added 4 commits November 10, 2026 15:02
The result used ModalDialog, a separate window that stayed above the
lock screen and could be closed without the PIN. It is now an in-screen
overlay like the source and confirm sheets, so the lock screen covers it
and it shows again after unlock. Back acknowledges the result as the
dialog did, and is ignored while the lock screen shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rnal Send

A Core send that builds a transaction now returns its txid: the payment
itself for Core -> Core, and the asset lock for Core -> Platform,
Core -> Shielded and Core -> own identity. The screen then opens
TransactionResultActivity once, acknowledges the outcome and returns
Home, as the Basic send flow does. It opens only while the screen is
resumed and the wallet is unlocked. Sends without a Core transaction,
and every failure or unknown outcome, keep the in-screen result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HashEngineering and others added 2 commits November 10, 2026 16:17
The material3 Card import added for the result overlay took precedence
over the screen's private Card, so the From/To cards drew as Material3
cards (lavender, no padding). The private one is now SendCard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Core -> Platform send interrupted after its transition was submitted
could never resume: each resume rebuilds the same bytes, Tenderdash
refuses them as already in its cache, and the SDK returns that error
without waiting for the result. The record was kept, so every later
Core -> Platform send was refused as still pending. The resume sweep now
clears the record on the SDK's AlreadyExists error. Platform consumes a
lock once, so nothing can be paid twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HashEngineering and others added 6 commits November 11, 2026 07:57
Pre-review findings on #1680:
- Platform, Identity and Shielded -> Core withdrawals now withdraw the
  amount plus the 190-duff Core fee, which Platform takes out of the
  withdrawn amount, so the recipient receives exactly what was
  confirmed. Limits and input selection use the gross amount; a
  Shielded -> Core Max shows the recipient amount net of the fee.
- A Core -> own identity send that only resumed an earlier unfinished
  top-up is now Not sent (EARLIER_TOP_UP_COMPLETED) instead of Sent.
- The confirm sheet's details scroll inside a weighted region, so the
  Cancel/Confirm row keeps its height on short screens or large text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A shield to another wallet's Orchard address seeded the same SHIELD
kind as a shield into the wallet's own pool, so history showed it as an
internal transfer although the funds left the wallet. The external path
now seeds SHIELD_EXTERNAL: sent arrow, outgoing amount, titled
"Shielded", as the Core -> Platform send is titled "Platform". Like
PLATFORM, the kind is in-memory only; after a restart the funding-type
fallback reads SHIELD again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every non Core -> Core External Send route, and the Core -> Platform
resume sweep, now submits under FundingSelectionLock.withSharedSubmission
with the final bound-wallet check inside the hold, so a Reset Wallet can
neither race a credit payment nor have a stale funding record written
back after it cleared the store.

ExternalSendExecutor now forgets its state on wallet wipe (wipe listener
+ generation counter), so a finished or late-completing send of the
wiped wallet is never shown to, or opened by, the next wallet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
int38 carries int37's External Send bindings plus v5.1-dev, including
platform#5556 (uncertain submission outcomes surface as typed
*Unconfirmed errors) and #5823 (proven transition outcomes; no Kotlin
binding yet). No wallet API changes were needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…med locks

- Classify every typed *Unconfirmed SDK error (StateTransitionResultUnconfirmed,
  TransactionBroadcastUnconfirmed, shielded/masternode variants) as "may have
  gone through", ahead of any message match, in the credit writes, the
  shielded invite claim and the top-up recovery.
- Core -> Platform resume: the "Object already exists" match is gone (int38
  waits for the proved result itself). An unconfirmed outcome keeps the
  pending record for the next sweep.
- An AssetLockAlreadyConsumed answer is not proof, so, as the iOS wallet
  does, the record is moved to a durable "completion unconfirmed" set: it is
  no longer resumed automatically and no longer blocks new Core -> Platform
  sends, but is kept for a later manual retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HashEngineering added a commit that referenced this pull request Nov 12, 2026
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 <noreply@anthropic.com>
…essages out of logs

- The SDK's identityCredits.topUpFromAddresses only finds identities the
  wallet manages, so a Platform -> someone else's identity send failed on
  device with "Identity not found". External Send now offers Platform ->
  Identity only for the wallet's own (SDK-managed) identity, like
  Core -> Identity, and the service refuses the rest before building.
  Someone else's identity needs a Kotlin binding of platform#5860.
- That failure was logged with the SDK message, which named the recipient
  identity. External Send now logs only error class names (and a native
  code) via safeErrorSummary, never an exception message or stack trace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HashEngineering

Copy link
Copy Markdown
Collaborator Author

classifyBroadcastFailure reports a pre-broadcast identity-nonce failure as Ambiguous

In the identity → external shielded flow (ExternalSendServiceImpl.kt:721 → ShieldedBalanceServiceImpl → shieldedShieldFromIdentityToRecipient), rs-platform-wallet first fetches the identity nonce. That happens before the transition is built, persisted or broadcast:

// rs-platform-wallet/src/wallet/shielded/operations.rs:1117-1122
let nonce = sdk
    .get_identity_nonce(identity_id, true, None)
    .await
    .map_err(|e| {
        PlatformWalletError::ShieldedBuildError(format!("fetch identity nonce: {e}"))
    })?;

If that fetch fails, for example on a network blip or an unreachable DAPI node, the FFI returns code 6 (WalletOperation) with a message containing fetch identity nonce: …. classifyBroadcastFailure (SdkDashPayWrites.kt) has no arm for it, so it falls through to else -> SdkWriteResult.Ambiguous(t). External Send then shows "may have gone through, do not retry" and requests a reconcile for a payment that was never built or sent.

Suggested fix: add a specific match to the existing pre-broadcast shielded build-input arm. Match this message only, not the general Shielded build error prefix, which the existing comment correctly warns can also appear after broadcast.

// rs-platform-wallet shield_from_identity fetches the identity nonce before
// building, persisting or broadcasting anything (shielded/operations.rs), so
// this failure is always pre-broadcast and retry-safe.
m.contains("fetch identity nonce") ||

Plus a unit test that a fetch identity nonce: … message classifies as NotBroadcast.

It doesn't lose funds; it only marks a retry-safe failure as uncertain. Found while reviewing dashpay/platform#5863 / #5896, which provide the binding this flow calls.

HashEngineering and others added 4 commits November 13, 2026 08:29
…tity

int39 adds IdentityCredits.topUpExternalIdentityFromAddresses (a Kotlin
binding of dashpay/platform#5860). Platform -> Identity now uses
topUpFromAddresses for an identity the SDK wallet manages and the external
top-up for any other; an unreadable managed set is NotSent. A missing
identity fails DashSdkError.NotFound before signing, read as NotSent.
Core -> someone else's identity stays unsupported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maxSendable returned null for a Platform source, so the Amount page fell
back to the raw balance and allowed amounts the send then refused as
INSUFFICIENT_FUNDS (MO-1121 QA). The cap now mirrors the withdrawal's own
input selection: the first-sorting input keeps the SDK preflight's fee
reserve and the 190-duff Core fee comes out of the gross. An unknown cap
blocks Continue instead of falling back to the balance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the identity-balance note (not in the design), use Figma's
info-rect-small and system_message-public icons for the two Shielded
notes, and keep the sheet clear of the system bars like the app's other
bottom sheets. Adds 320dp previews of the Shielded confirm sheet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IdentityTopUpFromAddresses pays its fee from the first-sorting input's
remainder (DeductFromInput(0)), but the inputs were picked to spend exactly
the amount, so a top-up that emptied that address could not pay its fee.
Select with the withdrawal selector and a fixed reserve (the SDK's
withdrawal reserve at 16 inputs), refuse amounts below the identity
funding minimum, and cap the Amount page at the same Max for both the
managed and the external top-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Retry a failed Max read for Platform -> Core / Identity while the
  balance is unchanged, so Continue can't stay blocked
- Show the recipient amount as unknown while a Max drain fee is unknown
- Advanced scan: use the shared DashConnectUri.isConnectUri predicate
  (dashpay://connect was rejected)
- Shielded external routes: log safeErrorSummary, not the throwable
- Core asset-lock Max: cap the confirmed balance at the SDK max-sendable
- Executor: don't clear a marker after a wipe; it may be the new wallet's
- Docs: drain amount check is best-effort; accepted-risk note for a
  failed outpoint write followed by process death

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HashEngineering

Copy link
Copy Markdown
Collaborator Author

Two items from our local pre-review that are deliberate. No code change for either:

Completion-unconfirmed Core → Platform fundings have no retry path (ExternalSendServiceImpl, the AssetLockAlreadyConsumed resume branch). An unproven "already consumed" answer moves the record into EXTERNAL_PLATFORM_FUNDING_UNCONFIRMED. From there it is no longer auto-resumed and no longer blocks new sends, and it is kept for an explicit retry. This matches dashwallet-ios AssetLockRecoveryService (completionUnconfirmed). Android has no manual-retry screen for address-funding locks yet. That's a follow-up, and it would read this set. A proof of consumption (platform#5823) has no binding for asset-lock funding yet. When one exists, it should be used to clear these records.

Core → third-party Shielded shows as an internal shield after a restart. SHIELD_EXTERNAL is seeded in memory on a successful send. After a restart or restore, funding type 5 resolves to SHIELD, as documented in the AssetLockKindResolver KDoc and in the comment in ShieldedBalanceServiceImpl. Getting it right across restarts needs recipient ownership persisted per asset lock, which is new persistence and out of scope for this PR. The funds and the amount shown are correct; only the direction arrow is wrong.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants