]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Merge pull request #2023 from futurepaul/fallback-to-address
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 7 Apr 2023 19:39:32 +0000 (14:39 -0500)
committerGitHub <noreply@github.com>
Fri, 7 Apr 2023 19:39:32 +0000 (14:39 -0500)
add `Fallback` getter that returns `Address`

1  2 
lightning-invoice/Cargo.toml
lightning-invoice/src/de.rs
lightning-invoice/src/lib.rs
lightning-invoice/src/ser.rs

index a3fb66a8f91425fc8459a38144023cfb8e9fe84e,0e92355c9278586b0b3a8772f19f909a8973af49..9ab9bd5482b6eacd359140750bb1ebdf363231ce
@@@ -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"}
index ab9fd9cb2bc21446920360759feefec87291f774,529d81a66fc2d791bb170c23655d0cb693dda9ca..925d7265c553526d993f94b29354adcac1db9ac1
@@@ -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
                                })
                        },
index 9ff22b8a3c316a3371149d8873e89f528e2f634b,929d6c2861caf62d81e6e6afa239e1874a2562d3..097bdc458ce5391090f7c87a1dde32e1782728a5
@@@ -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())
Simple merge