Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resume multiple payjoins #283

Merged
merged 10 commits into from
Jun 26, 2024
Merged

Resume multiple payjoins #283

merged 10 commits into from
Jun 26, 2024

Conversation

DanGould
Copy link
Contributor

@DanGould DanGould commented Jun 5, 2024

Fix #267

Send and receive now open sessions with the directory that can be persisted. This includes an e2e test in the UI. As of this PR each session is persisted forever, but a follow up will handle session expiration and archive past sessions for both sender and receiver

This also introduces a new payjoin-cli resume command that continues all active send and receive sessions from the database.

struct SessionContext

The V2Context has been replaced SessionContext that contains an address for the session's URI and an expiry time at which the session is no longer usable.

  • Save multiple payjoin send/receive sessions automatically upon send/receive command
  • Resume all open send/receive sessions with new resume command
  • send command checks bip21 pj=url against the database, resumes if it exists.
  • receive command lists and resumes active sessions and their bip21s
  • ensure e2e test runs in CI

Closes #205 as a side effect

@DanGould DanGould force-pushed the auto-retry branch 4 times, most recently from 4a3136d to 3c42333 Compare June 13, 2024 16:19
@DanGould DanGould added this to the payjoin-cli-0.0.7-alpha milestone Jun 17, 2024
@DanGould DanGould force-pushed the auto-retry branch 3 times, most recently from eb58f41 to 836873c Compare June 21, 2024 15:58
@DanGould DanGould requested a review from spacebear21 June 21, 2024 15:58
@DanGould
Copy link
Contributor Author

DanGould commented Jun 21, 2024

@grizznaut This is not yet quite buttoned up for release but is ready for a review. Before it gets released I'd like the end-to-end test to run the directory and ohttp relay locally. However I think I will leave session expiration to a follow up PR to be completed by the end of next week for the sake of review simplicity.

@DanGould DanGould marked this pull request as ready for review June 24, 2024 01:49
@DanGould DanGould force-pushed the auto-retry branch 3 times, most recently from 7ee2f66 to 8b2caa7 Compare June 24, 2024 17:09
Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

Love the flow for resuming all in-progress sessions without having to supply additional parameters. tACK with some minor comments.

let session = initializer
.process_res(ohttp_response.bytes().await?.to_vec().as_slice(), ctx)
.map_err(|e| anyhow!("Enrollment failed {}", e))?;
self.db.insert_recv_session(session.clone())?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should it follow the same "get or create session" pattern used in send_payjoin here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose not to because the receive command is making a request with a new amount. This way you can start parallel receive sessions. Otherwise, if you wanted to receive from A and B you would need some additional option to resume or not. I'd rather just leave that to the other command. If you accidentally start a new session and get a new BIP21 it's no big cost, but I could see it being a point of confusion. Did you expect it to resume? Perhaps receive should instruct one to use resume when the signal to shut down is given.

send knows the exact bip21 including the amount, so that made more sense to me to proceed with given an exact bip21 uri match than receive.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't have expectations one way or another but was wondering about the different treatment for send vs. receive. This makes sense to me.

Perhaps receive should instruct one to use resume when the signal to shut down is given.

Yeah, that sounds nice (same with send if it's still waiting on a response when shut down).

payjoin-cli/src/app/v2.rs Outdated Show resolved Hide resolved
payjoin-cli/src/app/v2.rs Outdated Show resolved Hide resolved
payjoin-cli/src/app/mod.rs Show resolved Hide resolved
payjoin-cli/src/app/v2.rs Outdated Show resolved Hide resolved
Copy link
Contributor Author

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

I believe I have addressed your concerns, and left one comment on the UX design regarding whether or not the receive command should resume past sessions.

edit: CI is failing because of #302

let session = initializer
.process_res(ohttp_response.bytes().await?.to_vec().as_slice(), ctx)
.map_err(|e| anyhow!("Enrollment failed {}", e))?;
self.db.insert_recv_session(session.clone())?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose not to because the receive command is making a request with a new amount. This way you can start parallel receive sessions. Otherwise, if you wanted to receive from A and B you would need some additional option to resume or not. I'd rather just leave that to the other command. If you accidentally start a new session and get a new BIP21 it's no big cost, but I could see it being a point of confusion. Did you expect it to resume? Perhaps receive should instruct one to use resume when the signal to shut down is given.

send knows the exact bip21 including the amount, so that made more sense to me to proceed with given an exact bip21 uri match than receive.

payjoin-cli/src/app/mod.rs Show resolved Hide resolved
@DanGould DanGould requested a review from spacebear21 June 25, 2024 20:22
DanGould added 6 commits June 26, 2024 00:10
The sender has RequestContext. Now the receiver has a SessionContext.
This API is precarious because downstream URIs get built from
multiple sources of BIP21 URI "Extras". If there were a way to export
and combine the extras a most robust interface would be possible.
This lets us create a static bitcoin URI consistent across sessions.
The new resume command resumes a single prior receive session.
DanGould added 4 commits June 26, 2024 00:10
Resume both send and receive sessions.
Remove payjoin-cli v2 CI builds because this tests v2 which also builds.
@DanGould
Copy link
Contributor Author

I just rebased on master so that tests could run once more

@DanGould DanGould merged commit e7ea236 into payjoin:master Jun 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

V2: Confusing sender/receiver UX flow Construct Uri from Enrolled method
2 participants