Skip to content

feat(payments): Internal transfers between own balances in Advanced mode (MO-1125) - #1683

Draft
HashEngineering wants to merge 27 commits into
feat/advanced-external-sendfrom
feat/advanced-internal-transfer
Draft

HashEngineering wants to merge 27 commits into
feat/advanced-external-sendfrom
feat/advanced-internal-transfer

Conversation

@HashEngineering

@HashEngineering HashEngineering commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

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 - iOS node 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). PaymentsInternalFragment and ShieldedBalanceActivity stay in the code; the invite and username "Shield first" options still open ShieldedBalanceActivity.

What was done?

  • Internal tab (ui/payments/internal/):
    • InternalTransferFragment, InternalTransferScreen and InternalTransferViewModel (single UIState, Hilt).
    • The amount uses the shared amount entry, with Max and a DASH/fiat toggle.
    • From and To cards, with a swap button between them.
    • "Transfer from" and "Transfer to" sheets, with a checkmark on the selected balance.
    • An "Insufficient balance" caption.
  • Confirm, sending and result are shared with External Send. They were moved out of ExternalSendScreen into SendConfirmComponents.kt.
  • InternalTransferService resolves the transfer route for each pair:
    • Destinations are always the user's own, and reading them fails closed.
    • Core destinations use the unadvertised address (checklist 4.15).
    • The SDK wallet id is pinned when the transfer is confirmed, and only one transfer runs at a time.
  • InternalTransferExecutor keeps a durable in-flight marker (DashPayConfig.INTERNAL_TRANSFER_IN_FLIGHT). It works the same way as ExternalSendExecutor, whose marker key is now a parameter.
  • New wallet-pinned methods on ShieldedBalanceService: shieldFromWalletPinned, shieldFromCreditsPinned, unshieldToCreditsPinned and ownPlatformAddressOf. The last one doesn't need the shielded runtime.
  • The Internal tab is always shown in Advanced Payments. Its picker, confirm sheet and sending card open in their own full-screen window, so they draw above the app's bottom navigation, and the page leaves the navigation's height free for Continue.

Pairs

From \ To Core Shielded Platform Identity
Core – ✅ shield (self) ⛔ not yet ✅ top up own identity
Shielded ✅ to unadvertised address – ✅ unshield to credits ✅ top up own identity
Platform ✅ withdraw to unadvertised address (#1680's partial withdrawal) ✅ shield from credits – ✅ top up own identity
Identity ✅ withdraw to unadvertised address ⛔ not yet ✅ transfer to own address –

The two ⛔ pairs show as "not available yet", because the SDK has no usable route for them yet:

  • Core→Platform: it needs the owned fundFromAssetLock with resume.
  • Identity→Shielded: it needs debit-recovery wiring.

Deferred

  • AC14: the history entry for an internal transfer.
  • AC11–13: the final designs for the withdrawal-delay and "becomes public" notes and for lock progress. The External Send notes and sending overlay stand in for now.
  • AC10 (all pairs): the two pairs above.
  • These sizes were built from written specs and not checked against Figma: the swap button's size and ring, its up/down icon and the checkmark.

How Has This Been Tested?

  • Unit tests:

    Test class Tests
    InternalTransferViewModelTest 26
    InternalTransferServiceImplTest 19
    InternalTransferExecutorTest 6
    InternalTransferModelsTest 8
    AdvancedPaymentsTabsTest 5

    The External Send suites (ExternalSendViewModelTest, ExternalSendServiceImplTest and ExternalSendModelsTest) still pass.

  • ktlintFormat is 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:

    • The Back handler was active on an offscreen page.
    • Confirm validated the live fiat form instead of the request it captured.
    • The fiat text of a Max amount didn't update when the rate changed.

    These fixes have not been reviewed again locally.

Known sibling issue: ExternalSendViewModel in #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:

  • I have performed a self-review of my own code
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 7, 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
  • 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 7, 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 64e6c6e. Normal review starts when eligible; priority review starts as soon as a slot is available.

HashEngineering and others added 3 commits November 9, 2026 06:16
…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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
@HashEngineering
HashEngineering force-pushed the feat/advanced-internal-transfer branch from 350b289 to 30c360c Compare November 9, 2026 14:16
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 21 commits November 9, 2026 15:44
…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 <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…l-transfer

Brings in #1680's fee/Max/read cleanup and applies the same cleanup here:

- estimateFee / maxSendable keyed on balance kinds replace the
  estimateFeeForPair / maxSendableForPair twins; InternalTransferService
  .estimateFee drops its unused amount; one public balanceKindOf.
- The Internal and External sources share top-level ownIdentityIdOrThrow,
  shieldedEnabledOrThrow, startedWalletManager and boundWalletIdOrNull
  instead of duplicate bodies.
- shieldFromWallet / shieldFromCredits / unshieldToCredits take an
  optional expectedWalletIdHex in place of the three *Pinned twins.
- AdvancedPaymentsFragment uses its fixed tab set directly; the
  constant-only ViewModel and dynamic-tab plumbing are gone, and
  shieldedEnabledFlow moves next to ReceiveViewModel, its only user.
- pickerBalances / hasShieldedLeg are shared; identity id length uses
  IDENTITY_ID_LENGTH.
- InternalTransferFragment remembers its actions; currencyCodesFor is
  shared and remembered per fiat code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
# Conflicts:
#	wallet/src/de/schildbach/wallet/ui/payments/send/ExternalSendScreen.kt
# Conflicts:
#	wallet/src/de/schildbach/wallet/ui/payments/AdvancedPaymentsFragment.kt
#	wallet/src/de/schildbach/wallet/ui/payments/internal/InternalTransferScreen.kt
#	wallet/test/de/schildbach/wallet/ui/payments/AdvancedPaymentsTabsTest.kt
…o feat/advanced-internal-transfer

# Conflicts:
#	wallet/src/de/schildbach/wallet/ui/dashpay/utils/DashPayConfig.kt
#	wallet/src/de/schildbach/wallet/ui/payments/send/ExternalSendExecutor.kt
#	wallet/src/de/schildbach/wallet/ui/payments/send/ExternalSendScreen.kt
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 <noreply@anthropic.com>
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 <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>
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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
HashEngineering and others added 2 commits November 13, 2026 19:54
…o feat/advanced-internal-transfer

# Conflicts:
#	wallet/src/de/schildbach/wallet/ui/payments/send/ExternalSendScreen.kt
#	wallet/src/de/schildbach/wallet/ui/payments/send/ExternalSendViewModel.kt
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 <noreply@anthropic.com>
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