@@ -15,6 +15,8 @@ pub(crate) mod utils;
15
15
16
16
use bitcoin:: secp256k1:: { self , PublicKey , Secp256k1 , SecretKey } ;
17
17
18
+ use core:: ops:: Deref ;
19
+
18
20
use crate :: ln:: msgs:: DecodeError ;
19
21
use crate :: offers:: invoice:: BlindedPayInfo ;
20
22
use crate :: routing:: gossip:: { NodeId , ReadOnlyNetworkGraph } ;
@@ -115,9 +117,9 @@ pub struct BlindedHop {
115
117
116
118
impl BlindedPath {
117
119
/// Create a one-hop blinded path for a message.
118
- pub fn one_hop_for_message < ES : EntropySource + ? Sized , T : secp256k1:: Signing + secp256k1:: Verification > (
119
- recipient_node_id : PublicKey , entropy_source : & ES , secp_ctx : & Secp256k1 < T >
120
- ) -> Result < Self , ( ) > {
120
+ pub fn one_hop_for_message < ES : Deref , T : secp256k1:: Signing + secp256k1:: Verification > (
121
+ recipient_node_id : PublicKey , entropy_source : ES , secp_ctx : & Secp256k1 < T >
122
+ ) -> Result < Self , ( ) > where ES :: Target : EntropySource {
121
123
Self :: new_for_message ( & [ recipient_node_id] , entropy_source, secp_ctx)
122
124
}
123
125
@@ -126,9 +128,9 @@ impl BlindedPath {
126
128
///
127
129
/// Errors if no hops are provided or if `node_pk`(s) are invalid.
128
130
// TODO: make all payloads the same size with padding + add dummy hops
129
- pub fn new_for_message < ES : EntropySource + ? Sized , T : secp256k1:: Signing + secp256k1:: Verification > (
130
- node_pks : & [ PublicKey ] , entropy_source : & ES , secp_ctx : & Secp256k1 < T >
131
- ) -> Result < Self , ( ) > {
131
+ pub fn new_for_message < ES : Deref , T : secp256k1:: Signing + secp256k1:: Verification > (
132
+ node_pks : & [ PublicKey ] , entropy_source : ES , secp_ctx : & Secp256k1 < T >
133
+ ) -> Result < Self , ( ) > where ES :: Target : EntropySource {
132
134
if node_pks. is_empty ( ) { return Err ( ( ) ) }
133
135
let blinding_secret_bytes = entropy_source. get_secure_random_bytes ( ) ;
134
136
let blinding_secret = SecretKey :: from_slice ( & blinding_secret_bytes[ ..] ) . expect ( "RNG is busted" ) ;
@@ -142,10 +144,10 @@ impl BlindedPath {
142
144
}
143
145
144
146
/// Create a one-hop blinded path for a payment.
145
- pub fn one_hop_for_payment < ES : EntropySource + ? Sized , T : secp256k1:: Signing + secp256k1:: Verification > (
147
+ pub fn one_hop_for_payment < ES : Deref , T : secp256k1:: Signing + secp256k1:: Verification > (
146
148
payee_node_id : PublicKey , payee_tlvs : payment:: ReceiveTlvs , min_final_cltv_expiry_delta : u16 ,
147
- entropy_source : & ES , secp_ctx : & Secp256k1 < T >
148
- ) -> Result < ( BlindedPayInfo , Self ) , ( ) > {
149
+ entropy_source : ES , secp_ctx : & Secp256k1 < T >
150
+ ) -> Result < ( BlindedPayInfo , Self ) , ( ) > where ES :: Target : EntropySource {
149
151
// This value is not considered in pathfinding for 1-hop blinded paths, because it's intended to
150
152
// be in relation to a specific channel.
151
153
let htlc_maximum_msat = u64:: max_value ( ) ;
@@ -164,11 +166,11 @@ impl BlindedPath {
164
166
///
165
167
/// [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
166
168
// TODO: make all payloads the same size with padding + add dummy hops
167
- pub fn new_for_payment < ES : EntropySource + ? Sized , T : secp256k1:: Signing + secp256k1:: Verification > (
169
+ pub fn new_for_payment < ES : Deref , T : secp256k1:: Signing + secp256k1:: Verification > (
168
170
intermediate_nodes : & [ payment:: ForwardNode ] , payee_node_id : PublicKey ,
169
171
payee_tlvs : payment:: ReceiveTlvs , htlc_maximum_msat : u64 , min_final_cltv_expiry_delta : u16 ,
170
- entropy_source : & ES , secp_ctx : & Secp256k1 < T >
171
- ) -> Result < ( BlindedPayInfo , Self ) , ( ) > {
172
+ entropy_source : ES , secp_ctx : & Secp256k1 < T >
173
+ ) -> Result < ( BlindedPayInfo , Self ) , ( ) > where ES :: Target : EntropySource {
172
174
let introduction_node = IntroductionNode :: NodeId (
173
175
intermediate_nodes. first ( ) . map_or ( payee_node_id, |n| n. node_id )
174
176
) ;
0 commit comments