Skip to content

feat(platform-wallet): one address top-up for any identity - #5929

Merged
romchornyi merged 30 commits into
v5.2-devfrom
feat/platform-wallet-top-up-any-identity
Nov 23, 2026
Merged

romchornyi merged 30 commits into
v5.2-devfrom
feat/platform-wallet-top-up-any-identity

Conversation

@romchornyi

@romchornyi romchornyi commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Refs #5925 (this PR does items 1 and 3; item 2, Rust selecting the funding inputs, stays open in that issue for a follow-up). Based on v5.2-dev, which now holds #5860 (e451c35); this PR is no longer stacked.

Hosts had to choose between two top-up exports (managed vs any other identity), so each app decided "is this identity mine?" on its own, and a managed identity topped up through the external route kept a stale cached balance until the next sync.

What was done?

One address top-up for any identity

  • PlatformWallet::top_up_identity_from_addresses: always fetches the identity from Platform; after a confirmed proof, record_top_up_balance writes the balance back only when the identity manager holds that id. No identity is ever added to the manager.
  • It runs on feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860's lifecycle split unchanged: liveness check, then the fetch and the signing outside the teardown gate, then the gate (generation_payment_guard) and a second liveness check before the broadcast, held through the result wait, the balance write-back and the reconciliation. A wallet removed or re-created before or during signing is WalletRemovedBeforeSend (FFI 98), nothing broadcast. Nonce binding, the balance-growth check against the balance read from Platform before signing, the oversized pre-check, the delivery rules (20 for anything possibly delivered, never 21) and funding_inputs validation are feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860's, shared by every route.
  • One addition to feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860's flow: the sign step checks once more, through the handle's generation, after the identity and address-nonce reads and before the host is asked to sign, so a wallet removed during those reads gets no signing prompt. The check under the gate stays the decisive one.
  • FFI platform_wallet_top_up_identity_from_addresses_with_signer, Swift ManagedPlatformWallet.topUpIdentityFromAddresses, Kotlin IdentityCredits.topUpIdentityFromAddresses (JNI CreditsNative.topUpIdentityFromAddresses). A Kotlin caller cancelled after the native top-up completed still gets its balance (opReturningCompletedResult).
  • Deprecated, still working and now running on the new operation: top_up_from_addresses, top_up_external_identity_from_addresses, their FFI exports, Swift topUpFromAddresses / topUpExternalIdentityFromAddresses, Kotlin topUpFromAddresses. Their documented errors are feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860's: the managed route refuses an identity the manager does not hold (7) before Platform is asked, a failed lookup is 80, and Platform returning no identity for the managed one is 58; the external route is now the same call as the new one. The example apps call the new method.
  • Parity manifest: the new export is listed under both address top-up capabilities, and Kotlin's external top-up is now supported (summary regenerated). ERROR_CODE_REGISTRY rows 58 and 80 name the exports that return them.

The earlier second commit of this PR (GatedAddressSigner, taking the gate after the last signature) is dropped: #5860 merged its own split of the gate (sign outside, top_up_identity_with rechecks under the gate before send), which closes the same window.

How Has This Been Tested?

  • cargo test -p platform-wallet -p platform-wallet-ffi --all-features: platform-wallet 2157 lib tests passed (27 address top-up tests), platform-wallet-ffi 611 passed and 1 ignored (18 top-up tests), plus the integration suites; rs-unified-sdk-jni 78 passed. New or changed tests: the new route submits for an unmanaged and for a managed identity, leaves the identity manager unchanged, and writes a managed identity's proved balance back from a confirmed top-up (through the composite's seam); the deprecated managed route refuses an unmanaged identity with 7 before Platform is asked and reports 58 when Platform has no identity; empty rows, overflowing rows, a stale or re-created wallet and an oversized transition are refused on every route; removal during signing completes without waiting and the top-up fails with WalletRemovedBeforeSend, for a managed identity and for any other; a wallet re-created during signing is refused the same way; a wallet removed during the identity and nonce reads asks the host for no signature. FFI: every export (new and both deprecated) for the argument guards, empty rows as a list or as (NULL, 0), the panic code and the registry release.
  • cargo fmt --all, cargo clippy -p platform-wallet -p platform-wallet-ffi -p rs-unified-sdk-jni --all-features --all-targets -- -D warnings; python3 scripts/check_sdk_parity_manifest.py passes.
  • Kotlin: :sdk:testDebugUnitTest :app:testDebugUnitTest green (619 + 300 tests), including IdentityAddressTopUpTest.
  • Swift: build_ios.sh --target all (release framework, SwiftExampleApp built with warnings as errors), then swift test: 1052 tests, 0 failures (1 skipped); SwiftExampleApp xcodebuild test on the simulator: 262 unit tests and 8 UI tests (1 skipped) green.

Breaking Changes

None in the API: additions and deprecations only (#[deprecated] on the two Rust routes, @available(*, deprecated) in Swift, @Deprecated in Kotlin). Behaviour of the deprecated routes:

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

🤖 Generated with Claude Code

PR Hygiene · 8f91488

  • Bots — thepastaclaw ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals
    • sdk-parity — you own it
    • kotlin-sdk (packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt, packages/kotlin-sdk/PARITY_SUMMARY.md and 4 more) — approved by HashEngineering
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md, packages/rs-platform-wallet-ffi/src/error.rs, packages/rs-platform-wallet-ffi/src/identity_top_up.rs and 3 more) — approved by HashEngineering
    • rs-platform-wallet (packages/rs-platform-wallet/src/wallet/identity/network/mod.rs, packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs, packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses/external_identity_tests.rs and 1 more) — approved by HashEngineering
    • swift-sdk — you own it

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

romchornyi and others added 22 commits November 11, 2026 13:18
…from Platform addresses

top_up_from_addresses reads the identity from the wallet's identity manager and
returns IdentityNotFound for any other identity, so a wallet could not pay
credits from its Platform addresses to someone else's identity.

- IdentityWallet::top_up_external_from_addresses fetches the identity from
  Platform and runs the same transition; it never adds the identity to the
  manager or persists anything about it. An unknown identity is IdentityNotFound
  with nothing signed or broadcast.
- PlatformWallet::top_up_external_identity_from_addresses reconciles the spent
  addresses through the same path as the managed composite.
- FFI: platform_wallet_top_up_external_identity_from_addresses_with_signer,
  sharing the input marshalling with the managed export.
- The build/broadcast/error mapping is shared by both paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Swift wrapper over platform_wallet_top_up_external_identity_from_addresses_with_signer:
tops up an identity the wallet does not manage from the wallet's Platform
addresses and returns the identity's new balance. It writes nothing to
SwiftData. The managed and external wrappers share one marshalling helper.
The parity manifest records the capability as unsupported in Kotlin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…funding-row policy

Review fixes for the external identity top-up:
- The external composite takes the wallet generation's payment guard and
  checks the generation is current before fetching the identity, holding it
  through signing, broadcast and reconcile; a removed or recreated wallet gets
  WalletRemovedBeforeSend with nothing signed or sent.
- platform-wallet now takes the funding rows, sums repeated addresses and
  refuses an overflowing sum with InvalidParameter; the FFI only converts row
  types, for both the managed and the external export. The managed export now
  errors on overflow instead of saturating, and its empty-input check moves to
  the library.
- The SDK's TransitionNoInputsError maps to InvalidParameter on both routes.
- Swift: the shared helper pins addressSigner with withExtendedLifetime across
  the synchronous FFI call; the exports are injectable and a test through both
  public wrappers shows each calls its own export.
- A composite seam test covers a confirmed external top-up: balance returned,
  spent address reconciled and persisted at the proof height, identity manager
  unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on the signer

Both address top-up exports ran block_on_worker inside
PLATFORM_WALLET_STORAGE.with_item, so the registry read guard stayed held
while the host signed. A wallet handle destroy (write lock) queued behind it,
and any registry read queued behind that destroy, so a signing completion that
reads a balance could never finish.

Clone the wallet Arc in a short with_item and wait on the signer after it
returns. The regression test holds a callback signer pending, then destroys a
second wallet handle and reads a balance; both must finish before the signer
is answered, for both exports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ted composite

Make IdentityWallet::top_up_external_from_addresses crate-private so the
only public route to topping up someone else's identity is
PlatformWallet::top_up_external_identity_from_addresses, which holds the
wallet lifecycle gate and refuses a removed or re-created wallet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…let-external-identity-top-up

# Conflicts:
#	packages/kotlin-sdk/PARITY_SUMMARY.md
…l top-up as not sent

A failed `Identity::fetch` on the external identity top-up surfaced as a
generic `Sdk` error although nothing had been signed or broadcast, which
a host treating unknown errors as "may have gone through" cannot tell
from a failure after a dispatch. It is now
`PlatformWalletError::IdentityLookupFailed`, mapped to the new FFI code
77 `ErrorIdentityLookupFailed` and mirrored in Swift and Kotlin. A missing
identity keeps `IdentityNotFound` (7). No existing code meant "refused
before anything was sent" for a Platform state transition.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r of the shielded spend plan codes

The failed identity lookup code was 77, which the shielded spend plan PR
already uses (77 plan changed, 78 too many notes, 79 withdrawal amount out
of range). Renumber it to 80 in the FFI enum, the registry (next free is
now 81), the Swift result code and the Kotlin error mapping, and update the
Rust, Swift and Kotlin pin tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… unbound state snapshot

The result proof of an identity top-up from addresses authenticates only
the identity and address state at the proof's block, not that this
transition executed. The wallet now signs with nonces it looked up itself
and keeps the result only when the proof shows every input address at or
past its submitted nonce. A snapshot from before is reported as the SDK's
unconfirmed outcome, with nothing reconciled from it, on both the managed
and the external top-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…into a result code

Both address top-up exports ran the composite through block_on_worker,
which re-panics a worker panic inside the extern "C" function and ends
the host. Their bodies now run under catch_panic_to_code and report
ErrorTransactionBroadcastUnconfirmed (20): the panic may strike after
signing or broadcast, so the top-up may still execute and must not be
submitted again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The address top-up promotes a nonce race and an empty input map to their
own errors; every other SDK error was flattened into an
InvalidIdentityData string, losing its typed variant and consensus cause.
It is now kept as PlatformWalletError::Sdk.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
IdentityLookupFailed (code 80) means nothing was signed, reserved or
broadcast, so the operation may be retried as it is; isRetryable now says
so, as the code-80 mapping test asserts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… did not grow as unconfirmed

Used input nonces show that a transition this wallet signed with them executed, not that it paid the
identity: another transition with the same nonces could have spent them elsewhere. The result now also
needs the proved identity balance above the one the top-up started from; otherwise it is
StateTransitionResultUnconfirmed(ExecutionNotProved) (FFI 20) and nothing is reconciled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The detached call copies the wallet handle that ManagedPlatformWallet's deinit destroys; pin the wallet
together with the signer for the whole synchronous FFI call, as refreshIdentityBalance does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… removal

PlatformWallet::top_up_from_addresses now runs through the same seam as the external top-up
(top_up_identity_with): it holds the generation's lifecycle gate from the liveness check through signing,
broadcast and reconciliation, and a wallet removed or re-created since the handle was taken is refused
with WalletRemovedBeforeSend, nothing signed or sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…efore any lookup

An empty row list was accepted and only refused later by the SDK, after
the external route's identity fetch, so it could surface as
IdentityLookupFailed or IdentityNotFound instead of InvalidParameter.
`funding_inputs` now refuses it on both routes before any network I/O,
which leaves the SDK's empty-input refusal unreachable from the top-up;
its promotion is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rm's balance

The managed route took the balance the top-up must grow from the identity
manager's cache. A cache above Platform's value (credits spent from
another device, not yet synced) made an executed top-up report
unconfirmed. The managed route now reads the identity's balance from
Platform before signing and binds the proof to it, as the external route
already does through its identity fetch. A failed read is
IdentityLookupFailed and an unknown identity IdentityNotFound, both
before anything is signed; the managed identity is still the one signed
for and reconciled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…firmed address top-up

The composite and FFI export docs described the unconfirmed outcome
(FFI 20) as nonces-only. A result stands only when its proof shows every
input address at or past its submitted nonce and the identity balance
above the balance the top-up started from, a fresh Platform read taken
before signing on both routes; otherwise it is 20 and nothing is
reconciled. The managed export also documents its new balance-read
errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…roof to its nonces

A competing transition signed by the same seam with the same nonces plus
an unrelated credit to the same identity still satisfies both checks;
closing that needs an execution-bound proof of this transition. The doc
also states that the wallet does not serialise address spends per input
address in-process: the address top-up holds only the shared lifecycle
read guard, and shield_guard covers shield-class operations only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cycle gate

`IdentityWallet::top_up_from_addresses` was public and reachable through
`PlatformWallet::identity()`, so a retained identity handle could spend
around the wallet-generation gate the composite holds. It is now
crate-private, as the external route's identity-side method already is;
callers outside the crate use `PlatformWallet::top_up_from_addresses`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add `PlatformWallet::top_up_identity_from_addresses`: it fetches the
identity from Platform whatever its owner, writes the proved balance back
when the identity manager holds the identity, and never adds an identity
to the manager. The host no longer decides whether an identity is its
own; a managed identity topped up through the external route no longer
keeps a stale cached balance until the next sync.

The lifecycle gate, liveness check, nonce binding, balance-growth check
and reconciliation at the proof's height are unchanged. The growth
baseline is the balance in the fetched identity, as on the external
route; the managed route read the same value through `IdentityBalance`.

Exposed as `platform_wallet_top_up_identity_from_addresses_with_signer`,
`ManagedPlatformWallet.topUpIdentityFromAddresses` (Swift) and
`IdentityCredits.topUpIdentityFromAddresses` (Kotlin, new JNI bridge
`CreditsNative.topUpIdentityFromAddresses`). The example apps use it.

Deprecated, still working on top of the new operation:
- `PlatformWallet::top_up_from_addresses` (`#[deprecated]`) and its
  export, Swift and Kotlin methods: still refuse an identity the manager
  does not hold with IdentityNotFound (7) before Platform is asked.
- `PlatformWallet::top_up_external_identity_from_addresses`
  (`#[deprecated]`) and its export and Swift method: now the same call.

Funding inputs are still chosen by the host (issue item 2 is later).

Refs #5925

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…signing

The address top-up held the wallet generation's payment gate from before
the identity fetch to the end of reconciliation, across the host's
signing prompt. That was agreed on #5860 to close a window in which a
retained handle could broadcast after removal. It contradicts the gate's
own contract (`WalletGeneration::teardown_guard`): an operation awaiting
an external signer takes the gate only after the signature returns, so an
open signing prompt cannot stall teardown. With the wide gate, removing a
wallet waited for whatever the host's signer did, and the write-preferring
lock queued every later payment of that wallet behind the removal.

The top-up now signs through `GatedAddressSigner`, as the contact request
send signs through its `GatedSigner`: when the last input's witness
returns, it takes the gate (`payment_guard_owned`) and checks under it
that the handle's generation is still the registered one. The gate is
then held through the broadcast, the result wait, the managed balance
write-back and the address reconciliation. The transition needs every
witness before it can be broadcast, so nothing reaches the network
without the gate. A wallet removed or re-created while the host signed is
refused there with WalletRemovedBeforeSend and nothing is broadcast; the
window #5860 closed stays closed, because the liveness check and the
broadcast are still one section under the gate. A handle already stale at
the start is still refused before anything is fetched or signed (an
ungated point-in-time check).

Replaces `should_hold_a_wallets_removal_until_its_top_up_returns` with
tests of the new contract: a removal during signing completes without
waiting and the top-up then abandons before broadcast (also for a wallet
re-created meanwhile), and a removal after the last signature waits until
the top-up lets the gate go.

This reverses the #5860 agreement, so it is a separate commit that can be
dropped if maintainers prefer the wide gate.

Refs #5925

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@thepastaclaw

thepastaclaw commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

🔍 Review in progress (commit 8f91488) · live progress

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The Rust routing and lifecycle-gate changes are generally sound, and the supplied CI snapshot contains no failed code checks. One blocking Kotlin cancellation path can hide a completed native top-up and permit a duplicate retry; several lower-severity API, documentation, lifecycle-proof, and test-coverage issues also remain.

🔴 1 blocking | 🟡 6 suggestion(s) | 💬 1 nitpick(s)

2 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Add compiler deprecation annotations to the old top-up wrappers
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift:794-838

The Rust compatibility routes are marked with #[deprecated], but Swift's topUpFromAddresses and topUpExternalIdentityFromAddresses only contain a **Deprecated:** doc comment. The corresponding Kotlin IdentityCredits.topUpFromAddresses method likewise lacks @Deprecated. Consumers therefore receive no compiler warning or migration guidance even though the PR introduces topUpIdentityFromAddresses as the single replacement route. Add @available(*, deprecated, message: ...) to the Swift methods and @Deprecated(...) to the Kotlin method, updating internal dispatch-test call sites as needed.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality)

💬 Nitpick: Document the new JNI top-up export
packages/rs-unified-sdk-jni/src/credits.rs:9-18

The module-level bridge list still documents only platform_wallet_top_up_from_addresses_with_signer as the ID-06 entry point, while the primary export is now platform_wallet_top_up_identity_from_addresses_with_signer. Update the list to document the new any-identity export and identify the old export as the deprecated managed-only variant.

//! - [`platform_wallet_top_up_identity_from_addresses_with_signer`] — top up any
//!   identity from Platform-address inputs (ID-06).
//! - [`platform_wallet_top_up_from_addresses_with_signer`] — deprecated managed-only
//!   variant of the same top-up (ID-06).

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change to funds movement and signing/lifecycle safety in PlatformWallet::top_up_identity_from_addresses and GatedAddressSigner, including broadcast gating and balance reconciliation.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:238-245: Preserve a completed native top-up when the coroutine is cancelled
  This new payment method uses `gate.op`, which runs the synchronous JNI call through `withContext(Dispatchers.IO)`. If cancellation occurs after `addressTopUpNative.call` has broadcast and completed but before the dispatcher handoff returns the value, `withContext` can throw `CancellationException` and discard the completed balance. The caller cannot distinguish a completed top-up from an unsent one and may retry with newly resolved address nonces, crediting the identity twice. Use `gate.opReturningCompletedResult` here, as the neighboring money-moving Kotlin APIs already do, and add a cancellation-after-native-completion regression test.

In `packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift`:
- [SUGGESTION] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift:794-838: Add compiler deprecation annotations to the old top-up wrappers
  The Rust compatibility routes are marked with `#[deprecated]`, but Swift's `topUpFromAddresses` and `topUpExternalIdentityFromAddresses` only contain a `**Deprecated:**` doc comment. The corresponding Kotlin `IdentityCredits.topUpFromAddresses` method likewise lacks `@Deprecated`. Consumers therefore receive no compiler warning or migration guidance even though the PR introduces `topUpIdentityFromAddresses` as the single replacement route. Add `@available(*, deprecated, message: ...)` to the Swift methods and `@Deprecated(...)` to the Kotlin method, updating internal dispatch-test call sites as needed.

In `packages/rs-platform-wallet/src/wallet/platform_wallet.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:717-731: Recheck wallet liveness before prompting the host signer
  `top_up_identity` performs its only ungated `is_current_generation` check before the Platform identity fetch. If the wallet is removed during that fetch or the subsequent nonce lookup, the operation still reaches the host signer and only fails when the last signature acquires the lifecycle gate. No funds are broadcast, but the user receives a needless signing prompt for an operation that is already known to be stale. Repeat the cheap current-generation check after the awaited pre-signing reads, ideally immediately before invoking the host signer; retain the gated check as the decisive race-safe check.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:722-755: Make the lifecycle gate a requirement of top-up bookkeeping
  The production path stores the returned guard in `_lifecycle` and relies on it remaining alive while `record_top_up` writes the managed balance and reconciles addresses, but `record_top_up` accepts no guard parameter. Because it is `pub(crate)`, a future caller can invoke it with a stale handle after the wallet id has been re-created, causing the manager lookup to write into the replacement generation. Thread a reference to the owned lifecycle guard through `record_top_up` and `record_top_up_balance` so the required gate is enforced by the API rather than by documentation and variable scope.

In `packages/rs-unified-sdk-jni/src/credits.rs`:
- [NITPICK] packages/rs-unified-sdk-jni/src/credits.rs:9-18: Document the new JNI top-up export
  The module-level bridge list still documents only `platform_wallet_top_up_from_addresses_with_signer` as the ID-06 entry point, while the primary export is now `platform_wallet_top_up_identity_from_addresses_with_signer`. Update the list to document the new any-identity export and identify the old export as the deprecated managed-only variant.

In `packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs:98-118: Replace the boolean top-up scope with a typed route
  `top_up_identity_from_addresses` uses `managed_only: bool`, and the public methods pass literal `false` and `true` at `platform_wallet.rs:640` and `platform_wallet.rs:669`. Swapping those literals would silently invert the authorization behavior without compiler help. The FFI layer already models this distinction with `AddressTopUpRoute`; use an equivalent Rust enum such as `TopUpScope::AnyIdentity` and `TopUpScope::ManagedOnly` in the wallet core.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs:230-329: Share the lifecycle-gated signer state machine
  This introduces a second lifecycle-gated signer state machine alongside `GatedSigner` in `contact_requests.rs`. Both implementations allow host signing without the teardown gate, acquire the generation read guard after the final signature, check generation identity under the manager lock, and retain the guard through publication and bookkeeping. Keeping these policies duplicated in separate network modules allows a future lock-ordering or stale-generation fix to update one payment path while leaving the other inconsistent. Extract the shared gating/finalization behavior into a common Rust wallet helper while retaining address- and identity-key-specific signing adapters.

In `packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses/external_identity_tests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses/external_identity_tests.rs:684-735: Test that the returned gate spans bookkeeping
  The lifecycle test holds the gate only until `gated.into_gate()` is immediately dropped, while the bookkeeping seam test calls `record_top_up` without any gate. There is no regression test proving that the production guard remains held across the manager write and address reconciliation, so dropping `_lifecycle` before bookkeeping would not be detected. Add a test that holds the returned gate while running `record_top_up` and verifies concurrent wallet removal remains blocked until bookkeeping completes.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Move account-scoped funding input selection into Rust — The Swift and Kotlin example flows still enumerate wallet addresses and greedily select funding rows in TopUpIdentityView.buildInputs and TopUpIdentityScreen.packInputs. This leaves account selection and input-selection behavior host-specific even though the new API centralizes identity ownership and top-up orchestration in Rust.
    • Follow-up: Open and link a follow-up issue or PR for Rust-owned account-scoped funding selection, then route both mobile examples through that operation.

romchornyi and others added 2 commits November 15, 2026 19:16
…ancelled

IdentityCredits.topUpIdentityFromAddresses ran under gate.op, so a
top-up that finished natively after its caller was cancelled had its
balance dropped and the caller could not tell the credits moved. Run it
under gate.opReturningCompletedResult, like the wallet's other
credit-moving calls, and pin that with a regression test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…keeping

record_top_up and record_top_up_balance now take the held lifecycle
guard, so the identity-manager write and the address reconciliation
cannot be called without it. The test seam acquires it the way
production does.

Mark the managed-only address top-up wrappers deprecated in favour of
topUpIdentityFromAddresses (Swift topUpFromAddresses and
topUpExternalIdentityFromAddresses, Kotlin IdentityCredits and
CreditsNative topUpFromAddresses), and list
platform_wallet_top_up_identity_from_addresses_with_signer in the JNI
credits module doc.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@romchornyi

Copy link
Copy Markdown
Contributor Author

Replies to the findings shown only in the review body:

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The any-identity address top-up is consistently wired through the Rust wallet, FFI, JNI, Swift, and Kotlin layers, and the lifecycle guard is now enforced through bookkeeping. One blocking cancellation issue remains in the deprecated Kotlin managed-only route, along with two non-blocking Rust API/UX concerns. CI shows the Kotlin build and tests passing; the review check is still in progress.

🔴 1 blocking | 🟡 2 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: Deprecated Kotlin top-up still drops a completed result on cancellation
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:266-280

The deprecated topUpFromAddresses route still uses gate.op, while the new any-identity route uses opReturningCompletedResult. If the synchronous JNI call broadcasts and completes before coroutine cancellation is observed during the withContext(Dispatchers.IO) handoff, gate.op can throw CancellationException and discard the completed balance. The caller cannot distinguish a completed top-up from an unsent one and may retry with newly resolved nonces, potentially crediting the identity twice. This route is explicitly retained and modified by this PR as the deprecated compatibility path, so it should preserve completed results under cancellation as well.

    suspend fun topUpFromAddresses(
        walletHandle: Long,
        identityId: ByteArray,
        inputs: List<FundingInput>,
        signerHandle: Long,
    ): Long = gate.opReturningCompletedResult {
        mapNativeErrors {
            CreditsNative.topUpFromAddresses(
                walletHandle,
                identityId,
                FundingInput.encode(inputs),
                signerHandle,
            )
        }
    }

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Still open from earlier rounds (2)

  • 🟡 Suggestion: Replace the boolean top-up scope with a typed route — packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs:98-118 (thread)
  • 🟡 Suggestion: Recheck wallet liveness before prompting the host signer — packages/rs-platform-wallet/src/wallet/platform_wallet.rs:714-731 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change to identity credit top-up transaction signing, broadcast, lifecycle gating, and balance write-back in PlatformWallet::top_up_identity_from_addresses and GatedAddressSigner, directly affecting funds movement and key-handling boundaries.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:266-280: Deprecated Kotlin top-up still drops a completed result on cancellation
  The deprecated `topUpFromAddresses` route still uses `gate.op`, while the new any-identity route uses `opReturningCompletedResult`. If the synchronous JNI call broadcasts and completes before coroutine cancellation is observed during the `withContext(Dispatchers.IO)` handoff, `gate.op` can throw `CancellationException` and discard the completed balance. The caller cannot distinguish a completed top-up from an unsent one and may retry with newly resolved nonces, potentially crediting the identity twice. This route is explicitly retained and modified by this PR as the deprecated compatibility path, so it should preserve completed results under cancellation as well.

In `packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs:98-118: Replace the boolean top-up scope with a typed route
  (carried; thread: https://github.com/dashpay/platform/pull/5929#discussion_r4578944933)

In `packages/rs-platform-wallet/src/wallet/platform_wallet.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:714-731: Recheck wallet liveness before prompting the host signer
  (carried; thread: https://github.com/dashpay/platform/pull/5929#discussion_r4578944929)
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Bind address top-up completion to the exact transition — The existing nonce-and-balance heuristic can accept a result when another transition consumes the same address nonces and unrelated credits raise the target identity balance. That can make an unexecuted top-up appear complete, although this limitation predates the reviewed range and is documented in the current implementation.
    • Follow-up: Create a follow-up PR adding an execution-bound proof or result binding for address-funded top-ups.

@romchornyi

Copy link
Copy Markdown
Contributor Author

Reject out-of-range Kotlin address types before u8 encoding (not inline). Fixed in 620392e: every Kotlin funding row that reaches the top-up bridges is a FundingInput, and its init now rejects an addressType outside 0..255 where the row is built, so no encoder narrows a wider value. Rust still decides which byte values are supported. Test: an address type outside a byte never reaches the native bridge (-1, 256, 257, Int.MAX_VALUE refused; 0 and 255 encoded unchanged). encodeWithdrawalInputs already checks the range. Two encoders outside this PR's diff, encodeCreditOutputs and encodeRecipients in ManagedPlatformWallet.kt, still narrow without a check; they are left for a follow-up.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 23, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ DEGRADED — Re-review — Final validation — Phase 2 only (queue backlog)

⚠️ DEGRADED review. The primary review models were unavailable (gpt-6.2-sol unavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache), so this review ran on stand-in models: gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped at high effort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.

Nothing blocks: no blocking finding stands on this head.

New on this head: This head adds two commits since 661ce18: a Kotlin FundingInput addressType 0..255 guard with edge tests, and a one-line ERROR_CODE_REGISTRY row 69 wording restore. CI shows Rust workspace tests in progress and Kotlin emulator queued with no failed checks reported.

🟡 4 suggestion(s)

Still open from earlier rounds (4)

  • 🟡 Suggestion: Bound wallet removal while the replacement test holds the signer — packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses/external_identity_tests.rs:883-887 (thread)
  • 🟡 Suggestion: Distinguish the managed and any-identity routes at the C boundary — packages/rs-platform-wallet-ffi/src/identity_top_up/external_identity_tests.rs:267-274 (thread)
  • 🟡 Suggestion: Fetch the proved balance without fetching every recipient key — packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs:131-136 (thread)
  • 🟡 Suggestion: Make the liveness regression test remove the wallet after the reads — packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses/external_identity_tests.rs:545-576 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: rust-quality); reviewer 5: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: security-auditor); final verifier: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: sol-verifier, role: final-verifier)

  • Degraded mode: gpt-6.2-sol unavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-11-23T09:07:27Z); stand-ins gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor; Phase 1 effort capped at high
  • Triage: normal by muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (effort low) — Large cross-cutting wallet/FFI/SDK unification that reuses the existing signing/broadcast lifecycle unchanged rather than modifying consensus, coin selection, cryptography, or serialization logic.
  • Phase 1 reviewers: not run (skipped for throughput: 19 PRs queued, above the 10 limit)
  • Fresh verifier: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — final-verifier; agent sol-verifier
  • Phase 2 reviewers: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — general (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — architecture-layering (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — ffi-engineer (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — rust-quality (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses/external_identity_tests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses/external_identity_tests.rs:883-887: Bound wallet removal while the replacement test holds the signer
  (carried; thread: https://github.com/dashpay/platform/pull/5929#discussion_r4638084415)
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses/external_identity_tests.rs:545-576: Make the liveness regression test remove the wallet after the reads
  (carried; thread: https://github.com/dashpay/platform/pull/5929#discussion_r4580715823)

In `packages/rs-platform-wallet-ffi/src/identity_top_up/external_identity_tests.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/identity_top_up/external_identity_tests.rs:267-274: Distinguish the managed and any-identity routes at the C boundary
  (carried; thread: https://github.com/dashpay/platform/pull/5929#discussion_r4638084408)

In `packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses.rs:131-136: Fetch the proved balance without fetching every recipient key
  (carried; thread: https://github.com/dashpay/platform/pull/5929#discussion_r4638084395)
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Remaining Kotlin encoders still narrow addressType without a range check — Outside this diff, encodeCreditOutputs and encodeRecipients in ManagedPlatformWallet.kt still do dos.writeByte(addressType) without the 0..255 require added to FundingInput and encodeWithdrawalInputs, so an out-of-range Int would silently truncate to a different script type.
    • Follow-up: File a follow-up to add the same 0..255 require or a shared checked encoder to encodeCreditOutputs and encodeRecipients, with tests pinning rejection of -1/256/257.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 23, 2026

@HashEngineering HashEngineering left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for kotlin-sdk.

Non-blocking notes:

  • The deprecated topUpFromAddresses KDoc says the unmanaged refusal is IdentityNotFound, but Kotlin surfaces code 7 as DashSdkError.NotFound.
  • topUpIdentityFromAddresses doesn't list its outcomes yet: 7 NotFound, 80 IdentityLookupFailed, 20 TransactionBroadcastUnconfirmed (may have executed; do not resubmit), 98 PlatformWallet.NotFound. It also doesn't say that the calling coroutine stays cancelled after opReturningCompletedResult returns a balance.

Plan for #5906: once this merges, it already covers the Kotlin top-up of someone else's identity, so I'll rescope #5906 instead of landing topUpExternalIdentityFromAddresses. It will drop that method and its JNI bridge, and move its outcome KDoc, error-mapping tests and the FfiSmokeTest JNI-binding check onto topUpIdentityFromAddresses. dash-wallet will call topUpIdentityFromAddresses for any identity.

@romchornyi

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@github-actions

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the waiting-self-review Waiting for the author to post /self-reviewed label Nov 23, 2026
@romchornyi
romchornyi merged commit 59fd81f into v5.2-dev Nov 23, 2026
29 checks passed
@romchornyi
romchornyi deleted the feat/platform-wallet-top-up-any-identity branch November 23, 2026 17:32
romchornyi added a commit to dashpay/dashwallet-ios that referenced this pull request Nov 23, 2026
identityNotFound is also the reason for an Identity-source send whose
identity the wallet does not hold, where Platform is never asked, so it now
reads "This identity could not be found". ADR-0045 (Proposed) records that
the send pays the holder's own identity with the same top-up for any identity
since dashpay/platform#5929; a test comment still described the old split.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
romchornyi added a commit that referenced this pull request Nov 23, 2026
…ilure

Moves ErrorShieldedIdentityCreateInputsConsumed from 77 to 81: #5865
holds 77-79 and #5929 took 80. The scoped broadcast tracker takes the
base's spend_broadcast_dispatches(sdk, None) and single_dispatch_settings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
romchornyi added a commit to dashpay/dashwallet-ios that referenced this pull request Nov 24, 2026
The send picked the managed top-up for the holder's Current identity and the
external one for any other. The managed one answers an identity Platform does
not show yet with identityBalanceUnavailable (58), which Send reads as in
progress although nothing was signed. The send now takes the SDK's top-up for
any identity (`topUpIdentityFromAddresses`, dashpay/platform#5929) for every
identity: Platform reads the identity before signing, and one it does not show
is identityNotFound, not sent, with Retry. The Top Up sheet keeps the managed
top-up.

identityNotFound now says "Platform could not find this identity" instead of
"not found in your wallet", which was wrong for someone else's identity.

The top-up compatibility harness implements the SDK's new call and tests that
the sheet and the send take different top-ups; its funding policy fakes plan
inputs instead of refusing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
romchornyi added a commit to dashpay/dashwallet-ios that referenced this pull request Nov 24, 2026
identityNotFound is also the reason for an Identity-source send whose
identity the wallet does not hold, where Platform is never asked, so it now
reads "This identity could not be found". ADR-0045 (Proposed) records that
the send pays the holder's own identity with the same top-up for any identity
since dashpay/platform#5929; a test comment still described the old split.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HashEngineering added a commit that referenced this pull request Nov 24, 2026
Keeps #5929's single address top-up export in place of this branch's copy of
the external one, adds this branch's callers to registry row 80, and renames
the Core route's balance write-back to record_core_top_up_balance beside
#5929's record_top_up_balance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HashEngineering added a commit that referenced this pull request Nov 24, 2026
Brings in v5.2-dev (#5929) and PR A's review fixes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	packages/kotlin-sdk/PARITY_SUMMARY.md
#	packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt
HashEngineering added a commit that referenced this pull request Nov 24, 2026
…e does not fit a byte

CreditOutput and FundRecipient are written to their native blobs with
DataOutputStream.writeByte, which keeps only the low 8 bits, so an
addressType of 256 reached Rust as 0 (P2PKH) and the credits went to an
address the caller did not name. Both now refuse a value outside 0..255
when constructed, as FundingInput and the withdrawal input already do.
Which byte values are supported stays Rust's decision.

Raised as an out-of-scope follow-up in the review of #5929.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HashEngineering added a commit that referenced this pull request Nov 25, 2026
…e does not fit a byte

CreditOutput and FundRecipient are written to their native blobs with
DataOutputStream.writeByte, which keeps only the low 8 bits, so an
addressType of 256 reached Rust as 0 (P2PKH) and the credits went to an
address the caller did not name. Both now refuse a value outside 0..255
when constructed, as FundingInput and the withdrawal input already do.
Which byte values are supported stays Rust's decision.

Raised as an out-of-scope follow-up in the review of #5929.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants