Skip to content

Commit

Permalink
Uppercase scheme and host in pj uri
Browse files Browse the repository at this point in the history
Also places the `pj` parameter last.

Following this change and assuming the bip21 # escaping bug fix is
merged, the alphanumeric encoding mode can be used for the entirety of
the (% escaped) pj parameter.
  • Loading branch information
nothingmuch committed Dec 2, 2024
1 parent 8dfda80 commit 1c4d154
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion payjoin/src/uri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,19 @@ impl bip21::SerializeParams for &PayjoinExtras {
type Iterator = std::vec::IntoIter<(Self::Key, Self::Value)>;

fn serialize_params(self) -> Self::Iterator {
// normalizing to uppercase enables QR alphanumeric mode encoding
// unfortunately Url normalizes these to be lowercase
let scheme = self.endpoint.scheme();
let host = self.endpoint.host_str().expect("host must be set");
let endpoint_str = self
.endpoint
.as_str()
.replacen(scheme, &scheme.to_uppercase(), 1)
.replacen(host, &host.to_uppercase(), 1);

vec![
("pj", self.endpoint.as_str().to_string()),
("pjos", if self.disable_output_substitution { "1" } else { "0" }.to_string()),
("pj", endpoint_str),
]
.into_iter()
}
Expand Down

0 comments on commit 1c4d154

Please sign in to comment.