Skip to content

Commit

Permalink
f - make ReceiveTlvs::tlvs read-only
Browse files Browse the repository at this point in the history
  • Loading branch information
jkczyz committed Dec 11, 2024
1 parent 26d27a2 commit 87359a3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fuzz/src/invoice_request_deser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
fee_base_msat: 1,
},
payment_constraints: PaymentConstraints {
max_cltv_expiry: payee_tlvs.tlvs.payment_constraints.max_cltv_expiry + 40,
max_cltv_expiry: payee_tlvs.tlvs().payment_constraints.max_cltv_expiry + 40,
htlc_minimum_msat: 100,
},
features: BlindedHopFeatures::empty(),
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/refund_deser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
fee_base_msat: 1,
},
payment_constraints: PaymentConstraints {
max_cltv_expiry: payee_tlvs.tlvs.payment_constraints.max_cltv_expiry + 40,
max_cltv_expiry: payee_tlvs.tlvs().payment_constraints.max_cltv_expiry + 40,
htlc_minimum_msat: 100,
},
features: BlindedHopFeatures::empty(),
Expand Down
9 changes: 8 additions & 1 deletion lightning/src/blinded_path/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,18 @@ pub struct ForwardTlvs {
#[derive(Clone, Debug)]
pub struct ReceiveTlvs {
/// The TLVs for which the HMAC in `authentication` is derived.
pub tlvs: UnauthenticatedReceiveTlvs,
pub(crate) tlvs: UnauthenticatedReceiveTlvs,
/// An HMAC of `tlvs` along with a nonce used to construct it.
pub(crate) authentication: (Hmac<Sha256>, Nonce),
}

impl ReceiveTlvs {
/// Returns the underlying TLVs.
pub fn tlvs(&self) -> &UnauthenticatedReceiveTlvs {
&self.tlvs
}
}

/// An unauthenticated [`ReceiveTlvs`].
#[derive(Clone, Debug)]
pub struct UnauthenticatedReceiveTlvs {
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref, S: Deref, SP: Size

let cltv_expiry_delta = payment_relay.cltv_expiry_delta as u32;
let payment_constraints = PaymentConstraints {
max_cltv_expiry: tlvs.tlvs.payment_constraints.max_cltv_expiry + cltv_expiry_delta,
max_cltv_expiry: tlvs.tlvs().payment_constraints.max_cltv_expiry + cltv_expiry_delta,
htlc_minimum_msat: details.inbound_htlc_minimum_msat.unwrap_or(0),
};
Some(PaymentForwardNode {
Expand Down

0 comments on commit 87359a3

Please sign in to comment.