From 432106edae85e3e5edc43e2a7c9053ac2d1e5532 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Wed, 14 Apr 2021 15:02:56 -0400 Subject: [PATCH] Adapt to the lightning_invoice crate moving to Rust-Lightning --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cli.rs | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c606e9..229654b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -287,7 +287,7 @@ dependencies = [ [[package]] name = "lightning-invoice" version = "0.4.0" -source = "git+https://github.com/rust-bitcoin/rust-lightning-invoice?rev=aa3a57b9dca5205fa25fa333a2db165d7e77b3b0#aa3a57b9dca5205fa25fa333a2db165d7e77b3b0" +source = "git+https://github.com/rust-bitcoin/rust-lightning?rev=3d51b11fe99c9d6a41b0d662efdf5693d9600552#3d51b11fe99c9d6a41b0d662efdf5693d9600552" dependencies = [ "bech32 0.7.2", "bitcoin_hashes", diff --git a/Cargo.toml b/Cargo.toml index 35bae49..2fae143 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ lightning = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "3d5 # lightning = { path = "../rust-lightning/lightning" } lightning-block-sync = { git = "https://github.com/rust-bitcoin/rust-lightning", features = ["rpc-client"], rev = "3d51b11fe99c9d6a41b0d662efdf5693d9600552" } # lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client"] } -lightning-invoice = { git = "https://github.com/rust-bitcoin/rust-lightning-invoice", rev = "aa3a57b9dca5205fa25fa333a2db165d7e77b3b0" } +lightning-invoice = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "3d51b11fe99c9d6a41b0d662efdf5693d9600552" } lightning-net-tokio = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "3d51b11fe99c9d6a41b0d662efdf5693d9600552" } # lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" } lightning-persister = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "3d51b11fe99c9d6a41b0d662efdf5693d9600552" } diff --git a/src/cli.rs b/src/cli.rs index 6773480..8033cda 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -16,6 +16,7 @@ use lightning::routing::network_graph::{NetGraphMsgHandler, RoutingFees}; use lightning::routing::router; use lightning::routing::router::RouteHint; use lightning::util::config::UserConfig; +use lightning_invoice::{Currency, Invoice, InvoiceBuilder, Route, RouteHop}; use rand; use rand::Rng; use std::env; @@ -194,7 +195,7 @@ pub(crate) async fn poll_for_user_input( continue; } - let invoice_res = lightning_invoice::Invoice::from_str(invoice_str.unwrap()); + let invoice_res = Invoice::from_str(invoice_str.unwrap()); if invoice_res.is_err() { println!("ERROR: invalid invoice: {:?}", invoice_res.unwrap_err()); print!("> "); @@ -202,7 +203,7 @@ pub(crate) async fn poll_for_user_input( continue; } let invoice = invoice_res.unwrap(); - let route_hints: Vec = + let route_hints: Vec = invoice.routes().iter().map(|&route| route.clone()).collect(); let amt_pico_btc = invoice.amount_pico_btc(); @@ -522,7 +523,7 @@ fn open_channel( fn send_payment( payee: PublicKey, amt_msat: u64, final_cltv: u32, payment_hash: PaymentHash, payment_secret: Option, payee_features: Option, - mut route_hints: Vec, + mut route_hints: Vec, router: Arc, Arc>>, channel_manager: Arc, payment_storage: PaymentInfoStorage, logger: Arc, @@ -597,10 +598,10 @@ fn get_invoice( let payment_hash = Sha256Hash::hash(&preimage); let our_node_pubkey = channel_manager.get_our_node_id(); - let mut invoice = lightning_invoice::InvoiceBuilder::new(match network { - Network::Bitcoin => lightning_invoice::Currency::Bitcoin, - Network::Testnet => lightning_invoice::Currency::BitcoinTestnet, - Network::Regtest => lightning_invoice::Currency::Regtest, + let mut invoice = InvoiceBuilder::new(match network { + Network::Bitcoin => Currency::Bitcoin, + Network::Testnet => Currency::BitcoinTestnet, + Network::Regtest => Currency::Regtest, Network::Signet => panic!("Signet invoices not supported"), }) .payment_hash(payment_hash) @@ -624,7 +625,7 @@ fn get_invoice( if forwarding_info.cltv_expiry_delta > min_final_cltv_expiry { min_final_cltv_expiry = forwarding_info.cltv_expiry_delta; } - invoice = invoice.route(vec![lightning_invoice::RouteHop { + invoice = invoice.route(vec![RouteHop { pubkey: channel.remote_network_id, short_channel_id, fee_base_msat: forwarding_info.fee_base_msat, -- 2.39.5