Skip to content

Commit c9ba4fa

Browse files
committed
Update to upstream LDK after 4263 and 4370
lightningdevkit/rust-lightning#4263 and lightningdevkit/rust-lightning#4370 changed the `lightning` API, which we update to here. We also switch to using a `Cargo.toml` `[patch...]` to avoid having to update the `bitcoin-payment-instructions` dep after each bump.
1 parent fbc7f94 commit c9ba4fa

4 files changed

Lines changed: 47 additions & 28 deletions

File tree

Cargo.toml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,20 @@ harness = false
154154
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
155155
#lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
156156

157-
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
158-
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
159-
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
160-
#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
161-
#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
162-
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
163-
#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
164-
#lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
165-
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
166-
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
167-
#lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
157+
[patch.'https://github.com/lightningdevkit/rust-lightning']
158+
# Cargo won't let us patch a git dependency with another rev from the same git dependency, so we
159+
# have to pick another copy of `rust-lightning` and pin the rev.
160+
lightning = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
161+
lightning-types = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
162+
lightning-invoice = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
163+
lightning-net-tokio = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
164+
lightning-persister = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
165+
lightning-background-processor = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
166+
lightning-rapid-gossip-sync = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
167+
lightning-block-sync = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
168+
lightning-transaction-sync = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
169+
lightning-liquidity = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
170+
lightning-macros = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "0bc5c95484345c6289dffd9a379982a9b66d688f" }
168171

169172
#vss-client-ng = { path = "../vss-client" }
170173
#vss-client-ng = { git = "https://github.com/lightningdevkit/vss-client", branch = "main" }

src/payment/bolt11.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ use std::sync::{Arc, RwLock};
1414
use bitcoin::hashes::sha256::Hash as Sha256;
1515
use bitcoin::hashes::Hash;
1616
use lightning::ln::channelmanager::{
17-
Bolt11InvoiceParameters, Bolt11PaymentError, PaymentId, Retry, RetryableSendFailure,
17+
Bolt11InvoiceParameters, OptionalBolt11PaymentParams, PaymentId,
18+
};
19+
use lightning::ln::outbound_payment::{
20+
Bolt11PaymentError, Retry, RetryableSendFailure,
1821
};
1922
use lightning::routing::router::{PaymentParameters, RouteParameters, RouteParametersConfig};
2023
use lightning_invoice::{
@@ -109,17 +112,21 @@ impl Bolt11Payment {
109112
}
110113
}
111114

112-
let route_parameters =
115+
let route_params_config =
113116
route_parameters.or(self.config.route_parameters).unwrap_or_default();
114117
let retry_strategy = Retry::Timeout(LDK_PAYMENT_RETRY_TIMEOUT);
115118
let payment_secret = Some(*invoice.payment_secret());
116119

120+
let optional_params = OptionalBolt11PaymentParams {
121+
retry_strategy,
122+
route_params_config,
123+
..Default::default()
124+
};
117125
match self.channel_manager.pay_for_bolt11_invoice(
118126
invoice,
119127
payment_id,
120128
None,
121-
route_parameters,
122-
retry_strategy,
129+
optional_params,
123130
) {
124131
Ok(()) => {
125132
let payee_pubkey = invoice.recover_payee_pub_key();
@@ -215,17 +222,22 @@ impl Bolt11Payment {
215222
}
216223
}
217224

218-
let route_parameters =
225+
let route_params_config =
219226
route_parameters.or(self.config.route_parameters).unwrap_or_default();
220227
let retry_strategy = Retry::Timeout(LDK_PAYMENT_RETRY_TIMEOUT);
221228
let payment_secret = Some(*invoice.payment_secret());
222229

230+
231+
let optional_params = OptionalBolt11PaymentParams {
232+
retry_strategy,
233+
route_params_config,
234+
..Default::default()
235+
};
223236
match self.channel_manager.pay_for_bolt11_invoice(
224237
invoice,
225238
payment_id,
226239
Some(amount_msat),
227-
route_parameters,
228-
retry_strategy,
240+
optional_params,
229241
) {
230242
Ok(()) => {
231243
let payee_pubkey = invoice.recover_payee_pub_key();

src/payment/bolt12.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use std::sync::{Arc, RwLock};
1414
use std::time::{Duration, SystemTime, UNIX_EPOCH};
1515

1616
use lightning::blinded_path::message::BlindedMessagePath;
17-
use lightning::ln::channelmanager::{OptionalOfferPaymentParams, PaymentId, Retry};
17+
use lightning::ln::channelmanager::{OptionalOfferPaymentParams, PaymentId};
18+
use lightning::ln::outbound_payment::Retry;
1819
use lightning::offers::offer::{Amount, Offer as LdkOffer, OfferFromHrn, Quantity};
1920
use lightning::offers::parse::Bolt12SemanticError;
2021
use lightning::routing::router::RouteParametersConfig;

src/payment/spontaneous.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
use std::sync::{Arc, RwLock};
1111

1212
use bitcoin::secp256k1::PublicKey;
13-
use lightning::ln::channelmanager::{PaymentId, RecipientOnionFields, Retry, RetryableSendFailure};
13+
use lightning::ln::channelmanager::PaymentId;
14+
use lightning::ln::outbound_payment::{
15+
RecipientCustomTlvs, RecipientOnionFields, Retry, RetryableSendFailure,
16+
};
1417
use lightning::routing::router::{PaymentParameters, RouteParameters, RouteParametersConfig};
1518
use lightning::sign::EntropySource;
1619
use lightning_types::payment::{PaymentHash, PaymentPreimage};
@@ -125,15 +128,15 @@ impl SpontaneousPayment {
125128
*max_channel_saturation_power_of_half;
126129
}
127130

128-
let recipient_fields = match custom_tlvs {
129-
Some(tlvs) => RecipientOnionFields::spontaneous_empty()
130-
.with_custom_tlvs(tlvs.into_iter().map(|tlv| (tlv.type_num, tlv.value)).collect())
131-
.map_err(|e| {
132-
log_error!(self.logger, "Failed to send payment with custom TLVs: {:?}", e);
131+
let mut recipient_fields = RecipientOnionFields::spontaneous_empty();
132+
if let Some(tlvs) = custom_tlvs {
133+
let tlvs_vec = tlvs.into_iter().map(|tlv| (tlv.type_num, tlv.value)).collect();
134+
recipient_fields =
135+
recipient_fields.with_custom_tlvs(RecipientCustomTlvs::new(tlvs_vec).map_err(|()| {
136+
log_error!(self.logger, "Attempted to set payment custom TLVs to a spec-defined value");
133137
Error::InvalidCustomTlvs
134-
})?,
135-
None => RecipientOnionFields::spontaneous_empty(),
136-
};
138+
})?);
139+
}
137140

138141
match self.channel_manager.send_spontaneous_payment(
139142
Some(payment_preimage),

0 commit comments

Comments
 (0)