@@ -24,7 +24,8 @@ use crate::io_extras::sink;
2424use crate :: ln:: chan_utils;
2525use crate :: ln:: chan_utils:: {
2626 shared_anchor_script_pubkey, HTLCOutputInCommitment , ANCHOR_INPUT_WITNESS_WEIGHT ,
27- HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT , HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT ,
27+ HTLC_SUCCESS_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT , HTLC_SUCCESS_INPUT_P2A_ANCHOR_WITNESS_WEIGHT ,
28+ HTLC_TIMEOUT_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT , HTLC_TIMEOUT_INPUT_P2A_ANCHOR_WITNESS_WEIGHT ,
2829 P2A_ANCHOR_INPUT_WITNESS_WEIGHT ,
2930} ;
3031use crate :: ln:: types:: ChannelId ;
@@ -864,16 +865,30 @@ where
864865 output : vec ! [ ] ,
865866 } ;
866867 let mut must_spend = Vec :: with_capacity ( htlc_descriptors. len ( ) ) ;
868+ let ( htlc_success_witness_weight, htlc_timeout_witness_weight) =
869+ if channel_type. supports_anchor_zero_fee_commitments ( ) {
870+ (
871+ HTLC_SUCCESS_INPUT_P2A_ANCHOR_WITNESS_WEIGHT ,
872+ HTLC_TIMEOUT_INPUT_P2A_ANCHOR_WITNESS_WEIGHT ,
873+ )
874+ } else if channel_type. supports_anchors_zero_fee_htlc_tx ( ) {
875+ (
876+ HTLC_SUCCESS_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT ,
877+ HTLC_TIMEOUT_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT ,
878+ )
879+ } else {
880+ panic ! ( "channel type should be either zero-fee HTLCs, or zero-fee commitments" ) ;
881+ } ;
867882 for htlc_descriptor in htlc_descriptors {
868883 let htlc_input = htlc_descriptor. unsigned_tx_input ( ) ;
869884 must_spend. push ( Input {
870885 outpoint : htlc_input. previous_output . clone ( ) ,
871886 previous_utxo : htlc_descriptor. previous_utxo ( & self . secp ) ,
872887 satisfaction_weight : EMPTY_SCRIPT_SIG_WEIGHT
873888 + if htlc_descriptor. preimage . is_some ( ) {
874- HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT
889+ htlc_success_witness_weight
875890 } else {
876- HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT
891+ htlc_timeout_witness_weight
877892 } ,
878893 } ) ;
879894 htlc_tx. input . push ( htlc_input) ;
0 commit comments