@@ -1670,7 +1670,6 @@ mod fuzzy_internal_msgs {
1670
1670
use crate :: prelude:: * ;
1671
1671
use crate :: ln:: { PaymentPreimage , PaymentSecret } ;
1672
1672
use crate :: ln:: features:: BlindedHopFeatures ;
1673
- use crate :: ln:: msgs:: VariableLengthOnionPacket ;
1674
1673
1675
1674
// These types aren't intended to be pub, but are exposed for direct fuzzing (as we deserialize
1676
1675
// them from untrusted input):
@@ -1728,7 +1727,7 @@ mod fuzzy_internal_msgs {
1728
1727
custom_tlvs : Vec < ( u64 , Vec < u8 > ) > ,
1729
1728
amt_msat : u64 ,
1730
1729
outgoing_cltv_value : u32 ,
1731
- trampoline_packet : Option < VariableLengthOnionPacket >
1730
+ trampoline_packet : Option < crate :: onion_message :: Packet >
1732
1731
} ,
1733
1732
BlindedForward {
1734
1733
encrypted_tlvs : Vec < u8 > ,
@@ -1789,29 +1788,6 @@ impl fmt::Debug for OnionPacket {
1789
1788
}
1790
1789
}
1791
1790
1792
- /// BOLT 4 onion packet including hop data for the next peer.
1793
- #[ derive( Clone , Hash , PartialEq , Eq ) ]
1794
- pub struct VariableLengthOnionPacket {
1795
- /// BOLT 4 version number.
1796
- pub version : u8 ,
1797
- /// In order to ensure we always return an error on onion decode in compliance with [BOLT
1798
- /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
1799
- /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
1800
- /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
1801
- /// like.
1802
- pub public_key : Result < PublicKey , secp256k1:: Error > ,
1803
- /// Variable number of bytes encrypted payload for the next hop; 650 by default for Trampoline
1804
- pub ( crate ) hop_data : Vec < u8 > ,
1805
- /// HMAC to verify the integrity of hop_data.
1806
- pub hmac : [ u8 ; 32 ] ,
1807
- }
1808
-
1809
- impl fmt:: Debug for VariableLengthOnionPacket {
1810
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1811
- f. write_fmt ( format_args ! ( "VariableLengthOnionPacket version {} with hmac {:?}" , self . version, & self . hmac[ ..] ) )
1812
- }
1813
- }
1814
-
1815
1791
#[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
1816
1792
pub ( crate ) struct OnionErrorPacket {
1817
1793
// This really should be a constant size slice, but the spec lets these things be up to 128KB?
@@ -2240,23 +2216,6 @@ impl Readable for OnionPacket {
2240
2216
}
2241
2217
}
2242
2218
2243
- // This will be written as the value of a TLV, so when reading, the length of the hop data will be
2244
- // inferred from a ReadableArg containing the total length. The standard hop data for Trampoline
2245
- // onions will prospectively be 650 bytes.
2246
- impl Writeable for VariableLengthOnionPacket {
2247
- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
2248
- self . version . write ( w) ?;
2249
- match self . public_key {
2250
- Ok ( pubkey) => pubkey. write ( w) ?,
2251
- Err ( _) => [ 0u8 ; 33 ] . write ( w) ?,
2252
- }
2253
- // don't encode the length of hop_data
2254
- w. write_all ( & self . hop_data ) ?;
2255
- & self . hmac . write ( w) ?;
2256
- Ok ( ( ) )
2257
- }
2258
- }
2259
-
2260
2219
impl_writeable_msg ! ( UpdateAddHTLC , {
2261
2220
channel_id,
2262
2221
htlc_id,
@@ -2879,7 +2838,7 @@ mod tests {
2879
2838
use crate :: ln:: { PaymentPreimage , PaymentHash , PaymentSecret } ;
2880
2839
use crate :: ln:: ChannelId ;
2881
2840
use crate :: ln:: features:: { ChannelFeatures , ChannelTypeFeatures , InitFeatures , NodeFeatures } ;
2882
- use crate :: ln:: msgs:: { self , FinalOnionHopData , OnionErrorPacket , VariableLengthOnionPacket } ;
2841
+ use crate :: ln:: msgs:: { self , FinalOnionHopData , OnionErrorPacket } ;
2883
2842
use crate :: ln:: msgs:: SocketAddress ;
2884
2843
use crate :: routing:: gossip:: { NodeAlias , NodeId } ;
2885
2844
use crate :: util:: ser:: { Writeable , Readable , ReadableArgs , Hostname , TransactionU16LenLimited , BigSize } ;
@@ -2906,6 +2865,7 @@ mod tests {
2906
2865
use std:: net:: { Ipv4Addr , Ipv6Addr , SocketAddr , SocketAddrV4 , SocketAddrV6 , ToSocketAddrs } ;
2907
2866
#[ cfg( feature = "std" ) ]
2908
2867
use crate :: ln:: msgs:: SocketAddressParseError ;
2868
+ use crate :: onion_message:: Packet ;
2909
2869
2910
2870
#[ test]
2911
2871
fn encoding_channel_reestablish ( ) {
@@ -4180,9 +4140,9 @@ mod tests {
4180
4140
let compressed_public_key = public_key. serialize ( ) ;
4181
4141
assert_eq ! ( compressed_public_key. len( ) , 33 ) ;
4182
4142
4183
- let trampoline_packet = VariableLengthOnionPacket {
4143
+ let trampoline_packet = Packet {
4184
4144
version : 0 ,
4185
- public_key : Ok ( public_key ) ,
4145
+ public_key,
4186
4146
hop_data : vec ! [ 1 ; 650 ] , // this should be the standard encoded length
4187
4147
hmac : [ 2 ; 32 ] ,
4188
4148
} ;
@@ -4222,9 +4182,9 @@ mod tests {
4222
4182
let compressed_public_key = public_key. serialize ( ) ;
4223
4183
assert_eq ! ( compressed_public_key. len( ) , 33 ) ;
4224
4184
4225
- let trampoline_packet = VariableLengthOnionPacket {
4185
+ let trampoline_packet = Packet {
4226
4186
version : 0 ,
4227
- public_key : Ok ( public_key ) ,
4187
+ public_key,
4228
4188
hop_data,
4229
4189
hmac
4230
4190
} ;
0 commit comments