@@ -31,9 +31,8 @@ use secp256k1;
31
31
32
32
use ln:: msgs:: DecodeError ;
33
33
use ln:: chan_utils;
34
- use ln:: chan_utils:: { HTLCOutputInCommitment , LocalCommitmentTransaction } ;
34
+ use ln:: chan_utils:: { HTLCOutputInCommitment , LocalCommitmentTransaction , HTLCType } ;
35
35
use ln:: channelmanager:: { HTLCSource , PaymentPreimage , PaymentHash } ;
36
- use ln:: channel:: { ACCEPTED_HTLC_SCRIPT_WEIGHT , OFFERED_HTLC_SCRIPT_WEIGHT } ;
37
36
use chain:: chaininterface:: { ChainListener , ChainWatchInterface , BroadcasterInterface , FeeEstimator , ConfirmationTarget , MIN_RELAY_FEE_SAT_PER_1000_WEIGHT } ;
38
37
use chain:: transaction:: OutPoint ;
39
38
use chain:: keysinterface:: SpendableOutputDescriptor ;
@@ -2677,10 +2676,10 @@ impl ChannelMonitor {
2677
2676
2678
2677
' outer_loop: for input in & tx. input {
2679
2678
let mut payment_data = None ;
2680
- let revocation_sig_claim = ( input. witness . len ( ) == 3 && input. witness [ 2 ] . len ( ) == OFFERED_HTLC_SCRIPT_WEIGHT && input. witness [ 1 ] . len ( ) == 33 )
2681
- || ( input. witness . len ( ) == 3 && input. witness [ 2 ] . len ( ) == ACCEPTED_HTLC_SCRIPT_WEIGHT && input. witness [ 1 ] . len ( ) == 33 ) ;
2682
- let accepted_preimage_claim = input. witness . len ( ) == 5 && input. witness [ 4 ] . len ( ) == ACCEPTED_HTLC_SCRIPT_WEIGHT ;
2683
- let offered_preimage_claim = input. witness . len ( ) == 3 && input. witness [ 2 ] . len ( ) == OFFERED_HTLC_SCRIPT_WEIGHT ;
2679
+ let revocation_sig_claim = ( input. witness . len ( ) == 3 && HTLCType :: scriptlen_to_htlctype ( input. witness [ 2 ] . len ( ) ) == Some ( HTLCType :: OfferedHTLC ) && input. witness [ 1 ] . len ( ) == 33 )
2680
+ || ( input. witness . len ( ) == 3 && HTLCType :: scriptlen_to_htlctype ( input. witness [ 2 ] . len ( ) ) == Some ( HTLCType :: AcceptedHTLC ) && input. witness [ 1 ] . len ( ) == 33 ) ;
2681
+ let accepted_preimage_claim = input. witness . len ( ) == 5 && HTLCType :: scriptlen_to_htlctype ( input. witness [ 4 ] . len ( ) ) == Some ( HTLCType :: AcceptedHTLC ) ;
2682
+ let offered_preimage_claim = input. witness . len ( ) == 3 && HTLCType :: scriptlen_to_htlctype ( input. witness [ 2 ] . len ( ) ) == Some ( HTLCType :: OfferedHTLC ) ;
2684
2683
2685
2684
macro_rules! log_claim {
2686
2685
( $tx_info: expr, $local_tx: expr, $htlc: expr, $source_avail: expr) => {
@@ -2871,7 +2870,8 @@ impl ChannelMonitor {
2871
2870
for per_outp_material in cached_claim_datas. per_input_material . values ( ) {
2872
2871
match per_outp_material {
2873
2872
& InputMaterial :: Revoked { ref script, ref is_htlc, ref amount, .. } => {
2874
- inputs_witnesses_weight += Self :: get_witnesses_weight ( if !is_htlc { & [ InputDescriptors :: RevokedOutput ] } else if script. len ( ) == OFFERED_HTLC_SCRIPT_WEIGHT { & [ InputDescriptors :: RevokedOfferedHTLC ] } else if script. len ( ) == ACCEPTED_HTLC_SCRIPT_WEIGHT { & [ InputDescriptors :: RevokedReceivedHTLC ] } else { & [ ] } ) ;
2873
+ log_trace ! ( self , "Is HLTC ? {}" , is_htlc) ;
2874
+ inputs_witnesses_weight += Self :: get_witnesses_weight ( if !is_htlc { & [ InputDescriptors :: RevokedOutput ] } else if HTLCType :: scriptlen_to_htlctype ( script. len ( ) ) == Some ( HTLCType :: OfferedHTLC ) { & [ InputDescriptors :: RevokedOfferedHTLC ] } else if HTLCType :: scriptlen_to_htlctype ( script. len ( ) ) == Some ( HTLCType :: AcceptedHTLC ) { & [ InputDescriptors :: RevokedReceivedHTLC ] } else { unreachable ! ( ) } ) ;
2875
2875
amt += * amount;
2876
2876
} ,
2877
2877
& InputMaterial :: RemoteHTLC { ref preimage, ref amount, .. } => {
@@ -2911,7 +2911,7 @@ impl ChannelMonitor {
2911
2911
bumped_tx. input [ i] . witness . push ( vec ! ( 1 ) ) ;
2912
2912
}
2913
2913
bumped_tx. input [ i] . witness . push ( script. clone ( ) . into_bytes ( ) ) ;
2914
- log_trace ! ( self , "Going to broadcast bumped Penalty Transaction {} claiming revoked {} output {} from {} with new feerate {}" , bumped_tx. txid( ) , if !is_htlc { "to_local" } else if script. len( ) == OFFERED_HTLC_SCRIPT_WEIGHT { "offered" } else if script. len( ) == ACCEPTED_HTLC_SCRIPT_WEIGHT { "received" } else { "" } , outp. vout, outp. txid, new_feerate) ;
2914
+ log_trace ! ( self , "Going to broadcast bumped Penalty Transaction {} claiming revoked {} output {} from {} with new feerate {}" , bumped_tx. txid( ) , if !is_htlc { "to_local" } else if HTLCType :: scriptlen_to_htlctype ( script. len( ) ) == Some ( HTLCType :: OfferedHTLC ) { "offered" } else if HTLCType :: scriptlen_to_htlctype ( script. len( ) ) == Some ( HTLCType :: AcceptedHTLC ) { "received" } else { "" } , outp. vout, outp. txid, new_feerate) ;
2915
2915
} ,
2916
2916
& InputMaterial :: RemoteHTLC { ref script, ref key, ref preimage, ref amount, ref locktime } => {
2917
2917
if !preimage. is_some ( ) { bumped_tx. lock_time = * locktime } ;
0 commit comments