From: Jeffrey Czyz Date: Fri, 7 Apr 2023 19:39:32 +0000 (-0500) Subject: Merge pull request #2023 from futurepaul/fallback-to-address X-Git-Tag: v0.0.115~29 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=1ceb41e08b2d76b23d2505a10a88db8d840895ca;p=rust-lightning Merge pull request #2023 from futurepaul/fallback-to-address add `Fallback` getter that returns `Address` --- 1ceb41e08b2d76b23d2505a10a88db8d840895ca diff --cc lightning-invoice/Cargo.toml index a3fb66a8f,0e92355c9..9ab9bd548 --- a/lightning-invoice/Cargo.toml +++ b/lightning-invoice/Cargo.toml @@@ -27,8 -27,9 +27,9 @@@ num-traits = { version = "0.2.8", defau bitcoin_hashes = { version = "0.11", default-features = false } hashbrown = { version = "0.8", optional = true } serde = { version = "1.0.118", optional = true } + bitcoin = { version = "0.29.0", default-features = false } [dev-dependencies] -lightning = { version = "0.0.113", path = "../lightning", default-features = false, features = ["_test_utils"] } +lightning = { version = "0.0.114", path = "../lightning", default-features = false, features = ["_test_utils"] } hex = "0.4" serde_json = { version = "1"} diff --cc lightning-invoice/src/de.rs index ab9fd9cb2,529d81a66..925d7265c --- a/lightning-invoice/src/de.rs +++ b/lightning-invoice/src/de.rs @@@ -6,8 -7,11 +7,10 @@@ use core::num::ParseIntError use core::str; use core::str::FromStr; -use bech32; use bech32::{u5, FromBase32}; + use bitcoin::{PubkeyHash, ScriptHash}; + use bitcoin::util::address::WitnessVersion; use bitcoin_hashes::Hash; use bitcoin_hashes::sha256; use crate::prelude::*; @@@ -550,9 -555,9 +553,9 @@@ impl FromBase32 for Fallback if bytes.len() < 2 || bytes.len() > 40 { return Err(ParseError::InvalidSegWitProgramLength); } - + let version = WitnessVersion::try_from(version).expect("0 through 16 are valid SegWit versions"); Ok(Fallback::SegWitProgram { - version: version, + version, program: bytes }) }, diff --cc lightning-invoice/src/lib.rs index 9ff22b8a3,929d6c286..097bdc458 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@@ -1969,10 -1955,10 +1997,10 @@@ mod test let builder = InvoiceBuilder::new(Currency::BitcoinTestnet) .amount_milli_satoshis(123) .duration_since_epoch(Duration::from_secs(1234567)) - .payee_pub_key(public_key.clone()) + .payee_pub_key(public_key) .expiry_time(Duration::from_secs(54321)) .min_final_cltv_expiry_delta(144) - .fallback(Fallback::PubKeyHash([0;20])) + .fallback(Fallback::PubKeyHash(PubkeyHash::from_slice(&[0;20]).unwrap())) .private_route(route_1.clone()) .private_route(route_2.clone()) .description_hash(sha256::Hash::from_slice(&[3;32][..]).unwrap())