-
Notifications
You must be signed in to change notification settings - Fork 40
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 and set ohttp=
parameter from pj
URL fragment
#300
Conversation
ohttp=
parameter from pj
URL fragment
9f0e415
to
101c429
Compare
Refactor `OhttpKeys` so that #300 can just focus on semantics. - First Commit removes a clippy warning - 2nd reduces unnecessary base64 verbosity. base64 dependency was being used where psbt.to_string was fine, and the custom configs were being built where confs could do - 3rd removes a vestigial PartialEq implementation - 4th disambiguates `Display` and `Serialize` roles. [OHTTP KeyConfigs encoding](https://www.ietf.org/rfc/rfc9458.html#name-key-configuration-encoding) for serialization is well specified by the rfc. We're using string representations in URLs and configs just for Payjoin V2 which is a separate thing
0bbef22
to
b2c5127
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.
Looks good. It would be helpful to add a unit test that parses a full BIP21 URI, in addition to just the pj URL. Specifically, a BIP21 URI with multiple parameters and &
separators to validate the logic in set_ohttp
Thanks for the approval but this is probably still not the correct abstraction, which is why I haven't re-requested review (I don't think I did at least). I wrote the tests you recommended locally and they would fail because this doesn't yet percent-encode the fragment '=' and '&' characters. They conflict with the bip21 params. So I think that such tess should be working to justify our new abstraction before it's merged |
Use InternalPjparseError so as not to require so much boilerplate.
This extension trait defines functions to parse and set the ohttp parameter in the fragment of a `pj=` URL. Close payjoin#298
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.
tACK e97238a
Close #298
This introduces a
Url
extension trait calledpayjoin::uri::UrlExt
which can set and getohttp=
as a fragment rather than a URI parameter. Doing so allows BIP 77 payjoin v2 parameters to be compliant with any BIP 21 bitcoin URI parser that already supports &pj= without introducing new params. This seems to simplify the v1/v2 feature gates too.This change also handles subdirectory parsing differently since the URL no longer ends with the subdirectory, but also the fragment. This introduces new V2 errors. On my first attempt I added subdirectory parsing and setting to
UrlExt
, but opted to remove that since it's out of scope for fragment handling and it would probably need to be considered to be feature gated behindsend
/receive
which could make theuri
module messier. (But also perhaps not sinceUriExt
is private andsend
/receive
gates can be enforced in those higher module abstractions whereUriExt
is depended upon).The
UriExt
is unit tested.I'm not sure how to best handle the difference between Ul paths with or without a trailing slash. Technically the latter is a true subdirectory but for our purposes, we're actually using HTTP endpoints that don't differentiate. Our parser should probably prefer one to another. I'm inclined to prefer fewer characters for simplicity.
e.g.
vs
This was done as prerequisite to #299 since I believe
exp
should be a payjoin-specific fragment parameter as well that gets added toUriExt