Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4178e09
fix(platform-wallet): check an invitation claim against Platform befo…
jeanpierreroma Oct 22, 2026
4bfbb24
docs(platform-wallet): name #5536 as the owner of codes 63-66
jeanpierreroma Oct 22, 2026
7863d1f
fix(platform-wallet): address review of the invitation claim preflight
jeanpierreroma Oct 22, 2026
5be60e7
fix(swift-sdk): keep Platform's refusal on invitationKeysAlreadyRegis…
jeanpierreroma Oct 22, 2026
b96690e
fix(sdk): pin the claim's preflight wiring and load our own identity …
jeanpierreroma Oct 24, 2026
a51289b
fix(sdk): keep a failed identity load apart from a missing identity i…
jeanpierreroma Oct 26, 2026
da374fc
fix(sdk): reject a negative index in loadIdentityAtIndex and scope th…
jeanpierreroma Oct 26, 2026
0f1630f
Merge branch 'v5.1-dev' into feat/invitation-claim-preflight
romchornyi Nov 11, 2026
415f5b0
Merge branch 'v5.1-dev' into feat/invitation-claim-preflight
romchornyi Nov 11, 2026
da9c91a
Merge branch 'v5.2-dev' into feat/invitation-claim-preflight
romchornyi Nov 13, 2026
ef70fa6
fix(swift-example-app): skip identity slots held by an in-flight regi…
romchornyi Nov 13, 2026
7415d59
fix(swift-example-app): reserve the invitation claim's identity slot …
romchornyi Nov 13, 2026
f312d90
fix(swift-example-app): save the invitation claim's slot reservation …
romchornyi Nov 13, 2026
e5deb4a
fix(sdk): refuse invitation claim keys that Platform's structural val…
romchornyi Nov 13, 2026
a489bff
fix(sdk): validate invitation claim keys at the network's protocol ve…
romchornyi Nov 15, 2026
8a78a87
fix(sdk): judge invitation claim keys by the network's verified proto…
romchornyi Nov 15, 2026
f160a3c
fix(platform-wallet): keep an invitation claim to the wallet generati…
romchornyi Nov 15, 2026
28852e6
fix(platform-wallet): fence an own-claim refusal and identity load to…
romchornyi Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/sdk/sdk-parity-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"platform_wallet_get_private_pair_held": "packages/rs-platform-wallet-ffi/src/private_contact_request.rs",
"platform_wallet_get_private_payments_restore_failure": "packages/rs-platform-wallet-ffi/src/private_contact_request.rs",
"platform_wallet_get_public_contact_request_unconfirmed": "packages/rs-platform-wallet-ffi/src/private_contact_request.rs",
"platform_wallet_invitation_claim_status_for_identity": "packages/rs-platform-wallet-ffi/src/invitation.rs",
"platform_wallet_manager_accept_contact_request_replying_in_kind": "packages/rs-platform-wallet-ffi/src/private_contact_request.rs",
"platform_wallet_manager_accept_private_contact_request": "packages/rs-platform-wallet-ffi/src/private_contact_request.rs",
"platform_wallet_manager_create_with_persistence_capabilities": "packages/rs-platform-wallet-ffi/src/manager.rs",
Expand Down Expand Up @@ -662,6 +663,47 @@
}
]
},
{
"id": "dashpay.invitation_claim_status_for_identity",
"title": "Invitation claim status tells whether this wallet made the claim",
"area": "shared-policy",
"shared_apis": [
"platform_wallet_invitation_claim_status_for_identity"
],
"required_persistence_capabilities": [],
"hosts": {
"swift": {
"sdk": "supported",
"example_app": "not-applicable",
"restart": "not_applicable",
"reason": null
},
"kotlin": {
"sdk": "unsupported",
"example_app": "not-applicable",
"restart": "not_applicable",
"reason": "The JNI exposes neither the invitation claim status nor its wallet-aware variant; Android can read the claim's typed outcomes (codes 63-66) but cannot ask before claiming. Bridge platform_wallet_invitation_claim_status_for_identity when an Android caller needs it."
}
},
"verification": [
{
"host": "swift",
"kind": "unit",
"file": "packages/swift-sdk/SwiftTests/SwiftDashSDKTests/ErrorHandlingTests.swift",
"id": "testShouldDecodeWhoseInvitationClaimItWas",
"command": "cd packages/swift-sdk && xcodebuild test -scheme SwiftDashSDK -destination 'platform=iOS Simulator,name=iPhone 17 Pro' -only-testing:SwiftDashSDKTests/ErrorHandlingTests",
"covers_restart": false
},
{
"host": "shared",
"kind": "unit",
"file": "packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs",
"id": "should_resolve_the_master_key_only_for_a_claimed_invitation",
"command": "cargo test -p platform-wallet --all-features --lib invitation",
"covers_restart": false
}
]
},
{
"id": "core.provider_restore",
"title": "Provider special transactions restore with wallet ownership",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.dashfoundation.dashsdk.errors.DashSdkError
import org.dashfoundation.dashsdk.identity.RegistrationKeys
import org.dashfoundation.dashsdk.tokens.InvitationPreview
import org.dashfoundation.dashsdk.wallet.PlatformWalletManager
import org.dashfoundation.example.di.LocalAppContainer
import org.dashfoundation.example.di.LocalAppState
import org.dashfoundation.example.services.DashpayKeyProvisioning
import org.dashfoundation.example.util.Base58
import org.dashfoundation.example.util.toHex

/**
Expand Down Expand Up @@ -162,13 +165,47 @@ fun ClaimInvitationSheet(
)
},
)
mgr.identityRegistration.claimInvitation(
walletHandle = wallet.handle,
uri = uri,
identityIndex = identityIndex,
keys = keySet,
signerHandle = mgr.signerHandle,
)
try {
mgr.identityRegistration.claimInvitation(
walletHandle = wallet.handle,
uri = uri,
identityIndex = identityIndex,
keys = keySet,
signerHandle = mgr.signerHandle,
)
} catch (e: DashSdkError.PlatformWallet.InvitationClaimedByThisWallet) {
// The invitation's identity is this wallet's: one it
// records, or one an earlier claim at this index
// created without recording it, which is loaded like
// any identity of this wallet. Only the identity the
// error names counts.
val claimedId = Base58.decodeIdentifier(e.identityId) ?: throw e
walletOwned.firstOrNull {
it.walletId?.contentEquals(wallet.walletId) == true &&
it.identityId.contentEquals(claimedId)
}?.identityId
?: identityAt(wallet.handle, mgr, identityIndex) { cause ->
"This invitation already created identity ${e.identityId} " +
"in this wallet, but loading it failed: $cause. Try again."
}?.takeIf { it.contentEquals(claimedId) }
?: throw e
Comment thread
romchornyi marked this conversation as resolved.
Resolved
} catch (e: DashSdkError.PlatformWallet.InvitationKeysAlreadyRegistered) {
// The keys at this index belong to an identity. When
// it is this wallet's own, unrecorded one, loading it
// records it, and the next claim takes the next index.
// Any other owner keeps the refusal.
val owner = e.identityId ?: throw e
val ownerId = Base58.decodeIdentifier(owner) ?: throw e
val loaded = identityAt(wallet.handle, mgr, identityIndex) { cause ->
"Identity $owner holds these keys, but checking whether it " +
"is this wallet's failed: $cause. Try again."
}
if (loaded?.contentEquals(ownerId) != true) throw e
throw ClaimRecoveryMessage(
"Identity $owner of this wallet already used these keys and " +
"is now loaded. Claim again once it is listed.",
)
}
}
val username = preview.inviterUsername
if (username != null) {
Expand All @@ -177,7 +214,13 @@ fun ClaimInvitationSheet(
onClose()
}
} catch (t: Throwable) {
errorMessage = t.message ?: "Claiming the invitation failed."
errorMessage = when (t) {
is DashSdkError.PlatformWallet.InvitationClaimedByThisWallet ->
"This invitation already created identity ${t.identityId} in this wallet. " +
"If it is not listed, try Search Wallets for Identities."
is ClaimRecoveryMessage -> t.message
else -> t.message ?: "Claiming the invitation failed."
}
} finally {
isClaiming = false
appUiState.invitationClaimInFlight.value = false
Expand Down Expand Up @@ -315,3 +358,29 @@ fun ClaimInvitationSheet(
)
}
}


/**
* Loads this wallet's identity at [identityIndex], recording it. A failed
* load is thrown as [ClaimRecoveryMessage] built by [failure] from its cause.
*/
private suspend fun identityAt(
walletHandle: Long,
mgr: PlatformWalletManager,
identityIndex: Int,
failure: (String) -> String,
): ByteArray? = try {
mgr.identityRegistration.loadIdentityAtIndex(
walletHandle = walletHandle,
mnemonicResolverHandle = mgr.mnemonicResolverHandle,
identityIndex = identityIndex,
)
} catch (e: Exception) {
throw ClaimRecoveryMessage(failure(e.message ?: e.javaClass.simpleName), e)
}

/** A recovery outcome of the claim, shown to the user as is. */
private class ClaimRecoveryMessage(
override val message: String,
cause: Throwable? = null,
) : Exception(message, cause)
15 changes: 8 additions & 7 deletions packages/kotlin-sdk/PARITY_SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
# Kotlin/Swift executable parity summary

Audit baseline: `PR #3999 @ 6dbc72a54df72d26eb9c4a014b425d2b95134e4e`
Capabilities tracked: **30**
Capabilities tracked: **31**

## Status counts

| Host | Surface | Supported | Partial | Unsupported | Not applicable |
| --- | --- | ---: | ---: | ---: | ---: |
| Swift | SDK | 17 | 11 | 1 | 1 |
| Swift | Example app | 5 | 14 | 2 | 9 |
| Kotlin | SDK | 14 | 14 | 1 | 1 |
| Kotlin | Example app | 6 | 13 | 1 | 10 |
| Swift | SDK | 18 | 11 | 1 | 1 |
| Swift | Example app | 5 | 14 | 2 | 10 |
| Kotlin | SDK | 14 | 14 | 2 | 1 |
| Kotlin | Example app | 6 | 13 | 1 | 11 |

## Restart coverage

| Host | Tested | Required | Not applicable |
| --- | ---: | ---: | ---: |
| Swift | 2 | 10 | 18 |
| Kotlin | 5 | 8 | 17 |
| Swift | 2 | 10 | 19 |
| Kotlin | 5 | 8 | 18 |

## Capability status

Expand All @@ -31,6 +31,7 @@ Capabilities tracked: **30**
| `tokens.full_u64_domain` | partial / partial / required | supported / supported / tested |
| `shielded.seedless_restart` | supported / partial / required | partial / partial / required |
| `dashpay.invitations` | supported / partial / required | supported / partial / required |
| `dashpay.invitation_claim_status_for_identity` | supported / not-applicable / not_applicable | unsupported / not-applicable / not_applicable |
| `core.provider_restore` | supported / partial / required | partial / partial / required |
| `dashpay.deferred_contact_crypto` | partial / partial / required | partial / partial / required |
| `dashpay.private_contact_requests` | partial / partial / required | partial / partial / required |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,57 @@ sealed class DashSdkError(
class AssetLockRecipientMismatch(message: String, cause: Throwable? = null) :
PlatformWallet(message, cause)

/**
* Code 63: a key of the DashPay invitation claim is already
* registered to another identity ([identityId], base58; `null` when
* Platform refused the broadcast without naming it). Definitive for
* these keys.
*/
class InvitationKeysAlreadyRegistered(
val identityId: String?,
cause: Throwable? = null,
) : PlatformWallet(
if (identityId == null) {
"A key of this invitation claim is already registered to another identity."
} else {
"A key of this invitation claim is already registered to identity $identityId."
},
cause,
)

/**
* Code 64: the invitation's identity ([identityId], base58) is this
* wallet's: it holds the claim's master key (an earlier claim landed)
* or the wallet already records it. Nothing was recorded, and nothing
* was broadcast unless a node that lagged behind let the claim
* through; load the identity like any of the wallet's own.
*/
class InvitationClaimedByThisWallet(
val identityId: String,
cause: Throwable? = null,
) : PlatformWallet(
"This invitation was already claimed by this wallet as identity $identityId.",
cause,
)

/**
* Code 65: the invitation claim could not verify Platform's answers
* yet. Nothing was broadcast; retry once synced.
*/
class InvitationNotReady(message: String, cause: Throwable? = null) :
PlatformWallet(message, cause) {
override val isRetryable: Boolean get() = true
}

/**
* Code 66: the asset lock is not usable yet (not propagated, or not
* chain-locked for a ChainLock proof). Retry later.
*/
class AssetLockNotChainLocked(message: String, cause: Throwable? = null) :
PlatformWallet(message, cause) {
override val isRetryable: Boolean get() = true
}

/**
* `ErrorShieldedNoRecordedAnchor` (native code 19). A shielded spend
* could not be built against a Platform-recorded anchor because the
Expand Down Expand Up @@ -922,6 +973,24 @@ sealed class DashSdkError(
29 -> PlatformWallet.AssetLockInsufficientFunds(message, cause) // ErrorAssetLockInsufficientFunds
60 -> PlatformWallet.AssetLockTooManyInputs(message, cause) // ErrorAssetLockTooManyInputs
61 -> PlatformWallet.AssetLockRecipientMismatch(message, cause) // ErrorAssetLockRecipientMismatch
63 -> parseErrorDetail(message)?.let { detail ->
runCatching {
PlatformWallet.InvitationKeysAlreadyRegistered(
identityId = detail.optionalString("identityId"),
cause = cause,
)
}.getOrNull()
} ?: PlatformWallet.Generic(code, message, cause)
64 -> parseErrorDetail(message)?.let { detail ->
runCatching {
PlatformWallet.InvitationClaimedByThisWallet(
identityId = requireNotNull(detail.optionalString("identityId")),
cause = cause,
)
}.getOrNull()
} ?: PlatformWallet.Generic(code, message, cause)
65 -> PlatformWallet.InvitationNotReady(message, cause) // ErrorInvitationNotReady
66 -> PlatformWallet.AssetLockNotChainLocked(message, cause) // ErrorAssetLockNotChainLocked
// 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 All @@ -932,7 +1001,7 @@ sealed class DashSdkError(
35 -> PlatformWallet.ReservationTokenConsumed(message, cause) // ErrorReservationTokenConsumed
36 -> PlatformWallet.ReservationWalletMismatch(message, cause) // ErrorReservationWalletMismatch
37 -> PlatformWallet.DocumentNotForSale(message, cause)
38 -> parseMarketplaceDetail(message)?.let { detail ->
38 -> parseErrorDetail(message)?.let { detail ->
runCatching {
PlatformWallet.DocumentPriceChanged(
documentId = detail.getString("documentId"),
Expand All @@ -942,7 +1011,7 @@ sealed class DashSdkError(
)
}.getOrNull()
} ?: PlatformWallet.Generic(code, message, cause)
39 -> parseMarketplaceDetail(message)?.let { detail ->
39 -> parseErrorDetail(message)?.let { detail ->
runCatching {
PlatformWallet.InsufficientIdentityCredits(
identityId = detail.getString("identityId"),
Expand All @@ -952,7 +1021,7 @@ sealed class DashSdkError(
)
}.getOrNull()
} ?: PlatformWallet.Generic(code, message, cause)
40 -> parseMarketplaceDetail(message)?.let { detail ->
40 -> parseErrorDetail(message)?.let { detail ->
runCatching {
PlatformWallet.ContestedNameNotTradable(
label = detail.getString("label"),
Expand Down Expand Up @@ -1017,11 +1086,15 @@ sealed class DashSdkError(
private fun isSigningKeyUnavailable(message: String): Boolean =
message.contains(PlatformWallet.SigningKeyUnavailable.MESSAGE_MARKER)

private fun parseMarketplaceDetail(message: String): JSONObject? =
private fun parseErrorDetail(message: String): JSONObject? =
runCatching { JSONObject(message) }.getOrNull()

private fun JSONObject.requiredULong(name: String): ULong =
get(name).toString().toULong()

/** A string, or `null` when the key is JSON `null` or absent. */
private fun JSONObject.optionalString(name: String): String? =
if (isNull(name)) null else requireNotNull(get(name) as? String) { "$name is not a string" }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ internal object IdentityNative {
inputsBlob: ByteArray,
): ByteArray

/**
* Load the identity registered for this wallet at [identityIndex],
* recording it like discovery does. Returns its 32-byte id, or an
* empty array when no identity is registered at that index.
*/
external fun loadIdentityAtIndex(
walletHandle: Long,
resolverHandle: Long,
identityIndex: Int,
): ByteArray

/**
* Scan the wallet's identity-authentication tree for registered
* identities (gap-limit walk, Rust-side). Returns the concatenated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,24 @@ class IdentityRegistration internal constructor(
}
}

/**
* Load the identity registered for this wallet at [identityIndex] and
* record it like discovery does. Returns its 32-byte id, or `null` when
* no identity is registered there; throws when Platform does not
* answer. Mirrors Swift `ManagedPlatformWallet.loadIdentity(atIndex:)`.
*/
suspend fun loadIdentityAtIndex(
walletHandle: Long,
mnemonicResolverHandle: Long,
identityIndex: Int,
): ByteArray? = gate.op {
require(identityIndex >= 0) { "identityIndex must be non-negative, got $identityIndex" }
val id = mapNativeErrors {
IdentityNative.loadIdentityAtIndex(walletHandle, mnemonicResolverHandle, identityIndex)
}
id.takeIf { it.size == 32 }
}

/**
* Scan the wallet for registered identities (gap-limit walk). Returns
* the discovered 32-byte identity ids.
Expand Down
Loading
Loading