Skip to content

Commit 2d6f607

Browse files
committed
BOLT12 invoice_feature methods for ChannelManager
1 parent fe3b967 commit 2d6f607

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn mpp_to_one_hop_blinded_path() {
8989
).unwrap();
9090

9191
let bolt12_features: Bolt12InvoiceFeatures =
92-
channelmanager::provided_bolt11_invoice_features(&UserConfig::default()).to_context();
92+
channelmanager::provided_bolt12_invoice_features(&UserConfig::default());
9393
let route_params = RouteParameters {
9494
payment_params: PaymentParameters::blinded(vec![blinded_path])
9595
.with_bolt12_features(bolt12_features).unwrap(),

lightning/src/ln/channelmanager.rs

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

7682+
/// Fetches the set of [`Bolt12InvoiceFeatures`] flags that are provided by or required by
7683+
/// [`ChannelManager`].
7684+
fn bolt12_invoice_features(&self) -> Bolt12InvoiceFeatures {
7685+
provided_bolt12_invoice_features(&self.default_configuration)
7686+
}
7687+
76827688
/// Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
76837689
/// [`ChannelManager`].
76847690
pub fn channel_features(&self) -> ChannelFeatures {
@@ -8241,6 +8247,12 @@ pub(crate) fn provided_bolt11_invoice_features(config: &UserConfig) -> Bolt11Inv
82418247
provided_init_features(config).to_context()
82428248
}
82438249

8250+
/// Fetches the set of [`Bolt12InvoiceFeatures`] flags that are provided by or required by
8251+
/// [`ChannelManager`].
8252+
pub(crate) fn provided_bolt12_invoice_features(config: &UserConfig) -> Bolt12InvoiceFeatures {
8253+
provided_init_features(config).to_context()
8254+
}
8255+
82448256
/// Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
82458257
/// [`ChannelManager`].
82468258
pub(crate) fn provided_channel_features(config: &UserConfig) -> ChannelFeatures {

lightning/src/routing/router.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,7 +2690,7 @@ mod tests {
26902690
use crate::chain::transaction::OutPoint;
26912691
use crate::sign::EntropySource;
26922692
use crate::ln::ChannelId;
2693-
use crate::ln::features::{BlindedHopFeatures, Bolt12InvoiceFeatures, ChannelFeatures, InitFeatures, NodeFeatures};
2693+
use crate::ln::features::{BlindedHopFeatures, ChannelFeatures, InitFeatures, NodeFeatures};
26942694
use crate::ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT};
26952695
use crate::ln::channelmanager;
26962696
use crate::offers::invoice::BlindedPayInfo;
@@ -4483,7 +4483,7 @@ mod tests {
44834483
do_simple_mpp_route_test(clear_payment_params);
44844484

44854485
// MPP to a 1-hop blinded path for nodes[2]
4486-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
4486+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
44874487
let blinded_path = BlindedPath {
44884488
introduction_node_id: nodes[2],
44894489
blinding_point: ln_test_utils::pubkey(42),
@@ -6588,7 +6588,7 @@ mod tests {
65886588
cltv_expiry_delta: 10,
65896589
features: BlindedHopFeatures::empty(),
65906590
};
6591-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
6591+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
65926592
let payment_params = PaymentParameters::blinded(vec![
65936593
(blinded_payinfo.clone(), blinded_path.clone()),
65946594
(blinded_payinfo.clone(), blinded_path.clone())])
@@ -6891,7 +6891,7 @@ mod tests {
68916891
let random_seed_bytes = keys_manager.get_secure_random_bytes();
68926892
let config = UserConfig::default();
68936893

6894-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
6894+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
68956895
let blinded_path_1 = BlindedPath {
68966896
introduction_node_id: nodes[2],
68976897
blinding_point: ln_test_utils::pubkey(42),
@@ -6919,7 +6919,7 @@ mod tests {
69196919
(blinded_payinfo_2.clone(), blinded_path_2.clone()),
69206920
];
69216921
let payment_params = PaymentParameters::blinded(blinded_hints.clone())
6922-
.with_bolt12_features(bolt12_features.clone()).unwrap();
6922+
.with_bolt12_features(bolt12_features).unwrap();
69236923

69246924
let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100_000);
69256925
let route = get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger),
@@ -7083,9 +7083,9 @@ mod tests {
70837083
blinded_hints[1].0.htlc_maximum_msat = 2_8089_0861_1584_0000;
70847084
blinded_hints[1].0.cltv_expiry_delta = 0;
70857085

7086-
let bolt12_features: Bolt12InvoiceFeatures = channelmanager::provided_bolt11_invoice_features(&config).to_context();
7086+
let bolt12_features = channelmanager::provided_bolt12_invoice_features(&config);
70877087
let payment_params = PaymentParameters::blinded(blinded_hints.clone())
7088-
.with_bolt12_features(bolt12_features.clone()).unwrap();
7088+
.with_bolt12_features(bolt12_features).unwrap();
70897089

70907090
let netgraph = network_graph.read_only();
70917091
let route_params = RouteParameters::from_payment_params_and_value(

0 commit comments

Comments
 (0)