Skip to content

Commit 8a8f29a

Browse files
authored
Merge pull request #2423 from wpaulino/2403-fixups
PR #2403 fixups
2 parents 2e86a59 + c7d84d8 commit 8a8f29a

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

lightning/src/chain/chaininterface.rs

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ pub enum ConfirmationTarget {
6868
/// A trait which should be implemented to provide feerate information on a number of time
6969
/// horizons.
7070
///
71+
/// If access to a local mempool is not feasible, feerate estimates should be fetched from a set of
72+
/// third-parties hosting them. Note that this enables them to affect the propagation of your
73+
/// pre-signed transactions at any time and therefore endangers the safety of channels funds. It
74+
/// should be considered carefully as a deployment.
75+
///
7176
/// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
7277
/// called from inside the library in response to chain events, P2P events, or timer events).
7378
pub trait FeeEstimator {

lightning/src/chain/onchaintx.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -633,11 +633,12 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
633633
.compute_package_feerate(fee_estimator, conf_target, force_feerate_bump);
634634
if let Some(input_amount_sat) = output.funding_amount {
635635
let fee_sat = input_amount_sat - tx.output.iter().map(|output| output.value).sum::<u64>();
636-
if compute_feerate_sat_per_1000_weight(fee_sat, tx.weight() as u64) >=
637-
package_target_feerate_sat_per_1000_weight
638-
{
639-
log_debug!(logger, "Commitment transaction {} already meets required feerate {} sat/kW",
640-
tx.txid(), package_target_feerate_sat_per_1000_weight);
636+
let commitment_tx_feerate_sat_per_1000_weight =
637+
compute_feerate_sat_per_1000_weight(fee_sat, tx.weight() as u64);
638+
if commitment_tx_feerate_sat_per_1000_weight >= package_target_feerate_sat_per_1000_weight {
639+
log_debug!(logger, "Pre-signed {} already has feerate {} sat/kW above required {} sat/kW",
640+
log_tx!(tx), commitment_tx_feerate_sat_per_1000_weight,
641+
package_target_feerate_sat_per_1000_weight);
641642
return Some((new_timer, 0, OnchainClaim::Tx(tx.clone())));
642643
}
643644
}

lightning/src/util/logger.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,15 @@ impl<'a> core::fmt::Display for DebugBytes<'a> {
173173
///
174174
/// This is not exported to bindings users as fmt can't be used in C
175175
#[doc(hidden)]
176-
pub struct DebugIter<T: fmt::Display, I: core::iter::Iterator<Item = T> + Clone>(pub core::cell::RefCell<I>);
176+
pub struct DebugIter<T: fmt::Display, I: core::iter::Iterator<Item = T> + Clone>(pub I);
177177
impl<T: fmt::Display, I: core::iter::Iterator<Item = T> + Clone> fmt::Display for DebugIter<T, I> {
178178
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
179-
use core::ops::DerefMut;
180179
write!(f, "[")?;
181-
let iter_ref = self.0.clone();
182-
let mut iter = iter_ref.borrow_mut();
183-
for item in iter.deref_mut() {
180+
let mut iter = self.0.clone();
181+
if let Some(item) = iter.next() {
184182
write!(f, "{}", item)?;
185-
break;
186183
}
187-
for item in iter.deref_mut() {
184+
while let Some(item) = iter.next() {
188185
write!(f, ", {}", item)?;
189186
}
190187
write!(f, "]")?;

lightning/src/util/macro_logger.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::util::logger::DebugBytes;
1919

2020
macro_rules! log_iter {
2121
($obj: expr) => {
22-
$crate::util::logger::DebugIter(core::cell::RefCell::new($obj))
22+
$crate::util::logger::DebugIter($obj)
2323
}
2424
}
2525

0 commit comments

Comments
 (0)