-
Notifications
You must be signed in to change notification settings - Fork 37
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
docs: clarify send,receive function documentation #407
Conversation
payjoin/src/send/mod.rs
Outdated
@@ -350,6 +355,7 @@ impl V1Context { | |||
|
|||
#[cfg(feature = "v2")] | |||
pub struct V2PostContext { | |||
/// The endpoint to send the request to. This is either a pj directory or a receiver's endpoint. |
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.
/// The endpoint to send the request to. This is either a pj directory or a receiver's endpoint. | |
/// The payjoin directory subdirectory to send the request to. |
I may have misinformed you. This is always the payjoin directory subdirectory in this typestate. Only V1Context's endpoint is a V1 receiver's endpoint.
payjoin/src/send/mod.rs
Outdated
/// This is either the pj directory or the receiver's endpoint | ||
endpoint: Url, |
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.
Same comment as above. This is always the payjoin directory subdirectory to GET from
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.
This still hasn't been addressed
payjoin/src/send/mod.rs
Outdated
/// Ensure that the payee output spk is found the list of outputs only once. | ||
/// And that the amount is the same as in the original PSBT. |
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.
Prefer "output script" or "output scriptPubKey" to "output spk." In general less jargon makes for clearer communication. Refer to Murch's terminology BIP for unambiguous consistent vocabulary
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.
This is checking in the build step not between PSBTs. Do you think "And that the amount is the same as in the original PSBT" is sufficiently clear?
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.
Got it. Thats my misunderstanding.
rephrashing to "Ensure that the payee's output scriptPubKey appears in the list of outputs exactly once, and that the payee's output amount matches the requested amount."
payjoin/src/send/mod.rs
Outdated
@@ -763,6 +772,7 @@ fn clear_unneeded_fields(psbt: &mut Psbt) { | |||
} | |||
} | |||
|
|||
/// Check that the output contributing to the fee is not less than the fee. |
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.
/// Check that the output contributing to the fee is not less than the fee. | |
/// Ensure that an additional fee output is sufficient to pay for the specified additional fee |
payjoin/src/send/mod.rs
Outdated
/// Find the sender's change output. | ||
/// The first output should always be the payee spk. | ||
/// If the fee contribution is clamped, any non-payee spk can be the change output. |
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.
/// Find the sender's change output. | |
/// The first output should always be the payee spk. | |
/// If the fee contribution is clamped, any non-payee spk can be the change output. | |
/// Find the sender's change output index by eliminating the payee's as a candidate. |
@spacebear21 "The first output should always be the payee script" screams privacy leak to me since receivers maintain relative ordering. I think this comment is wrong but please help me double check. If that is the behavior, must randomize this to address the issue. However, I believe the second line of the proposed comment is actually wrong since later in the function we check for the payee with .find()
in the case of 2 outputs. This docstring suggests a readability refactor since the unit type return branch (2, _) => (),
was misread to produce this docstring. An inline comment would help fix the misread.
I do NOT believe clamped fee contribution suggests which script can be a change output either. Rather, it ensures that in the case that a SenderBuilder-parameterized additional fee output can't pay for the parameterized max additional fee contribution, then the SenderBuilder will return a Sender with a decreased additional fee contribution rather than producing an error.
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.
The first output should always be the payee script
This seems to only be true if there is no second output. Which makes sense as then we only have one output and that has to the the payee spk
payjoin/src/send/mod.rs
Outdated
/// Checks that the change output index is valid | ||
/// and that the amount is not less than the fee we are suppose to | ||
/// be contributing. |
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.
/// Checks that the change output index is valid | |
/// and that the amount is not less than the fee we are suppose to | |
/// be contributing. | |
/// Check that the change output index is not out of bounds | |
/// and that the additional fee contribution is not less than specified. |
- Use imperative mood.
- Saying "and that the additional fee contribution is not less than specified" covers both amount and clamp parameters.
The "and..." suggests to me the name is incorrect (should be check_change) but that's a nit and suggests the two *_change_index calls in determine_fee_contribution could both be named *_change instead. But this is a major nit and does not actually need to change.
fc3afc6
to
9a73fa2
Compare
Also, this isn't this definitely |
0b0e2c3
to
86fb9e1
Compare
payjoin/src/receive/v2/mod.rs
Outdated
@@ -237,7 +237,7 @@ impl UncheckedProposal { | |||
/// | |||
/// Receiver MUST check that the Original PSBT from the sender | |||
/// can be broadcast, i.e. `testmempoolaccept` bitcoind rpc returns { "allowed": true,.. } | |||
/// for `extract_tx_to_sheculed_broadcast()` before calling this method. | |||
/// for `extract_tx_to_scheduled_broadcast()` before calling this method. |
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.
Should be extract_tx_to_schedule_broadcast
86fb9e1
to
3b0f0be
Compare
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.
ACK 3b0f0be
Many thanks for persisting with me to get all these details right
Yeah you got it. Thanks for the review |
Took some notes while I was reading the sender functions. Thought this could be useful for future contributors.
Also noticed that functions had docs but were not using doc comments
///
. Let me know if that was an intentional decision, I can revert that. But doc comments are nice b/c my ide will ussually describe the function when I hover over it.