@@ -488,13 +488,13 @@ macro_rules! subtract_high_prio_fee {
488
488
( $self: ident, $fee_estimator: expr, $value: expr, $predicted_weight: expr, $spent_txid: expr, $used_feerate: expr) => {
489
489
{
490
490
$used_feerate = $fee_estimator. get_est_sat_per_1000_weight( ConfirmationTarget :: HighPriority ) ;
491
- let mut fee = $used_feerate * $predicted_weight / 1000 ;
491
+ let mut fee = $used_feerate * ( $predicted_weight as u64 ) / 1000 ;
492
492
if $value <= fee {
493
493
$used_feerate = $fee_estimator. get_est_sat_per_1000_weight( ConfirmationTarget :: Normal ) ;
494
- fee = $used_feerate * $predicted_weight / 1000 ;
494
+ fee = $used_feerate * ( $predicted_weight as u64 ) / 1000 ;
495
495
if $value <= fee {
496
496
$used_feerate = $fee_estimator. get_est_sat_per_1000_weight( ConfirmationTarget :: Background ) ;
497
- fee = $used_feerate * $predicted_weight / 1000 ;
497
+ fee = $used_feerate * ( $predicted_weight as u64 ) / 1000 ;
498
498
if $value <= fee {
499
499
log_error!( $self, "Failed to generate an on-chain punishment tx spending {} as even low priority fee ({} sat) was more than the entire claim balance ({} sat)" ,
500
500
$spent_txid, fee, $value) ;
@@ -602,7 +602,7 @@ impl ChannelMonitor {
602
602
}
603
603
}
604
604
605
- fn get_witnesses_weight ( inputs : & [ InputDescriptors ] ) -> u64 {
605
+ fn get_witnesses_weight ( inputs : & [ InputDescriptors ] ) -> usize {
606
606
let mut tx_weight = 2 ; // count segwit flags
607
607
for inp in inputs {
608
608
// We use expected weight (and not actual) as signatures and time lock delays may vary
@@ -3307,7 +3307,7 @@ mod tests {
3307
3307
let secp_ctx = Secp256k1 :: new ( ) ;
3308
3308
let privkey = SecretKey :: from_slice ( & hex:: decode ( "0101010101010101010101010101010101010101010101010101010101010101" ) . unwrap ( ) [ ..] ) . unwrap ( ) ;
3309
3309
let pubkey = PublicKey :: from_secret_key ( & secp_ctx, & privkey) ;
3310
- let mut sum_actual_sigs: u64 = 0 ;
3310
+ let mut sum_actual_sigs = 0 ;
3311
3311
3312
3312
macro_rules! sign_input {
3313
3313
( $sighash_parts: expr, $input: expr, $idx: expr, $amount: expr, $input_type: expr, $sum_actual_sigs: expr) => {
@@ -3323,7 +3323,7 @@ mod tests {
3323
3323
let sig = secp_ctx. sign( & sighash, & privkey) ;
3324
3324
$input. witness. push( sig. serialize_der( ) . to_vec( ) ) ;
3325
3325
$input. witness[ 0 ] . push( SigHashType :: All as u8 ) ;
3326
- sum_actual_sigs += $input. witness[ 0 ] . len( ) as u64 ;
3326
+ sum_actual_sigs += $input. witness[ 0 ] . len( ) ;
3327
3327
if * $input_type == InputDescriptors :: RevokedOutput {
3328
3328
$input. witness. push( vec!( 1 ) ) ;
3329
3329
} else if * $input_type == InputDescriptors :: RevokedOfferedHTLC || * $input_type == InputDescriptors :: RevokedReceivedHTLC {
@@ -3366,7 +3366,7 @@ mod tests {
3366
3366
for ( idx, inp) in claim_tx. input . iter_mut ( ) . zip ( inputs_des. iter ( ) ) . enumerate ( ) {
3367
3367
sign_input ! ( sighash_parts, inp. 0 , idx as u32 , 0 , inp. 1 , sum_actual_sigs) ;
3368
3368
}
3369
- assert_eq ! ( base_weight + ChannelMonitor :: get_witnesses_weight( & inputs_des[ ..] ) , claim_tx. get_weight( ) + /* max_length_sig */ ( 73 * inputs_des. len( ) as u64 - sum_actual_sigs) ) ;
3369
+ assert_eq ! ( base_weight + ChannelMonitor :: get_witnesses_weight( & inputs_des[ ..] ) , claim_tx. get_weight( ) + /* max_length_sig */ ( 73 * inputs_des. len( ) - sum_actual_sigs) ) ;
3370
3370
3371
3371
// Claim tx with 1 offered HTLCs, 3 received HTLCs
3372
3372
claim_tx. input . clear ( ) ;
@@ -3388,7 +3388,7 @@ mod tests {
3388
3388
for ( idx, inp) in claim_tx. input . iter_mut ( ) . zip ( inputs_des. iter ( ) ) . enumerate ( ) {
3389
3389
sign_input ! ( sighash_parts, inp. 0 , idx as u32 , 0 , inp. 1 , sum_actual_sigs) ;
3390
3390
}
3391
- assert_eq ! ( base_weight + ChannelMonitor :: get_witnesses_weight( & inputs_des[ ..] ) , claim_tx. get_weight( ) + /* max_length_sig */ ( 73 * inputs_des. len( ) as u64 - sum_actual_sigs) ) ;
3391
+ assert_eq ! ( base_weight + ChannelMonitor :: get_witnesses_weight( & inputs_des[ ..] ) , claim_tx. get_weight( ) + /* max_length_sig */ ( 73 * inputs_des. len( ) - sum_actual_sigs) ) ;
3392
3392
3393
3393
// Justice tx with 1 revoked HTLC-Success tx output
3394
3394
claim_tx. input . clear ( ) ;
@@ -3408,7 +3408,7 @@ mod tests {
3408
3408
for ( idx, inp) in claim_tx. input . iter_mut ( ) . zip ( inputs_des. iter ( ) ) . enumerate ( ) {
3409
3409
sign_input ! ( sighash_parts, inp. 0 , idx as u32 , 0 , inp. 1 , sum_actual_sigs) ;
3410
3410
}
3411
- assert_eq ! ( base_weight + ChannelMonitor :: get_witnesses_weight( & inputs_des[ ..] ) , claim_tx. get_weight( ) + /* max_length_isg */ ( 73 * inputs_des. len( ) as u64 - sum_actual_sigs) ) ;
3411
+ assert_eq ! ( base_weight + ChannelMonitor :: get_witnesses_weight( & inputs_des[ ..] ) , claim_tx. get_weight( ) + /* max_length_isg */ ( 73 * inputs_des. len( ) - sum_actual_sigs) ) ;
3412
3412
}
3413
3413
3414
3414
// Further testing is done in the ChannelManager integration tests.
0 commit comments