Skip to content

Commit ac75cff

Browse files
committed
Update weight units to be u64
1 parent 00906f1 commit ac75cff

File tree

10 files changed

+73
-73
lines changed

10 files changed

+73
-73
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4781,7 +4781,7 @@ mod tests {
47814781
let sig = secp_ctx.sign_ecdsa(&sighash, &privkey);
47824782
let mut ser_sig = sig.serialize_der().to_vec();
47834783
ser_sig.push(EcdsaSighashType::All as u8);
4784-
$sum_actual_sigs += ser_sig.len();
4784+
$sum_actual_sigs += ser_sig.len() as u64;
47854785
let witness = $sighash_parts.witness_mut($idx).unwrap();
47864786
witness.push(ser_sig);
47874787
if *$weight == WEIGHT_REVOKED_OUTPUT {
@@ -4823,7 +4823,7 @@ mod tests {
48234823
script_pubkey: script_pubkey.clone(),
48244824
value: 0,
48254825
});
4826-
let base_weight = claim_tx.weight();
4826+
let base_weight = claim_tx.weight().to_wu();
48274827
let inputs_weight = vec![WEIGHT_REVOKED_OUTPUT, weight_revoked_offered_htlc(channel_type_features), weight_revoked_offered_htlc(channel_type_features), weight_revoked_received_htlc(channel_type_features)];
48284828
let mut inputs_total_weight = 2; // count segwit flags
48294829
{
@@ -4833,7 +4833,7 @@ mod tests {
48334833
inputs_total_weight += inp;
48344834
}
48354835
}
4836-
assert_eq!(base_weight + inputs_total_weight as usize, claim_tx.weight() + /* max_length_sig */ (73 * inputs_weight.len() - sum_actual_sigs));
4836+
assert_eq!(base_weight + inputs_total_weight, claim_tx.weight().to_wu() + /* max_length_sig */ (73 * inputs_weight.len() as u64 - sum_actual_sigs));
48374837
}
48384838

48394839
// Claim tx with 1 offered HTLCs, 3 received HTLCs
@@ -4855,7 +4855,7 @@ mod tests {
48554855
script_pubkey: script_pubkey.clone(),
48564856
value: 0,
48574857
});
4858-
let base_weight = claim_tx.weight();
4858+
let base_weight = claim_tx.weight().to_wu();
48594859
let inputs_weight = vec![weight_offered_htlc(channel_type_features), weight_received_htlc(channel_type_features), weight_received_htlc(channel_type_features), weight_received_htlc(channel_type_features)];
48604860
let mut inputs_total_weight = 2; // count segwit flags
48614861
{
@@ -4865,7 +4865,7 @@ mod tests {
48654865
inputs_total_weight += inp;
48664866
}
48674867
}
4868-
assert_eq!(base_weight + inputs_total_weight as usize, claim_tx.weight() + /* max_length_sig */ (73 * inputs_weight.len() - sum_actual_sigs));
4868+
assert_eq!(base_weight + inputs_total_weight, claim_tx.weight().to_wu() + /* max_length_sig */ (73 * inputs_weight.len() as u64 - sum_actual_sigs));
48694869
}
48704870

48714871
// Justice tx with 1 revoked HTLC-Success tx output
@@ -4885,7 +4885,7 @@ mod tests {
48854885
script_pubkey: script_pubkey.clone(),
48864886
value: 0,
48874887
});
4888-
let base_weight = claim_tx.weight();
4888+
let base_weight = claim_tx.weight().to_wu();
48894889
let inputs_weight = vec![WEIGHT_REVOKED_OUTPUT];
48904890
let mut inputs_total_weight = 2; // count segwit flags
48914891
{
@@ -4895,7 +4895,7 @@ mod tests {
48954895
inputs_total_weight += inp;
48964896
}
48974897
}
4898-
assert_eq!(base_weight + inputs_total_weight as usize, claim_tx.weight() + /* max_length_isg */ (73 * inputs_weight.len() - sum_actual_sigs));
4898+
assert_eq!(base_weight + inputs_total_weight, claim_tx.weight().to_wu() + /* max_length_isg */ (73 * inputs_weight.len() as u64 - sum_actual_sigs));
48994899
}
49004900
}
49014901

lightning/src/chain/onchaintx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
608608
cur_height, self, output_value, self.destination_script.clone(), logger
609609
).unwrap();
610610
log_trace!(logger, "...with timer {} and feerate {}", new_timer, new_feerate);
611-
assert!(predicted_weight >= transaction.weight());
611+
assert!(predicted_weight >= transaction.weight().to_wu());
612612
return Some((new_timer, new_feerate, OnchainClaim::Tx(transaction)));
613613
}
614614
} else {
@@ -637,7 +637,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
637637
if let Some(input_amount_sat) = output.funding_amount {
638638
let fee_sat = input_amount_sat - tx.output.iter().map(|output| output.value).sum::<u64>();
639639
let commitment_tx_feerate_sat_per_1000_weight =
640-
compute_feerate_sat_per_1000_weight(fee_sat, tx.weight() as u64);
640+
compute_feerate_sat_per_1000_weight(fee_sat, tx.weight().to_wu());
641641
if commitment_tx_feerate_sat_per_1000_weight >= package_target_feerate_sat_per_1000_weight {
642642
log_debug!(logger, "Pre-signed {} already has feerate {} sat/kW above required {} sat/kW",
643643
log_tx!(tx), commitment_tx_feerate_sat_per_1000_weight,

lightning/src/chain/package.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ impl PackageTemplate {
876876

877877
locktime
878878
}
879-
pub(crate) fn package_weight(&self, destination_script: &Script) -> usize {
879+
pub(crate) fn package_weight(&self, destination_script: &Script) -> u64 {
880880
let mut inputs_weight = 0;
881881
let mut witnesses_weight = 2; // count segwit flags
882882
for (_, outp) in self.inputs.iter() {
@@ -888,7 +888,7 @@ impl PackageTemplate {
888888
let transaction_weight = 10 * WITNESS_SCALE_FACTOR;
889889
// value: 8 bytes ; var_int: 1 byte ; pk_script: `destination_script.len()`
890890
let output_weight = (8 + 1 + destination_script.len()) * WITNESS_SCALE_FACTOR;
891-
inputs_weight + witnesses_weight + transaction_weight + output_weight
891+
(inputs_weight + witnesses_weight + transaction_weight + output_weight) as u64
892892
}
893893
pub(crate) fn construct_malleable_package_with_external_funding<Signer: WriteableEcdsaChannelSigner>(
894894
&self, onchain_handler: &mut OnchainTxHandler<Signer>,
@@ -963,7 +963,7 @@ impl PackageTemplate {
963963
/// which was used to generate the value. Will not return less than `dust_limit_sats` for the
964964
/// value.
965965
pub(crate) fn compute_package_output<F: Deref, L: Deref>(
966-
&self, predicted_weight: usize, dust_limit_sats: u64, force_feerate_bump: bool,
966+
&self, predicted_weight: u64, dust_limit_sats: u64, force_feerate_bump: bool,
967967
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
968968
) -> Option<(u64, u64)>
969969
where
@@ -1111,21 +1111,21 @@ impl Readable for PackageTemplate {
11111111
///
11121112
/// [`OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep
11131113
/// [`FEERATE_FLOOR_SATS_PER_KW`]: crate::chain::chaininterface::MIN_RELAY_FEE_SAT_PER_1000_WEIGHT
1114-
fn compute_fee_from_spent_amounts<F: Deref, L: Deref>(input_amounts: u64, predicted_weight: usize, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L) -> Option<(u64, u64)>
1114+
fn compute_fee_from_spent_amounts<F: Deref, L: Deref>(input_amounts: u64, predicted_weight: u64, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L) -> Option<(u64, u64)>
11151115
where F::Target: FeeEstimator,
11161116
L::Target: Logger,
11171117
{
11181118
let sweep_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::OnChainSweep);
1119-
let fee_rate = cmp::min(sweep_feerate, compute_feerate_sat_per_1000_weight(input_amounts / 2, predicted_weight as u64)) as u64;
1120-
let fee = fee_rate * (predicted_weight as u64) / 1000;
1119+
let fee_rate = cmp::min(sweep_feerate, compute_feerate_sat_per_1000_weight(input_amounts / 2, predicted_weight));
1120+
let fee = fee_rate as u64 * (predicted_weight) / 1000;
11211121

11221122
// if the fee rate is below the floor, we don't sweep
1123-
if fee_rate < FEERATE_FLOOR_SATS_PER_KW as u64 {
1123+
if fee_rate < FEERATE_FLOOR_SATS_PER_KW {
11241124
log_error!(logger, "Failed to generate an on-chain tx with fee ({} sat/kw) was less than the floor ({} sat/kw)",
11251125
fee_rate, FEERATE_FLOOR_SATS_PER_KW);
11261126
None
11271127
} else {
1128-
Some((fee, fee_rate))
1128+
Some((fee, fee_rate as u64))
11291129
}
11301130
}
11311131

@@ -1136,7 +1136,7 @@ fn compute_fee_from_spent_amounts<F: Deref, L: Deref>(input_amounts: u64, predic
11361136
/// verify that those bumping heuristics respect BIP125 rules 3) and 4) and if required adjust the
11371137
/// new fee to meet the RBF policy requirement.
11381138
fn feerate_bump<F: Deref, L: Deref>(
1139-
predicted_weight: usize, input_amounts: u64, previous_feerate: u64, force_feerate_bump: bool,
1139+
predicted_weight: u64, input_amounts: u64, previous_feerate: u64, force_feerate_bump: bool,
11401140
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
11411141
) -> Option<(u64, u64)>
11421142
where
@@ -1148,12 +1148,12 @@ where
11481148
if new_feerate > previous_feerate {
11491149
(new_fee, new_feerate)
11501150
} else if !force_feerate_bump {
1151-
let previous_fee = previous_feerate * (predicted_weight as u64) / 1000;
1151+
let previous_fee = previous_feerate * predicted_weight / 1000;
11521152
(previous_fee, previous_feerate)
11531153
} else {
11541154
// ...else just increase the previous feerate by 25% (because that's a nice number)
11551155
let bumped_feerate = previous_feerate + (previous_feerate / 4);
1156-
let bumped_fee = bumped_feerate * (predicted_weight as u64) / 1000;
1156+
let bumped_fee = bumped_feerate * predicted_weight / 1000;
11571157
if input_amounts <= bumped_fee {
11581158
log_warn!(logger, "Can't 25% bump new claiming tx, amount {} is too small", input_amounts);
11591159
return None;
@@ -1172,8 +1172,8 @@ where
11721172
return Some((new_fee, new_feerate));
11731173
}
11741174

1175-
let previous_fee = previous_feerate * (predicted_weight as u64) / 1000;
1176-
let min_relay_fee = MIN_RELAY_FEE_SAT_PER_1000_WEIGHT * (predicted_weight as u64) / 1000;
1175+
let previous_fee = previous_feerate * predicted_weight / 1000;
1176+
let min_relay_fee = MIN_RELAY_FEE_SAT_PER_1000_WEIGHT * predicted_weight / 1000;
11771177
// BIP 125 Opt-in Full Replace-by-Fee Signaling
11781178
// * 3. The replacement transaction pays an absolute fee of at least the sum paid by the original transactions.
11791179
// * 4. The replacement transaction must also pay for its own bandwidth at or above the rate set by the node's minimum relay fee setting.
@@ -1182,7 +1182,7 @@ where
11821182
} else {
11831183
new_fee
11841184
};
1185-
Some((new_fee, new_fee * 1000 / (predicted_weight as u64)))
1185+
Some((new_fee, new_fee * 1000 / predicted_weight))
11861186
}
11871187

11881188
#[cfg(test)]
@@ -1402,27 +1402,27 @@ mod tests {
14021402
let secp_ctx = Secp256k1::new();
14031403

14041404
// (nVersion (4) + nLocktime (4) + count_tx_in (1) + prevout (36) + sequence (4) + script_length (1) + count_tx_out (1) + value (8) + var_int (1)) * WITNESS_SCALE_FACTOR + witness marker (2)
1405-
let weight_sans_output = (4 + 4 + 1 + 36 + 4 + 1 + 1 + 8 + 1) * WITNESS_SCALE_FACTOR + 2;
1405+
let weight_sans_output = (4 + 4 + 1 + 36 + 4 + 1 + 1 + 8 + 1) * WITNESS_SCALE_FACTOR as u64 + 2;
14061406

14071407
{
14081408
let revk_outp = dumb_revk_output!(secp_ctx, false);
14091409
let package = PackageTemplate::build_package(txid, 0, revk_outp, 0, 100);
1410-
assert_eq!(package.package_weight(&Script::new()), weight_sans_output + WEIGHT_REVOKED_OUTPUT as usize);
1410+
assert_eq!(package.package_weight(&Script::new()), weight_sans_output + WEIGHT_REVOKED_OUTPUT);
14111411
}
14121412

14131413
{
14141414
for channel_type_features in [ChannelTypeFeatures::only_static_remote_key(), ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies()].iter() {
14151415
let counterparty_outp = dumb_counterparty_output!(secp_ctx, 1_000_000, channel_type_features.clone());
14161416
let package = PackageTemplate::build_package(txid, 0, counterparty_outp, 1000, 100);
1417-
assert_eq!(package.package_weight(&Script::new()), weight_sans_output + weight_received_htlc(channel_type_features) as usize);
1417+
assert_eq!(package.package_weight(&Script::new()), weight_sans_output + weight_received_htlc(channel_type_features));
14181418
}
14191419
}
14201420

14211421
{
14221422
for channel_type_features in [ChannelTypeFeatures::only_static_remote_key(), ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies()].iter() {
14231423
let counterparty_outp = dumb_counterparty_offered_output!(secp_ctx, 1_000_000, channel_type_features.clone());
14241424
let package = PackageTemplate::build_package(txid, 0, counterparty_outp, 1000, 100);
1425-
assert_eq!(package.package_weight(&Script::new()), weight_sans_output + weight_offered_htlc(channel_type_features) as usize);
1425+
assert_eq!(package.package_weight(&Script::new()), weight_sans_output + weight_offered_htlc(channel_type_features));
14261426
}
14271427
}
14281428
}

lightning/src/events/bump_transaction.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ where
409409
}
410410
}
411411
let fee_to_spend_utxo = fee_for_weight(
412-
target_feerate_sat_per_1000_weight, BASE_INPUT_WEIGHT as u64 + utxo.satisfaction_weight,
412+
target_feerate_sat_per_1000_weight, BASE_INPUT_WEIGHT + utxo.satisfaction_weight,
413413
);
414414
let should_spend = if tolerate_high_network_feerates {
415415
utxo.output.value > fee_to_spend_utxo
@@ -588,7 +588,7 @@ where
588588
let must_spend = vec![Input {
589589
outpoint: anchor_descriptor.outpoint,
590590
previous_utxo: anchor_utxo,
591-
satisfaction_weight: commitment_tx.weight() as u64 + ANCHOR_INPUT_WITNESS_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT,
591+
satisfaction_weight: commitment_tx.weight().to_wu() + ANCHOR_INPUT_WITNESS_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT,
592592
}];
593593
#[cfg(debug_assertions)]
594594
let must_spend_amount = must_spend.iter().map(|input| input.previous_utxo.value).sum::<u64>();
@@ -618,7 +618,7 @@ where
618618

619619
debug_assert_eq!(anchor_tx.output.len(), 1);
620620
#[cfg(debug_assertions)]
621-
let unsigned_tx_weight = anchor_tx.weight() as u64 - (anchor_tx.input.len() as u64 * EMPTY_SCRIPT_SIG_WEIGHT);
621+
let unsigned_tx_weight = anchor_tx.weight().to_wu() - (anchor_tx.input.len() as u64 * EMPTY_SCRIPT_SIG_WEIGHT);
622622

623623
log_debug!(self.logger, "Signing anchor transaction {}", anchor_txid);
624624
anchor_tx = self.utxo_source.sign_tx(anchor_tx)?;
@@ -628,15 +628,15 @@ where
628628
anchor_tx.input[0].witness = anchor_descriptor.tx_input_witness(&anchor_sig);
629629

630630
#[cfg(debug_assertions)] {
631-
let signed_tx_weight = anchor_tx.weight() as u64;
631+
let signed_tx_weight = anchor_tx.weight().to_wu();
632632
let expected_signed_tx_weight = unsigned_tx_weight + total_satisfaction_weight;
633633
// Our estimate should be within a 1% error margin of the actual weight and we should
634634
// never underestimate.
635635
assert!(expected_signed_tx_weight >= signed_tx_weight &&
636636
expected_signed_tx_weight - (expected_signed_tx_weight / 100) <= signed_tx_weight);
637637

638638
let expected_package_fee = fee_for_weight(package_target_feerate_sat_per_1000_weight,
639-
signed_tx_weight + commitment_tx.weight() as u64);
639+
signed_tx_weight + commitment_tx.weight().to_wu());
640640
let package_fee = total_input_amount -
641641
anchor_tx.output.iter().map(|output| output.value).sum::<u64>();
642642
// Our fee should be within a 5% error margin of the expected fee based on the
@@ -704,7 +704,7 @@ where
704704
self.process_coin_selection(&mut htlc_tx, coin_selection);
705705

706706
#[cfg(debug_assertions)]
707-
let unsigned_tx_weight = htlc_tx.weight() as u64 - (htlc_tx.input.len() as u64 * EMPTY_SCRIPT_SIG_WEIGHT);
707+
let unsigned_tx_weight = htlc_tx.weight().to_wu() - (htlc_tx.input.len() as u64 * EMPTY_SCRIPT_SIG_WEIGHT);
708708

709709
log_debug!(self.logger, "Signing HTLC transaction {}", htlc_tx.txid());
710710
htlc_tx = self.utxo_source.sign_tx(htlc_tx)?;
@@ -719,7 +719,7 @@ where
719719
}
720720

721721
#[cfg(debug_assertions)] {
722-
let signed_tx_weight = htlc_tx.weight() as u64;
722+
let signed_tx_weight = htlc_tx.weight().to_wu();
723723
let expected_signed_tx_weight = unsigned_tx_weight + total_satisfaction_weight;
724724
// Our estimate should be within a 1% error margin of the actual weight and we should
725725
// never underestimate.

lightning/src/ln/chan_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ impl<'a> TrustedCommitmentTransaction<'a> {
18191819
input,
18201820
output,
18211821
};
1822-
let weight = justice_tx.weight() as u64 + WEIGHT_REVOKED_OUTPUT;
1822+
let weight = justice_tx.weight().to_wu() + WEIGHT_REVOKED_OUTPUT;
18231823
let fee = fee_for_weight(feerate_per_kw as u32, weight);
18241824
justice_tx.output[0].value = value.checked_sub(fee).ok_or(())?;
18251825
Ok(justice_tx)

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ pub fn do_check_spends<F: Fn(&bitcoin::blockdata::transaction::OutPoint) -> Opti
14151415
for output in tx.output.iter() {
14161416
total_value_out += output.value;
14171417
}
1418-
let min_fee = (tx.weight() as u64 + 3) / 4; // One sat per vbyte (ie per weight/4, rounded up)
1418+
let min_fee = (tx.weight().to_wu() as u64 + 3) / 4; // One sat per vbyte (ie per weight/4, rounded up)
14191419
// Input amount - output amount = fee, so check that out + min_fee is smaller than input
14201420
assert!(total_value_out + min_fee <= total_value_in);
14211421
tx.verify(get_output).unwrap();

lightning/src/ln/functional_tests.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7417,7 +7417,7 @@ fn test_bump_penalty_txn_on_revoked_commitment() {
74177417
assert_eq!(node_txn[0].output.len(), 1);
74187418
check_spends!(node_txn[0], revoked_txn[0]);
74197419
let fee_1 = penalty_sum - node_txn[0].output[0].value;
7420-
feerate_1 = fee_1 * 1000 / node_txn[0].weight() as u64;
7420+
feerate_1 = fee_1 * 1000 / node_txn[0].weight().to_wu();
74217421
penalty_1 = node_txn[0].txid();
74227422
node_txn.clear();
74237423
};
@@ -7437,7 +7437,7 @@ fn test_bump_penalty_txn_on_revoked_commitment() {
74377437
// Verify new bumped tx is different from last claiming transaction, we don't want spurrious rebroadcast
74387438
assert_ne!(penalty_2, penalty_1);
74397439
let fee_2 = penalty_sum - node_txn[0].output[0].value;
7440-
feerate_2 = fee_2 * 1000 / node_txn[0].weight() as u64;
7440+
feerate_2 = fee_2 * 1000 / node_txn[0].weight().to_wu();
74417441
// Verify 25% bump heuristic
74427442
assert!(feerate_2 * 100 >= feerate_1 * 125);
74437443
node_txn.clear();
@@ -7460,7 +7460,7 @@ fn test_bump_penalty_txn_on_revoked_commitment() {
74607460
// Verify new bumped tx is different from last claiming transaction, we don't want spurrious rebroadcast
74617461
assert_ne!(penalty_3, penalty_2);
74627462
let fee_3 = penalty_sum - node_txn[0].output[0].value;
7463-
feerate_3 = fee_3 * 1000 / node_txn[0].weight() as u64;
7463+
feerate_3 = fee_3 * 1000 / node_txn[0].weight().to_wu();
74647464
// Verify 25% bump heuristic
74657465
assert!(feerate_3 * 100 >= feerate_2 * 125);
74667466
node_txn.clear();
@@ -7579,7 +7579,7 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
75797579
first = node_txn[3].txid();
75807580
// Store both feerates for later comparison
75817581
let fee_1 = revoked_htlc_txn[0].output[0].value + revoked_htlc_txn[1].output[0].value - node_txn[3].output[0].value;
7582-
feerate_1 = fee_1 * 1000 / node_txn[3].weight() as u64;
7582+
feerate_1 = fee_1 * 1000 / node_txn[3].weight().to_wu();
75837583
penalty_txn = vec![node_txn[2].clone()];
75847584
node_txn.clear();
75857585
}
@@ -7603,7 +7603,7 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
76037603
// Verify bumped tx is different and 25% bump heuristic
76047604
assert_ne!(first, node_txn[0].txid());
76057605
let fee_2 = revoked_htlc_txn[0].output[0].value + revoked_htlc_txn[1].output[0].value - node_txn[0].output[0].value;
7606-
let feerate_2 = fee_2 * 1000 / node_txn[0].weight() as u64;
7606+
let feerate_2 = fee_2 * 1000 / node_txn[0].weight().to_wu();
76077607
assert!(feerate_2 * 100 > feerate_1 * 125);
76087608
let txn = vec![node_txn[0].clone()];
76097609
node_txn.clear();
@@ -7679,7 +7679,7 @@ fn test_bump_penalty_txn_on_remote_commitment() {
76797679
preimage = node_txn[0].txid();
76807680
let index = node_txn[0].input[0].previous_output.vout;
76817681
let fee = remote_txn[0].output[index as usize].value - node_txn[0].output[0].value;
7682-
feerate_preimage = fee * 1000 / node_txn[0].weight() as u64;
7682+
feerate_preimage = fee * 1000 / node_txn[0].weight().to_wu();
76837683

76847684
let (preimage_bump_tx, timeout_tx) = if node_txn[2].input[0].previous_output == node_txn[0].input[0].previous_output {
76857685
(node_txn[2].clone(), node_txn[1].clone())
@@ -7694,7 +7694,7 @@ fn test_bump_penalty_txn_on_remote_commitment() {
76947694
timeout = timeout_tx.txid();
76957695
let index = timeout_tx.input[0].previous_output.vout;
76967696
let fee = remote_txn[0].output[index as usize].value - timeout_tx.output[0].value;
7697-
feerate_timeout = fee * 1000 / timeout_tx.weight() as u64;
7697+
feerate_timeout = fee * 1000 / timeout_tx.weight().to_wu();
76987698

76997699
node_txn.clear();
77007700
};
@@ -7713,13 +7713,13 @@ fn test_bump_penalty_txn_on_remote_commitment() {
77137713

77147714
let index = preimage_bump.input[0].previous_output.vout;
77157715
let fee = remote_txn[0].output[index as usize].value - preimage_bump.output[0].value;
7716-
let new_feerate = fee * 1000 / preimage_bump.weight() as u64;
7716+
let new_feerate = fee * 1000 / preimage_bump.weight().to_wu();
77177717
assert!(new_feerate * 100 > feerate_timeout * 125);
77187718
assert_ne!(timeout, preimage_bump.txid());
77197719

77207720
let index = node_txn[0].input[0].previous_output.vout;
77217721
let fee = remote_txn[0].output[index as usize].value - node_txn[0].output[0].value;
7722-
let new_feerate = fee * 1000 / node_txn[0].weight() as u64;
7722+
let new_feerate = fee * 1000 / node_txn[0].weight().to_wu();
77237723
assert!(new_feerate * 100 > feerate_preimage * 125);
77247724
assert_ne!(preimage, node_txn[0].txid());
77257725

0 commit comments

Comments
 (0)