Skip to content

feat(wallet): Add ability to track wallet transaction history#1041

Open
edgarmuyomba wants to merge 5 commits into
cashubtc:mainfrom
edgarmuyomba:feat/track-transaction-history
Open

feat(wallet): Add ability to track wallet transaction history#1041
edgarmuyomba wants to merge 5 commits into
cashubtc:mainfrom
edgarmuyomba:feat/track-transaction-history

Conversation

@edgarmuyomba

@edgarmuyomba edgarmuyomba commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Closes #173

Supersedes #315

Summary

This PR introduces functionality to the wallet to be able to keep track of past transactions. It adds code that hooks into transaction facing functions of the wallet to store transaction details in the transactions database table that can be queried later to examine the history.

Changes

  • Adds migration m017 to create the transactions table
  • Adds crud functionality for the transactions table: store_transactions(...), update_transaction_state(...) and get_transaction_state(...) -> cashu/wallet/crud.py
  • Modifies the send, receive, mint and melt methods in the cashu/wallet/helpers.py and cashu/wallet/wallet.py files to store and update transactions when they take place
  • Adds the history command to the wallet cli in cashu/wallet/cli/cli.py.
  • Adds tests in the tests/wallet/test_wallet_cli.py and tests/wallet/test_wallet_crud_unit.py covering storing, update and querying of the transactions table

Transactions Table Structure

Field Data-Type Notes
id INTEGER PRIMARY KEY
type TEXT 'mint' / 'melt' / 'send' / 'receive'
amount INTEGER
unit TEXT e.g. 'sat'
mint TEXT mint URL
state TEXT 'pending' / 'completed' / 'failed'
quote_id TEXT bolt11 quote id for mint/melt; NULL for ecash
fee INTEGER melt only: actual fee paid
preimage TEXT melt only: payment preimage
created_time INTEGER unix timestamp

Example Ouput

After running command cashu history

-------------- Transaction history --------------
Type                Amount  State       Time
-------------------------------------------------
mint           +100000 sat  completed   2026-06-09 05:28
melt                -1 sat  completed   2026-06-09 05:23
mint              +100 sat  completed   2026-06-09 03:19
send              -300 sat  completed   2026-06-09 03:18

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.19231% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.26%. Comparing base (654de18) to head (63c4c6f).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
cashu/wallet/cli/cli.py 93.33% 2 Missing ⚠️
cashu/wallet/helpers.py 80.00% 1 Missing ⚠️
cashu/wallet/wallet.py 90.90% 1 Missing ⚠️
cashu/wallet/wallet_transaction.py 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1041      +/-   ##
==========================================
+ Coverage   75.09%   75.26%   +0.17%     
==========================================
  Files         110      111       +1     
  Lines       12093    12193     +100     
==========================================
+ Hits         9081     9177      +96     
- Misses       3012     3016       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Wallet] Show tx history in CLI

1 participant