mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 15:20:24 +01:00
Parameterize BlindedPath::new_for_payment by min final CLTV delta.
Currently we are not including this value in the aggregated CLTV delta, which is wrong.
This commit is contained in:
parent
a9d73c2889
commit
fa44185ba8
3 changed files with 17 additions and 12 deletions
|
@ -85,14 +85,15 @@ impl BlindedPath {
|
|||
|
||||
/// Create a one-hop blinded path for a payment.
|
||||
pub fn one_hop_for_payment<ES: EntropySource + ?Sized, T: secp256k1::Signing + secp256k1::Verification>(
|
||||
payee_node_id: PublicKey, payee_tlvs: payment::ReceiveTlvs, entropy_source: &ES,
|
||||
secp_ctx: &Secp256k1<T>
|
||||
payee_node_id: PublicKey, payee_tlvs: payment::ReceiveTlvs, min_final_cltv_expiry_delta: u16,
|
||||
entropy_source: &ES, secp_ctx: &Secp256k1<T>
|
||||
) -> Result<(BlindedPayInfo, Self), ()> {
|
||||
// This value is not considered in pathfinding for 1-hop blinded paths, because it's intended to
|
||||
// be in relation to a specific channel.
|
||||
let htlc_maximum_msat = u64::max_value();
|
||||
Self::new_for_payment(
|
||||
&[], payee_node_id, payee_tlvs, htlc_maximum_msat, entropy_source, secp_ctx
|
||||
&[], payee_node_id, payee_tlvs, htlc_maximum_msat, min_final_cltv_expiry_delta,
|
||||
entropy_source, secp_ctx
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -107,8 +108,8 @@ impl BlindedPath {
|
|||
// TODO: make all payloads the same size with padding + add dummy hops
|
||||
pub fn new_for_payment<ES: EntropySource + ?Sized, T: secp256k1::Signing + secp256k1::Verification>(
|
||||
intermediate_nodes: &[payment::ForwardNode], payee_node_id: PublicKey,
|
||||
payee_tlvs: payment::ReceiveTlvs, htlc_maximum_msat: u64, entropy_source: &ES,
|
||||
secp_ctx: &Secp256k1<T>
|
||||
payee_tlvs: payment::ReceiveTlvs, htlc_maximum_msat: u64, min_final_cltv_expiry_delta: u16,
|
||||
entropy_source: &ES, secp_ctx: &Secp256k1<T>
|
||||
) -> Result<(BlindedPayInfo, Self), ()> {
|
||||
let blinding_secret_bytes = entropy_source.get_secure_random_bytes();
|
||||
let blinding_secret = SecretKey::from_slice(&blinding_secret_bytes[..]).expect("RNG is busted");
|
||||
|
|
|
@ -61,7 +61,7 @@ fn blinded_payment_path(
|
|||
let mut secp_ctx = Secp256k1::new();
|
||||
BlindedPath::new_for_payment(
|
||||
&intermediate_nodes[..], *node_ids.last().unwrap(), payee_tlvs,
|
||||
channel_upds.last().unwrap().htlc_maximum_msat, keys_manager, &secp_ctx
|
||||
channel_upds.last().unwrap().htlc_maximum_msat, TEST_FINAL_CLTV as u16, keys_manager, &secp_ctx
|
||||
).unwrap()
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,8 @@ fn do_one_hop_blinded_path(success: bool) {
|
|||
};
|
||||
let mut secp_ctx = Secp256k1::new();
|
||||
let blinded_path = BlindedPath::one_hop_for_payment(
|
||||
nodes[1].node.get_our_node_id(), payee_tlvs, &chanmon_cfgs[1].keys_manager, &secp_ctx
|
||||
nodes[1].node.get_our_node_id(), payee_tlvs, TEST_FINAL_CLTV as u16,
|
||||
&chanmon_cfgs[1].keys_manager, &secp_ctx
|
||||
).unwrap();
|
||||
|
||||
let route_params = RouteParameters::from_payment_params_and_value(
|
||||
|
@ -141,7 +142,8 @@ fn mpp_to_one_hop_blinded_path() {
|
|||
},
|
||||
};
|
||||
let blinded_path = BlindedPath::one_hop_for_payment(
|
||||
nodes[3].node.get_our_node_id(), payee_tlvs, &chanmon_cfgs[3].keys_manager, &secp_ctx
|
||||
nodes[3].node.get_our_node_id(), payee_tlvs, TEST_FINAL_CLTV as u16,
|
||||
&chanmon_cfgs[3].keys_manager, &secp_ctx
|
||||
).unwrap();
|
||||
|
||||
let bolt12_features =
|
||||
|
|
|
@ -14,7 +14,7 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1, self};
|
|||
use crate::blinded_path::{BlindedHop, BlindedPath};
|
||||
use crate::blinded_path::payment::{ForwardNode, ForwardTlvs, PaymentConstraints, PaymentRelay, ReceiveTlvs};
|
||||
use crate::ln::PaymentHash;
|
||||
use crate::ln::channelmanager::{ChannelDetails, PaymentId};
|
||||
use crate::ln::channelmanager::{ChannelDetails, PaymentId, MIN_FINAL_CLTV_EXPIRY_DELTA};
|
||||
use crate::ln::features::{BlindedHopFeatures, Bolt11InvoiceFeatures, Bolt12InvoiceFeatures, ChannelFeatures, NodeFeatures};
|
||||
use crate::ln::msgs::{DecodeError, ErrorAction, LightningError, MAX_VALUE_MSAT};
|
||||
use crate::offers::invoice::{BlindedPayInfo, Bolt12Invoice};
|
||||
|
@ -134,7 +134,8 @@ impl<G: Deref<Target = NetworkGraph<L>> + Clone, L: Deref, ES: Deref, S: Deref,
|
|||
})
|
||||
.map(|forward_node| {
|
||||
BlindedPath::new_for_payment(
|
||||
&[forward_node], recipient, tlvs.clone(), u64::MAX, &*self.entropy_source, secp_ctx
|
||||
&[forward_node], recipient, tlvs.clone(), u64::MAX, MIN_FINAL_CLTV_EXPIRY_DELTA,
|
||||
&*self.entropy_source, secp_ctx
|
||||
)
|
||||
})
|
||||
.take(MAX_PAYMENT_PATHS)
|
||||
|
@ -144,8 +145,9 @@ impl<G: Deref<Target = NetworkGraph<L>> + Clone, L: Deref, ES: Deref, S: Deref,
|
|||
Ok(paths) if !paths.is_empty() => Ok(paths),
|
||||
_ => {
|
||||
if network_graph.nodes().contains_key(&NodeId::from_pubkey(&recipient)) {
|
||||
BlindedPath::one_hop_for_payment(recipient, tlvs, &*self.entropy_source, secp_ctx)
|
||||
.map(|path| vec![path])
|
||||
BlindedPath::one_hop_for_payment(
|
||||
recipient, tlvs, MIN_FINAL_CLTV_EXPIRY_DELTA, &*self.entropy_source, secp_ctx
|
||||
).map(|path| vec![path])
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue