]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Move BlindedPayInfo into blinded_path::payment module.
authorValentine Wallace <vwallace@protonmail.com>
Mon, 19 Aug 2024 19:08:20 +0000 (15:08 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Mon, 19 Aug 2024 20:42:22 +0000 (16:42 -0400)
fuzz/src/router.rs
lightning/src/blinded_path/payment.rs
lightning/src/ln/max_payment_path_len_tests.rs
lightning/src/offers/invoice.rs
lightning/src/offers/test_utils.rs
lightning/src/routing/router.rs

index c315f58e250249b5141df211e4532bd3c4e91597..cc28f5ae9f63c15fd5a74e95380fe78a4e33e1b3 100644 (file)
@@ -12,7 +12,7 @@ use bitcoin::constants::ChainHash;
 use bitcoin::script::Builder;
 use bitcoin::transaction::TxOut;
 
-use lightning::blinded_path::payment::BlindedPaymentPath;
+use lightning::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath};
 use lightning::blinded_path::BlindedHop;
 use lightning::chain::transaction::OutPoint;
 use lightning::ln::channel_state::{ChannelCounterparty, ChannelDetails, ChannelShutdownState};
@@ -20,7 +20,6 @@ use lightning::ln::channelmanager;
 use lightning::ln::features::{BlindedHopFeatures, Bolt12InvoiceFeatures};
 use lightning::ln::msgs;
 use lightning::ln::types::ChannelId;
-use lightning::offers::invoice::BlindedPayInfo;
 use lightning::routing::gossip::{NetworkGraph, RoutingFees};
 use lightning::routing::router::{
        find_route, PaymentParameters, RouteHint, RouteHintHop, RouteParameters,
index 4c7066b9ad58c93b5a19f86b9afb32fa5cadc621..e128e6675205c3d908bae8114cb90b9b16048504 100644 (file)
@@ -21,7 +21,6 @@ use crate::ln::channel_state::CounterpartyForwardingInfo;
 use crate::ln::features::BlindedHopFeatures;
 use crate::ln::msgs::DecodeError;
 use crate::ln::onion_utils;
-use crate::offers::invoice::BlindedPayInfo;
 use crate::offers::invoice_request::InvoiceRequestFields;
 use crate::offers::offer::OfferId;
 use crate::routing::gossip::{NodeId, ReadOnlyNetworkGraph};
@@ -34,6 +33,44 @@ use core::ops::Deref;
 #[allow(unused_imports)]
 use crate::prelude::*;
 
+/// Information needed to route a payment across a [`BlindedPaymentPath`].
+#[derive(Clone, Debug, Hash, Eq, PartialEq)]
+pub struct BlindedPayInfo {
+       /// Base fee charged (in millisatoshi) for the entire blinded path.
+       pub fee_base_msat: u32,
+
+       /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
+       /// (i.e., 10,000 is 1%).
+       pub fee_proportional_millionths: u32,
+
+       /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
+       /// path.
+       pub cltv_expiry_delta: u16,
+
+       /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
+       /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
+       /// seen by the recipient.
+       pub htlc_minimum_msat: u64,
+
+       /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
+       /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
+       /// seen by the recipient.
+       pub htlc_maximum_msat: u64,
+
+       /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
+       /// onion payload.
+       pub features: BlindedHopFeatures,
+}
+
+impl_writeable!(BlindedPayInfo, {
+       fee_base_msat,
+       fee_proportional_millionths,
+       cltv_expiry_delta,
+       htlc_minimum_msat,
+       htlc_maximum_msat,
+       features
+});
+
 /// A blinded path to be used for sending or receiving a payment, hiding the identity of the
 /// recipient.
 #[derive(Clone, Debug, Hash, PartialEq, Eq)]
index a22d7d1643c8b275688a8b4f7a726aab6c32073c..69ae3cd7679786d7ec294b04b1c44a31f64139cb 100644 (file)
@@ -12,7 +12,7 @@
 
 use bitcoin::secp256k1::{Secp256k1, PublicKey};
 use crate::blinded_path::BlindedHop;
-use crate::blinded_path::payment::{BlindedPaymentPath, PaymentConstraints, PaymentContext, ReceiveTlvs};
+use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath, PaymentConstraints, PaymentContext, ReceiveTlvs};
 use crate::events::{Event, MessageSendEventsProvider};
 use crate::ln::PaymentSecret;
 use crate::ln::blinded_payment_tests::get_blinded_route_parameters;
@@ -24,7 +24,6 @@ use crate::ln::msgs::OnionMessageHandler;
 use crate::ln::onion_utils;
 use crate::ln::onion_utils::MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY;
 use crate::ln::outbound_payment::{RecipientOnionFields, Retry, RetryableSendFailure};
-use crate::offers::invoice::BlindedPayInfo;
 use crate::prelude::*;
 use crate::routing::router::{DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, PaymentParameters, RouteParameters};
 use crate::util::errors::APIError;
index 693e8e00f54174121a69b768d5cac1063ed9774e..40ee4009040165cd273d6be4db0a783f3b8053da 100644 (file)
@@ -29,8 +29,8 @@
 //! use lightning::util::ser::Writeable;
 //!
 //! # use lightning::ln::types::PaymentHash;
-//! # use lightning::offers::invoice::{BlindedPayInfo, ExplicitSigningPubkey, InvoiceBuilder};
-//! # use lightning::blinded_path::payment::BlindedPaymentPath;
+//! # use lightning::offers::invoice::{ExplicitSigningPubkey, InvoiceBuilder};
+//! # use lightning::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath};
 //! #
 //! # fn create_payment_paths() -> Vec<BlindedPaymentPath> { unimplemented!() }
 //! # fn create_payment_hash() -> PaymentHash { unimplemented!() }
@@ -112,10 +112,10 @@ use core::hash::{Hash, Hasher};
 use crate::io;
 use crate::blinded_path::BlindedPath;
 use crate::blinded_path::message::BlindedMessagePath;
-use crate::blinded_path::payment::BlindedPaymentPath;
+use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath};
 use crate::ln::types::PaymentHash;
 use crate::ln::channelmanager::PaymentId;
-use crate::ln::features::{BlindedHopFeatures, Bolt12InvoiceFeatures, InvoiceRequestFeatures, OfferFeatures};
+use crate::ln::features::{Bolt12InvoiceFeatures, InvoiceRequestFeatures, OfferFeatures};
 use crate::ln::inbound_payment::{ExpandedKey, IV_LEN};
 use crate::ln::msgs::DecodeError;
 use crate::offers::invoice_macros::{invoice_accessors_common, invoice_builder_methods_common};
@@ -1216,44 +1216,6 @@ pub(super) type BlindedPayInfoIter<'a> = core::iter::Map<
        for<'r> fn(&'r BlindedPaymentPath) -> &'r BlindedPayInfo,
 >;
 
-/// Information needed to route a payment across a [`BlindedPaymentPath`].
-#[derive(Clone, Debug, Hash, Eq, PartialEq)]
-pub struct BlindedPayInfo {
-       /// Base fee charged (in millisatoshi) for the entire blinded path.
-       pub fee_base_msat: u32,
-
-       /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
-       /// (i.e., 10,000 is 1%).
-       pub fee_proportional_millionths: u32,
-
-       /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
-       /// path.
-       pub cltv_expiry_delta: u16,
-
-       /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
-       /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
-       /// seen by the recipient.
-       pub htlc_minimum_msat: u64,
-
-       /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
-       /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
-       /// seen by the recipient.
-       pub htlc_maximum_msat: u64,
-
-       /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
-       /// onion payload.
-       pub features: BlindedHopFeatures,
-}
-
-impl_writeable!(BlindedPayInfo, {
-       fee_base_msat,
-       fee_proportional_millionths,
-       cltv_expiry_delta,
-       htlc_minimum_msat,
-       htlc_maximum_msat,
-       features
-});
-
 /// Wire representation for an on-chain fallback address.
 #[derive(Clone, Debug, PartialEq)]
 pub(super) struct FallbackAddress {
index d815338d7579f0280897e8fdde3aa78822f8e5c4..735354cb896bf6532704d7ed8069357c7d276ca2 100644 (file)
@@ -14,11 +14,10 @@ use bitcoin::secp256k1::schnorr::Signature;
 
 use core::time::Duration;
 use crate::blinded_path::BlindedHop;
-use crate::blinded_path::payment::BlindedPaymentPath;
+use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath};
 use crate::sign::EntropySource;
 use crate::ln::types::PaymentHash;
 use crate::ln::features::BlindedHopFeatures;
-use crate::offers::invoice::BlindedPayInfo;
 use crate::offers::merkle::TaggedHash;
 
 #[allow(unused_imports)]
index 495ff30a92006e14bd7258fc76401db3b1fdc77a..c40e6ab3132c8f1919b1fcf4a4ffe97d2cc73041 100644 (file)
@@ -1282,7 +1282,7 @@ pub struct OneHopBlindedPathCandidate<'a> {
        ///
        /// This is not exported to bindings users as lifetimes are not expressible in most languages.
        ///
-       /// [`BlindedPayInfo`]: crate::offers::invoice::BlindedPayInfo
+       /// [`BlindedPayInfo`]: crate::blinded_path::payment::BlindedPayInfo
        pub hint: &'a BlindedPaymentPath,
        /// Index of the hint in the original list of blinded hints.
        ///
@@ -1334,7 +1334,7 @@ pub enum CandidateRouteHop<'a> {
        /// This primarily exists to track that we need to included a blinded path at the end of our
        /// [`Route`], even though it doesn't actually add an additional hop in the payment.
        ///
-       /// [`BlindedPayInfo`]: crate::offers::invoice::BlindedPayInfo
+       /// [`BlindedPayInfo`]: crate::blinded_path::payment::BlindedPayInfo
        OneHopBlinded(OneHopBlindedPathCandidate<'a>),
 }
 
@@ -3553,7 +3553,7 @@ fn build_route_from_hops_internal<L: Deref>(
 #[cfg(test)]
 mod tests {
        use crate::blinded_path::BlindedHop;
-       use crate::blinded_path::payment::BlindedPaymentPath;
+       use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath};
        use crate::routing::gossip::{NetworkGraph, P2PGossipSync, NodeId, EffectiveCapacity};
        use crate::routing::utxo::UtxoResult;
        use crate::routing::router::{get_route, build_route_from_hops_internal, add_random_cltv_offset, default_node_features,
@@ -3567,7 +3567,6 @@ mod tests {
        use crate::ln::features::{BlindedHopFeatures, ChannelFeatures, InitFeatures, NodeFeatures};
        use crate::ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT};
        use crate::ln::channelmanager;
-       use crate::offers::invoice::BlindedPayInfo;
        use crate::util::config::UserConfig;
        use crate::util::test_utils as ln_test_utils;
        use crate::crypto::chacha20::ChaCha20;