Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #2403 fixups #2423

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lightning/src/chain/chaininterface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ pub enum ConfirmationTarget {
/// A trait which should be implemented to provide feerate information on a number of time
/// horizons.
///
/// If access to a local mempool is not feasible, feerate estimates should be fetched from a set of
/// third-parties hosting them. Note that this enables them to affect the propagation of your
/// pre-signed transactions at any time and therefore endangers the safety of channels funds. It
/// should be considered carefully as a deployment.
///
/// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
/// called from inside the library in response to chain events, P2P events, or timer events).
pub trait FeeEstimator {
Expand Down
11 changes: 6 additions & 5 deletions lightning/src/chain/onchaintx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,11 +633,12 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
.compute_package_feerate(fee_estimator, conf_target, force_feerate_bump);
if let Some(input_amount_sat) = output.funding_amount {
let fee_sat = input_amount_sat - tx.output.iter().map(|output| output.value).sum::<u64>();
if compute_feerate_sat_per_1000_weight(fee_sat, tx.weight() as u64) >=
package_target_feerate_sat_per_1000_weight
{
log_debug!(logger, "Commitment transaction {} already meets required feerate {} sat/kW",
tx.txid(), package_target_feerate_sat_per_1000_weight);
let commitment_tx_feerate_sat_per_1000_weight =
compute_feerate_sat_per_1000_weight(fee_sat, tx.weight() as u64);
if commitment_tx_feerate_sat_per_1000_weight >= package_target_feerate_sat_per_1000_weight {
log_debug!(logger, "Pre-signed {} already has feerate {} sat/kW above required {} sat/kW",
log_tx!(tx), commitment_tx_feerate_sat_per_1000_weight,
package_target_feerate_sat_per_1000_weight);
return Some((new_timer, 0, OnchainClaim::Tx(tx.clone())));
}
}
Expand Down
11 changes: 4 additions & 7 deletions lightning/src/util/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,15 @@ impl<'a> core::fmt::Display for DebugBytes<'a> {
///
/// This is not exported to bindings users as fmt can't be used in C
#[doc(hidden)]
pub struct DebugIter<T: fmt::Display, I: core::iter::Iterator<Item = T> + Clone>(pub core::cell::RefCell<I>);
pub struct DebugIter<T: fmt::Display, I: core::iter::Iterator<Item = T> + Clone>(pub I);
impl<T: fmt::Display, I: core::iter::Iterator<Item = T> + Clone> fmt::Display for DebugIter<T, I> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
use core::ops::DerefMut;
write!(f, "[")?;
let iter_ref = self.0.clone();
let mut iter = iter_ref.borrow_mut();
for item in iter.deref_mut() {
let mut iter = self.0.clone();
if let Some(item) = iter.next() {
write!(f, "{}", item)?;
break;
}
for item in iter.deref_mut() {
while let Some(item) = iter.next() {
write!(f, ", {}", item)?;
}
write!(f, "]")?;
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/util/macro_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::util::logger::DebugBytes;

macro_rules! log_iter {
($obj: expr) => {
$crate::util::logger::DebugIter(core::cell::RefCell::new($obj))
$crate::util::logger::DebugIter($obj)
}
}

Expand Down