Repository navigation
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Expected Behavior
A wallet can top up someone else's identity from its Core balance (asset lock → IdentityTopUp),
and an interrupted top-up resumes to the recipient the user confirmed, never to an identity the
resuming caller happens to pass.
Current Behavior
rs-platform-wallet can only top up an identity the wallet manages, and an asset lock does not record
which identity it was meant for:
IdentityWallet::top_up_identity_with_fundinglooks the identity up in the wallet's
IdentityManagerand returnsIdentityNotFoundfor any other identity; the bound funding account it
derives from is keyed by that identity's registration index
(registration.rs#L382-L408,
build.rs#L291-L294).TrackedAssetLockstoresfunding_typeandidentity_index, but no recipient for an identity
top-up; only the shielded funding (Type 18) records its recipient before dispatch
(tracked.rs#L129-L155).- On resume, an unbound top-up lock is "deliberately eligible for any target"
(orchestration.rs#L700-L725),
and the resume entry points take the identity from the caller
(platform_wallet_topup_identity_with_existing_asset_lock_signer,
SwiftresumeTopUpWithAssetLock).
A host's recovery passes its own identity, so an interrupted top-up of someone else's identity would
be paid into the holder's identity.
Because of (3), both wallets keep Core → someone else's identity unavailable (dashpay/dash-wallet#1680,
and the iOS external send in dashpay/dashwallet-ios#1406–#1409), while Shielded and Identity sources can
already pay any identity, and Platform addresses will with #5860.
Possible Solution
- External top-up operation in
rs-platform-wallet, e.g.
top_up_external_identity_with_funding(identity_id, funding, signer, settings): fetch the identity
from Platform instead of theIdentityManager, touch no identity-manager state, and fund the lock
from the unbound top-up account (IdentityTopUpNotBound, DIP-9), which needs no local registration
index (see Option to fund identity top-ups from the unbound (legacy-compatible) top-up account #4253). - Record the recipient before broadcast: a new immutable
TrackedAssetLockfield (e.g.
identity_recipient: Option<Identifier>), written with the row before the lock is dispatched, as
shielded_recipientis. This is a persistence change: changeset / serde adapters, the FFI
asset-lock persistence callbacks and the hosts' stores. - Resume pays the recorded recipient: when a lock carries
identity_recipient, the resume uses it
and refuses (or ignores) a different caller-supplied identity;validate_existing_asset_lock_role
stops treating such a lock as eligible for any target. Locks without a record keep today's behaviour. - Restore from seed: the recipient is not on chain (the credit output is the next unused address
of the unbound account), so a reconstructed lock has no record. It must not be auto-resumed into the
holder's identity; surface it to the host as an unassigned lock instead. The funds stay recoverable,
since the wallet holds the lock key. - Completion is decided by the recipient's proved balance, as in feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860 (there is no local
ManagedIdentityto persist), and the operation goes through the same wallet-lifecycle fence as
the other top-ups (platform-wallet: an asset-lock build is not excluded from wallet removal, so a lock can be broadcast for a wallet that is gone #5516). - FFI and Swift/Kotlin bindings: one export for the top-up and one for its resume, with the
identity-not-found / lookup-failed codes the external top-up from addresses uses (feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860).
Alternatives Considered
- Register the foreign identity in the wallet's
IdentityManagerfirst: no new operation, but the
wallet would list someone else's identity as its own, and recovery would still pay it as a managed
identity. - Keep the pair unavailable (today): Core-only users cannot pay an identity without first moving
funds to Shielded or Platform.
Additional Context
- Related: Option to fund identity top-ups from the unbound (legacy-compatible) top-up account #4253 (top-ups from the unbound account), Asset-lock restore safety: chain rediscovery, external lock adoption, consumed reconciliation #4254 (asset-lock restore safety), platform-wallet: an asset-lock build is not excluded from wallet removal, so a lock can be broadcast for a wallet that is gone #5516
(asset-lock build vs wallet removal), feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860 (external identity top-up from Platform addresses). - Hosts after this lands: the iOS and Android external send can enable Core → any Identity ID, and
their asset-lock recovery must take the recipient from the lock record instead of the current
identity. - Code references are at
v5.2-deva7669077c5.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity
HashEngineering commentedon Nov 13, 2026
Plan: top up someone else's identity from Core (#5924)
Findings
IdentityWallet::top_up_identity_with_fundingrequires an identity thewallet manages (
rs-platform-wallet/src/wallet/identity/network/registration.rs:382-408).validate_existing_asset_lock_role(wallet/asset_lock/orchestration.rs:700-725) accepts anunbound top-up lock for any identity.
wallet/asset_lock/build.rs:495,:609).create_special_purpose_accounts, rust-dashcorec9aeac0).wallet/asset_lock/sync/reconstruction.rs:202).IdentityTopUpNotBoundlock; onlythe generic FFI builder can, if a host passes funding type 2. Unbound locks with no recorded
recipient are therefore almost all rebuilt from a seed, which makes stricter handling cheap.
shielded_recipientdoes the same job for shielded funding:V020__asset_lock_shielded_recipient;wallet/apply.rskeeps the field from being overwritten;ASSET_LOCK_SHIELDED_RECIPIENTS);AssetLockRecipientMismatch.slot, and
AssetLockEntityhas no column for it, so a shielded recipient is lost on restart. Anew identity-recipient field would be lost the same way unless Kotlin wires it.
PersistentAssetLock.shieldedRecipientRaw43,PlatformWalletPersistenceHandler.persistAssetLockShieldedRecipient), so its part is smaller.Plan
PR A: Rust core, storage and FFI
Target
v5.2-dev, stacked on #5860 (it reuses #5860's error codes and its Platform lookup).identity_recipient: Option<Identifier>toTrackedAssetLockandAssetLockEntry.core_bridge.apply.rs, keep the field fixed once it is set, asshielded_recipientis.V020.build an unbound lock for an external top-up without a recipient.
IdentityWallet::top_up_external_identity_with_funding(identity_id, funding, signer, settings).Expose it through a
PlatformWalletwrapper that checks the wallet is still current (platform-wallet: an asset-lock build is not excluded from wallet removal, so a lock can be broadcast for a wallet that is gone #5516), asfeat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860 does.
IdentityNotFound(7); if the lookup fails, returnIdentityLookupFailed(80). Nothing isspent in either case.
IdentityTopUpNotBound, index 0), with the recipientrecorded.
submit_with_chain_lock_fallback.submitting. Otherwise return
StateTransitionResultUnconfirmed(20).validate_existing_asset_lock_role.AssetLockRecipientMismatch(61). This applies on the managed route too, so a host recoverythat passes the holder's identity can no longer redirect the payment.
uses the managed path if that identity is managed and the external path if not.
tracked_identity_recovery_asset_locks.the wallet, so the funds remain recoverable.
with the issue's point 4 (restore from seed).
platform_wallet_top_up_external_identity_with_funding_signer, and a resumeexport that reads the recipient from the lock.
platform_wallet_topup_identity_with_existing_asset_lock_signernow returns 61 when the lockwas recorded for a different identity.
asset_lock/manager.rs): addhas_identity_recipientandidentity_recipient_32.on_persist_asset_lock_identity_recipient_fn/on_load_asset_lock_identity_recipient_fnpair and capability bit 16(
ASSET_LOCK_IDENTITY_RECIPIENTS).ERROR_CODE_REGISTRY.md.registry_release_testspattern: don't callblock_on_workerinsidePLATFORM_WALLET_STORAGE.with_item.clash on symbols as gap 3b and feat(swift-sdk): shieldedShieldFromIdentityToRecipient #5863 did.
anything if the host hasn't declared bit 16. Without it, a restart turns the lock into an
unassigned one: not paid to the wrong person, but stuck until someone assigns it by hand.
PR A tests
apply.rs).recipient makes it resumable.
path otherwise.
PR B: Kotlin SDK
CreditsNativeexports;IdentityCredits.topUpExternalIdentityFromCore(...);IdentityCredits.resumeTopUpToRecordedRecipient(lock).TrackedAssetLockgetsidentityRecipientandshieldedRecipient.identityRecipientIdandshieldedRecipientRaw43toAssetLockEntity;NativePersistenceBridgepersist/load callbacks for both slot pairs;DashSdkError.PARITY_SUMMARY.md.FfiSmokeTestcase.IdentityAssetLockRecoveryandResumableTopUpsresume to the recorded recipientand show unassigned locks.
PR C: Swift SDK (iOS developer's part, likely romchornyi)
Smaller than Kotlin, because Swift already saves the shielded recipient.
ManagedPlatformWallet.swift:topUpExternalIdentityWithFunding(identityId:…), alongsidetopUpIdentityWithFunding(
:5552);resumeTopUpWithAssetLock(:5632) stays for bound locks and now gets 61 when the lock wasrecorded for a different identity.
ManagedAssetLockManager.swiftreadshas_identity_recipient/identity_recipient_32, as it doesshieldedRecipientRaw43(:85,:138).PersistentAssetLockgetsidentityRecipientId: Data?.PlatformWalletPersistenceHandlergets persist/load callbacks with the same "never change arecorded recipient" check as
persistAssetLockShieldedRecipient(:707-721).1 << 16next toassetLockShieldedRecipients(
PlatformWalletManager.swift:116), declared by the handler.PlatformWalletResult.swift.7, 80, 61 and 20 are already mapped once feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860 lands.
TransitionDetailView.swift:766resumes to the recorded recipient instead of an identity thecaller picks.
ReclaimInvitationSheet.swift:226) doesn't change.Host wallets (e.g. dashwallet-ios #1406–#1409) need a matching recovery change: resume to the
recorded recipient and skip unassigned locks.
Order
Open decisions
the issue's "locks without a record behave as today"?
romchornyi commentedon Nov 14, 2026
Review of the plan: architecture, completeness, security
🟡 4 high · 8 medium · no blockers to the direction. Reviewed against
a7669077c5(the commit the plan cites) and the #5860 head2ce86e8430.Code claims marked ✔ were checked against the code by a separate verifier. Claims marked (not verified) were not.
High
The completion rule "proved balance higher than before" can strand funds or cause a second payment. (Plan A2, A3)
AssetLockAlreadyConsumedand the row stays non-terminal (orchestration.rs#L329-L395).Okhere with no growth check (registration.rs#L455-L531).reconcile_asset_lock_submit_result.The external entry can pay a bound lock, or an invitation voucher, to a stranger. (Plan A2, A3)
validate_existing_asset_lock_rolecompares only funding type and index. With expectedIdentityTopUp, it accepts a bound top-up lock of the same index (orchestration.rs#L704-L734).IdentityTopUpand bypasses the validator (#L641-L697).AssetLockFunding, includingFromExistingAssetLock. Bound locks carry no recipient, so neither 61 nor the "unassigned" rule catches them. It is also a second door for unassigned locks.FromWalletBalanceand validates with expectedIdentityTopUpNotBound(exact type match).consume_invitation_voucher.tracked_resume_metadata, not in a separate read as the shielded path does, to avoid a race with assign.Gating "as feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860 does" would block wallet removal for the whole Core flow. (Plan A2 and its test "a removal waits for a running top-up")
generation_payment_guardacross the whole top-up future (platform_wallet.rs#L688-L704). The lock is write-preferring and not reentrant, and its docs say signer-awaiting operations take it only after signing (generation.rs#L446-L451).IdentityWalletmethodpub(crate)so routing and the gate live in thePlatformWalletwrapper. Today the FFI callsIdentityWalletdirectly.No minimum-amount floor on the new path. (Plan A2, A5)
MIN_TOP_UP_DUFFS = 50_500, "accepted by Core … rejected by Platform, stranding the funds"). The Rust op has none.Medium
Assign / unassigned is under-specified and has no FFI. (Plan A4, A5)
IdentityTopUpNotBound, no recipient, not Consumed, never an invitation lock;Sweep, then reinstate, can drop the recipient.
remove_tracked_asset_locks_for_sweptremoves the entries and the stores delete non-consumed rows. Reconstruction re-inserts the lock with no recovery metadata (reconstruction.rs#L392-L427, #L229-L246).Exports that bypass the recipient check, and other producers of recipient-less unbound locks.
asset_lock_manager_resumereturns the proof and credit-key path with no role or recipient check. It refuses only Consumed, drain-without-persistence and over-cap rows (sync.rs#L213-L259).asset_lock_manager_create_funded_proofaccepts funding type 2 (build.rs#L122-L160). So doesasset_lock_manager_recoverwith a host-supplied type-2 row (not verified).asset_lock_manager_resumerefuse recipient-carrying locks, or return the recipient and document that callers must honour it.Recovery eligibility is planned in a function that is not Rust.
tracked_identity_recovery_asset_locksdoes not exist in Rust. It is Kotlin'strackedIdentityRecoveryAssetLocks(PlatformWalletManager.kt#L822).fundingType 0...2themselves. Under the plan, the "unassigned" rule would be re-derived in Rust, the Kotlin SDK, both example apps and both host wallets.The Kotlin list row has no recipient, so PR B has no source for it.
platform_wallet_tracked_asset_locks_list→TrackedAssetLockSnapshot, which carries no recipient, not even the shielded one (manager_diagnostics.rs#L258-L297). A5 extends onlyTrackedAssetLockFFI, which Swift reads.rs-unified-sdk-jniare Rust work that the PR A / PR B split doesn't assign (not verified that the shielded slot is absent there).Kotlin
@Upsertwould wipe the new column. (PR B)onPersistAssetLockUpsertbuilds a freshAssetLockEntityon every status upsert, keeping onlycreatedAt(PlatformWalletPersistenceHandler.kt#L2395-L2441). Swift carries the value forward and refuses a change (PlatformWalletPersistenceHandler.swift#L707-L724).Routing managed vs external.
OutOfWalletidentities with no index, and the managed top-up then fails withIdentityIndexNotSet(lifecycle.rs#L154-L200, registration.rs#L401-L407).IdentityLocation::InWallet.identity_indexin the same entry, or record the recipient on managed top-ups too.Capability bit 16 is already claimed, and the gate is an attestation.
v5.1-dev) definesOUTPOINT_LOCKS = 1 << 16. With two meanings for one bit, a host that wired only outpoint-lock slots passes the check, and the recipient sidecar is then skipped with only a log line. Reserve the bit, and the new error code (81 after feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860; 77–79 are taken by feat(platform-wallet): plan a shielded spend with its exact fee and spend against the plan #5865), before PR B/C hardcode them.Builtrow with recipient R survives, and launch catch-up plus the new recovery can pay R after the user already re-sent. Make that removal store + flush for recipient-carrying rows.Low
ErrorTransactionBroadcastUnconfirmed, notStateTransitionResultUnconfirmed.AssetLockRecipientMismatchprints both recipients in full and is typed for 43-byte shielded recipients (error.rs#L662-L676). Add an identity variant that prints no IDs, and keep recipients out of above-debug logs.DEFAULT_SPECIAL_GAP_LIMIT). An index is not handed back after a rejected broadcast or a failed recipient store (not verified), so 5 unlanded attempts could exhaust the pool.struct_size. Give the serde fielddefault, asshielded_recipienthas.Completeness
AssetLockEntry::preserve_recovery_metadata(changeset.rs#L1640-L1668). Bothapply.rsandMergeuse it, so extending onlyapply.rsmisses the merge. Assign must be the only writer of None → Some. SQLite COALESCE, Swift and (new) Room checks are defence in depth.IdentityCredits.resumeTopUpWithExistingAssetLockwill start getting 61, and PR B doesn't mention it.c9aeac0may not have it (not verified).asset_lock_manager_recover.asset_lock_manager_resumeon unassigned and on recipient-carrying locks.What the plan gets right
block_on_workerinsidewith_item.Open questions
consume_invitation_voucher? Without it, a sub-floor amount, an unpayable recorded ID, or a payment the user no longer wants is permanent.Review details
a7669077c5and the feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860 head2ce86e8430; no code was changed.🤖 Reviewed with Claude Code
refactor(platform-wallet): simplify the identity top-up recipient code
fix(platform-wallet): address the #5924 plan review in the Core top-u…
feat(kotlin-sdk): top up someone else's identity from the Core balance