Skip to content

Comments

Payjoin persistence#242

Open
Mshehu5 wants to merge 4 commits intobitcoindevkit:masterfrom
Mshehu5:payjion_persistance
Open

Payjoin persistence#242
Mshehu5 wants to merge 4 commits intobitcoindevkit:masterfrom
Mshehu5:payjion_persistance

Conversation

@Mshehu5
Copy link
Contributor

@Mshehu5 Mshehu5 commented Feb 16, 2026

Description

Address #149 also follow up to #200
This PR adds persistance to existing async payjoin integration
This introduces neccessary database model and tables also add commad for resume to allow interrupted sessions to be continued also a particular session either send or receive.
A history commad to view payjoin history and status has been added

Notes to the reviewers

Step to review this include making a payjoin transaction

Run a receiver to get a BIP21 URI then pass it to the sender as seen in docs

bdk-cli/README.md

Lines 121 to 141 in b9cf2ac

To start a Payjoin session as the receiver with regtest RPC and example OHTTP relays:
```
cargo run --features rpc -- --network regtest wallet --wallet payjoin_wallet1 config --ext-descriptor "wpkh(tprv8ZgxMBicQKsPd2PoUEcGNDHPZmVWgtPYERAwMG6qHheX6LN4oaazp3qZU7mykiaAZga1ZB2SJJR6Mriyq8MocMs7QTe7toaabSwTWu5fRFz/84h/1h/0h/0/*)#8guqp7rn" --client-type rpc --database-type sqlite --url "127.0.0.1:18443"
cargo run --features rpc -- wallet --wallet payjoin_wallet1 sync
cargo run --features rpc -- wallet --wallet payjoin_wallet1 balance
cargo run --features rpc -- wallet --wallet payjoin_wallet1 receive_payjoin --amount 400000 --max_fee_rate 1000 --directory "https://payjo.in" --ohttp_relay "https://pj.bobspacebkk.com" --ohttp_relay "https://pj.benalleng.com"
```
To send a Payjoin with regtest RPC and example OHTTP relays:
```
cargo run --features rpc -- --network regtest wallet --wallet payjoin_wallet2 config --ext-descriptor "wpkh(tprv8ZgxMBicQKsPfBxswkATvZRQ9kDdRbJPtHYZaZCARL2myxcK7DqsqPhRo2G2rRVHFPbowq63BE6S4k2pUMYeF2fUMTT63Q7zhoXtKsM1FaS/84'/1'/0'/0/*)#qf5gnqrf" --client-type rpc --database-type sqlite --url "127.0.0.1:18443"
cargo run --features rpc -- wallet --wallet payjoin_wallet2 sync
cargo run --features rpc -- wallet --wallet payjoin_wallet2 balance
cargo run --features rpc -- wallet --wallet payjoin_wallet2 send_payjoin --ohttp_relay "https://pj.bobspacebkk.com" --ohttp_relay "https://pj.benalleng.com" --fee_rate 1 --uri "<URI>"
```

To test resumption, interrupt either side with Ctrl+C mid-session then run resume on that side to continue. A few scenarios worth covering: receiver resuming after interrupt and sender resuming after interrupt. Use history after each scenario to confirm the session state was persisted correctly.

docs for this can be seen in 7e4ffd1

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

@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

@notmandatory notmandatory moved this to In Progress in BDK-CLI Feb 18, 2026
@Mshehu5 Mshehu5 changed the title Payjoin persistance Payjoin persistence Feb 21, 2026
@Mshehu5 Mshehu5 force-pushed the payjion_persistance branch from 7e4ffd1 to ef73b66 Compare February 24, 2026 05:38
@Mshehu5 Mshehu5 marked this pull request as ready for review February 24, 2026 05:41
- 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
@Mshehu5 Mshehu5 force-pushed the payjion_persistance branch 3 times, most recently from ce0d5d9 to a5e2482 Compare February 24, 2026 11:35
- 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
@Mshehu5 Mshehu5 force-pushed the payjion_persistance branch from a5e2482 to c79bd95 Compare February 24, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants