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
When the `TxBuilder` API is made public in the future, this trait method
will let implementers build custom commitment transactions as part of
the lightning state machine.
if $htlc.is_dust(local, feerate_per_kw, broadcaster_dust_limit_sat, funding.get_channel_type()) {
4570
-
log_trace!(logger, " ...including {} {} dust HTLC {} (hash {}) with value {} due to dust limit", if $outbound { "outbound" } else { "inbound" }, $htlc.state, $htlc.htlc_id, $htlc.payment_hash, $htlc.amount_msat);
4571
-
} else {
4572
-
log_trace!(logger, " ...including {} {} HTLC {} (hash {}) with value {}", if $outbound { "outbound" } else { "inbound" }, $htlc.state, $htlc.htlc_id, $htlc.payment_hash, $htlc.amount_msat);
4573
-
nondust_htlcs.push(htlc_in_tx);
4574
-
}
4562
+
let htlc = get_htlc_in_commitment!($htlc, $outbound == local);
4563
+
htlcs_included.push((htlc, $source));
4575
4564
}
4576
4565
}
4577
4566
@@ -4580,11 +4569,13 @@ where
4580
4569
4581
4570
for htlc in self.pending_inbound_htlcs.iter() {
4582
4571
if htlc.state.included_in_commitment(generated_by_local) {
4572
+
log_trace!(logger, " ...including inbound {} HTLC {} (hash {}) with value {}", htlc.state, htlc.htlc_id, htlc.payment_hash, htlc.amount_msat);
4583
4573
add_htlc_output!(htlc, false, None);
4584
4574
} else {
4585
4575
log_trace!(logger, " ...not including inbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, htlc.payment_hash, htlc.amount_msat, htlc.state);
4586
4576
if let Some(preimage) = htlc.state.preimage() {
4587
4577
inbound_htlc_preimages.push(preimage);
4578
+
value_to_self_claimed_msat += htlc.amount_msat;
4588
4579
}
4589
4580
}
4590
4581
};
@@ -4594,53 +4585,35 @@ where
4594
4585
outbound_htlc_preimages.push(preimage);
4595
4586
}
4596
4587
if htlc.state.included_in_commitment(generated_by_local) {
4588
+
log_trace!(logger, " ...including outbound {} HTLC {} (hash {}) with value {}", htlc.state, htlc.htlc_id, htlc.payment_hash, htlc.amount_msat);
4597
4589
add_htlc_output!(htlc, true, Some(&htlc.source));
4598
4590
} else {
4599
4591
log_trace!(logger, " ...not including outbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, htlc.payment_hash, htlc.amount_msat, htlc.state);
4592
+
if htlc.state.preimage().is_some() {
4593
+
value_to_remote_claimed_msat += htlc.amount_msat;
4594
+
}
4600
4595
}
4601
4596
};
4602
4597
4603
-
// We MUST use saturating subs here, as the funder's balance is not guaranteed to be greater
4604
-
// than or equal to `commit_tx_fee_sat`.
4598
+
// # Panics
4605
4599
//
4606
-
// This is because when the remote party sends an `update_fee` message, we build the new
4607
-
// commitment transaction *before* checking whether the remote party's balance is enough to
4608
-
// cover the total fee.
4609
-
4610
-
let (value_to_self, value_to_remote) = if funding.is_outbound() {
log_trace!(logger," ...trimming {} HTLC with value {}sat, hash {}, due to dust limit {}",if htlc.offered == local {"outbound"} else {"inbound"}, htlc.amount_msat / 1000, htlc.payment_hash, broadcaster_dust_limit_sat);
111
+
false
112
+
}else{
113
+
true
114
+
}
115
+
});
116
+
117
+
// # Panics
118
+
//
119
+
// The value going to each party MUST be 0 or positive, even if all HTLCs pending in the
120
+
// commitment clear by failure.
121
+
122
+
let commit_tx_fee_sat = self.commit_tx_fee_sat(feerate_per_kw, htlcs_in_tx.len(),&channel_parameters.channel_type_features);
123
+
let value_to_self_after_htlcs_msat = value_to_self_msat.checked_sub(local_htlc_total_msat).unwrap();
0 commit comments