Skip to content

Commit 432106e

Browse files
Adapt to the lightning_invoice crate moving to Rust-Lightning
1 parent 85e890b commit 432106e

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ lightning = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "3d5
1919
# lightning = { path = "../rust-lightning/lightning" }
2020
lightning-block-sync = { git = "https://github.com/rust-bitcoin/rust-lightning", features = ["rpc-client"], rev = "3d51b11fe99c9d6a41b0d662efdf5693d9600552" }
2121
# lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client"] }
22-
lightning-invoice = { git = "https://github.com/rust-bitcoin/rust-lightning-invoice", rev = "aa3a57b9dca5205fa25fa333a2db165d7e77b3b0" }
22+
lightning-invoice = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "3d51b11fe99c9d6a41b0d662efdf5693d9600552" }
2323
lightning-net-tokio = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "3d51b11fe99c9d6a41b0d662efdf5693d9600552" }
2424
# lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
2525
lightning-persister = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "3d51b11fe99c9d6a41b0d662efdf5693d9600552" }

src/cli.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use lightning::routing::network_graph::{NetGraphMsgHandler, RoutingFees};
1616
use lightning::routing::router;
1717
use lightning::routing::router::RouteHint;
1818
use lightning::util::config::UserConfig;
19+
use lightning_invoice::{Currency, Invoice, InvoiceBuilder, Route, RouteHop};
1920
use rand;
2021
use rand::Rng;
2122
use std::env;
@@ -194,15 +195,15 @@ pub(crate) async fn poll_for_user_input(
194195
continue;
195196
}
196197

197-
let invoice_res = lightning_invoice::Invoice::from_str(invoice_str.unwrap());
198+
let invoice_res = Invoice::from_str(invoice_str.unwrap());
198199
if invoice_res.is_err() {
199200
println!("ERROR: invalid invoice: {:?}", invoice_res.unwrap_err());
200201
print!("> ");
201202
io::stdout().flush().unwrap();
202203
continue;
203204
}
204205
let invoice = invoice_res.unwrap();
205-
let route_hints: Vec<lightning_invoice::Route> =
206+
let route_hints: Vec<Route> =
206207
invoice.routes().iter().map(|&route| route.clone()).collect();
207208

208209
let amt_pico_btc = invoice.amount_pico_btc();
@@ -522,7 +523,7 @@ fn open_channel(
522523
fn send_payment(
523524
payee: PublicKey, amt_msat: u64, final_cltv: u32, payment_hash: PaymentHash,
524525
payment_secret: Option<PaymentSecret>, payee_features: Option<InvoiceFeatures>,
525-
mut route_hints: Vec<lightning_invoice::Route>,
526+
mut route_hints: Vec<Route>,
526527
router: Arc<NetGraphMsgHandler<Arc<dyn chain::Access>, Arc<FilesystemLogger>>>,
527528
channel_manager: Arc<ChannelManager>, payment_storage: PaymentInfoStorage,
528529
logger: Arc<FilesystemLogger>,
@@ -597,10 +598,10 @@ fn get_invoice(
597598
let payment_hash = Sha256Hash::hash(&preimage);
598599

599600
let our_node_pubkey = channel_manager.get_our_node_id();
600-
let mut invoice = lightning_invoice::InvoiceBuilder::new(match network {
601-
Network::Bitcoin => lightning_invoice::Currency::Bitcoin,
602-
Network::Testnet => lightning_invoice::Currency::BitcoinTestnet,
603-
Network::Regtest => lightning_invoice::Currency::Regtest,
601+
let mut invoice = InvoiceBuilder::new(match network {
602+
Network::Bitcoin => Currency::Bitcoin,
603+
Network::Testnet => Currency::BitcoinTestnet,
604+
Network::Regtest => Currency::Regtest,
604605
Network::Signet => panic!("Signet invoices not supported"),
605606
})
606607
.payment_hash(payment_hash)
@@ -624,7 +625,7 @@ fn get_invoice(
624625
if forwarding_info.cltv_expiry_delta > min_final_cltv_expiry {
625626
min_final_cltv_expiry = forwarding_info.cltv_expiry_delta;
626627
}
627-
invoice = invoice.route(vec![lightning_invoice::RouteHop {
628+
invoice = invoice.route(vec![RouteHop {
628629
pubkey: channel.remote_network_id,
629630
short_channel_id,
630631
fee_base_msat: forwarding_info.fee_base_msat,

0 commit comments

Comments
 (0)