-
Notifications
You must be signed in to change notification settings - Fork 85
Fix PR review issues from PR #812 #823
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ use crate::output_substitution::OutputSubstitution; | |||||||||||||||||||||||
| use crate::persist::SessionPersister; | ||||||||||||||||||||||||
| use crate::receive::v2::{extract_err_req, SessionError}; | ||||||||||||||||||||||||
| use crate::receive::{v1, JsonReply}; | ||||||||||||||||||||||||
| use crate::{ImplementationError, IntoUrl, PjUri, Request}; | ||||||||||||||||||||||||
| use crate::{ImplementationError, IntoUrl, PjUri, Request, Version}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /// Errors that can occur when replaying a receiver event log | ||||||||||||||||||||||||
| #[derive(Debug)] | ||||||||||||||||||||||||
|
|
@@ -78,11 +78,20 @@ pub struct SessionHistory { | |||||||||||||||||||||||
| impl SessionHistory { | ||||||||||||||||||||||||
| /// Receiver session Payjoin URI | ||||||||||||||||||||||||
| pub fn pj_uri<'a>(&self) -> Option<PjUri<'a>> { | ||||||||||||||||||||||||
| self.events.iter().find_map(|event| match event { | ||||||||||||||||||||||||
| SessionEvent::Created(session_context) => | ||||||||||||||||||||||||
| Some(crate::receive::v2::pj_uri(session_context, OutputSubstitution::Disabled)), | ||||||||||||||||||||||||
| let session_context = self.events.iter().find_map(|event| match event { | ||||||||||||||||||||||||
| SessionEvent::Created(session_context) => Some(session_context), | ||||||||||||||||||||||||
| _ => None, | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
| })?; | ||||||||||||||||||||||||
| let mut output_substitution = OutputSubstitution::Enabled; | ||||||||||||||||||||||||
| for event in &self.events { | ||||||||||||||||||||||||
| if let SessionEvent::UncheckedProposal((unchecked_proposal, _)) = event { | ||||||||||||||||||||||||
| if unchecked_proposal.params.v == Version::One { | ||||||||||||||||||||||||
| output_substitution = OutputSubstitution::Disabled; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Some(crate::receive::v2::pj_uri(session_context, output_substitution)) | ||||||||||||||||||||||||
|
Comment on lines
+85
to
+94
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately there is a bug (#843) that appears to have caused some confusion with this behavior
since v2 messages are end to end encrypted with integrity protection, a v2 receiver receiving from a v2 sender can substitute outputs even though it specified pjos=0 in the uri, so this code fragment checking the event data is correct for determining the correct behavior for the receiver, it's just not the right value to use when constructing pj_uri. Feel free to fix this bug here, but then please edit the pull request title and description accordingly
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also I guess this method should be documented to say that it returns the pj_url that was sent to the sender, and to note that although
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #847 |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /// Fallback transaction from the session if present | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind adding a test below to prevent future regressions?