mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-15 15:39:09 +01:00
Only allow creating 1-hop blinded paths.
Useful until forwarding and receiving to multi-hop blinded paths is supported.
This commit is contained in:
parent
3e377a1d2f
commit
ebdc4ae80a
2 changed files with 18 additions and 7 deletions
|
@ -76,6 +76,19 @@ impl BlindedPath {
|
|||
})
|
||||
}
|
||||
|
||||
/// Create a one-hop blinded path for a payment.
|
||||
pub fn one_hop_for_payment<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>(
|
||||
payee_node_id: PublicKey, payee_tlvs: payment::ReceiveTlvs, 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
|
||||
)
|
||||
}
|
||||
|
||||
/// Create a blinded path for a payment, to be forwarded along `intermediate_nodes`.
|
||||
///
|
||||
/// Errors if:
|
||||
|
@ -85,7 +98,7 @@ impl BlindedPath {
|
|||
///
|
||||
/// [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
|
||||
// TODO: make all payloads the same size with padding + add dummy hops
|
||||
pub fn new_for_payment<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>(
|
||||
pub(crate) fn new_for_payment<ES: EntropySource, 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>
|
||||
|
|
|
@ -43,9 +43,8 @@ fn do_one_hop_blinded_path(success: bool) {
|
|||
},
|
||||
};
|
||||
let mut secp_ctx = Secp256k1::new();
|
||||
let blinded_path = BlindedPath::new_for_payment(
|
||||
&[], nodes[1].node.get_our_node_id(), payee_tlvs, chan_upd.htlc_maximum_msat,
|
||||
&chanmon_cfgs[1].keys_manager, &secp_ctx
|
||||
let blinded_path = BlindedPath::one_hop_for_payment(
|
||||
nodes[1].node.get_our_node_id(), payee_tlvs, &chanmon_cfgs[1].keys_manager, &secp_ctx
|
||||
).unwrap();
|
||||
|
||||
let route_params = RouteParameters {
|
||||
|
@ -85,9 +84,8 @@ fn mpp_to_one_hop_blinded_path() {
|
|||
htlc_minimum_msat: chan_upd_1_3.htlc_minimum_msat,
|
||||
},
|
||||
};
|
||||
let blinded_path = BlindedPath::new_for_payment(
|
||||
&[], nodes[3].node.get_our_node_id(), payee_tlvs, u64::max_value(),
|
||||
&chanmon_cfgs[3].keys_manager, &secp_ctx
|
||||
let blinded_path = BlindedPath::one_hop_for_payment(
|
||||
nodes[3].node.get_our_node_id(), payee_tlvs, &chanmon_cfgs[3].keys_manager, &secp_ctx
|
||||
).unwrap();
|
||||
|
||||
let bolt12_features: Bolt12InvoiceFeatures =
|
||||
|
|
Loading…
Add table
Reference in a new issue