@@ -185,6 +185,10 @@ fn shift_arr_right(arr: &mut [u8; ONION_DATA_LEN], amt: usize) {
185
185
}
186
186
}
187
187
188
+ #[ inline]
189
+ fn shift_vec_right ( vec : & mut Vec < u8 > , amt : usize ) {
190
+ }
191
+
188
192
pub ( super ) fn route_size_insane ( payloads : & Vec < msgs:: OnionHopData > ) -> bool {
189
193
let mut len = 0 ;
190
194
for payload in payloads. iter ( ) {
@@ -206,7 +210,8 @@ pub(super) fn construct_onion_packet(payloads: Vec<msgs::OnionHopData>, onion_ke
206
210
let mut chacha = ChaCha20 :: new ( & prng_seed, & [ 0 ; 8 ] ) ;
207
211
chacha. process ( & [ 0 ; ONION_DATA_LEN ] , & mut packet_data) ;
208
212
209
- construct_onion_packet_with_init_noise ( payloads, onion_keys, packet_data, associated_data)
213
+ construct_onion_packet_with_init_noise (
214
+ payloads, onion_keys, PacketData :: Payment ( packet_data) , Some ( associated_data) ) . try_into ( ) . unwrap ( )
210
215
}
211
216
212
217
#[ cfg( test) ]
@@ -218,11 +223,38 @@ pub(super) fn construct_onion_packet_bogus_hopdata<HD: Writeable>(payloads: Vec<
218
223
let mut chacha = ChaCha20 :: new ( & prng_seed, & [ 0 ; 8 ] ) ;
219
224
chacha. process ( & [ 0 ; ONION_DATA_LEN ] , & mut packet_data) ;
220
225
221
- construct_onion_packet_with_init_noise ( payloads, onion_keys, packet_data, associated_data)
226
+ construct_onion_packet_with_init_noise (
227
+ payloads, onion_keys, PacketData :: Payment ( packet_data) , Some ( associated_data) ) . try_into ( ) . unwrap ( )
228
+ }
229
+
230
+ enum PacketData {
231
+ Payment ( [ u8 ; ONION_DATA_LEN ] ) ,
232
+ Message ( Vec < u8 > ) ,
233
+ }
234
+
235
+ impl PacketData {
236
+ fn len ( & self ) -> usize {
237
+ }
238
+ }
239
+
240
+ impl TryFrom < Packet > for onion_message:: Packet {
241
+ type Error = ( ) ;
242
+ fn try_from ( packet : Packet ) -> Result < Self , Self :: Error > {
243
+ }
244
+ }
245
+ impl TryFrom < Packet > for msgs:: OnionPacket {
246
+ type Error = ( ) ;
247
+ fn try_from ( packet : Packet ) -> Result < Self , Self :: Error > {
248
+ }
249
+ }
250
+
251
+ enum Packet {
252
+ Payment ( msgs:: OnionPacket ) ,
253
+ Message ( onion_message:: Packet ) ,
222
254
}
223
255
224
256
/// panics if route_size_insane(paylods)
225
- fn construct_onion_packet_with_init_noise < HD : Writeable > ( mut payloads : Vec < HD > , onion_keys : Vec < OnionKeys > , mut packet_data : [ u8 ; ONION_DATA_LEN ] , associated_data : & PaymentHash ) -> msgs :: OnionPacket {
257
+ fn construct_onion_packet_with_init_noise < HD : Writeable > ( mut payloads : Vec < HD > , onion_keys : Vec < OnionKeys > , mut packet_data : PacketData , associated_data : Option < & PaymentHash > ) -> Packet {
226
258
let filler = {
227
259
const ONION_HOP_DATA_LEN : usize = 65 ; // We may decrease this eventually after TLV is common
228
260
let mut res = Vec :: with_capacity ( ONION_HOP_DATA_LEN * ( payloads. len ( ) - 1 ) ) ;
0 commit comments