Skip to content

Commit 10b8f4c

Browse files
authored
Merge pull request #2039 from jkczyz/2023-02-offer-flow
BOLT 12 Offers message flow
2 parents 33bbf26 + fe90448 commit 10b8f4c

21 files changed

+758
-201
lines changed

lightning/src/blinded_path/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl BlindedPath {
8484
}
8585

8686
/// Create a one-hop blinded path for a payment.
87-
pub fn one_hop_for_payment<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>(
87+
pub fn one_hop_for_payment<ES: EntropySource + ?Sized, T: secp256k1::Signing + secp256k1::Verification>(
8888
payee_node_id: PublicKey, payee_tlvs: payment::ReceiveTlvs, entropy_source: &ES,
8989
secp_ctx: &Secp256k1<T>
9090
) -> Result<(BlindedPayInfo, Self), ()> {
@@ -105,7 +105,7 @@ impl BlindedPath {
105105
///
106106
/// [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
107107
// TODO: make all payloads the same size with padding + add dummy hops
108-
pub(crate) fn new_for_payment<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>(
108+
pub(crate) fn new_for_payment<ES: EntropySource + ?Sized, T: secp256k1::Signing + secp256k1::Verification>(
109109
intermediate_nodes: &[payment::ForwardNode], payee_node_id: PublicKey,
110110
payee_tlvs: payment::ReceiveTlvs, htlc_maximum_msat: u64, entropy_source: &ES,
111111
secp_ctx: &Secp256k1<T>

lightning/src/blinded_path/payment.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ pub struct PaymentRelay {
8989
/// [`BlindedHop`]: crate::blinded_path::BlindedHop
9090
#[derive(Clone, Debug)]
9191
pub struct PaymentConstraints {
92-
/// The maximum total CLTV delta that is acceptable when relaying a payment over this
93-
/// [`BlindedHop`].
92+
/// The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`].
9493
pub max_cltv_expiry: u32,
9594
/// The minimum value, in msat, that may be accepted by the node corresponding to this
9695
/// [`BlindedHop`].

lightning/src/events/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,13 @@ pub enum Event {
514514
sender_intended_total_msat: Option<u64>,
515515
},
516516
/// Indicates a request for an invoice failed to yield a response in a reasonable amount of time
517-
/// or was explicitly abandoned by [`ChannelManager::abandon_payment`].
517+
/// or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an
518+
/// [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed.
518519
///
519520
/// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
520-
#[cfg(invreqfailed)]
521+
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
522+
/// [`Offer`]: crate::offers::offer::Offer
523+
/// [`Refund`]: crate::offers::refund::Refund
521524
InvoiceRequestFailed {
522525
/// The `payment_id` to have been associated with payment for the requested invoice.
523526
payment_id: PaymentId,
@@ -1164,7 +1167,6 @@ impl Writeable for Event {
11641167
(8, funding_txo, required),
11651168
});
11661169
},
1167-
#[cfg(invreqfailed)]
11681170
&Event::InvoiceRequestFailed { ref payment_id } => {
11691171
33u8.write(writer)?;
11701172
write_tlv_fields!(writer, {
@@ -1558,7 +1560,6 @@ impl MaybeReadable for Event {
15581560
};
15591561
f()
15601562
},
1561-
#[cfg(invreqfailed)]
15621563
33u8 => {
15631564
let f = || {
15641565
_init_and_read_len_prefixed_tlv_fields!(reader, {

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::blinded_path::payment::{PaymentConstraints, ReceiveTlvs};
1313
use crate::events::MessageSendEventsProvider;
1414
use crate::ln::channelmanager;
1515
use crate::ln::channelmanager::{PaymentId, RecipientOnionFields};
16-
use crate::ln::features::Bolt12InvoiceFeatures;
1716
use crate::ln::functional_test_utils::*;
1817
use crate::ln::outbound_payment::Retry;
1918
use crate::prelude::*;
@@ -88,11 +87,10 @@ fn mpp_to_one_hop_blinded_path() {
8887
nodes[3].node.get_our_node_id(), payee_tlvs, &chanmon_cfgs[3].keys_manager, &secp_ctx
8988
).unwrap();
9089

91-
let bolt12_features: Bolt12InvoiceFeatures =
92-
channelmanager::provided_invoice_features(&UserConfig::default()).to_context();
90+
let bolt12_features =
91+
channelmanager::provided_bolt12_invoice_features(&UserConfig::default());
9392
let route_params = RouteParameters::from_payment_params_and_value(
94-
PaymentParameters::blinded(vec![blinded_path])
95-
.with_bolt12_features(bolt12_features).unwrap(),
93+
PaymentParameters::blinded(vec![blinded_path]).with_bolt12_features(bolt12_features).unwrap(),
9694
amt_msat,
9795
);
9896
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::spontaneous_empty(), PaymentId(payment_hash.0), route_params, Retry::Attempts(0)).unwrap();

0 commit comments

Comments
 (0)