@@ -55,7 +55,7 @@ use crate::io_extras::read_to_end;
55
55
use crate :: events:: { EventsProvider , MessageSendEventsProvider } ;
56
56
use crate :: crypto:: streams:: ChaChaPolyReadAdapter ;
57
57
use crate :: util:: logger;
58
- use crate :: util:: ser:: { LengthReadable , LengthReadableArgs , Readable , ReadableArgs , Writeable , Writer , WithoutLength , FixedLengthReader , HighZeroBytesDroppedBigSize , Hostname , TransactionU16LenLimited , BigSize } ;
58
+ use crate :: util:: ser:: { BigSize , FixedLengthReader , HighZeroBytesDroppedBigSize , Hostname , LengthRead , LengthReadable , LengthReadableArgs , Readable , ReadableArgs , TransactionU16LenLimited , WithoutLength , Writeable , Writer } ;
59
59
use crate :: util:: base32;
60
60
61
61
use crate :: routing:: gossip:: { NodeAlias , NodeId } ;
@@ -1856,6 +1856,26 @@ impl Writeable for TrampolineOnionPacket {
1856
1856
}
1857
1857
}
1858
1858
1859
+ impl LengthReadable for TrampolineOnionPacket {
1860
+ fn read < R : LengthRead > ( r : & mut R ) -> Result < Self , DecodeError > {
1861
+ let version = Readable :: read ( r) ?;
1862
+ let public_key = Readable :: read ( r) ?;
1863
+
1864
+ let hop_data_len = r. total_bytes ( ) . saturating_sub ( 66 ) ; // 1 (version) + 33 (pubkey) + 32 (HMAC) = 66
1865
+ let mut rd = FixedLengthReader :: new ( r, hop_data_len) ;
1866
+ let hop_data = WithoutLength :: < Vec < u8 > > :: read ( & mut rd) ?. 0 ;
1867
+
1868
+ let hmac = Readable :: read ( r) ?;
1869
+
1870
+ Ok ( TrampolineOnionPacket {
1871
+ version,
1872
+ public_key,
1873
+ hop_data,
1874
+ hmac,
1875
+ } )
1876
+ }
1877
+ }
1878
+
1859
1879
impl Debug for TrampolineOnionPacket {
1860
1880
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1861
1881
f. write_fmt ( format_args ! ( "TrampolineOnionPacket version {} with hmac {:?}" , self . version, & self . hmac[ ..] ) )
0 commit comments