Repository navigation
Open
Description
Problem
fund_from_asset_lock_external builds and broadcasts a Core asset lock meant to pay third-party Platform addresses. If the Platform submission then fails, or the app restarts before it completes, the saved lock has nothing that says who it was for:
TrackedAssetLock/AssetLockEntrystore no recipients and no "external" flag.- The funding type is
AssetLockAddressTopUp(set infund_from_asset_lock_inner), identical to an owned top-up.
As a result, recovery treats the lock as owned:
- Generic recovery (KotlinExampleApp
ResumableTopUps.resumeRouteFor→FundFromAssetLockScreen, and the SwiftExampleApp equivalent) resumes it through owned funding with a fresh wallet address as the remainder. - Rust's recipient validation accepts that, because it has no record of the original intent.
- The lock is consumed and the money goes back to the sender's wallet. The intended payee is never paid, yet the UI reports success.
Today hosts have to record the outpoint → recipients link themselves in the on_asset_lock_built callback. That isn't reliable:
- The callback can't fail. The JNI trampoline clears a thrown exception and funding carries on to broadcast.
- Recovery paths that can't see the host's record ignore it anyway.
Platform-address funding (owned and external) calls broadcast_funded_asset_lock_with_funding, which passes no AssetLockOperationContext. Only the shielded wallet-drain flow uses that durable checkpoint today.
Scope: rs-platform-wallet, then the FFI, Swift and Kotlin
- Store the payment intent (recipient map, remainder recipient, ownership scope: owned or external) on the tracked lock in rs-platform-wallet. Make it durable before broadcast, either with the existing
AssetLockOperationContextcheckpoint or something equivalent. - Give external locks a distinct funding type or an explicit flag so they never look like
AssetLockAddressTopUp. - When resuming an external lock, restore or verify the saved recipients. Refuse an owned resume that would replace them.
- Expose the intent through persistence (
onPersistAssetLockUpsert/AssetLockEntity, and the Swift equivalent) so hosts can show it. Route example-app recovery by the saved intent, and remove the host-side association requirement from thefundFromAssetLockExternaldocs in both SDKs.
Acceptance criteria
- External lock with a failed Platform submit, then restart: recovery pays the original recipients, or refuses. It never refunds to the wallet.
- A throwing
on_asset_lock_builtcallback no longer affects whether the lock can be recovered. - Rust tests cover resuming an external lock through the owned path, which must be rejected.
References
- feat(kotlin-sdk): bind fund_from_asset_lock_external (Core → third-party Platform address) #5797: Kotlin
fundFromAssetLockExternalbinding ("Known limitation" section, review thread feat(kotlin-sdk): bind fund_from_asset_lock_external (Core → third-party Platform address) #5797 (comment)) - feat(platform-wallet)!: report a freshly built asset lock's outpoint to the caller #5476:
AssetLockBuiltFnbuilt-lock callback - Swift
fundFromAssetLockExternalbinding, which has the same recovery path
Metadata
Metadata
Assignees
Labels
No labels
Activity