@@ -22,7 +22,7 @@ use bitcoin::hash_types::{Txid, PubkeyHash};
2222
2323use ln:: { PaymentHash , PaymentPreimage } ;
2424use ln:: msgs:: DecodeError ;
25- use util:: ser:: { Readable , Writeable , Writer , MAX_BUF_SIZE } ;
25+ use util:: ser:: { Readable , Writeable , Writer } ;
2626use util:: byte_utils;
2727
2828use bitcoin:: hash_types:: WPubkeyHash ;
@@ -36,18 +36,11 @@ use core::cmp;
3636use ln:: chan_utils;
3737use util:: transaction_utils:: sort_outputs;
3838use ln:: channel:: INITIAL_COMMITMENT_NUMBER ;
39- use std:: io:: Read ;
4039use core:: ops:: Deref ;
4140use chain;
4241
43- // Maximum size of a serialized HTLCOutputInCommitment
44- pub ( crate ) const HTLC_OUTPUT_IN_COMMITMENT_SIZE : usize = 1 + 8 + 4 + 32 + 5 ;
45-
4642pub ( crate ) const MAX_HTLCS : u16 = 483 ;
4743
48- // This checks that the buffer size is greater than the maximum possible size for serialized HTLCS
49- const _EXCESS_BUFFER_SIZE: usize = MAX_BUF_SIZE - MAX_HTLCS as usize * HTLC_OUTPUT_IN_COMMITMENT_SIZE ;
50-
5144pub ( super ) const HTLC_SUCCESS_TX_WEIGHT : u64 = 703 ;
5245pub ( super ) const HTLC_TIMEOUT_TX_WEIGHT : u64 = 663 ;
5346
@@ -866,44 +859,16 @@ impl PartialEq for CommitmentTransaction {
866859 }
867860}
868861
869- /// (C-not exported) as users never need to call this directly
870- impl Writeable for Vec < HTLCOutputInCommitment > {
871- #[ inline]
872- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
873- ( self . len ( ) as u16 ) . write ( w) ?;
874- for e in self . iter ( ) {
875- e. write ( w) ?;
876- }
877- Ok ( ( ) )
878- }
879- }
880-
881- /// (C-not exported) as users never need to call this directly
882- impl Readable for Vec < HTLCOutputInCommitment > {
883- #[ inline]
884- fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
885- let len: u16 = Readable :: read ( r) ?;
886- let byte_size = ( len as usize )
887- . checked_mul ( HTLC_OUTPUT_IN_COMMITMENT_SIZE )
888- . ok_or ( DecodeError :: BadLengthDescriptor ) ?;
889- if byte_size > MAX_BUF_SIZE {
890- return Err ( DecodeError :: BadLengthDescriptor ) ;
891- }
892- let mut ret = Vec :: with_capacity ( len as usize ) ;
893- for _ in 0 ..len { ret. push ( HTLCOutputInCommitment :: read ( r) ?) ; }
894- Ok ( ret)
895- }
896- }
897-
898862impl_writeable_tlv_based ! ( CommitmentTransaction , {
899863 ( 0 , commitment_number) ,
900864 ( 2 , to_broadcaster_value_sat) ,
901865 ( 4 , to_countersignatory_value_sat) ,
902866 ( 6 , feerate_per_kw) ,
903- ( 8 , htlcs) ,
904- ( 10 , keys) ,
905- ( 12 , built) ,
906- } , { } , { } ) ;
867+ ( 8 , keys) ,
868+ ( 10 , built) ,
869+ } , { } , {
870+ ( 12 , htlcs) ,
871+ } ) ;
907872
908873impl CommitmentTransaction {
909874 /// Construct an object of the class while assigning transaction output indices to HTLCs.
0 commit comments