Skip to content

refactor(platform-wallet): drop always-zero Core address balance - #6036

Merged
lklimek merged 2 commits into
v5.2-devfrom
refactor/core-address-entry-drop-balance
Dec 1, 2026
Merged

lklimek merged 2 commits into
v5.2-devfrom
refactor/core-address-entry-drop-balance

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: The per-address balance field that wallet storage hosts received was always zero and never read; it is removed from the native interface and from the Swift and Kotlin apps.

User story

As a Swift or Kotlin SDK developer, I want the address records the wallet hands me to contain only real data, so that I don't show or store a balance that is always zero.

Scenario

Base flow

A host app persists the wallet's Core address pool entries through the persistence callbacks and shows them in its storage explorer.

Actual behavior

Each entry carries a balance that is always 0, because the wallet library keeps no per-address balance. The example apps display it, and a Kotlin test asserts it.

Expected behavior

The field is gone. Hosts and example apps no longer store or show it.

Detailed discussion

What was done

CoreAddressEntryFFI.balance is removed from the C struct, the JNI bridge and descriptor, the Kotlin and Swift persistence handlers and models, and the example-app views and tests.

Stacked on #6035 (funding-pool fix), which is stacked on #5951; split out of #5951 because the rust-dashcore bump does not require it.

Testing

CI-scope clippy and nextest for the wallet crates pass locally. Swift and Kotlin were not built locally; CI covers them.

Breaking changes

CoreAddressEntryFFI loses balance, which changes its C layout and the onPersistAccountAddressPoolEntry JNI signature. Hosts rebuild against the new header. Not consensus.

Checklist

  • I have performed a self-review of my own code
  • My Rust 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
  • Breaking changes described above (API only, not consensus)
  • I have made corresponding changes to the documentation if needed

🤖 Co-authored by Claudius the Magnificent AI Agent

🤖 Generated with Claude Code

https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR

PR Hygiene · e032667

  • Bots — thepastaclaw ✓
  • Self-review — not asked of a bot author
  • Build green
  • Approvals
    • kotlin-sdk (packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/storage/StorageModels.kt, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/storage/StorageRecordDetailScreen.kt, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/AccountDetailScreen.kt and 7 more) — approved by HashEngineering
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/src/core_address_types.rs, packages/rs-platform-wallet-ffi/src/persistence.rs) — approved by HashEngineering, llbartekll
    • swift-sdk (packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentCoreAddress.swift, packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/AccountDetailView.swift and 4 more) — approved by llbartekll

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.

Summary by CodeRabbit

  • Bug Fixes
    • Core receive-address pools now identify unused addresses by usage status, regardless of balance. An address with a balance can still be considered unused if it has not been used.
  • Updates
    • Core address balances are no longer shown in account and storage details. Address index, usage status, and activity information remain available. Balance information for other address types continues to appear in its existing views.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Core address-pool persistence and restore data no longer include per-address balances. Core address selection uses the isUsed flag, and example views no longer display Core address balances. Platform payment address balance handling remains separate.

Changes: Core Address Balance Handling

Layer / File(s) Summary
Core address-pool data contract
packages/rs-platform-wallet-ffi/src/core_address_types.rs, packages/rs-unified-sdk-jni/src/persistence.rs, packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/NativePersistenceBridge.kt, packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift
The FFI row, JNI callback, Kotlin restore data, and Swift address snapshot no longer carry Core address balances.
Persistence and restore behavior
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/PlatformWalletPersistenceHandler.kt, packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift, packages/rs-platform-wallet-ffi/src/persistence.rs, packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/entities/CoreAddressEntity.kt, packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentCoreAddress.swift, packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/persistence/PlatformWalletPersistenceHandlerTest.kt, packages/swift-sdk/SwiftTests/SwiftDashSDKTests/*
Core address persistence and restore paths no longer read or write address balances. Platform payment address rows retain existing balances or initialize new rows to zero. Related tests and fixtures omit Core address balances.
Address selection and display
packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/ReceiveAddressSheet.kt, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/AccountDetailScreen.kt, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/AccountDetailView.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageModelListViews.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageRecordDetailViews.swift, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/storage/StorageModels.kt, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/storage/StorageRecordDetailScreen.kt, packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/storage/StorageModelsTest.kt
Core address selection treats entries with !isUsed as unused, regardless of balance. Kotlin and Swift example views omit Core address balances. Kotlin storage details exclude the Core address balance column and include tests for Core and other storage models.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

Suggested reviewers: bezibalazs, thepastaclaw, quantumexplorer

Merge Risk: Minimal · up to e0326

This change removes an always-zero Core address balance from the native interface and the example apps. No concrete defect was found. Hosts must rebuild against the new header because the struct layout and JNI signature changed, as the author states.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: removing the always-zero per-address balance from Core address records. The changeset removes the balance field from CoreAddressEntryFFI, the JNI bridge and descriptor…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: removing the always-zero per-address balance from Core address records. The changeset removes the balance field from CoreAddressEntryFFI, the JNI bridge and descriptor, persistence handlers, models, and example-app views, which matches the title's scope. The 'refactor(platform-wallet)' prefix fits the stated intent, and the title is a single concise sentence with no file lists or vague terms.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 56f0a3a and e032667.

Files selected for processing: 3

  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/storage/StorageModels.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/storage/StorageRecordDetailScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/storage/StorageModelsTest.kt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@thepastaclaw

thepastaclaw commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit e032667) · triage: normal

@lklimek
lklimek added this pull request to stack #6217 November 24, 2026 11:38
@lklimek
lklimek force-pushed the refactor/core-address-entry-drop-balance branch from 3945502 to e403e0e Compare November 24, 2026 11:57
@Claudius-Maginificent Claudius-Maginificent changed the title refactor(platform-wallet-ffi)!: drop the always-zero balance from CoreAddressEntryFFI refactor(platform-wallet): drop always-zero Core address balance Nov 24, 2026
@lklimek
lklimek force-pushed the refactor/core-address-entry-drop-balance branch from e403e0e to 8b6bc5b Compare November 25, 2026 09:19
Base automatically changed from fix/funding-pool-lost-row-in-window to v5.2-dev November 27, 2026 14:11
…eAddressEntryFFI

Preserve the final PR scope, including merge resolutions, on the updated native stack.

Co-Authored-By: Codex <[email protected]>
@lklimek
lklimek force-pushed the refactor/core-address-entry-drop-balance branch from 8b6bc5b to 56f0a3a Compare November 27, 2026 14:11
@github-actions github-actions Bot added this to the v5.2.0 milestone Nov 27, 2026
@lklimek
lklimek marked this pull request as ready for review November 27, 2026 14:12
@github-actions

github-actions Bot commented Nov 27, 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 the waiting-bots Waiting for the review bots to report on this head label Nov 27, 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.

Final validation — Phase 1 + Phase 2

Updated after discussion: 1 finding(s) of this review were settled in the inline threads; no blocking finding remains.

  • ⏭️ Deferred (maintainer decision): 🔴 Android’s Core receive sheet shows no QR code when Room has no unused address (tracked in #6389)

Changes requested: 1 0 blockers: none remains

  • Android’s Core receive sheet shows no QR code when Room has no unused address — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/ReceiveAddressSheet.kt:127-130 (new) — settled: ⏭️ Deferred (maintainer decision)
    Impact: Example-app users who tap Receive before Room contains an unused external address see a prompt to sync instead of a QR code, even if the live wallet can supply an address.

This PR removes the always-zero Core address balance from the native persistence ABI and updates the Swift and Kotlin bindings without changing either database schema or wallet restore behavior. Rust workspace tests, Kotlin emulator build and tests, and the Swift frozen-schema check passed; the Swift SDK build and tests are pending.

🔴 1 0 blocking | 🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — Removing one always-zero field is a small, mechanical change across bindings, persistence handlers, and views, with no change to consensus or funds movement.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); 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 (zai below 15% reserve: 5h 100% left, weekly 0% left)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort medium); 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/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/ReceiveAddressSheet.kt`:
- [BLOCKING → DEFERRED by a maintainer; not blocking, do not fix in this PR] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/ReceiveAddressSheet.kt:127-130: Android’s Core receive sheet shows no QR code when Room has no unused address
  Impact: Example-app users who tap Receive before Room contains an unused external address see a prompt to sync instead of a QR code, even if the live wallet can supply an address.
  The sheet cannot show a receive address that is missing from Room: it filters the persisted external pool and picks the lowest unused index itself. Removing the balance check changes that eligibility rule but leaves the address-selection decision in the view, which the book’s wallet ownership rule assigns to Rust. `ManagedCoreWallet.nextReceiveAddress(accountIndex)` already asks the live key-wallet pool for an available address and can derive one if none is available. Use that binding to select the address, and use Room only to look up optional display metadata for the returned address.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/entities/CoreAddressEntity.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/entities/CoreAddressEntity.kt:50-54: Android’s Storage Explorer still shows a balance when a Core address is opened
  Impact: Developers who open a Core address in Storage Explorer see the retained `balance` column, usually as zero, even though the wallet does not track that value.
  The Core address detail makes a schema placeholder look like wallet data. `loadStorageRow` in `StorageModels.kt` selects every column, and `StorageRecordDetailScreen.kt:106–109` renders them all. The Core Addresses list subtitle also displays the column if it contains a positive value. Keep the Room column for schema compatibility, but omit it from the Core Addresses list and detail presentation, as the Swift explorer does. Leave tracked balances on other models visible.

@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 27, 2026
…e Storage Explorer

The Core Addresses list and record detail still showed the Room balance
column, which the wallet no longer tracks. Keep the column for schema
compatibility but leave it out of both views; real balances of other
models stay visible.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

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

@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 after discussion — commit 56f0a3a

Standing review was CHANGES_REQUESTED; this re-review is APPROVE: no blocking findings remain.

Approved: the discussion withdrew or deferred every blocker the full review of 56f0a3ab (run 15324) raised, and the approval rests on that review. The 1 non-blocking finding(s) still standing are optional: fix them forward.

No longer blocking:

  • Android’s Core receive sheet shows no QR code when Room has no unused address

Same commit as the standing review; the inline threads above carry the per-finding outcome. This follow-up exists only to correct the verdict.

Review provenance

Source: conversation lane gpt-6.2-sol (agent: conversation); no reviewer or verifier lanes ran for this follow-up

  • Verdict moved because the inline discussion withdrew or deferred findings of the standing review of this commit; the code was not re-reviewed

@github-actions

github-actions Bot commented Nov 29, 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 29, 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.

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

New on this head: The incremental commit removes the retained Core-address balance from the Kotlin Storage Explorer list and detail views while preserving balances for other models, with regression tests covering null, zero, and positive retained values. Kotlin and Rust checks passed; the Swift SDK build remains in progress, with no failed code checks reported.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — This is a cross-language API and persistence refactor spanning Rust FFI, JNI, Swift, Kotlin, and example tests, but it does not change consensus, funds movement, cryptography, or storage migration behavior.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (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)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Ready for review — kotlin-sdk: HashEngineering.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-bots Waiting for the review bots to report on this head labels Nov 29, 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.

Kotlin side looks good. One nit: the PR title should carry a ! (as commit 56f0a3a does). CoreAddressEntryFFI.balance has shipped in every release from v5.0.0-beta.1 through v5.1.1, and the public Kotlin onPersistAccountAddressPoolEntry signature and the CoreAddressRestoreData constructor change, so a squash merge with the current title would hide the break in the changelog.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot removed the ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. label Dec 1, 2026
@lklimek
lklimek merged commit 28a6d56 into v5.2-dev Dec 1, 2026
35 checks passed
@lklimek
lklimek deleted the refactor/core-address-entry-drop-balance branch December 1, 2026 08:24
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.

5 participants