Skip to content

Conversation

@louisinger
Copy link
Contributor

@louisinger louisinger commented Oct 18, 2025

This PR contains an hotfix regarding vtxos filtrering ("settleBy" must not be considered as spendable).

It also sources the app data from the DB instead of contacting service worker.

Summary by CodeRabbit

  • Refactor

    • Revised wallet integration for transaction and vtxo retrieval.
    • Improved vtxo classification to more accurately distinguish spent vs. spendable items.
  • Chores

    • Added debug logging during wallet reload to surface current transactions, vtxos, and balance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 18, 2025

Walkthrough

Replaces IWallet with ServiceWorkerWallet in ASP VTXO retrieval: import added, getVtxos signature changed, address obtained via wallet.getAddress() and VTXOs fetched via wallet.walletRepository.getVtxos(address). Also adds debug logs in wallet reload showing TXs, VTXOs, and balance.

Changes

Cohort / File(s) Change Summary
Wallet type and VTXO retrieval
src/lib/asp.ts
Added ServiceWorkerWallet import; changed getVtxos signature to accept ServiceWorkerWallet; obtains address via wallet.getAddress() and fetches VTXOs via wallet.walletRepository.getVtxos(address); classification now uses isSpentOffchain (spentBy) and isSettled (settledBy).
Reload logging
src/providers/wallet.tsx
Added three debug console.log statements in reloadWallet: SET TXS, SET VTXOS, and SET BALANCE to output current txs, vtxos, and balance.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant SWWallet as ServiceWorkerWallet
    participant Repo as walletRepository

    Caller->>SWWallet: getVtxos(wallet)
    SWWallet->>SWWallet: getAddress()
    SWWallet->>Repo: getVtxos(address)
    Repo-->>SWWallet: [vtxo[]]
    SWWallet-->>Caller: return classified VTXOs
    note right of SWWallet #e6f7ff: Classification uses isSpentOffchain and isSettled
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "asp.ts: read history and vtxos from database" accurately captures a primary aspect of the changeset in src/lib/asp.ts. The code changes show that the getVtxos function now retrieves vtxos through wallet.walletRepository.getVtxos(address), which appears to be database-backed based on the PR objectives. The title correctly identifies the file being modified and the core behavioral change of sourcing vtxo data from the database. While the title doesn't encompass the entire scope of the PR (such as the hotfix for vtxos filtering logic regarding settledBy entries), it still clearly references a real and significant part of the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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 read-from-db

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

cloudflare-workers-and-pages bot commented Oct 18, 2025

Deploying wallet-bitcoin-v8 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 96d6ee5
Status: ✅  Deploy successful!
Preview URL: https://36b79d88.wallet-v8.pages.dev
Branch Preview URL: https://read-from-db.wallet-v8.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0ccea5 and e0889c6.

📒 Files selected for processing (1)
  • src/lib/asp.ts (3 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
🧬 Code graph analysis (1)
src/lib/asp.ts (1)
src/lib/types.ts (2)
  • Tx (70-80)
  • Vtxo (95-95)
🔇 Additional comments (3)
src/lib/asp.ts (3)

1-1: LGTM: Import added for ServiceWorkerWallet.

The import is necessary for the updated function signatures.


129-131: ---

The code correctly uses "settledBy" — no issue found.

The codebase uses settledBy consistently at src/lib/asp.ts:130, and there are no usages of settleBy elsewhere. The property name appears correct (semantically, "settledBy" is the past participle form, meaning "settled by [transaction]"). The review comment's concern about a discrepancy between PR description and code cannot be verified without access to the PR objectives, but the implementation itself is consistent and correct.


123-125: The concern in the review comment is invalid. The getVtxos signature change is justified and not a problematic breaking change.

The implementation requires wallet.walletRepository.getVtxos(address), which is a ServiceWorkerWallet-specific property. This pattern is consistent with getTxHistory, which already has a ServiceWorkerWallet signature and similarly uses wallet.walletRepository.getTransactionHistory(address). Unlike getBalance and collaborativeExit that can accept IWallet, the getVtxos function cannot function with IWallet due to missing the repository property.

The single caller in src/providers/wallet.tsx:112 already passes swWallet, which is ServiceWorkerWallet, so no additional updates are needed.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 18, 2025

Deploying wallet-signet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 96d6ee5
Status: ✅  Deploy successful!
Preview URL: https://7622c838.wallet-23u.pages.dev
Branch Preview URL: https://read-from-db.wallet-23u.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 18, 2025

Deploying wallet-mutinynet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 96d6ee5
Status: ✅  Deploy successful!
Preview URL: https://63458145.arkade-wallet.pages.dev
Branch Preview URL: https://read-from-db.arkade-wallet.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4719ccd and d215505.

📒 Files selected for processing (1)
  • src/providers/wallet.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 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.

@tiero
Copy link
Member

tiero commented Oct 18, 2025

ack

@tiero tiero requested a review from bordalix October 18, 2025 10:27
Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
Signed-off-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>
@tiero tiero merged commit c6d2332 into master Oct 19, 2025
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 29, 2025
@bordalix bordalix deleted the read-from-db branch November 26, 2025 14:31
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.

4 participants