Skip to content

Commit 569e910

Browse files
authored
Merge pull request #639 from joostjager/pay-for-offer-refactor
Adapt to new pay_for_offer call
2 parents 0f1d66c + 97f404f commit 569e910

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ default = []
5252
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
5353
#lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
5454

55-
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4", features = ["std"] }
56-
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4" }
57-
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4", features = ["std"] }
58-
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4" }
59-
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4" }
60-
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4" }
61-
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4" }
62-
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4", features = ["rest-client", "rpc-client", "tokio"] }
63-
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4", features = ["esplora-async-https", "electrum-rustls-ring", "time"] }
64-
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4" }
65-
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4" }
55+
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6", features = ["std"] }
56+
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6" }
57+
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6", features = ["std"] }
58+
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6" }
59+
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6" }
60+
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6" }
61+
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6" }
62+
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6", features = ["rest-client", "rpc-client", "tokio"] }
63+
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6", features = ["esplora-async-https", "electrum-rustls-ring", "time"] }
64+
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6" }
65+
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6" }
6666

6767
#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
6868
#lightning-types = { path = "../rust-lightning/lightning-types" }
@@ -109,7 +109,7 @@ winapi = { version = "0.3", features = ["winbase"] }
109109
[dev-dependencies]
110110
#lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
111111
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
112-
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "b002e43ec5f9c1cbdcd1ac8588402c5a65ecd2e4", features = ["std", "_test_utils"] }
112+
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "50391d3a3efa7a8f32d119d126a633e4b1981ee6", features = ["std", "_test_utils"] }
113113
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
114114
proptest = "1.0.0"
115115
regex = "1.5.6"

src/payment/bolt12.rs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::payment::store::{PaymentDetails, PaymentDirection, PaymentKind, Payme
1717
use crate::types::{ChannelManager, PaymentStore};
1818

1919
use lightning::blinded_path::message::BlindedMessagePath;
20-
use lightning::ln::channelmanager::{PaymentId, Retry};
20+
use lightning::ln::channelmanager::{OptionalOfferPaymentParams, PaymentId, Retry};
2121
use lightning::offers::offer::{Amount, Offer as LdkOffer, Quantity};
2222
use lightning::offers::parse::Bolt12SemanticError;
2323
use lightning::routing::router::RouteParametersConfig;
@@ -102,15 +102,19 @@ impl Bolt12Payment {
102102
},
103103
};
104104

105-
match self.channel_manager.pay_for_offer(
106-
&offer,
107-
quantity,
108-
None,
109-
payer_note.clone(),
110-
payment_id,
105+
let params = OptionalOfferPaymentParams {
106+
payer_note: payer_note.clone(),
111107
retry_strategy,
112108
route_params_config,
113-
) {
109+
};
110+
let res = if let Some(quantity) = quantity {
111+
self.channel_manager
112+
.pay_for_offer_with_quantity(&offer, None, payment_id, params, quantity)
113+
} else {
114+
self.channel_manager.pay_for_offer(&offer, None, payment_id, params)
115+
};
116+
117+
match res {
114118
Ok(()) => {
115119
let payee_pubkey = offer.issuer_signing_pubkey();
116120
log_info!(
@@ -209,15 +213,24 @@ impl Bolt12Payment {
209213
return Err(Error::InvalidAmount);
210214
}
211215

212-
match self.channel_manager.pay_for_offer(
213-
&offer,
214-
quantity,
215-
Some(amount_msat),
216-
payer_note.clone(),
217-
payment_id,
216+
let params = OptionalOfferPaymentParams {
217+
payer_note: payer_note.clone(),
218218
retry_strategy,
219219
route_params_config,
220-
) {
220+
};
221+
let res = if let Some(quantity) = quantity {
222+
self.channel_manager.pay_for_offer_with_quantity(
223+
&offer,
224+
Some(amount_msat),
225+
payment_id,
226+
params,
227+
quantity,
228+
)
229+
} else {
230+
self.channel_manager.pay_for_offer(&offer, Some(amount_msat), payment_id, params)
231+
};
232+
233+
match res {
221234
Ok(()) => {
222235
let payee_pubkey = offer.issuer_signing_pubkey();
223236
log_info!(

0 commit comments

Comments
 (0)