Skip to content

Commit 1d00fed

Browse files
authored
Set disableoutputsubstitution to 'true' if used (payjoin#485)
Noticed this when writing tests for a new multiparty optional param. In the sender if we are setting `disableoutputsubstitution` we set it to "1", however in the reciever we are only treating "true" string value if as the set state.
2 parents 8272492 + d3373a3 commit 1d00fed

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

payjoin/src/send/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ fn serialize_url(
406406
let mut url = endpoint;
407407
url.query_pairs_mut().append_pair("v", version);
408408
if disable_output_substitution {
409-
url.query_pairs_mut().append_pair("disableoutputsubstitution", "1");
409+
url.query_pairs_mut().append_pair("disableoutputsubstitution", "true");
410410
}
411411
if let Some((amount, index)) = fee_contribution {
412412
url.query_pairs_mut()
@@ -427,7 +427,9 @@ pub(crate) mod test {
427427

428428
use bitcoin::psbt::Psbt;
429429
use bitcoin::FeeRate;
430+
use url::Url;
430431

432+
use super::serialize_url;
431433
use crate::psbt::PsbtExt;
432434

433435
pub(crate) const ORIGINAL_PSBT: &str = "cHNidP8BAHMCAAAAAY8nutGgJdyYGXWiBEb45Hoe9lWGbkxh/6bNiOJdCDuDAAAAAAD+////AtyVuAUAAAAAF6kUHehJ8GnSdBUOOv6ujXLrWmsJRDCHgIQeAAAAAAAXqRR3QJbbz0hnQ8IvQ0fptGn+votneofTAAAAAAEBIKgb1wUAAAAAF6kU3k4ekGHKWRNbA1rV5tR5kEVDVNCHAQcXFgAUx4pFclNVgo1WWAdN1SYNX8tphTABCGsCRzBEAiB8Q+A6dep+Rz92vhy26lT0AjZn4PRLi8Bf9qoB/CMk0wIgP/Rj2PWZ3gEjUkTlhDRNAQ0gXwTO7t9n+V14pZ6oljUBIQMVmsAaoNWHVMS02LfTSe0e388LNitPa1UQZyOihY+FFgABABYAFEb2Giu6c4KO5YW0pfw3lGp9jMUUAAA=";
@@ -484,4 +486,17 @@ pub(crate) mod test {
484486
proposal.unsigned_tx.output[1].value += bitcoin::Amount::from_btc(0.5).unwrap();
485487
ctx.process_proposal(proposal).unwrap();
486488
}
489+
490+
#[test]
491+
fn test_disable_output_substitution_query_param() {
492+
let url =
493+
serialize_url(Url::parse("http://localhost").unwrap(), true, None, FeeRate::ZERO, "2")
494+
.unwrap();
495+
assert_eq!(url, Url::parse("http://localhost?v=2&disableoutputsubstitution=true").unwrap());
496+
497+
let url =
498+
serialize_url(Url::parse("http://localhost").unwrap(), false, None, FeeRate::ZERO, "2")
499+
.unwrap();
500+
assert_eq!(url, Url::parse("http://localhost?v=2").unwrap());
501+
}
487502
}

0 commit comments

Comments
 (0)