Merge pull request #2423 from wpaulino/2403-fixups

PR #2403 fixups
This commit is contained in:
Matt Corallo 2023-07-19 17:43:30 +00:00 committed by GitHub
commit 8a8f29a8bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 13 deletions

View file

@ -68,6 +68,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 {

View file

@ -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())));
}
}

View file

@ -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, "]")?;

View file

@ -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)
}
}