Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private fun statusLabel(status: Int): String = when (status) {
0 -> "Pending"
1 -> "Confirmed"
2 -> "Failed"
4 -> "Failed, inputs spent"
else -> "Unknown"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,21 @@ sealed class DashSdkError(
class PublicContactRequestUnconfirmed(message: String, cause: Throwable? = null) :
PlatformWallet(message, cause)

/**
* `ErrorShieldedIdentityCreateInputsConsumed` (native code 77). An
* identity create from the shielded pool did not create its identity
* and can never execute, as proven reads show: its notes are spent and
* the identity is absent. The wallet marked the notes spent. Not
* retryable: the notes are gone. The reads do not say what spent them:
* Platform's paid failure path for this transition (which credits the
* denomination minus a penalty to its fallback address) is one
* possible cause, the same notes spent by another transition (another
* device with this wallet's keys) another.
* ← Swift `PlatformWalletError.shieldedIdentityCreateInputsConsumed`.
*/
class ShieldedIdentityCreateInputsConsumed(message: String, cause: Throwable? = null) :
PlatformWallet(message, cause)

/**
* Any other `PlatformWalletFFIResultCode` without a dedicated type.
* Carries the platform-wallet [nativeCode] (already de-offset) and
Expand Down Expand Up @@ -1004,6 +1019,7 @@ sealed class DashSdkError(
74 -> PlatformWallet.PrivateContactStoreNotRead(message, cause) // ErrorPrivateContactStoreNotRead
75 -> PlatformWallet.SdkPinnedBelowProtocolVersion(message, cause) // ErrorSdkPinnedBelowProtocolVersion
76 -> PlatformWallet.PublicContactRequestUnconfirmed(message, cause) // ErrorPublicContactRequestUnconfirmed
77 -> PlatformWallet.ShieldedIdentityCreateInputsConsumed(message, cause) // ErrorShieldedIdentityCreateInputsConsumed
else ->
// @Deprecated fallback — see the code-6 arm; code 31 is the
// real discriminator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,16 @@ class DashSdkErrorTest {
assertFalse("a sync settles it, not a retry", mapped.isRetryable)
}

@Test
fun consumedShieldedIdentityCreateCode77MapsTyped() {
val detail = "Shielded identity create did not create its identity"
val native = DashSDKException(DashSdkError.PLATFORM_WALLET_CODE_OFFSET + 77, detail)
val mapped = DashSdkError.fromNative(native)
assertTrue(mapped is DashSdkError.PlatformWallet.ShieldedIdentityCreateInputsConsumed)
assertEquals(detail, mapped.message)
assertFalse("its notes are spent", mapped.isRetryable)
}

@Test
fun platformShieldCapacityCode41MapsTyped() {
val message =
Expand Down
10 changes: 10 additions & 0 deletions packages/rs-dapi-client/src/dapi_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ impl DapiClient {
&self.address_list
}

/// A copy of this client that selects its addresses from `address_list`
/// instead, with the same settings, certificate and proxy. The original
/// client and its address list are not changed.
pub fn with_address_list(&self, address_list: AddressList) -> Self {
Self {
address_list,
..self.clone()
}
}

/// Get all non-banned addresses from the address list.
///
/// Returns a vector of addresses that are not currently banned or whose ban period has expired.
Expand Down
7 changes: 5 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: 77**: 27–76 are all claimed (27, 29, 31, 34–42
**Next allocatable integer: 78**: 27–77 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 @@ -128,7 +128,9 @@ renumbered from 59 when #5322 took that number on `v5.1-dev`); 61 proposed by
by open branches with no row here yet
(62 both `ErrorShieldedClaimBindingMismatch` and `ErrorIdentityRevisionMismatch`,
63–66 the invitation-claim preflight, 67 `ErrorShieldedTreeInconsistent`); 68
to 76 proposed for DashPay private contact requests; 28, 30,
to 76 proposed for DashPay private contact requests; 77 proposed for a
shielded identity create proven to have its inputs consumed without its
identity; 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 @@ -192,6 +194,7 @@ Fork-era numbers remain in the collision history, which is immutable record.
| 74 | `ErrorPrivateContactStoreNotRead` | DashPay private contact requests | Proposed. Maps `PlatformWalletError::PrivateContactStoreNotRead`: DashPay's private contact request store was not read to its end for the identity, with the keys Platform proves it holds, before a contact request or acceptance, public or private, was decided (every one reads it from the identity's cursor first). Nothing was reserved, sealed, paid or broadcast; calling again continues the read from where it stopped. A node behind the store already seen, or keys that kept changing, stop it. It was reported as 71 before, which says not to submit again. Mapped by the blanket conversion and kept by the shielded spend contract (`map_spend_result`). Swift types it (`PlatformWalletError.privateContactStoreNotRead`, `ErrorHandlingTests` pin) and SwiftExampleApp offers a retry with no pending row; Kotlin types it (`DashSdkError.PlatformWallet.PrivateContactStoreNotRead`, `DashSdkErrorTest` pin) and KotlinExampleApp offers a retry with no pending row |
| 75 | `ErrorSdkPinnedBelowProtocolVersion` | DashPay private contact requests | Proposed. The SDK refused a request without sending it because the SDK itself is pinned below the protocol version the request needs (`dash_sdk::Error::ProtocolVersionNotActive` with `pinned`), whatever the network runs: for example every contact request's private store read with the SDK pinned below protocol version 15 on a network at 15. A network upgrade does not lift it; only raising or removing the pin does. Before, it shared 70 with a network proven below the version, which lifts by itself. Mapped by the blanket conversion. Swift types it (`PlatformWalletError.sdkPinnedBelowProtocolVersion`, `ErrorHandlingTests` pin) and SwiftExampleApp shows a developer-facing message; Kotlin types it (`DashSdkError.PlatformWallet.SdkPinnedBelowProtocolVersion`, `DashSdkErrorTest` pin) and KotlinExampleApp shows a developer-facing message |
| 76 | `ErrorPublicContactRequestUnconfirmed` | DashPay private contact requests | Proposed. Maps `PlatformWalletError::PublicContactRequestUnconfirmed`: a public contact request to that identity was broadcast and may have been delivered, and no proof settled its outcome yet, so the wallet holds the pair and signs nothing new to it, public or private. The send or accept that broadcast it reported 20; every later one is refused with 76 until a public contact request sync settles it (its document proved on Platform: recorded as sent; its transition proved unable to write it: the pair freed), broadcasting the same signed bytes again meanwhile. Not a private request pending (71). Mapped by the blanket conversion and by `map_spend_result`. `platform_wallet_get_public_contact_request_unconfirmed` reads the hold per pair (`DashPayView::public_contact_request_unconfirmed`; 7 for a sender the wallet does not hold). Swift types it (`PlatformWalletError.publicContactRequestUnconfirmed`, `ErrorHandlingTests` pin) and wraps the read (`ManagedPlatformWallet.publicContactRequestUnconfirmed`); SwiftExampleApp shows the pair as being checked, with no request or accept offered, until the read says settled, and its refreshes run the DashPay sync that settles it; Kotlin types it (`DashSdkError.PlatformWallet.PublicContactRequestUnconfirmed`, `DashSdkErrorTest` pin), bridges the read (`DashpayNative.publicContactRequestUnconfirmed`, `Dashpay.publicContactRequestsUnconfirmed`), and KotlinExampleApp shows the pair as SwiftExampleApp does |
| 77 | `ErrorShieldedIdentityCreateInputsConsumed` | Shielded identity create, inputs consumed | Proposed. Maps `PlatformWalletError::ShieldedIdentityCreateInputsConsumed`: an identity created from the shielded pool (Type 20) whose result wait failed, its identity not found, is proven by reads at the node it was delivered to to have its inputs consumed without its identity: every nullifier it spends is spent, and the identity is absent at or above the height they were spent by. It can never execute. The notes are marked spent and the activity row failed; the recovery record keeps the outcome until the sync pass has written that row durably; nothing is to be re-submitted. The reads do not say what spent the notes: Platform's paid failure path for this transition is one possible cause, the same notes spent by another transition another. `out_identity_id` is not written and no consensus code rides the result. Typed in Rust, Swift (`PlatformWalletError.shieldedIdentityCreateInputsConsumed`) and Kotlin (`PlatformWallet.ShieldedIdentityCreateInputsConsumed`) |

**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
47 changes: 46 additions & 1 deletion packages/rs-platform-wallet-ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ pub enum PlatformWalletFFIResultCode {
/// could not confirm its execution result (a broadcast attempt that failed
/// in transport, an endpoint's refusal or verdict, a result-proof
/// fetch/verify failure, …), and a direct fetch of the derived id also
/// came back empty. The wallet keeps the notes reserved and the create's
/// came back empty, without proven reads showing a paid failure
/// ([`Self::ErrorShieldedIdentityCreateInputsConsumed`]). The wallet keeps the notes reserved and the create's
/// recovery record, which it saved before the broadcast. The identity may
/// already exist on chain, so the caller must NOT treat
/// it as unregistered or re-submit. UNLIKE every other error code,
Expand Down Expand Up @@ -768,6 +769,23 @@ pub enum PlatformWalletFFIResultCode {
/// [`Self::ErrorPrivateContactRequestPending`] (71).
ErrorPublicContactRequestUnconfirmed = 76,

/// Maps `PlatformWalletError::ShieldedIdentityCreateInputsConsumed`: an
/// identity create from the shielded pool did not create its identity and
/// can never execute, as proven reads (at the node it was delivered to)
/// show: every note it spends is spent, and the identity is absent at or
/// above the height they were spent by. The wallet marked the notes spent
/// and its activity row failed; the create's recovery record keeps the
/// outcome until the sync pass has written that row durably. Nothing is
/// to be re-submitted. The reads do not show what
/// spent the notes: Platform's paid failure path for this transition (a
/// key-state check failing in the block, which credits the denomination
/// minus a penalty to `send_to_address_on_creation_failure`) is one
/// possible cause, the same notes spent by another transition (another
/// device with this wallet's keys) another. `out_identity_id` is not
/// written. No consensus code rides the result: the proof is the reads,
/// not a node's verdict.
ErrorShieldedIdentityCreateInputsConsumed = 77,

/// The named thing does not exist.
///
/// Originally (and still mostly) the code for every `Option` returned as an
Expand Down Expand Up @@ -1080,6 +1098,9 @@ impl From<PlatformWalletError> for PlatformWalletFFIResult {
PlatformWalletError::ShieldedBroadcastUnconfirmed { .. } => {
PlatformWalletFFIResultCode::ErrorShieldedBroadcastUnconfirmed
}
PlatformWalletError::ShieldedIdentityCreateInputsConsumed { .. } => {
PlatformWalletFFIResultCode::ErrorShieldedIdentityCreateInputsConsumed
}
// A broadcast that may have been delivered may still execute: it
// reads as unconfirmed, never as failed, so a host does not pay
// again with other notes.
Expand Down Expand Up @@ -3120,6 +3141,30 @@ mod private_contact_request_error_tests {
);
}

/// A shielded identity create proven unable to execute without its
/// identity reaches the host by its own code, with its message, and no
/// consensus code: the proof is the reads, not a node's verdict.
#[test]
fn should_report_a_consumed_shielded_identity_create_by_its_own_code() {
let consumed = PlatformWalletError::ShieldedIdentityCreateInputsConsumed {
identity_id: dpp::prelude::Identifier::from([7u8; 32]),
consumed_by_height: 12,
reason: "result wait failed".to_string(),
};
let rendered = consumed.to_string();
let result = PlatformWalletFFIResult::from(consumed);
assert_eq!(
result.code,
PlatformWalletFFIResultCode::ErrorShieldedIdentityCreateInputsConsumed
);
assert_eq!(result.code as u32, 77);
assert_eq!(result.consensus_code, 0);
let msg = unsafe { std::ffi::CStr::from_ptr(result.message) }
.to_string_lossy()
.into_owned();
assert_eq!(msg, rendered, "Display payload must survive verbatim");
}

/// A public contact request a loaded wallet refuses until its private
/// payments are restored reaches the host by its own code, not as a
/// contact's pending request.
Expand Down
5 changes: 4 additions & 1 deletion packages/rs-platform-wallet-ffi/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4779,14 +4779,15 @@ fn activity_direction_tag(d: &platform_wallet::wallet::shielded::ShieldedDirecti
}

/// Discriminant byte for a `ShieldedActivityStatus` (FFI: 0 Pending,
/// 1 Confirmed, 2 Failed, 3 Unknown).
/// 1 Confirmed, 2 Failed, 3 Unknown, 4 InputsConsumed).
#[cfg(feature = "shielded")]
fn activity_status_tag(s: &ShieldedActivityStatus) -> u8 {
match s {
ShieldedActivityStatus::Pending => 0,
ShieldedActivityStatus::Confirmed => 1,
ShieldedActivityStatus::Failed => 2,
ShieldedActivityStatus::Unknown => 3,
ShieldedActivityStatus::InputsConsumed => 4,
}
}

Expand All @@ -4798,6 +4799,7 @@ fn activity_status_from_tag(tag: u8) -> ShieldedActivityStatus {
1 => ShieldedActivityStatus::Confirmed,
2 => ShieldedActivityStatus::Failed,
3 => ShieldedActivityStatus::Unknown,
4 => ShieldedActivityStatus::InputsConsumed,
other => {
tracing::warn!(
status = other,
Expand All @@ -4820,6 +4822,7 @@ mod activity_status_tests {
(ShieldedActivityStatus::Confirmed, 1),
(ShieldedActivityStatus::Failed, 2),
(ShieldedActivityStatus::Unknown, 3),
(ShieldedActivityStatus::InputsConsumed, 4),
] {
assert_eq!(activity_status_tag(&status), tag);
assert_eq!(activity_status_from_tag(tag), status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub struct ShieldedActivityFFI {
pub kind_tag: u8,
/// Direction: 0 In, 1 Out, 2 Self.
pub direction: u8,
/// Status: 0 Pending, 1 Confirmed, 2 Failed, 3 Unknown.
/// Status: 0 Pending, 1 Confirmed, 2 Failed, 3 Unknown, 4 InputsConsumed.
pub status: u8,
/// Display amount in credits (principal; excludes self-change and
/// zero-value fillers).
Expand Down
13 changes: 12 additions & 1 deletion packages/rs-platform-wallet-ffi/src/shielded_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,12 @@ fn map_asset_lock_funding_result(
/// expose). If identity creation fails a stateful check (a public-key hash already registered to
/// another identity) the spend is still finalized and the value is credited to this address minus a
/// penalty, exactly like the asset-lock / address-funded identity-create penalties. It is bound into
/// the transition sighash, so it cannot be redirected after signing.
/// the transition sighash, so it cannot be redirected after signing. A create whose notes proven
/// reads show spent and whose identity they show absent returns
/// [`ErrorShieldedIdentityCreateInputsConsumed`]: that path is one possible cause, the same notes
/// spent by another transition another, and the result does not say which.
///
/// [`ErrorShieldedIdentityCreateInputsConsumed`]: crate::error::PlatformWalletFFIResultCode::ErrorShieldedIdentityCreateInputsConsumed
///
/// `mnemonic_resolver_handle` supplies the per-operation Orchard spend authority (see
/// `platform_wallet_manager_shielded_transfer`).
Expand Down Expand Up @@ -1115,6 +1120,10 @@ pub unsafe extern "C" fn platform_wallet_manager_shielded_identity_create_from_p
PlatformWalletFFIResultCode::ErrorShieldedNoRecordedAnchor,
format!("Wallet is still syncing to a confirmed state — try again shortly. ({e})"),
),
// Proven unable to execute: its notes are spent and its identity is absent. The notes
// were marked spent wallet-side; `out_identity_id` is not written, as the identity does
// not exist.
Err(e @ PlatformWalletError::ShieldedIdentityCreateInputsConsumed { .. }) => e.into(),
// Definitive failure: the transition was not executed and the spent notes were released.
Err(e @ PlatformWalletError::ShieldedBroadcastFailed(_)) => PlatformWalletFFIResult::err(
PlatformWalletFFIResultCode::ErrorShieldedBroadcastFailed,
Expand Down Expand Up @@ -2487,6 +2496,8 @@ mod tests {
.arm_redrive(
SubwalletId::new([7; 32], 9),
PendingRedrive {
outcome_endpoint: None,
identity_outcome: None,
activity_id: [8; 32],
anchor: [9; 32],
nullifiers: vec![[10; 32]],
Expand Down
Loading
Loading