diff --git a/Cargo.toml b/Cargo.toml index a2f4f1984..0e979f80b 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -154,17 +154,20 @@ harness = false #lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" } #lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" } -#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } -#lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" } +[patch.'https://github.com/lightningdevkit/rust-lightning'] +# Cargo won't let us patch a git dependency with another rev from the same git dependency, so we +# have to pick another copy of `rust-lightning` and pin the rev. +lightning = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-types = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-invoice = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-net-tokio = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-persister = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-background-processor = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-rapid-gossip-sync = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-block-sync = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-transaction-sync = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-liquidity = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } +lightning-macros = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" } #vss-client-ng = { path = "../vss-client" } #vss-client-ng = { git = "https://github.com/lightningdevkit/vss-client", branch = "main" } diff --git a/src/payment/bolt11.rs b/src/payment/bolt11.rs index 41597bfcc..9592d993f 100644 --- a/src/payment/bolt11.rs +++ b/src/payment/bolt11.rs @@ -14,7 +14,10 @@ use std::sync::{Arc, RwLock}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::hashes::Hash; use lightning::ln::channelmanager::{ - Bolt11InvoiceParameters, Bolt11PaymentError, PaymentId, Retry, RetryableSendFailure, + Bolt11InvoiceParameters, OptionalBolt11PaymentParams, PaymentId, +}; +use lightning::ln::outbound_payment::{ + Bolt11PaymentError, Retry, RetryableSendFailure, }; use lightning::routing::router::{PaymentParameters, RouteParameters, RouteParametersConfig}; use lightning_invoice::{ @@ -109,17 +112,21 @@ impl Bolt11Payment { } } - let route_parameters = + let route_params_config = route_parameters.or(self.config.route_parameters).unwrap_or_default(); let retry_strategy = Retry::Timeout(LDK_PAYMENT_RETRY_TIMEOUT); let payment_secret = Some(*invoice.payment_secret()); + let optional_params = OptionalBolt11PaymentParams { + retry_strategy, + route_params_config, + ..Default::default() + }; match self.channel_manager.pay_for_bolt11_invoice( invoice, payment_id, None, - route_parameters, - retry_strategy, + optional_params, ) { Ok(()) => { let payee_pubkey = invoice.recover_payee_pub_key(); @@ -215,17 +222,22 @@ impl Bolt11Payment { } } - let route_parameters = + let route_params_config = route_parameters.or(self.config.route_parameters).unwrap_or_default(); let retry_strategy = Retry::Timeout(LDK_PAYMENT_RETRY_TIMEOUT); let payment_secret = Some(*invoice.payment_secret()); + + let optional_params = OptionalBolt11PaymentParams { + retry_strategy, + route_params_config, + ..Default::default() + }; match self.channel_manager.pay_for_bolt11_invoice( invoice, payment_id, Some(amount_msat), - route_parameters, - retry_strategy, + optional_params, ) { Ok(()) => { let payee_pubkey = invoice.recover_payee_pub_key(); diff --git a/src/payment/bolt12.rs b/src/payment/bolt12.rs index 98f1d21ef..ada4cd7e2 100644 --- a/src/payment/bolt12.rs +++ b/src/payment/bolt12.rs @@ -14,7 +14,8 @@ use std::sync::{Arc, RwLock}; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use lightning::blinded_path::message::BlindedMessagePath; -use lightning::ln::channelmanager::{OptionalOfferPaymentParams, PaymentId, Retry}; +use lightning::ln::channelmanager::{OptionalOfferPaymentParams, PaymentId}; +use lightning::ln::outbound_payment::Retry; use lightning::offers::offer::{Amount, Offer as LdkOffer, OfferFromHrn, Quantity}; use lightning::offers::parse::Bolt12SemanticError; use lightning::routing::router::RouteParametersConfig; diff --git a/src/payment/spontaneous.rs b/src/payment/spontaneous.rs index 6c074f308..df34ef462 100644 --- a/src/payment/spontaneous.rs +++ b/src/payment/spontaneous.rs @@ -10,7 +10,10 @@ use std::sync::{Arc, RwLock}; use bitcoin::secp256k1::PublicKey; -use lightning::ln::channelmanager::{PaymentId, RecipientOnionFields, Retry, RetryableSendFailure}; +use lightning::ln::channelmanager::PaymentId; +use lightning::ln::outbound_payment::{ + RecipientCustomTlvs, RecipientOnionFields, Retry, RetryableSendFailure, +}; use lightning::routing::router::{PaymentParameters, RouteParameters, RouteParametersConfig}; use lightning::sign::EntropySource; use lightning_types::payment::{PaymentHash, PaymentPreimage}; @@ -125,15 +128,15 @@ impl SpontaneousPayment { *max_channel_saturation_power_of_half; } - let recipient_fields = match custom_tlvs { - Some(tlvs) => RecipientOnionFields::spontaneous_empty() - .with_custom_tlvs(tlvs.into_iter().map(|tlv| (tlv.type_num, tlv.value)).collect()) - .map_err(|e| { - log_error!(self.logger, "Failed to send payment with custom TLVs: {:?}", e); + let mut recipient_fields = RecipientOnionFields::spontaneous_empty(); + if let Some(tlvs) = custom_tlvs { + let tlvs_vec = tlvs.into_iter().map(|tlv| (tlv.type_num, tlv.value)).collect(); + recipient_fields = + recipient_fields.with_custom_tlvs(RecipientCustomTlvs::new(tlvs_vec).map_err(|()| { + log_error!(self.logger, "Attempted to set payment custom TLVs to a spec-defined value"); Error::InvalidCustomTlvs - })?, - None => RecipientOnionFields::spontaneous_empty(), - }; + })?); + } match self.channel_manager.send_spontaneous_payment( Some(payment_preimage),