Repository navigation
feat(payments): External Send from any balance in Advanced mode - #1680
HashEngineering wants to merge 36 commits into
Conversation
…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>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: truePre-merge checks:
|
|
🕓 Review not started yet because this PR is a draft.
Commit ddbf90a. Normal review starts when eligible; priority review starts as soon as a slot is available. |
…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>
…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>
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>
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>
…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>
- 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>
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>
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>
…ernal-send-fa5ded
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>
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>
|
In the identity → external shielded flow ( // 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 Suggested fix: add a specific match to the existing pre-broadcast shielded build-input arm. Match this message only, not the general // 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 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. |
…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>
|
Two items from our local pre-review that are deliberate. No code change for either: Completion-unconfirmed Core → Platform fundings have no retry path ( Core → third-party Shielded shows as an internal shield after a restart. 🤖 Generated with Claude Code |
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.AdvancedSendFragmentis the tab page.ExternalSendFragment,ExternalSendScreenandExternalSendViewModelhold the flow, with a singleUIStateStateFlow and Hilt.ExternalSendExecutoris an@Singletonthat runs the send on the application scope, so leaving the screen doesn't cancel it.DashPayConfig.EXTERNAL_SEND_IN_FLIGHT) means that, after process death, the next launch shows "may have gone through" instead of the editable form.Service (
service/platform/sdk/ExternalSendService*,ExternalSendModels):dash1z…, Platformdash1k…/dash1s…, a Base58 identity ID, anddash:URIs.SdkWriteResultas Sent, Not sent, or "may have gone through", which is never retried.ShieldedBalanceServicegains 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.ManagedPlatformWallet.fundFromAssetLockExternal(Core → third-party Platform address).withdrawCredits(partial Platform-address withdrawal),shieldedShieldToRecipientandshieldedShieldFromIdentityToRecipient.Core → Platform address (
ExternalPlatformFunding.kt):amount + 62 000 duffspays the payee exactlyamount; 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.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.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_amountplus 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:
PlatformAddressSyncServicestarts 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
Still unavailable, shown as disabled in the source sheet:
Fees:
Figma (section 6860:47472):
ModalDialog.How Has This Been Tested?
Unit tests:
ExternalSendModelsTestExternalSendServiceImplTestExternalSendViewModelTestShieldedBalanceServiceTestSdkDashPayWritesTestCutoverUiDataServiceTestPlatformAddressSyncServiceTestPlatformSyncEngineRestartTest/TeardownTestAddressParserTest,WifKeyTestTestnet emulators, between two wallets:
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
AssetLockAlreadyConsumedmoves 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.topUpFromAddressesonly 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.AddressNotEnoughFundsErroris not yet classified as Not sent.AddressUtils.decodeandWifKeyin common now reject an empty payload instead of throwing.Breaking Changes
None. Advanced mode only; Basic mode's send screen is unchanged.
Checklist:
🤖 Generated with Claude Code