Skip to content

Payjoin persistance#242

Draft
Mshehu5 wants to merge 8 commits intobitcoindevkit:masterfrom
Mshehu5:payjion_persistance
Draft

Payjoin persistance#242
Mshehu5 wants to merge 8 commits intobitcoindevkit:masterfrom
Mshehu5:payjion_persistance

Conversation

@Mshehu5
Copy link
Contributor

@Mshehu5 Mshehu5 commented Feb 16, 2026

Description

Open as draft cause #230 needs to be merged first
Address #149 also follow up to #200
This PR adds persistance to existing async payjoin integration
This introduces neccessary database model for tables, add commad for resume and history also to reume a particular session

Notes to the reviewers

Review for this PR can start at 8614e22

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added docs for the new feature

Refactor KyotoClient to use a KyotoClientHandle struct instead of
Box<LightClient>. Previously, the Box<LightClient> was consumed
when destructured in sync_kyoto_client, preventing the function
from being called multiple times or borrowed. With the handle
pattern, sync_kyoto_client now takes &mut KyotoClientHandle,
allowing it to be borrowed and reused.

This also allows the node to be started at creation time in
new_blockchain_client rather than during sync, making the client
ready for use immediately after creation.

- Add KyotoClientHandle struct containing requester and
  update_subscriber
- Move node startup and logger spawning to new_blockchain_client
- Update sync_kyoto_client to accept &mut KyotoClientHandle
  instead of consuming Box<LightClient>
Update function signatures to accept &BlockchainClient instead of taking
ownership. This refactoring to allow the client to be Referenced across
multiple operations including repeated calls to sync_kyoto_client.

- Update handle_online_wallet_subcommand signature
- Update all PayjoinManager methods to use &BlockchainClient
- Fix parameter dereferencing in full_scan calls
- Update all call sites to pass references
Replace single sync-and-check with periodic polling loop.
This allows multiple sync operations since sync_wallet now accepts
a reference to BlockchainClient, enabling proper long-running
monitoring instead of a one-time check.
Replace Error::Generic with specific Payjoin error variants using #[from] derives for applicable places, enabling automatic conversion and eliminating verbose .map_err() calls.
- Create db.rs with Database, SenderPersister and ReceiverPersister
- Implement SessionPersister trait for both sender and receiver
- Add session ID management and query methods
- Add input deduplication tracking to prevent probing attacks
- Add timestamp formatting utilities
- Add database initialization in handlers
- Replace NoopSessionPersister with real persisters
- Implement session resumption for existing sessions
- Add input-seen-before tracking in receiver flow
- Remove verbose error wrapping (use ? operator)
- Implement resume_payjoins() to continue pending sessions
- Add history() to display all session states
- Add session status text helpers for UI display
- Support filtering by session ID
- Document resume and history commands
- Add sqlite dependecy for payjoin
@coveralls
Copy link

Pull Request Test Coverage Report for Build 22068931916

Details

  • 0 of 763 (0.0%) changed or added relevant lines in 5 files are covered.
  • 5 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-1.9%) to 8.848%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/error.rs 0 21 0.0%
src/utils.rs 0 22 0.0%
src/handlers.rs 0 50 0.0%
src/payjoin/db.rs 0 262 0.0%
src/payjoin/mod.rs 0 408 0.0%
Files with Coverage Reduction New Missed Lines %
src/utils.rs 1 0.0%
src/handlers.rs 2 12.81%
src/payjoin/mod.rs 2 0.0%
Totals Coverage Status
Change from base Build 21153868360: -1.9%
Covered Lines: 268
Relevant Lines: 3029

💛 - Coveralls

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants