]> git.bitcoin.ninja Git - ldk-sample/commitdiff
Adapt to the lightning_invoice crate moving to Rust-Lightning
authorValentine Wallace <vwallace@protonmail.com>
Wed, 14 Apr 2021 19:02:56 +0000 (15:02 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Mon, 3 May 2021 22:31:03 +0000 (18:31 -0400)
Cargo.lock
Cargo.toml
src/cli.rs

index 8c606e9115ae56dfc6762c9f9d3935b527935f1a..229654bd81c660599c58e454779afad87f1ca131 100644 (file)
@@ -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",
index 35bae4964625ace92fddeb2819e9a8a135bc3a19..2fae143fad473c29d204a53cf9d1f8952c2f80ac 100644 (file)
@@ -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" }
index 677348090da7aabc6bc60b0802a687903e946d29..8033cdada51642a48e64b5eee947da7d956c18fc 100644 (file)
@@ -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<lightning_invoice::Route> =
+                                       let route_hints: Vec<Route> =
                                                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<PaymentSecret>, payee_features: Option<InvoiceFeatures>,
-       mut route_hints: Vec<lightning_invoice::Route>,
+       mut route_hints: Vec<Route>,
        router: Arc<NetGraphMsgHandler<Arc<dyn chain::Access>, Arc<FilesystemLogger>>>,
        channel_manager: Arc<ChannelManager>, payment_storage: PaymentInfoStorage,
        logger: Arc<FilesystemLogger>,
@@ -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,