You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4368,10 +4368,18 @@ impl<SP: Deref> Channel<SP> where
4368
4368
total_fee_satoshis += (-value_to_counterparty) as u64;
4369
4369
}
4370
4370
4371
+
debug_assert!(value_to_counterparty >= 0);
4372
+
if value_to_counterparty < 0 {
4373
+
return Err(ChannelError::close(format!("Value to counterparty below 0: {}", value_to_counterparty)))
4374
+
}
4371
4375
if skip_remote_output || value_to_counterparty as u64 <= self.context.holder_dust_limit_satoshis {
4372
4376
value_to_counterparty = 0;
4373
4377
}
4374
4378
4379
+
debug_assert!(value_to_holder >= 0);
4380
+
if value_to_holder < 0 {
4381
+
return Err(ChannelError::close(format!("Value to holder below 0: {}", value_to_holder)))
4382
+
}
4375
4383
if value_to_holder as u64 <= self.context.holder_dust_limit_satoshis {
4376
4384
value_to_holder = 0;
4377
4385
}
@@ -4382,7 +4390,7 @@ impl<SP: Deref> Channel<SP> where
4382
4390
let funding_outpoint = self.funding_outpoint().into_bitcoin_outpoint();
4383
4391
4384
4392
let closing_transaction = ClosingTransaction::new(value_to_holder as u64, value_to_counterparty as u64, holder_shutdown_script, counterparty_shutdown_script, funding_outpoint);
4385
-
(closing_transaction, total_fee_satoshis)
4393
+
Ok((closing_transaction, total_fee_satoshis))
4386
4394
}
4387
4395
4388
4396
fn funding_outpoint(&self) -> OutPoint {
@@ -6136,19 +6144,27 @@ impl<SP: Deref> Channel<SP> where
6136
6144
if let Some((fee, skip_remote_output, fee_range, holder_sig)) = self.context.last_sent_closing_fee.clone() {
6137
6145
debug_assert!(holder_sig.is_none());
6138
6146
log_trace!(logger, "Attempting to generate pending closing_signed...");
6139
-
let (closing_tx, fee) = self.build_closing_transaction(fee, skip_remote_output);
6140
-
let closing_signed = self.get_closing_signed_msg(&closing_tx, skip_remote_output,
let (closing_tx, total_fee_satoshis) = self.build_closing_transaction(our_min_fee, false);
6635
+
let (closing_tx, total_fee_satoshis) = self.build_closing_transaction(our_min_fee, false)?;
6620
6636
log_trace!(logger, "Proposing initial closing_signed for our counterparty with a fee range of {}-{} sat (with initial proposal {} sats)",
6621
6637
our_min_fee, our_max_fee, total_fee_satoshis);
6622
6638
@@ -6850,7 +6866,7 @@ impl<SP: Deref> Channel<SP> where
6850
6866
6851
6867
let funding_redeemscript = self.context.get_funding_redeemscript();
6852
6868
let mut skip_remote_output = false;
6853
-
let (mut closing_tx, used_total_fee) = self.build_closing_transaction(msg.fee_satoshis, skip_remote_output);
6869
+
let (mut closing_tx, used_total_fee) = self.build_closing_transaction(msg.fee_satoshis, skip_remote_output)?;
6854
6870
if used_total_fee != msg.fee_satoshis {
6855
6871
return Err(ChannelError::close(format!("Remote sent us a closing_signed with a fee other than the value they can claim. Fee in message: {}. Actual closing tx fee: {}", msg.fee_satoshis, used_total_fee)));
6856
6872
}
@@ -6862,7 +6878,7 @@ impl<SP: Deref> Channel<SP> where
6862
6878
// The remote end may have decided to revoke their output due to inconsistent dust
6863
6879
// limits, so check for that case by re-checking the signature here.
0 commit comments