Skip to content

Commit

Permalink
Revert
Browse files Browse the repository at this point in the history
This reverts commit d63f2ff.
This reverts commit 874733e.
This reverts commit 0d6fa48.
  • Loading branch information
nothingmuch committed Oct 23, 2024
1 parent 0d6fa48 commit 047ff35
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 21 deletions.
1 change: 0 additions & 1 deletion Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,6 @@ dependencies = [
"ohttp-relay",
"once_cell",
"payjoin-directory",
"percent-encoding-rfc3986",
"rcgen",
"reqwest",
"rustls 0.22.4",
Expand Down
1 change: 0 additions & 1 deletion Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,6 @@ dependencies = [
"ohttp-relay",
"once_cell",
"payjoin-directory",
"percent-encoding-rfc3986",
"rcgen",
"reqwest",
"rustls 0.22.4",
Expand Down
1 change: 0 additions & 1 deletion payjoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ reqwest = { version = "0.12", default-features = false, optional = true }
rustls = { version = "0.22.4", optional = true }
url = "2.2.2"
serde_json = "1.0.108"
percent-encoding-rfc3986 = "0.1.3"

[dev-dependencies]
bitcoind = { version = "0.36.0", features = ["0_21_2"] }
Expand Down
13 changes: 3 additions & 10 deletions payjoin/src/uri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::borrow::Cow;
use bitcoin::address::NetworkChecked;
use bitcoin::{Address, Amount};
pub use error::PjParseError;
use percent_encoding_rfc3986::{percent_decode_str, utf8_percent_encode, AsciiSet, CONTROLS};
use url::Url;

use crate::uri::error::InternalPjParseError;
Expand Down Expand Up @@ -193,16 +192,14 @@ impl<'a> bip21::SerializeParams for &'a MaybePayjoinExtras {
}
}

const FRAGMENT_SEPARATOR: &AsciiSet = &CONTROLS.add(b'#');

impl<'a> bip21::SerializeParams for &'a PayjoinExtras {
type Key = &'static str;
type Value = String;
type Iterator = std::vec::IntoIter<(Self::Key, Self::Value)>;

fn serialize_params(self) -> Self::Iterator {
vec![
("pj", utf8_percent_encode(self.endpoint.as_str(), FRAGMENT_SEPARATOR).to_string()), // FIXME remove work around bip21::Uri not escaping '#' in query parameter values once fixed upstream
("pj", self.endpoint.as_str().to_string()),
("pjos", if self.disable_output_substitution { "1" } else { "0" }.to_string()),
]
.into_iter()
Expand All @@ -224,12 +221,8 @@ impl<'a> bip21::de::DeserializationState<'a> for DeserializationState {
> {
match key {
"pj" if self.pj.is_none() => {
let encoded = Cow::try_from(value).map_err(|_| InternalPjParseError::NotUtf8)?;
let decoded = percent_decode_str(&encoded)
.map_err(|_| InternalPjParseError::BadEndpoint)?
.decode_utf8()
.map_err(|_| InternalPjParseError::NotUtf8)?;
let url = Url::parse(&decoded).map_err(|_| InternalPjParseError::BadEndpoint)?;
let endpoint = Cow::try_from(value).map_err(|_| InternalPjParseError::NotUtf8)?;
let url = Url::parse(&endpoint).map_err(|_| InternalPjParseError::BadEndpoint)?;
self.pj = Some(url);

Ok(bip21::de::ParamKind::Known)
Expand Down
9 changes: 1 addition & 8 deletions payjoin/src/uri/url_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,9 @@ mod tests {

#[test]
fn test_valid_v2_url_fragment_on_bip21() {
let uri = "bitcoin:12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX?amount=0.01\
&pjos=0&pj=https://example.com\
%23ohttp%3DAQO6SMScPUqSo60A7MY6Ak2hDO0CGAxz7BLYp60syRu0gw";
let uri = Uri::try_from(uri).unwrap().assume_checked().check_pj_supported().unwrap();
assert!(uri.extras.endpoint().ohttp().is_some());

let uri = "bitcoin:12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX?amount=0.01\
&pj=https://example.com\
%23ohttp%3DAQO6SMScPUqSo60A7MY6Ak2hDO0CGAxz7BLYp60syRu0gw\
&pjos=0";
#ohttp%3DAQO6SMScPUqSo60A7MY6Ak2hDO0CGAxz7BLYp60syRu0gw";
let uri = Uri::try_from(uri).unwrap().assume_checked().check_pj_supported().unwrap();
assert!(uri.extras.endpoint().ohttp().is_some());
}
Expand Down

0 comments on commit 047ff35

Please sign in to comment.