X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fblinded_path%2Fpayment.rs;h=f4df1e379d931b3ac65cbcdae65441c629554c6c;hb=6e6bd44138e0674cda1c0034b0e1d4b48e54204d;hp=32181f7889c350fa3f23f2bdfe37a437d99808d4;hpb=f3616e606ffd76b1769638c910e8db2234bbf5ff;p=rust-lightning diff --git a/lightning/src/blinded_path/payment.rs b/lightning/src/blinded_path/payment.rs index 32181f78..f4df1e37 100644 --- a/lightning/src/blinded_path/payment.rs +++ b/lightning/src/blinded_path/payment.rs @@ -8,6 +8,7 @@ use crate::blinded_path::BlindedHop; use crate::blinded_path::utils; use crate::io; use crate::ln::PaymentSecret; +use crate::ln::channelmanager::CounterpartyForwardingInfo; use crate::ln::features::BlindedHopFeatures; use crate::ln::msgs::DecodeError; use crate::offers::invoice::BlindedPayInfo; @@ -89,14 +90,22 @@ pub struct PaymentRelay { /// [`BlindedHop`]: crate::blinded_path::BlindedHop #[derive(Clone, Debug)] pub struct PaymentConstraints { - /// The maximum total CLTV delta that is acceptable when relaying a payment over this - /// [`BlindedHop`]. + /// The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. pub max_cltv_expiry: u32, /// The minimum value, in msat, that may be accepted by the node corresponding to this /// [`BlindedHop`]. pub htlc_minimum_msat: u64, } +impl From for PaymentRelay { + fn from(info: CounterpartyForwardingInfo) -> Self { + let CounterpartyForwardingInfo { + fee_base_msat, fee_proportional_millionths, cltv_expiry_delta + } = info; + Self { cltv_expiry_delta, fee_proportional_millionths, fee_base_msat } + } +} + impl Writeable for ForwardTlvs { fn write(&self, w: &mut W) -> Result<(), io::Error> { encode_tlv_stream!(w, { @@ -173,7 +182,7 @@ pub(super) fn blinded_hops( } /// `None` if underflow occurs. -fn amt_to_forward_msat(inbound_amt_msat: u64, payment_relay: &PaymentRelay) -> Option { +pub(crate) fn amt_to_forward_msat(inbound_amt_msat: u64, payment_relay: &PaymentRelay) -> Option { let inbound_amt = inbound_amt_msat as u128; let base = payment_relay.fee_base_msat as u128; let prop = payment_relay.fee_proportional_millionths as u128;