Skip to content

Asset-lock callback exports cannot report a lock abandoned before it was sent #6428

Backlog

Description

@romchornyi

Expected Behavior

When a funding call fails with a lock that was abandoned before it was sent, the host learns that nothing was sent and that the outpoint it was given is dead, so a new payment is safe.

Current Behavior

The exports that take on_asset_lock_built (external and owned Platform-address funding, shielded funding) hand the outpoint to the host before the lock's row is durable. If the recipient cannot be made durable, the wallet removes the row, releases the inputs and returns AssetLockAbandonedBeforeSend (build.rs). At the FFI that is ErrorUnknown (99), the code of any other failure, and the callback cannot withdraw the outpoint (built_callback.rs). A resume then returns ErrorAssetLockNotTracked (23), which does not establish that nothing was sent. The host is left with a payment it can neither finish nor safely repeat. No funds are lost.

The identity top-up export does not have this problem: it returns the outpoint in an out-parameter and zeroes it for this error (identity_top_up.rs).

Found while updating #5930, which adds the Platform-address case; there the limit is only documented.

Possible Solution

Give AssetLockAbandonedBeforeSend its own FFI result code, mapped in Swift and Kotlin, meaning "the lock the callback reported was never sent and is gone; a new call is safe". One code covers every export that takes the callback and needs no ABI change to them. It must not cover the case where the row's removal is not durable or the wallet was replaced meanwhile: those stay ErrorTransactionBroadcastUnconfirmed (20).

Tests: the code for each export kind; 20 for a removal that is not durable and for a replaced wallet; both hosts map it.

Alternatives Considered

  • An out-parameter for the outpoint, as the identity top-up has: changes the signature of every export that takes the callback.
  • A withdrawal callback: a second callback the host must order against the first and against the result.
  • Calling on_asset_lock_built after the row is durable: a host that watches persisted rows would briefly see a lock nobody reported, which the current order exists to prevent.

Additional Context

#5930, #5931. The payment class carried by #6379 (NotSent) tells the host that nothing was sent, but not that the reported outpoint is dead.

Activity

  1. added
    enhancement
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions