@@ -16,9 +16,10 @@ use ln::channel::{Channel, ChannelKeys};
16
16
use ln:: channelmonitor:: ManyChannelMonitor ;
17
17
use ln:: router:: { Route , RouteHop } ;
18
18
use ln:: msgs;
19
- use ln:: msgs:: { HandleError , ChannelMessageHandler , MsgEncodable , MsgDecodable } ;
19
+ use ln:: msgs:: { HandleError , ChannelMessageHandler } ;
20
20
use util:: { byte_utils, events, internal_traits, rng} ;
21
21
use util:: sha2:: Sha256 ;
22
+ use util:: ser:: { Readable , Writeable } ;
22
23
use util:: chacha20poly1305rfc:: ChaCha20 ;
23
24
use util:: logger:: Logger ;
24
25
use util:: errors:: APIError ;
@@ -32,6 +33,7 @@ use crypto::symmetriccipher::SynchronousStreamCipher;
32
33
use std:: { ptr, mem} ;
33
34
use std:: collections:: HashMap ;
34
35
use std:: collections:: hash_map;
36
+ use std:: io:: Cursor ;
35
37
use std:: sync:: { Mutex , MutexGuard , Arc } ;
36
38
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
37
39
use std:: time:: { Instant , Duration } ;
@@ -819,7 +821,7 @@ impl ChannelManager {
819
821
let next_hop_data = {
820
822
let mut decoded = [ 0 ; 65 ] ;
821
823
chacha. process ( & msg. onion_routing_packet . hop_data [ 0 ..65 ] , & mut decoded) ;
822
- match msgs:: OnionHopData :: decode ( & decoded[ ..] ) {
824
+ match msgs:: OnionHopData :: read ( & mut Cursor :: new ( & decoded[ ..] ) ) {
823
825
Err ( err) => {
824
826
let error_code = match err {
825
827
msgs:: DecodeError :: UnknownRealmByte => 0x4000 | 1 ,
@@ -1717,7 +1719,7 @@ impl ChannelManager {
1717
1719
chacha. process ( & packet_decrypted, & mut decryption_tmp[ ..] ) ;
1718
1720
packet_decrypted = decryption_tmp;
1719
1721
1720
- if let Ok ( err_packet) = msgs:: DecodedOnionErrorPacket :: decode ( & packet_decrypted) {
1722
+ if let Ok ( err_packet) = msgs:: DecodedOnionErrorPacket :: read ( & mut Cursor :: new ( & packet_decrypted) ) {
1721
1723
if err_packet. failuremsg . len ( ) >= 2 {
1722
1724
let um = ChannelManager :: gen_um_from_shared_secret ( & shared_secret) ;
1723
1725
@@ -1733,7 +1735,7 @@ impl ChannelManager {
1733
1735
if err_packet. failuremsg . len ( ) >= 4 {
1734
1736
let update_len = byte_utils:: slice_to_be16 ( & err_packet. failuremsg [ 2 ..4 ] ) as usize ;
1735
1737
if err_packet. failuremsg . len ( ) >= 4 + update_len {
1736
- if let Ok ( chan_update) = msgs:: ChannelUpdate :: decode ( & err_packet. failuremsg [ 4 ..4 + update_len] ) {
1738
+ if let Ok ( chan_update) = msgs:: ChannelUpdate :: read ( & mut Cursor :: new ( & err_packet. failuremsg [ 4 ..4 + update_len] ) ) {
1737
1739
res = Some ( msgs:: HTLCFailChannelUpdate :: ChannelUpdateMessage {
1738
1740
msg : chan_update,
1739
1741
} ) ;
@@ -2250,11 +2252,12 @@ mod tests {
2250
2252
use ln:: channelmanager:: { ChannelManager , OnionKeys } ;
2251
2253
use ln:: router:: { Route , RouteHop , Router } ;
2252
2254
use ln:: msgs;
2253
- use ln:: msgs:: { MsgEncodable , ChannelMessageHandler , RoutingMessageHandler } ;
2255
+ use ln:: msgs:: { ChannelMessageHandler , RoutingMessageHandler } ;
2254
2256
use util:: test_utils;
2255
2257
use util:: events:: { Event , EventsProvider } ;
2256
- use util:: logger:: Logger ;
2257
2258
use util:: errors:: APIError ;
2259
+ use util:: logger:: Logger ;
2260
+ use util:: ser:: Writeable ;
2258
2261
2259
2262
use bitcoin:: util:: hash:: Sha256dHash ;
2260
2263
use bitcoin:: blockdata:: block:: { Block , BlockHeader } ;
0 commit comments