@@ -1690,7 +1690,6 @@ mod fuzzy_internal_msgs {
1690
1690
use crate :: ln:: { PaymentPreimage , PaymentSecret } ;
1691
1691
use crate :: ln:: features:: BlindedHopFeatures ;
1692
1692
use super :: FinalOnionHopData ;
1693
- use crate :: ln:: msgs:: VariableLengthOnionPacket ;
1694
1693
1695
1694
// These types aren't intended to be pub, but are exposed for direct fuzzing (as we deserialize
1696
1695
// them from untrusted input):
@@ -1741,7 +1740,7 @@ mod fuzzy_internal_msgs {
1741
1740
custom_tlvs : Vec < ( u64 , Vec < u8 > ) > ,
1742
1741
sender_intended_htlc_amt_msat : u64 ,
1743
1742
cltv_expiry_height : u32 ,
1744
- trampoline_packet : Option < VariableLengthOnionPacket >
1743
+ trampoline_packet : Option < crate :: onion_message :: Packet >
1745
1744
} ,
1746
1745
BlindedForward {
1747
1746
encrypted_tlvs : Vec < u8 > ,
@@ -1802,29 +1801,6 @@ impl fmt::Debug for OnionPacket {
1802
1801
}
1803
1802
}
1804
1803
1805
- /// BOLT 4 onion packet including hop data for the next peer.
1806
- #[ derive( Clone , Hash , PartialEq , Eq ) ]
1807
- pub struct VariableLengthOnionPacket {
1808
- /// BOLT 4 version number.
1809
- pub version : u8 ,
1810
- /// In order to ensure we always return an error on onion decode in compliance with [BOLT
1811
- /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
1812
- /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
1813
- /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
1814
- /// like.
1815
- pub public_key : Result < PublicKey , secp256k1:: Error > ,
1816
- /// Variable number of bytes encrypted payload for the next hop; 650 by default for Trampoline
1817
- pub ( crate ) hop_data : Vec < u8 > ,
1818
- /// HMAC to verify the integrity of hop_data.
1819
- pub hmac : [ u8 ; 32 ] ,
1820
- }
1821
-
1822
- impl fmt:: Debug for VariableLengthOnionPacket {
1823
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1824
- f. write_fmt ( format_args ! ( "VariableLengthOnionPacket version {} with hmac {:?}" , self . version, & self . hmac[ ..] ) )
1825
- }
1826
- }
1827
-
1828
1804
#[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
1829
1805
pub ( crate ) struct OnionErrorPacket {
1830
1806
// This really should be a constant size slice, but the spec lets these things be up to 128KB?
@@ -2253,23 +2229,6 @@ impl Readable for OnionPacket {
2253
2229
}
2254
2230
}
2255
2231
2256
- // This will be written as the value of a TLV, so when reading, the length of the hop data will be
2257
- // inferred from a ReadableArg containing the total length. The standard hop data for Trampoline
2258
- // onions will prospectively be 650 bytes.
2259
- impl Writeable for VariableLengthOnionPacket {
2260
- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
2261
- self . version . write ( w) ?;
2262
- match self . public_key {
2263
- Ok ( pubkey) => pubkey. write ( w) ?,
2264
- Err ( _) => [ 0u8 ; 33 ] . write ( w) ?,
2265
- }
2266
- // don't encode the length of hop_data
2267
- w. write_all ( & self . hop_data ) ?;
2268
- & self . hmac . write ( w) ?;
2269
- Ok ( ( ) )
2270
- }
2271
- }
2272
-
2273
2232
impl_writeable_msg ! ( UpdateAddHTLC , {
2274
2233
channel_id,
2275
2234
htlc_id,
@@ -2900,7 +2859,7 @@ mod tests {
2900
2859
use crate :: ln:: { PaymentPreimage , PaymentHash , PaymentSecret } ;
2901
2860
use crate :: ln:: ChannelId ;
2902
2861
use crate :: ln:: features:: { ChannelFeatures , ChannelTypeFeatures , InitFeatures , NodeFeatures } ;
2903
- use crate :: ln:: msgs:: { self , FinalOnionHopData , OnionErrorPacket , VariableLengthOnionPacket } ;
2862
+ use crate :: ln:: msgs:: { self , FinalOnionHopData , OnionErrorPacket } ;
2904
2863
use crate :: ln:: msgs:: SocketAddress ;
2905
2864
use crate :: routing:: gossip:: { NodeAlias , NodeId } ;
2906
2865
use crate :: util:: ser:: { Writeable , Readable , ReadableArgs , Hostname , TransactionU16LenLimited , BigSize } ;
@@ -2927,6 +2886,7 @@ mod tests {
2927
2886
use std:: net:: { Ipv4Addr , Ipv6Addr , SocketAddr , SocketAddrV4 , SocketAddrV6 , ToSocketAddrs } ;
2928
2887
#[ cfg( feature = "std" ) ]
2929
2888
use crate :: ln:: msgs:: SocketAddressParseError ;
2889
+ use crate :: onion_message:: Packet ;
2930
2890
2931
2891
#[ test]
2932
2892
fn encoding_channel_reestablish ( ) {
@@ -4201,9 +4161,9 @@ mod tests {
4201
4161
let compressed_public_key = public_key. serialize ( ) ;
4202
4162
assert_eq ! ( compressed_public_key. len( ) , 33 ) ;
4203
4163
4204
- let trampoline_packet = VariableLengthOnionPacket {
4164
+ let trampoline_packet = Packet {
4205
4165
version : 0 ,
4206
- public_key : Ok ( public_key ) ,
4166
+ public_key,
4207
4167
hop_data : vec ! [ 1 ; 650 ] , // this should be the standard encoded length
4208
4168
hmac : [ 2 ; 32 ] ,
4209
4169
} ;
@@ -4243,9 +4203,9 @@ mod tests {
4243
4203
let compressed_public_key = public_key. serialize ( ) ;
4244
4204
assert_eq ! ( compressed_public_key. len( ) , 33 ) ;
4245
4205
4246
- let trampoline_packet = VariableLengthOnionPacket {
4206
+ let trampoline_packet = Packet {
4247
4207
version : 0 ,
4248
- public_key : Ok ( public_key ) ,
4208
+ public_key,
4249
4209
hop_data,
4250
4210
hmac
4251
4211
} ;
0 commit comments