@@ -54,7 +54,7 @@ use crate::ln::wire::Encode;
54
54
use crate :: chain:: keysinterface:: { Sign , KeysInterface , KeysManager , Recipient } ;
55
55
use crate :: util:: config:: { UserConfig , ChannelConfig } ;
56
56
use crate :: util:: events:: { Event , EventHandler , EventsProvider , MessageSendEvent , MessageSendEventsProvider , ClosureReason , HTLCDestination } ;
57
- use crate :: util:: { byte_utils , events} ;
57
+ use crate :: util:: events;
58
58
use crate :: util:: wakers:: { Future , Notifier } ;
59
59
use crate :: util:: scid_utils:: fake_scid;
60
60
use crate :: util:: ser:: { BigSize , FixedLengthReader , Readable , ReadableArgs , MaybeReadable , Writeable , Writer , VecWriter } ;
@@ -2041,7 +2041,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2041
2041
return Err ( ReceiveError {
2042
2042
msg : "Upstream node set CLTV to the wrong value" ,
2043
2043
err_code : 18 ,
2044
- err_data : byte_utils :: be32_to_array ( cltv_expiry) . to_vec ( )
2044
+ err_data : cltv_expiry. to_be_bytes ( ) . to_vec ( )
2045
2045
} )
2046
2046
}
2047
2047
// final_expiry_too_soon
@@ -2060,7 +2060,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2060
2060
if hop_data. amt_to_forward > amt_msat {
2061
2061
return Err ( ReceiveError {
2062
2062
err_code : 19 ,
2063
- err_data : byte_utils :: be64_to_array ( amt_msat) . to_vec ( ) ,
2063
+ err_data : amt_msat. to_be_bytes ( ) . to_vec ( ) ,
2064
2064
msg : "Upstream node sent less than we were supposed to receive in payment" ,
2065
2065
} ) ;
2066
2066
}
@@ -3439,9 +3439,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3439
3439
3440
3440
macro_rules! fail_htlc {
3441
3441
( $htlc: expr, $payment_hash: expr) => {
3442
- let mut htlc_msat_height_data = byte_utils :: be64_to_array ( $htlc. value) . to_vec( ) ;
3442
+ let mut htlc_msat_height_data = $htlc. value. to_be_bytes ( ) . to_vec( ) ;
3443
3443
htlc_msat_height_data. extend_from_slice(
3444
- & byte_utils :: be32_to_array ( self . best_block. read( ) . unwrap( ) . height( ) ) ,
3444
+ & self . best_block. read( ) . unwrap( ) . height( ) . to_be_bytes ( ) ,
3445
3445
) ;
3446
3446
failed_forwards. push( ( HTLCSource :: PreviousHopData ( HTLCPreviousHopData {
3447
3447
short_channel_id: $htlc. prev_hop. short_channel_id,
@@ -3895,9 +3895,8 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3895
3895
let removed_source = self . claimable_htlcs . lock ( ) . unwrap ( ) . remove ( payment_hash) ;
3896
3896
if let Some ( ( _, mut sources) ) = removed_source {
3897
3897
for htlc in sources. drain ( ..) {
3898
- let mut htlc_msat_height_data = byte_utils:: be64_to_array ( htlc. value ) . to_vec ( ) ;
3899
- htlc_msat_height_data. extend_from_slice ( & byte_utils:: be32_to_array (
3900
- self . best_block . read ( ) . unwrap ( ) . height ( ) ) ) ;
3898
+ let mut htlc_msat_height_data = htlc. value . to_be_bytes ( ) . to_vec ( ) ;
3899
+ htlc_msat_height_data. extend_from_slice ( & self . best_block . read ( ) . unwrap ( ) . height ( ) . to_be_bytes ( ) ) ;
3901
3900
self . fail_htlc_backwards_internal (
3902
3901
HTLCSource :: PreviousHopData ( htlc. prev_hop ) , payment_hash,
3903
3902
HTLCFailReason :: Reason { failure_code : 0x4000 | 15 , data : htlc_msat_height_data } ,
@@ -4291,9 +4290,8 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4291
4290
mem:: drop ( channel_state_lock) ;
4292
4291
if !valid_mpp {
4293
4292
for htlc in sources. drain ( ..) {
4294
- let mut htlc_msat_height_data = byte_utils:: be64_to_array ( htlc. value ) . to_vec ( ) ;
4295
- htlc_msat_height_data. extend_from_slice ( & byte_utils:: be32_to_array (
4296
- self . best_block . read ( ) . unwrap ( ) . height ( ) ) ) ;
4293
+ let mut htlc_msat_height_data = htlc. value . to_be_bytes ( ) . to_vec ( ) ;
4294
+ htlc_msat_height_data. extend_from_slice ( & self . best_block . read ( ) . unwrap ( ) . height ( ) . to_be_bytes ( ) ) ;
4297
4295
self . fail_htlc_backwards_internal (
4298
4296
HTLCSource :: PreviousHopData ( htlc. prev_hop ) , & payment_hash,
4299
4297
HTLCFailReason :: Reason { failure_code : 0x4000 |15 , data : htlc_msat_height_data } ,
@@ -6267,8 +6265,8 @@ where
6267
6265
// number of blocks we generally consider it to take to do a commitment update,
6268
6266
// just give up on it and fail the HTLC.
6269
6267
if height >= htlc. cltv_expiry - HTLC_FAIL_BACK_BUFFER {
6270
- let mut htlc_msat_height_data = byte_utils :: be64_to_array ( htlc. value ) . to_vec ( ) ;
6271
- htlc_msat_height_data. extend_from_slice ( & byte_utils :: be32_to_array ( height) ) ;
6268
+ let mut htlc_msat_height_data = htlc. value . to_be_bytes ( ) . to_vec ( ) ;
6269
+ htlc_msat_height_data. extend_from_slice ( & height. to_be_bytes ( ) ) ;
6272
6270
timed_out_htlcs. push ( ( HTLCSource :: PreviousHopData ( htlc. prev_hop . clone ( ) ) , payment_hash. clone ( ) , HTLCFailReason :: Reason {
6273
6271
failure_code : 0x4000 | 15 ,
6274
6272
data : htlc_msat_height_data
0 commit comments