Skip to content

Commit 6f6e086

Browse files
committed
BOLT12 invoice_feature methods for ChannelManager
1 parent 1d85efe commit 6f6e086

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 2 additions & 3 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,8 +87,8 @@ 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_bolt11_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(
9493
PaymentParameters::blinded(vec![blinded_path]).with_bolt12_features(bolt12_features).unwrap(),
9594
amt_msat,

lightning/src/ln/channelmanager.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use crate::events::{Event, EventHandler, EventsProvider, MessageSendEvent, Messa
4343
// construct one themselves.
4444
use crate::ln::{inbound_payment, ChannelId, PaymentHash, PaymentPreimage, PaymentSecret};
4545
use crate::ln::channel::{Channel, ChannelPhase, ChannelContext, ChannelError, ChannelUpdateStatus, ShutdownResult, UnfundedChannelContext, UpdateFulfillCommitFetch, OutboundV1Channel, InboundV1Channel};
46-
use crate::ln::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
46+
use crate::ln::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
4747
#[cfg(any(feature = "_test_utils", test))]
4848
use crate::ln::features::Bolt11InvoiceFeatures;
4949
use crate::routing::gossip::NetworkGraph;
@@ -8260,6 +8260,12 @@ where
82608260
provided_bolt11_invoice_features(&self.default_configuration)
82618261
}
82628262

8263+
/// Fetches the set of [`Bolt12InvoiceFeatures`] flags that are provided by or required by
8264+
/// [`ChannelManager`].
8265+
fn bolt12_invoice_features(&self) -> Bolt12InvoiceFeatures {
8266+
provided_bolt12_invoice_features(&self.default_configuration)
8267+
}
8268+
82638269
/// Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
82648270
/// [`ChannelManager`].
82658271
pub fn channel_features(&self) -> ChannelFeatures {
@@ -8821,6 +8827,12 @@ pub(crate) fn provided_bolt11_invoice_features(config: &UserConfig) -> Bolt11Inv
88218827
provided_init_features(config).to_context()
88228828
}
88238829

8830+
/// Fetches the set of [`Bolt12InvoiceFeatures`] flags that are provided by or required by
8831+
/// [`ChannelManager`].
8832+
pub(crate) fn provided_bolt12_invoice_features(config: &UserConfig) -> Bolt12InvoiceFeatures {
8833+
provided_init_features(config).to_context()
8834+
}
8835+
88248836
/// Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
88258837
/// [`ChannelManager`].
88268838
pub(crate) fn provided_channel_features(config: &UserConfig) -> ChannelFeatures {

lightning/src/routing/router.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,7 +2818,7 @@ mod tests {
28182818
use crate::chain::transaction::OutPoint;
28192819
use crate::sign::EntropySource;
28202820
use crate::ln::ChannelId;
2821-
use crate::ln::features::{BlindedHopFeatures, Bolt12InvoiceFeatures, ChannelFeatures, InitFeatures, NodeFeatures};
2821+
use crate::ln::features::{BlindedHopFeatures, ChannelFeatures, InitFeatures, NodeFeatures};
28222822
use crate::ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT};
28232823
use crate::ln::channelmanager;
28242824
use crate::offers::invoice::BlindedPayInfo;
@@ -4674,7 +4674,7 @@ mod tests {
46744674
do_simple_mpp_route_test(clear_payment_params);
46754675

46764676
// MPP to a 1-hop blinded path for nodes[2]
4677-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
4677+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
46784678
let blinded_path = BlindedPath {
46794679
introduction_node_id: nodes[2],
46804680
blinding_point: ln_test_utils::pubkey(42),
@@ -6795,7 +6795,7 @@ mod tests {
67956795
cltv_expiry_delta: 10,
67966796
features: BlindedHopFeatures::empty(),
67976797
};
6798-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
6798+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
67996799
let payment_params = PaymentParameters::blinded(vec![
68006800
(blinded_payinfo.clone(), blinded_path.clone()),
68016801
(blinded_payinfo.clone(), blinded_path.clone())])
@@ -7104,7 +7104,7 @@ mod tests {
71047104
let random_seed_bytes = keys_manager.get_secure_random_bytes();
71057105
let config = UserConfig::default();
71067106

7107-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
7107+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
71087108
let blinded_path_1 = BlindedPath {
71097109
introduction_node_id: nodes[2],
71107110
blinding_point: ln_test_utils::pubkey(42),
@@ -7132,7 +7132,7 @@ mod tests {
71327132
(blinded_payinfo_2.clone(), blinded_path_2.clone()),
71337133
];
71347134
let payment_params = PaymentParameters::blinded(blinded_hints.clone())
7135-
.with_bolt12_features(bolt12_features.clone()).unwrap();
7135+
.with_bolt12_features(bolt12_features).unwrap();
71367136

71377137
let mut route_params = RouteParameters::from_payment_params_and_value(payment_params, 100_000);
71387138
route_params.max_total_routing_fee_msat = Some(100_000);
@@ -7297,9 +7297,9 @@ mod tests {
72977297
blinded_hints[1].0.htlc_maximum_msat = 2_8089_0861_1584_0000;
72987298
blinded_hints[1].0.cltv_expiry_delta = 0;
72997299

7300-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
7300+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
73017301
let payment_params = PaymentParameters::blinded(blinded_hints.clone())
7302-
.with_bolt12_features(bolt12_features.clone()).unwrap();
7302+
.with_bolt12_features(bolt12_features).unwrap();
73037303

73047304
let netgraph = network_graph.read_only();
73057305
let route_params = RouteParameters::from_payment_params_and_value(
@@ -7349,7 +7349,7 @@ mod tests {
73497349
];
73507350
blinded_hints[1].1.introduction_node_id = nodes[6];
73517351

7352-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
7352+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
73537353
let payment_params = PaymentParameters::blinded(blinded_hints.clone())
73547354
.with_bolt12_features(bolt12_features.clone()).unwrap();
73557355

@@ -7406,7 +7406,7 @@ mod tests {
74067406

74077407
blinded_hints[2].1.introduction_node_id = nodes[6];
74087408

7409-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
7409+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
74107410
let payment_params = PaymentParameters::blinded(blinded_hints.clone())
74117411
.with_bolt12_features(bolt12_features.clone()).unwrap();
74127412

@@ -7466,7 +7466,7 @@ mod tests {
74667466
cltv_expiry_delta: 0,
74677467
features: BlindedHopFeatures::empty(),
74687468
};
7469-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
7469+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
74707470
PaymentParameters::blinded(vec![(blinded_payinfo, blinded_path)])
74717471
.with_bolt12_features(bolt12_features.clone()).unwrap()
74727472
} else {
@@ -7549,7 +7549,7 @@ mod tests {
75497549
features: BlindedHopFeatures::empty(),
75507550
}, blinded_path.clone()));
75517551
}
7552-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
7552+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
75537553
PaymentParameters::blinded(blinded_hints.clone())
75547554
.with_bolt12_features(bolt12_features.clone()).unwrap()
75557555
} else {
@@ -7640,7 +7640,7 @@ mod tests {
76407640
],
76417641
})
76427642
];
7643-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
7643+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
76447644
let payment_params = PaymentParameters::blinded(blinded_hints.clone())
76457645
.with_bolt12_features(bolt12_features.clone()).unwrap();
76467646
let route_params = RouteParameters::from_payment_params_and_value(
@@ -7700,7 +7700,7 @@ mod tests {
77007700
features: BlindedHopFeatures::empty(),
77017701
}, blinded_path.clone()));
77027702
}
7703-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
7703+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
77047704
PaymentParameters::blinded(blinded_hints.clone())
77057705
.with_bolt12_features(bolt12_features.clone()).unwrap()
77067706
};

0 commit comments

Comments
 (0)