Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ sealed class DashSdkError(
class AssetLockTooManyInputs(message: String, cause: Throwable? = null) :
PlatformWallet(message, cause)

/**
* Code 61: a shielded fund-from-asset-lock resume named a different Orchard
* recipient than the one the tracked lock recorded when it was built. Nothing
* was submitted or paid; resume with the recorded recipient. Locks tracked
* before the recipient was recorded carry none and accept the caller's.
*/
class AssetLockRecipientMismatch(message: String, cause: Throwable? = null) :
PlatformWallet(message, cause)

/**
* `ErrorShieldedNoRecordedAnchor` (native code 19). A shielded spend
* could not be built against a Platform-recorded anchor because the
Expand Down Expand Up @@ -771,6 +780,7 @@ sealed class DashSdkError(
27 -> PlatformWallet.ShutdownIncomplete(message, cause) // ErrorShutdownIncomplete
29 -> PlatformWallet.AssetLockInsufficientFunds(message, cause) // ErrorAssetLockInsufficientFunds
60 -> PlatformWallet.AssetLockTooManyInputs(message, cause) // ErrorAssetLockTooManyInputs
61 -> PlatformWallet.AssetLockRecipientMismatch(message, cause) // ErrorAssetLockRecipientMismatch
// The deferred-token trio sits at the contiguous block 34-36 because
// 27-33 are claimed elsewhere: 27 ErrorShutdownIncomplete
// (dashpay/platform#4268, merged), 29 ErrorAssetLockInsufficientFunds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ class DashSdkErrorTest {
assertFalse(mapped.isRetryable)
}

@Test
fun shouldPreserveAssetLockRecipientMismatchAsATypedRefusal() {
val native = DashSDKException(DashSdkError.PLATFORM_WALLET_CODE_OFFSET + 61, "cannot be resumed to")
val mapped = DashSdkError.fromNative(native)
assertTrue(mapped is DashSdkError.PlatformWallet.AssetLockRecipientMismatch)
assertEquals(native.message, mapped.message)
assertFalse(mapped.isRetryable)
}

@Test
fun mapsNativeCodesToHierarchy() {
// Codes mirror DashSDKErrorCode in rs-sdk-ffi/src/error.rs.
Expand Down
6 changes: 4 additions & 2 deletions packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ These are shipped ABI. Do not renumber.
| 98 | `NotFound` | Sentinel — `Option` returned as an error |
| 99 | `ErrorUnknown` | Sentinel — unmapped/flattened errors |

**Next allocatable integer: 61** — 27–60 are all claimed (27, 29, 31, 34–42
**Next allocatable integer: 62** — 27–61 are all claimed (27, 29, 31, 34–42
and 46 merged; 43–45 proposed by active #4313 at head `0302b188ab`; 47 and
48 proposed by active #4356 (47 renumbered from 42, 48 from 43 — see their
rows below); 49–54 proposed by active #4586 (the persister
Expand All @@ -123,7 +123,8 @@ shield debits and durable recovery errors; 58 proposed by #4799 for an unavailab
identity balance response; 59 proposed by #5322 for an SPV
teardown that needs a process restart; 60 proposed by the pooled Core-to-shielded
wallet drain for `ErrorAssetLockTooManyInputs` (Rust, Swift and Kotlin mirrors —
renumbered from 59 when #5322 took that number on `v5.1-dev`); 28, 30,
renumbered from 59 when #5322 took that number on `v5.1-dev`); 61 proposed by
#5603 for `ErrorAssetLockRecipientMismatch`; 28, 30,
32 and 33 reserved). **28, 30,
32 and 33 are RESERVED, not free**: 28 and 30 were vacated when the
reservation trio moved to 34–36; 32 and 33 lapsed when their in-repo owners
Expand Down Expand Up @@ -177,6 +178,7 @@ Fork-era numbers remain in the collision history, which is immutable record.
| 58 | `ErrorIdentityBalanceUnavailable` | #4799 | Proposed — Platform returned no balance for a managed identity. Retrying the read is safe; this is distinct from missing wallet ownership and must not trigger registration or funding |
| 59 | `ErrorSpvProcessRestartRequired` | #5322 | Proposed — SPV startup or teardown panicked; restart the host process. Not retryable, unlike 27, which SPV start, stop and storage clear now return while an SPV teardown is still running. Typed in Rust, Swift and Kotlin (the PR also types 27 on Kotlin) |
| 60 | `ErrorAssetLockTooManyInputs` | Core-to-shielded pooled Max | Proposed — an asset lock needs more inputs than one may carry (100 on Dash Core relay policy and Platform consensus): the full drain, or since #5712 a fixed amount held only in many small coins (identity registration, top-up, invitation, platform-address funding). Two meanings. On a build: nothing was broadcast, the reservation is released, no partial drain, and a rebuild after consolidating is safe. On the resume of a tracked `Built` / `Broadcast` lock over the cap (since #5714): it is not re-sent, but an earlier attempt may have reached peers; the row stays tracked and nothing is released. Rust, Swift and Kotlin retain the typed refusal. Renumbered from 59 after #5322 claimed it |
| 61 | `ErrorAssetLockRecipientMismatch` | dashpay/platform#5603 (tracked-lock shielded recipient) | Proposed — a shielded fund-from-asset-lock resume (the generic outpoint resume or a repeated-UUID wallet drain) names a different Orchard recipient than the one the tracked lock recorded when it was built. Nothing was submitted or paid; resume with the recorded recipient, which the row and `TrackedAssetLockFFI` expose. Rows tracked before recipients were recorded carry none and accept the caller's. Typed in Rust, Swift and Kotlin |
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

**Code 31 left this table on 2026-08-04.** `ErrorSigningKeyUnavailable` sat here
as #4183's proposal until #4183 merged (`189a3abb1c`); it is now in the merged
Expand Down
10 changes: 10 additions & 0 deletions packages/rs-platform-wallet-ffi/src/asset_lock/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ pub struct TrackedAssetLockFFI {
pub status: u32,
/// Whether a proof is attached.
pub has_proof: bool,
/// Whether `shielded_recipient_raw_43` carries the Orchard recipient a
/// shielded funding (funding type 5) was built to pay. False for other
/// funding types and for shielded locks tracked before the recipient was
/// recorded (a resume of those pays the recipient the caller names).
pub has_shielded_recipient: bool,
/// The raw 43-byte Orchard recipient a resume of this lock pays, valid
/// only when `has_shielded_recipient` is true (all zero otherwise).
pub shielded_recipient_raw_43: [u8; 43],
Comment thread
llbartekll marked this conversation as resolved.
Resolved
}

/// Destroy an AssetLockManager handle.
Expand Down Expand Up @@ -85,6 +93,8 @@ pub unsafe extern "C" fn asset_lock_manager_list_tracked_locks(
AssetLockStatus::DrainCompleted => 6,
},
has_proof: lock.proof.is_some(),
has_shielded_recipient: lock.shielded_recipient.is_some(),
shielded_recipient_raw_43: lock.shielded_recipient.unwrap_or([0; 43]),
}
})
.collect();
Expand Down
39 changes: 39 additions & 0 deletions packages/rs-platform-wallet-ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,13 @@ pub enum PlatformWalletFFIResultCode {
/// coins lets either lock fit.
ErrorAssetLockTooManyInputs = 60,

/// A shielded funding is being resumed to a different Orchard recipient
/// than the one its tracked asset lock recorded when it was built. Nothing
/// was submitted and nothing was paid; resume with the recorded recipient
/// (the row exposes it). Rows tracked before the recipient was recorded
/// carry none and accept the caller's.
ErrorAssetLockRecipientMismatch = 61,

/// The named thing does not exist.
///
/// Originally (and still mostly) the code for every `Option` returned as an
Expand Down Expand Up @@ -1050,6 +1057,9 @@ impl From<PlatformWalletError> for PlatformWalletFFIResult {
PlatformWalletError::AssetLockTooManyInputs { .. } => {
PlatformWalletFFIResultCode::ErrorAssetLockTooManyInputs
}
PlatformWalletError::AssetLockRecipientMismatch { .. } => {
PlatformWalletFFIResultCode::ErrorAssetLockRecipientMismatch
}
// A quiesce/drain barrier that did not complete within budget
// (clear/reset paths). The host must fail closed: keep its
// callback context alive and skip any paired persistence wipe.
Expand Down Expand Up @@ -2249,6 +2259,35 @@ mod tests {
/// starts emitting it. The message must carry the typed `Display` —
/// including the spender's finality — since that is the only detail
/// channel the frozen `{ code, message }` ABI has.
/// The recipient-mismatch refusal a shielded resume raises, pinned so the
/// Swift/Kotlin mirrors decode it, together with the conversion that keeps
/// it from flattening to `ErrorUnknown`.
#[test]
fn asset_lock_recipient_mismatch_code_is_pinned_at_61() {
assert_eq!(
PlatformWalletFFIResultCode::ErrorAssetLockRecipientMismatch as i32,
61
);
let recorded = [1u8; 43];
let requested = [2u8; 43];
let result: PlatformWalletFFIResult = PlatformWalletError::AssetLockRecipientMismatch {
out_point: dashcore::OutPoint::null(),
recorded,
requested,
}
.into();
assert_eq!(
result.code,
PlatformWalletFFIResultCode::ErrorAssetLockRecipientMismatch
);
let message = message_of(&result);
assert!(
message.contains("cannot be resumed to"),
"the typed Display must survive the conversion: {message}"
);
assert!(message.contains(&hex::encode(recorded)));
}

#[test]
fn asset_lock_input_conflict_code_is_pinned_at_47() {
use dashcore::OutPoint;
Expand Down
13 changes: 11 additions & 2 deletions packages/rs-platform-wallet-ffi/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use crate::event_handler::{
use crate::handle::*;
use crate::persistence::{
FFIPersister, FreeTrackedMasternodesFn, LoadAssetLockOperationIdFn,
LoadIdentityBalanceBlockTimeFn, LoadTrackedMasternodesFn, PersistAssetLockOperationIdFn,
PersistDpnsNameStatesFn, PersistIdentityBalanceBlockTimeFn, PersistTrackedMasternodesFn,
LoadAssetLockShieldedRecipientFn, LoadIdentityBalanceBlockTimeFn, LoadTrackedMasternodesFn,
PersistAssetLockOperationIdFn, PersistAssetLockShieldedRecipientFn, PersistDpnsNameStatesFn,
PersistIdentityBalanceBlockTimeFn, PersistTrackedMasternodesFn,
PersistWalletChangesetChainLockHeightFn, PersistWalletChangesetSweepsFn,
PersistWalletChangesetUtxoVerdictsFn, PersistWalletDashPayBackfillFn, PersistenceCallbacks,
PersistenceCallbacksExtension, PersistenceCapabilitiesFFI, PersistenceExtensionCallbacks,
Expand Down Expand Up @@ -290,6 +291,14 @@ unsafe fn persistence_extension_callbacks(
on_load_asset_lock_operation_id_fn,
LoadAssetLockOperationIdFn
),
persist_asset_lock_shielded_recipient: slot!(
on_persist_asset_lock_shielded_recipient_fn,
PersistAssetLockShieldedRecipientFn
),
load_asset_lock_shielded_recipient: slot!(
on_load_asset_lock_shielded_recipient_fn,
LoadAssetLockShieldedRecipientFn
),
}
}

Expand Down
Loading
Loading