Skip to content

Conversation

@bordalix
Copy link
Collaborator

@bordalix bordalix commented Oct 14, 2025

Summary by CodeRabbit

  • New Features

    • Wallet now refreshes automatically after renewing coins, updating balances, history, and VTXOs in one step.
    • Settings screen provides clearer success feedback when coin renewal completes.
  • Bug Fixes

    • Improved synchronization of VTXO/UTXO state with background updates, reducing stale or inconsistent wallet data.
    • Centralized reload flow ensures more reliable updates after service events and coin operations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Adds a new getVtxos function in asp library, integrates it into wallet reload flow, updates WalletContext reloadWallet signature to accept an optional ServiceWorkerWallet, centralizes VTXO updates during reload, and invokes reloadWallet from the Settings Vtxos screen after coin renewal.

Changes

Cohort / File(s) Summary
ASP VTXO retrieval
src/lib/asp.ts
Introduces exported getVtxos(wallet: IWallet) returning { spendable: Vtxo[]; spent: Vtxo[] }; updates imports to include Vtxo.
Wallet provider reload flow
src/providers/wallet.tsx
Changes reloadWallet signature to (svcWallet?: ServiceWorkerWallet) => Promise<void>; centralizes VTXO fetching via getVtxos during reload; removes prior effect-based VTXO fetches; updates service worker message handling to call reloadWallet with current svcWallet.
Settings VTXO screen integration
src/screens/Settings/Vtxos.tsx
Consumes new reloadWallet from context; calls reloadWallet after VTXO settlement; adjusts success notification placement.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant VtxosScreen as Settings/Vtxos
  participant WalletProvider
  participant SvcWorker as ServiceWorkerWallet
  participant ASP as asp.getVtxos

  User->>VtxosScreen: Renew coins
  VtxosScreen->>WalletProvider: reloadWallet(svcWallet?)
  alt svcWallet provided
    WalletProvider->>SvcWorker: fetch balance/txs (existing calls)
  else no svcWallet
    WalletProvider->>WalletProvider: use current svcWallet if available
  end
  WalletProvider->>ASP: getVtxos(wallet)
  ASP-->>WalletProvider: {spendable[], spent[]}
  WalletProvider->>WalletProvider: setState(balance, txs, vtxos)

  note over WalletProvider: Centralized VTXO update during reload

  SvcWorker-->>WalletProvider: message: balance/utxo update
  WalletProvider->>WalletProvider: reloadWallet(current svcWallet)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the core issue addressed by this changeset—ensuring VTXO reload after settling in coin control—and directly matches the main changes made to reloadWallet and component updates.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_wallet_reload

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d98259 and c9c98d5.

📒 Files selected for processing (3)
  • src/lib/asp.ts (2 hunks)
  • src/providers/wallet.tsx (5 hunks)
  • src/screens/Settings/Vtxos.tsx (4 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: bordalix
PR: arkade-os/wallet#114
File: src/lib/asp.ts:0-0
Timestamp: 2025-06-30T18:33:29.839Z
Learning: In src/lib/asp.ts, only the collaborativeExit function should accept both IWallet and ServiceWorkerWallet types. Other wallet functions (getBalance, getTxHistory, getReceivingAddresses, redeemNotes, sendOnChain, settleVtxos) should maintain their original IWallet-only signatures and not be updated for consistency.
📚 Learning: 2025-06-30T18:33:29.839Z
Learnt from: bordalix
PR: arkade-os/wallet#114
File: src/lib/asp.ts:0-0
Timestamp: 2025-06-30T18:33:29.839Z
Learning: In src/lib/asp.ts, only the collaborativeExit function should accept both IWallet and ServiceWorkerWallet types. Other wallet functions (getBalance, getTxHistory, getReceivingAddresses, redeemNotes, sendOnChain, settleVtxos) should maintain their original IWallet-only signatures and not be updated for consistency.

Applied to files:

  • src/lib/asp.ts
  • src/providers/wallet.tsx
🧬 Code graph analysis (3)
src/lib/asp.ts (1)
src/lib/types.ts (1)
  • Vtxo (95-95)
src/providers/wallet.tsx (1)
src/lib/asp.ts (3)
  • getTxHistory (86-120)
  • getBalance (80-84)
  • getVtxos (122-131)
src/screens/Settings/Vtxos.tsx (2)
src/providers/wallet.tsx (1)
  • WalletContext (39-53)
src/components/Warning.tsx (1)
  • WarningBox (12-38)
🔇 Additional comments (5)
src/lib/asp.ts (1)

122-131: LGTM!

The function correctly partitions VTXOs into spendable and spent based on the spentBy field. The signature adheres to the established pattern of accepting only IWallet (consistent with other wallet functions in this file).

src/screens/Settings/Vtxos.tsx (2)

77-88: LGTM!

The wallet reload after settling VTXOs ensures that balance, transaction history, and VTXO state are refreshed. The error handling correctly prevents success state from being set if the reload fails.


141-141: LGTM!

Success messages are appropriately placed in both the coins list view and the renewal date view, ensuring users see confirmation regardless of which view is active when the renewal completes.

Also applies to: 153-153

src/providers/wallet.tsx (2)

109-124: LGTM!

The centralized reload implementation efficiently fetches VTXOs, transaction history, and balance in parallel. The optional parameter allows callers to explicitly provide a wallet instance or default to the current state, which is particularly useful during initialization sequences.


147-152: LGTM!

Explicitly passing the svcWallet closure variable to both immediate and delayed reloadWallet calls is good practice. This ensures the message handler uses the freshly created wallet instance rather than potentially stale state, avoiding race conditions during initialization.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

Deploying wallet-signet with  Cloudflare Pages  Cloudflare Pages

Latest commit: c9c98d5
Status: ✅  Deploy successful!
Preview URL: https://8fc48599.wallet-23u.pages.dev
Branch Preview URL: https://fix-wallet-reload.wallet-23u.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

Deploying wallet-mutinynet with  Cloudflare Pages  Cloudflare Pages

Latest commit: c9c98d5
Status: ✅  Deploy successful!
Preview URL: https://0f253dcd.arkade-wallet.pages.dev
Branch Preview URL: https://fix-wallet-reload.arkade-wallet.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

Deploying wallet-bitcoin-v8 with  Cloudflare Pages  Cloudflare Pages

Latest commit: c9c98d5
Status: ✅  Deploy successful!
Preview URL: https://9400566d.wallet-v8.pages.dev
Branch Preview URL: https://fix-wallet-reload.wallet-v8.pages.dev

View logs

@bordalix bordalix merged commit 96d69de into master Oct 14, 2025
5 checks passed
@bordalix bordalix deleted the fix_wallet_reload branch October 15, 2025 13:51
@coderabbitai coderabbitai bot mentioned this pull request Dec 17, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jan 26, 2026
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.

2 participants