]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove now-redundant checks in BOLT12 `Invoice` fallback addresses 2023-11-bitcoin-0.30-followups
authorMatt Corallo <git@bluematt.me>
Sun, 26 Nov 2023 19:09:06 +0000 (19:09 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 26 Nov 2023 19:09:06 +0000 (19:09 +0000)
Now that we use the `rust-bitcoin` `WitnessProgram` to check our
addresses, we can just rely on it, rather than checking the program
length and version.

lightning/src/offers/invoice.rs

index d0e866b2f2ba9e2acbfa56f8912d8ffe2fbe62fb..02d68b635363356736b727287f9cf6949c02be02 100644 (file)
@@ -926,20 +926,11 @@ impl InvoiceContents {
                        };
 
                        let program = &address.program;
-                       if program.len() < 2 || program.len() > 40 {
-                               return None;
-                       }
-
                        let witness_program = match WitnessProgram::new(version, program.clone()) {
                                Ok(witness_program) => witness_program,
                                Err(_) => return None,
                        };
-                       let address = Address::new(network, Payload::WitnessProgram(witness_program));
-                       if !address.is_spend_standard() && version == WitnessVersion::V0 {
-                               return None;
-                       }
-
-                       Some(address)
+                       Some(Address::new(network, Payload::WitnessProgram(witness_program)))
                };
 
                self.fields().fallbacks