Conversation
Pull Request Test Coverage Report for Build 22068931916Details
💛 - Coveralls |
7e4ffd1 to
ef73b66
Compare
- 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
ce0d5d9 to
a5e2482
Compare
- 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
a5e2482 to
c79bd95
Compare
tvpeter
left a comment
There was a problem hiding this comment.
Thank you @Mshehu5 for working on this feature.
Below are some of the observations that I think will make the implementation better:
- I noticed that the implementation used only the
sqlitedb, and sincesqliteis a db option in the project, I think it will be ideal if you also include implementation forredbdb so users are free to choose any to use. - The implementation does not provide for pruning/cleanup of data. Given that the db will tend to grow linearly and become sizable over time, I think it will be great to consider adding a pruning subcommand or mechanism that deletes irrelevant data.
- Since the
save_eventis generated at multiple transitions in a session, I think it will be great if you consider grouping such updates in a db transaction to ensure that entries are saved successfully.
I have also left some comments in the code.
Thank you.
| ) -> Result<std::sync::Arc<crate::payjoin::db::Database>, Error> { | ||
| use crate::payjoin::db::{DB_FILENAME, Database}; | ||
| let home_dir = prepare_home_dir(datadir)?; | ||
| let db_path = home_dir.join(DB_FILENAME); |
There was a problem hiding this comment.
I think it will be more reasonable if the db path includes the specific wallet that is used instead of having the payjoin db at the directory level
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "payjoin")] |
There was a problem hiding this comment.
Since sqlite is also a feature, this should be available only when both sqlite and payjoin features are enabled
| } | ||
|
|
||
| #[cfg(feature = "payjoin")] | ||
| pub fn open_payjoin_db( |
There was a problem hiding this comment.
The fn will be more suitable in the utils file
| send_session_ids.retain(|id| id.as_i64() == session_id); | ||
|
|
||
| if recv_session_ids.is_empty() && send_session_ids.is_empty() { | ||
| return Ok(serde_json::to_string_pretty(&json!({ |
There was a problem hiding this comment.
Instead of erroring out when no session id is provided, I think it will be a better flow to select the most recent session id and resume that session.
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 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:
cargo fmtandcargo clippybefore committingNew Features: