Skip to content

Commit 8460fd3

Browse files
committed
Avoid searching for LNURL override in bitcoin: URIs
If we have a bitcoin: URI like `bitcoin:thing?lnurl=LNURL...` we really shouldn't use the LNURL override to only resolve the instructions as LNURL. Instead, we fall back to normal URI parsing.
1 parent 9a4ad4a commit 8460fd3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,8 @@ impl PaymentInstructions {
918918
supports_proof_of_payment_callbacks: bool,
919919
) -> Result<PaymentInstructions, ParseError> {
920920
let supports_pops = supports_proof_of_payment_callbacks;
921+
let (uri_proto, _uri_suffix) = split_once(instructions, ':');
922+
921923
if let Ok(hrn) = HumanReadableName::from_encoded(instructions) {
922924
let resolution = hrn_resolver.resolve_hrn(&hrn).await;
923925
let resolution = resolution.map_err(ParseError::HrnResolutionError)?;
@@ -947,6 +949,10 @@ impl PaymentInstructions {
947949
))
948950
},
949951
}
952+
} else if uri_proto.eq_ignore_ascii_case("bitcoin:") {
953+
// If it looks like a BIP 353 URI, jump straight to parsing it and ignore any LNURL
954+
// overrides.
955+
parse_resolved_instructions(instructions, network, supports_pops, None, None)
950956
} else if let Some(idx) = instructions.to_ascii_lowercase().rfind("lnurl") {
951957
let mut lnurl_str = &instructions[idx..];
952958
// first try to decode as a bech32-encoded lnurl, if that fails, try to drop a

0 commit comments

Comments
 (0)