-
Notifications
You must be signed in to change notification settings - Fork 5
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
Parse sender params #30
Conversation
Did you find the names confusing? I intentionally named them shorter for non-public code. Perhaps a comment would be better? I'm not a hater of long names it's just that those seemed good enough for non-public code. Edit: oh, sorry, there are also public items not named after spec. Theses really should be renamed. |
payjoin-client/src/main.rs
Outdated
@@ -57,7 +57,7 @@ fn main() { | |||
.psbt; | |||
let psbt = load_psbt_from_base64(psbt.as_bytes()).unwrap(); | |||
println!("Original psbt: {:#?}", psbt); | |||
let pj_params = bip78::sender::Params::with_fee_contribution(bip78::bitcoin::Amount::from_sat(10000), None); | |||
let pj_params = bip78::sender::Params::non_incentivizing(); |
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.
There's nothing against spec here, this is client-side code where client wants the library to detect the change coming from bitcoind. It's useful in simple scenarios like this one.
From doc:
change_index
specifies which output can be used to pay fee. INone
is provided, then
the output is auto-detected unless the supplied transaction has more than two outputs
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.
ok, Let's keep it. That's useful.
bip78/src/sender/mod.rs
Outdated
@@ -36,7 +36,7 @@ type InternalResult<T> = Result<T, InternalValidationError>; | |||
/// Builder for sender-side payjoin parameters | |||
/// | |||
/// These parameters define how client wants to handle PayJoin. | |||
pub(super) struct Params { | |||
pub struct Params { |
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 destroys forward-compatibility and is definitely not acceptable. #[non_exhaustive]
would work but builders are still more convenient for user code.
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.
I'm confused about this comment. That change is only on an intermediate commit. The original is pub struct Params {
as exists on master right now
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 fields are public and adding a public field to a public struct is breaking change unless it's non_exhaustive
.
Also could you please split sender and receiver contributions into two PRs? It's much easier to handle them that way. |
I now realized what you meant by this PR, in case you read this before #27 see this comment: #27 (comment) |
A note to clarify what may be confusion, there are receiver params aka |
I'm can try to separate the name issues from the architectural ones. I think names like I think the naming & interface clean up is better off in another pr. There's more work than what's needed to get a basic receiver to parse the sender params, which is the goal of this change. |
9c16190
to
a259d1e
Compare
This is now the minimum change to parse. I split it according to ##27 (comment). Other things I attempted before are noted in #31 |
a259d1e
to
43f5e38
Compare
43f5e38
to
39bd78c
Compare
rebased on #27, I believed I addressed at the comments |
/// | ||
/// Note: mixed spends do not necessarily indicate distinct wallet fingerprints. | ||
/// This check is intended to prevent some types of wallet fingerprinting. | ||
pub fn assume_no_mixed_input_scripts(self) -> MaybeInputsSeen { |
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.
We can actually do this check internally, no need to burden the consumer with it. The consumer only needs to get one address type which is the same for all inputs and check that one.
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.
Is this true? Can we stay up to date on all the possible bitcoin scripts?
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.
It's a good point that allowing people to manually check would allow them to work around the library not being updated but if we fail to maintain it they probably should fork it rather than using an obsolete library for potentially security-critical software.
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.
it'd be better if the alpha version of this forgoes mixed input script check since we want to use it for loptos. Is it blocking this PR or may we leave it for the next iteration like some of the warns? I'd love for us to get loptos out ASAP
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.
Even if we skip the check AFAIK there are no wallets currently that support mixed inputs, so that's still useless. If you know of any wallet that does please let me know.
c8f37b1
to
7f715a1
Compare
Requested changes applied ✅ |
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.
I'd like at least macros not be public, the rest are just suggestions.
} | ||
} | ||
} | ||
|
||
impl MaybeInputsOwned { | ||
/// The receiver should not be able to sign for any of these Original PSBT inputs. | ||
/// Check that none of them are owned by the receiver downstream before proceeding. |
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.
Separate into paragraphs.
@@ -36,14 +36,14 @@ type InternalResult<T> = Result<T, InternalValidationError>; | |||
/// Builder for sender-side payjoin parameters | |||
/// | |||
/// These parameters define how client wants to handle PayJoin. | |||
pub struct Params { | |||
pub struct Configuration { | |||
disable_output_substitution: bool, | |||
fee_contribution: Option<(bitcoin::Amount, Option<usize>)>, | |||
clamp_fee_contribution: bool, | |||
min_fee_rate: FeeRate, |
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.
Params
could be inside but not sure if it helps anything.
7f715a1
to
daabe0f
Compare
d8294b9
to
b0fcb51
Compare
b0fcb51
to
850f0d9
Compare
This PR clarifies the
sender::Params
struct to more closely resemble spec (additional fee contribution != fee contribution) and parses it fromquery: &str
. hyper and reqwest can passquery.unwrap_or("")
which can be shown in integration.The changed
Params
struct varied from spec in that it allowed independentmaxadditionalfeerate
andadditionalfeeoutput
index. Spec says those come together or not at all. Else we log:warn! and ignore.