Skip to content

Commit f9bc326

Browse files
Move BlindedPayInfo into blinded_path::payment module.
1 parent ef40c7e commit f9bc326

File tree

5 files changed

+45
-49
lines changed

5 files changed

+45
-49
lines changed

lightning/src/blinded_path/payment.rs

+38-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use crate::ln::channel_state::CounterpartyForwardingInfo;
2121
use crate::ln::features::BlindedHopFeatures;
2222
use crate::ln::msgs::DecodeError;
2323
use crate::ln::onion_utils;
24-
use crate::offers::invoice::BlindedPayInfo;
2524
use crate::offers::invoice_request::InvoiceRequestFields;
2625
use crate::offers::offer::OfferId;
2726
use crate::routing::gossip::{NodeId, ReadOnlyNetworkGraph};
@@ -34,6 +33,44 @@ use core::ops::Deref;
3433
#[allow(unused_imports)]
3534
use crate::prelude::*;
3635

36+
/// Information needed to route a payment across a [`BlindedPaymentPath`].
37+
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
38+
pub struct BlindedPayInfo {
39+
/// Base fee charged (in millisatoshi) for the entire blinded path.
40+
pub fee_base_msat: u32,
41+
42+
/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
43+
/// (i.e., 10,000 is 1%).
44+
pub fee_proportional_millionths: u32,
45+
46+
/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
47+
/// path.
48+
pub cltv_expiry_delta: u16,
49+
50+
/// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
51+
/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
52+
/// seen by the recipient.
53+
pub htlc_minimum_msat: u64,
54+
55+
/// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
56+
/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
57+
/// seen by the recipient.
58+
pub htlc_maximum_msat: u64,
59+
60+
/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
61+
/// onion payload.
62+
pub features: BlindedHopFeatures,
63+
}
64+
65+
impl_writeable!(BlindedPayInfo, {
66+
fee_base_msat,
67+
fee_proportional_millionths,
68+
cltv_expiry_delta,
69+
htlc_minimum_msat,
70+
htlc_maximum_msat,
71+
features
72+
});
73+
3774
/// A blinded path to be used for sending or receiving a payment, hiding the identity of the
3875
/// recipient.
3976
#[derive(Clone, Debug, Hash, PartialEq, Eq)]

lightning/src/ln/max_payment_path_len_tests.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use bitcoin::secp256k1::{Secp256k1, PublicKey};
1414
use crate::blinded_path::BlindedHop;
15-
use crate::blinded_path::payment::{BlindedPaymentPath, PaymentConstraints, PaymentContext, ReceiveTlvs};
15+
use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath, PaymentConstraints, PaymentContext, ReceiveTlvs};
1616
use crate::events::{Event, MessageSendEventsProvider};
1717
use crate::ln::PaymentSecret;
1818
use crate::ln::blinded_payment_tests::get_blinded_route_parameters;
@@ -24,7 +24,6 @@ use crate::ln::msgs::OnionMessageHandler;
2424
use crate::ln::onion_utils;
2525
use crate::ln::onion_utils::MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY;
2626
use crate::ln::outbound_payment::{RecipientOnionFields, Retry, RetryableSendFailure};
27-
use crate::offers::invoice::BlindedPayInfo;
2827
use crate::prelude::*;
2928
use crate::routing::router::{DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, PaymentParameters, RouteParameters};
3029
use crate::util::errors::APIError;

lightning/src/offers/invoice.rs

+2-40
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ use core::hash::{Hash, Hasher};
112112
use crate::io;
113113
use crate::blinded_path::BlindedPath;
114114
use crate::blinded_path::message::BlindedMessagePath;
115-
use crate::blinded_path::payment::BlindedPaymentPath;
115+
use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath};
116116
use crate::ln::types::PaymentHash;
117117
use crate::ln::channelmanager::PaymentId;
118-
use crate::ln::features::{BlindedHopFeatures, Bolt12InvoiceFeatures, InvoiceRequestFeatures, OfferFeatures};
118+
use crate::ln::features::{Bolt12InvoiceFeatures, InvoiceRequestFeatures, OfferFeatures};
119119
use crate::ln::inbound_payment::{ExpandedKey, IV_LEN};
120120
use crate::ln::msgs::DecodeError;
121121
use crate::offers::invoice_macros::{invoice_accessors_common, invoice_builder_methods_common};
@@ -1216,44 +1216,6 @@ pub(super) type BlindedPayInfoIter<'a> = core::iter::Map<
12161216
for<'r> fn(&'r BlindedPaymentPath) -> &'r BlindedPayInfo,
12171217
>;
12181218

1219-
/// Information needed to route a payment across a [`BlindedPaymentPath`].
1220-
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
1221-
pub struct BlindedPayInfo {
1222-
/// Base fee charged (in millisatoshi) for the entire blinded path.
1223-
pub fee_base_msat: u32,
1224-
1225-
/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
1226-
/// (i.e., 10,000 is 1%).
1227-
pub fee_proportional_millionths: u32,
1228-
1229-
/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
1230-
/// path.
1231-
pub cltv_expiry_delta: u16,
1232-
1233-
/// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1234-
/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1235-
/// seen by the recipient.
1236-
pub htlc_minimum_msat: u64,
1237-
1238-
/// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1239-
/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1240-
/// seen by the recipient.
1241-
pub htlc_maximum_msat: u64,
1242-
1243-
/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
1244-
/// onion payload.
1245-
pub features: BlindedHopFeatures,
1246-
}
1247-
1248-
impl_writeable!(BlindedPayInfo, {
1249-
fee_base_msat,
1250-
fee_proportional_millionths,
1251-
cltv_expiry_delta,
1252-
htlc_minimum_msat,
1253-
htlc_maximum_msat,
1254-
features
1255-
});
1256-
12571219
/// Wire representation for an on-chain fallback address.
12581220
#[derive(Clone, Debug, PartialEq)]
12591221
pub(super) struct FallbackAddress {

lightning/src/offers/test_utils.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ use bitcoin::secp256k1::schnorr::Signature;
1414

1515
use core::time::Duration;
1616
use crate::blinded_path::BlindedHop;
17-
use crate::blinded_path::payment::BlindedPaymentPath;
17+
use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath};
1818
use crate::sign::EntropySource;
1919
use crate::ln::types::PaymentHash;
2020
use crate::ln::features::BlindedHopFeatures;
21-
use crate::offers::invoice::BlindedPayInfo;
2221
use crate::offers::merkle::TaggedHash;
2322

2423
#[allow(unused_imports)]

lightning/src/routing/router.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ pub struct OneHopBlindedPathCandidate<'a> {
12811281
///
12821282
/// This is not exported to bindings users as lifetimes are not expressible in most languages.
12831283
///
1284-
/// [`BlindedPayInfo`]: crate::offers::invoice::BlindedPayInfo
1284+
/// [`BlindedPayInfo`]: crate::blinded_path::payment::BlindedPayInfo
12851285
pub hint: &'a BlindedPaymentPath,
12861286
/// Index of the hint in the original list of blinded hints.
12871287
///
@@ -1333,7 +1333,7 @@ pub enum CandidateRouteHop<'a> {
13331333
/// This primarily exists to track that we need to included a blinded path at the end of our
13341334
/// [`Route`], even though it doesn't actually add an additional hop in the payment.
13351335
///
1336-
/// [`BlindedPayInfo`]: crate::offers::invoice::BlindedPayInfo
1336+
/// [`BlindedPayInfo`]: crate::blinded_path::payment::BlindedPayInfo
13371337
OneHopBlinded(OneHopBlindedPathCandidate<'a>),
13381338
}
13391339

@@ -3552,7 +3552,7 @@ fn build_route_from_hops_internal<L: Deref>(
35523552
#[cfg(test)]
35533553
mod tests {
35543554
use crate::blinded_path::BlindedHop;
3555-
use crate::blinded_path::payment::BlindedPaymentPath;
3555+
use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath};
35563556
use crate::routing::gossip::{NetworkGraph, P2PGossipSync, NodeId, EffectiveCapacity};
35573557
use crate::routing::utxo::UtxoResult;
35583558
use crate::routing::router::{get_route, build_route_from_hops_internal, add_random_cltv_offset, default_node_features,
@@ -3566,7 +3566,6 @@ mod tests {
35663566
use crate::ln::features::{BlindedHopFeatures, ChannelFeatures, InitFeatures, NodeFeatures};
35673567
use crate::ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT};
35683568
use crate::ln::channelmanager;
3569-
use crate::offers::invoice::BlindedPayInfo;
35703569
use crate::util::config::UserConfig;
35713570
use crate::util::test_utils as ln_test_utils;
35723571
use crate::crypto::chacha20::ChaCha20;

0 commit comments

Comments
 (0)