Revert "Pass entropy source when queueing monitor event"
What changed, and why it matters
This commit is a straightforward code cleanup: it removes an unused 'entropy source' argument that was previously passed around when creating monitor events. The project now generates those event IDs deterministically, so the randomness source is no longer needed. There is no indication this fixes a security bug; it is an API simplification and refactoring change.
No security action required. Treat as a normal API refactor; downstream callers will need to remove the entropy_source argument when upgrading, but this is a compatibility change, not a security patch.
Security signals we found
No security-relevant behavioral change: only removes an unused parameter
Deterministic monitor event IDs already in place before this revert
No mention of vulnerability, CVE, bug bounty, or security fix in commit message
No cryptographic operation is altered; entropy source was only used for event ID randomness, which is now gone
Evidence from the diff
The change reverts an earlier commit that threaded an EntropySource through ChannelMonitor, ChainMonitor, and related interfaces so that monitor event IDs could be generated randomly. Because IDs are now produced deterministically via monitor_event_id(), the entropy_source parameter and its generic constraints are removed across public methods (block_connected, transactions_confirmed, best_block_updated, update_monitor, etc.) and internal helpers (push_monitor_event, generate_claimable_outpoints_and_watch_outputs, etc.). The Listen/Confirm tuple implementations are also simplified from 5-tuples to 4-tuples. Tests and documentation call sites are updated accordingly.
Changed components
lightning/src/chain/channelmonitor.rslightning/src/chain/chainmonitor.rslightning-block-sync/src/init.rslightning/src/util/persist.rsfuzz/src/chanmon_consistency.rslightning/src/ln/functional_tests.rslightning/src/ln/monitor_tests.rsInspect captured patch +83 / −144
### fuzz/src/chanmon_consistency.rs
@@ -1354,15 +1354,13 @@ impl<'a> HarnessNode<'a> {
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self.keys_manager,
);
monitor.best_block_updated(
header,
height,
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self.keys_manager,
);
}
let (header, txn) = chain_state.block_at(target_height);
@@ -1375,7 +1373,6 @@ impl<'a> HarnessNode<'a> {
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self.keys_manager,
);
}
}
### lightning-block-sync/src/init.rs
@@ -117,8 +117,7 @@ where
/// };
///
/// // Synchronize any channel monitors and the channel manager to be on the best block.
-/// let mut monitor_listener =
-/// (monitor, &*tx_broadcaster, &*fee_estimator, &*logger, &*entropy_source);
+/// let mut monitor_listener = (monitor, &*tx_broadcaster, &*fee_estimator, &*logger);
/// let listeners = vec![
/// (monitor_best_block, &monitor_listener as &dyn chain::Listen),
/// (manager_best_block, &manager as &dyn chain::Listen),
### lightning/src/chain/chainmonitor.rs
@@ -1210,7 +1210,6 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self._entropy_source,
);
let update_id = update.update_id;
@@ -1487,7 +1486,6 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self._entropy_source,
)
});
@@ -1515,7 +1513,6 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self._entropy_source,
);
}
}
@@ -1549,7 +1546,6 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self._entropy_source,
)
});
// Assume we may have some new events and wake the event processor
@@ -1565,7 +1561,6 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self._entropy_source,
);
}
}
@@ -1587,7 +1582,6 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self._entropy_source,
)
});
### lightning/src/chain/channelmonitor.rs
@@ -217,10 +217,7 @@ pub(super) fn monitor_event_id(event: &MonitorEvent) -> u128 {
u128::from_be_bytes(id_bytes)
}
-fn push_monitor_event<ES: EntropySource>(
- pending_monitor_events: &mut Vec<(u128, MonitorEvent)>, event: MonitorEvent,
- _entropy_source: ES,
-) {
+fn push_monitor_event(pending_monitor_events: &mut Vec<(u128, MonitorEvent)>, event: MonitorEvent) {
pending_monitor_events.push((monitor_event_id(&event), event));
}
@@ -2177,18 +2174,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
/// itself.
///
/// panics if the given update is not the next update by update_id.
- pub fn update_monitor<
- B: BroadcasterInterface,
- F: FeeEstimator,
- L: Logger,
- ES: EntropySource,
- >(
+ pub fn update_monitor<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&self, updates: &ChannelMonitorUpdate, broadcaster: &B, fee_estimator: &F, logger: &L,
- entropy_source: &ES,
) -> Result<(), ()> {
let mut inner = self.inner.lock().unwrap();
let logger = WithChannelMonitor::from_impl(logger, &*inner, None);
- inner.update_monitor(updates, broadcaster, fee_estimator, &logger, entropy_source)
+ inner.update_monitor(updates, broadcaster, fee_estimator, &logger)
}
/// Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
@@ -2484,9 +2475,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
B: BroadcasterInterface,
F: FeeEstimator,
L: Logger,
- ES: EntropySource,
>(
- &self, broadcaster: &B, fee_estimator: &F, logger: &L, entropy_source: &ES,
+ &self, broadcaster: &B, fee_estimator: &F, logger: &L,
) {
let mut inner = self.inner.lock().unwrap();
let fee_estimator = LowerBoundedFeeEstimator::new(fee_estimator);
@@ -2497,7 +2487,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
&fee_estimator,
&logger,
false,
- entropy_source,
);
}
@@ -2525,36 +2514,29 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
///
/// [`get_outputs_to_watch`]: #method.get_outputs_to_watch
#[rustfmt::skip]
- pub fn block_connected<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ pub fn block_connected<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&self,
header: &Header,
txdata: &TransactionData,
height: u32,
broadcaster: B,
fee_estimator: F,
logger: &L,
- entropy_source: &ES,
) -> Vec<TransactionOutputs> {
let mut inner = self.inner.lock().unwrap();
let logger = WithChannelMonitor::from_impl(logger, &*inner, None);
inner.block_connected(
- header, txdata, height, broadcaster, fee_estimator, &logger, entropy_source)
+ header, txdata, height, broadcaster, fee_estimator, &logger)
}
/// Determines if the disconnected block contained any transactions of interest and updates
/// appropriately.
- pub fn blocks_disconnected<
- B: BroadcasterInterface,
- F: FeeEstimator,
- L: Logger,
- ES: EntropySource,
- >(
+ pub fn blocks_disconnected<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&self, fork_point: BlockLocator, broadcaster: B, fee_estimator: F, logger: &L,
- entropy_source: &ES,
) {
let mut inner = self.inner.lock().unwrap();
let logger = WithChannelMonitor::from_impl(logger, &*inner, None);
- inner.blocks_disconnected(fork_point, broadcaster, fee_estimator, &logger, entropy_source)
+ inner.blocks_disconnected(fork_point, broadcaster, fee_estimator, &logger)
}
/// Processes transactions confirmed in a block with the given header and height, returning new
@@ -2565,21 +2547,20 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
///
/// [`block_connected`]: Self::block_connected
#[rustfmt::skip]
- pub fn transactions_confirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ pub fn transactions_confirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&self,
header: &Header,
txdata: &TransactionData,
height: u32,
broadcaster: B,
fee_estimator: F,
logger: &L,
- entropy_source: &ES,
) -> Vec<TransactionOutputs> {
let bounded_fee_estimator = LowerBoundedFeeEstimator::new(fee_estimator);
let mut inner = self.inner.lock().unwrap();
let logger = WithChannelMonitor::from_impl(logger, &*inner, None);
inner.transactions_confirmed(
- header, txdata, height, broadcaster, &bounded_fee_estimator, &logger, entropy_source)
+ header, txdata, height, broadcaster, &bounded_fee_estimator, &logger)
}
/// Processes a transaction that was reorganized out of the chain.
@@ -2589,19 +2570,18 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
///
/// [`blocks_disconnected`]: Self::blocks_disconnected
#[rustfmt::skip]
- pub fn transaction_unconfirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ pub fn transaction_unconfirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&self,
txid: &Txid,
broadcaster: B,
fee_estimator: F,
logger: &L,
- entropy_source: &ES,
) {
let bounded_fee_estimator = LowerBoundedFeeEstimator::new(fee_estimator);
let mut inner = self.inner.lock().unwrap();
let logger = WithChannelMonitor::from_impl(logger, &*inner, None);
inner.transaction_unconfirmed(
- txid, broadcaster, &bounded_fee_estimator, &logger, entropy_source
+ txid, broadcaster, &bounded_fee_estimator, &logger
);
}
@@ -2613,20 +2593,19 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
///
/// [`block_connected`]: Self::block_connected
#[rustfmt::skip]
- pub fn best_block_updated<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ pub fn best_block_updated<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&self,
header: &Header,
height: u32,
broadcaster: B,
fee_estimator: F,
logger: &L,
- entropy_source: &ES,
) -> Vec<TransactionOutputs> {
let bounded_fee_estimator = LowerBoundedFeeEstimator::new(fee_estimator);
let mut inner = self.inner.lock().unwrap();
let logger = WithChannelMonitor::from_impl(logger, &*inner, None);
inner.best_block_updated(
- header, height, broadcaster, &bounded_fee_estimator, &logger, entropy_source
+ header, height, broadcaster, &bounded_fee_estimator, &logger
)
}
@@ -4059,9 +4038,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
}
#[rustfmt::skip]
- fn generate_claimable_outpoints_and_watch_outputs<ES: EntropySource>(
+ fn generate_claimable_outpoints_and_watch_outputs(
&mut self, generate_monitor_event_with_reason: Option<ClosureReason>,
- require_funding_seen: bool, entropy_source: ES,
+ require_funding_seen: bool,
) -> (Vec<PackageTemplate>, Vec<TransactionOutputs>) {
let funding = get_confirmed_funding_scope!(self);
let holder_commitment_tx = &funding.current_holder_commitment_tx;
@@ -4082,7 +4061,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
outpoint: funding_outpoint,
channel_id: self.channel_id,
};
- push_monitor_event(&mut self.pending_monitor_events, event, entropy_source);
+ push_monitor_event(&mut self.pending_monitor_events, event);
}
// Although we aren't signing the transaction directly here, the transaction will be signed
@@ -4133,16 +4112,16 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
/// See also [`ChannelMonitor::broadcast_latest_holder_commitment_txn`].
///
/// [`ChannelMonitor::broadcast_latest_holder_commitment_txn`]: crate::chain::channelmonitor::ChannelMonitor::broadcast_latest_holder_commitment_txn
- pub(crate) fn queue_latest_holder_commitment_txn_for_broadcast<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ pub(crate) fn queue_latest_holder_commitment_txn_for_broadcast<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&mut self, broadcaster: &B, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &WithContext<L>,
- require_funding_seen: bool, entropy_source: &ES,
+ require_funding_seen: bool,
) {
let reason = ClosureReason::HolderForceClosed {
broadcasted_latest_txn: Some(true),
message: "ChannelMonitor-initiated commitment transaction broadcast".to_owned(),
};
let (claimable_outpoints, _) =
- self.generate_claimable_outpoints_and_watch_outputs(Some(reason), require_funding_seen, entropy_source);
+ self.generate_claimable_outpoints_and_watch_outputs(Some(reason), require_funding_seen);
// In manual-broadcast mode, if `require_funding_seen` is true and we have not yet observed
// the funding transaction on-chain, do not queue any transactions.
if require_funding_seen && self.is_manual_broadcast && !self.funding_seen_onchain {
@@ -4369,9 +4348,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
}
#[rustfmt::skip]
- fn update_monitor<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
- &mut self, updates: &ChannelMonitorUpdate, broadcaster: &B, fee_estimator: &F, logger: &WithContext<L>,
- entropy_source: &ES,
+ fn update_monitor<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
+ &mut self, updates: &ChannelMonitorUpdate, broadcaster: &B, fee_estimator: &F, logger: &WithContext<L>
) -> Result<(), ()> {
if self.latest_update_id == LEGACY_CLOSED_CHANNEL_UPDATE_ID && updates.update_id == LEGACY_CLOSED_CHANNEL_UPDATE_ID {
log_info!(logger, "Applying pre-0.1 post-force-closed update to monitor {} with {} change(s).",
@@ -4496,7 +4474,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
ChannelMonitorUpdateStep::ChannelForceClosed { should_broadcast, counterparty_failed_htlcs } => {
log_trace!(logger, "Updating ChannelMonitor: channel force closed, should broadcast: {}", should_broadcast);
self.lockdown_from_offchain = true;
- self.fail_counterparty_failed_htlcs(counterparty_failed_htlcs, logger, entropy_source);
+ self.fail_counterparty_failed_htlcs(counterparty_failed_htlcs, logger);
if *should_broadcast {
// There's no need to broadcast our commitment transaction if we've seen one
// confirmed (even with 1 confirmation) as it'll be rejected as
@@ -4508,7 +4486,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
log_trace!(logger, "Avoiding commitment broadcast, already detected confirmed spend onchain");
continue;
}
- self.queue_latest_holder_commitment_txn_for_broadcast(broadcaster, &bounded_fee_estimator, logger, true, entropy_source);
+ self.queue_latest_holder_commitment_txn_for_broadcast(broadcaster, &bounded_fee_estimator, logger, true);
} else if !self.holder_tx_signed {
log_error!(logger, "WARNING: You have a potentially-unsafe holder commitment transaction available to broadcast");
log_error!(logger, " in channel monitor!");
@@ -4554,7 +4532,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
htlc_outputs.iter().filter_map(|(htlc, source)| {
source.as_ref().map(|s| (&**s, htlc.payment_hash, htlc.amount_msat))
}),
- logger, entropy_source
+ logger,
);
},
ChannelMonitorUpdateStep::LatestCounterpartyCommitment {
@@ -4581,7 +4559,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
});
self.fail_htlcs_from_update_after_funding_spend(
nondust.chain(dust),
- logger, entropy_source,
+ logger,
);
},
_ => {},
@@ -4642,9 +4620,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
/// the counterparty can still claim them on-chain. They are instead resolved on-chain or, for
/// forwarded HTLCs, failed backwards as the inbound HTLCs approach expiry, like any other HTLC
/// we track.
- fn fail_counterparty_failed_htlcs<L: Logger, ES: EntropySource>(
+ fn fail_counterparty_failed_htlcs<L: Logger>(
&mut self, htlcs: &[(HTLCSource, PaymentHash)], logger: &WithContext<L>,
- entropy_source: &ES,
) {
let in_counterparty_commitment = |source: &HTLCSource| {
[
@@ -4700,7 +4677,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
payment_hash: *payment_hash,
htlc_value_satoshis,
}),
- entropy_source,
);
}
}
@@ -4716,9 +4692,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
/// Only truly new HTLCs (not present in any previously-known commitment) need to be failed
/// here. HTLCs that were already tracked by the monitor will be handled by the existing
/// `fail_unbroadcast_htlcs` logic when the spending transaction confirms.
- fn fail_htlcs_from_update_after_funding_spend<'a, L: Logger, ES: EntropySource>(
+ fn fail_htlcs_from_update_after_funding_spend<'a, L: Logger>(
&mut self, htlcs: impl Iterator<Item = (&'a HTLCSource, PaymentHash, u64)>,
- logger: &WithContext<L>, entropy_source: &ES,
+ logger: &WithContext<L>,
) {
let pending_spend_entry = self
.onchain_events_awaiting_threshold_conf
@@ -4790,7 +4766,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
source: source.clone(),
htlc_value_satoshis,
}),
- entropy_source,
);
self.htlcs_resolved_on_chain.push(IrrevocablyResolvedHTLC {
commitment_tx_output_idx: None,
@@ -4856,8 +4831,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
&self.outputs_to_watch
}
- fn push_monitor_event<ES: EntropySource>(&mut self, event: MonitorEvent, entropy_source: ES) {
- push_monitor_event(&mut self.pending_monitor_events, event, entropy_source);
+ fn push_monitor_event(&mut self, event: MonitorEvent) {
+ push_monitor_event(&mut self.pending_monitor_events, event);
}
fn ack_monitor_event(&mut self, event_id: u128) {
@@ -5729,30 +5704,29 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
}
#[rustfmt::skip]
- fn block_connected<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ fn block_connected<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&mut self, header: &Header, txdata: &TransactionData, height: u32, broadcaster: B,
- fee_estimator: F, logger: &WithContext<L>, entropy_source: &ES
+ fee_estimator: F, logger: &WithContext<L>,
) -> Vec<TransactionOutputs> {
let bounded_fee_estimator = LowerBoundedFeeEstimator::new(fee_estimator);
- self.transactions_confirmed(header, txdata, height, broadcaster, &bounded_fee_estimator, logger, entropy_source)
+ self.transactions_confirmed(header, txdata, height, broadcaster, &bounded_fee_estimator, logger)
}
#[rustfmt::skip]
- fn best_block_updated<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ fn best_block_updated<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&mut self,
header: &Header,
height: u32,
broadcaster: B,
fee_estimator: &LowerBoundedFeeEstimator<F>,
logger: &WithContext<L>,
- entropy_source: &ES,
) -> Vec<TransactionOutputs> {
let block_hash = header.block_hash();
if height > self.best_block.height {
self.best_block.update_for_new_tip(block_hash, height);
log_trace!(logger, "Connecting new block {} at height {}", block_hash, height);
- self.block_confirmed(height, block_hash, vec![], vec![], vec![], &broadcaster, &fee_estimator, logger, entropy_source)
+ self.block_confirmed(height, block_hash, vec![], vec![], vec![], &broadcaster, &fee_estimator, logger)
} else if block_hash != self.best_block.block_hash {
self.best_block = BlockLocator::new(block_hash, height);
log_trace!(logger, "Best block re-orged, replaced with new block {} at height {}", block_hash, height);
@@ -5767,15 +5741,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
}
#[rustfmt::skip]
- fn transactions_confirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ fn transactions_confirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&mut self,
header: &Header,
txdata: &TransactionData,
height: u32,
broadcaster: B,
fee_estimator: &LowerBoundedFeeEstimator<F>,
logger: &WithContext<L>,
- entropy_source: &ES,
) -> Vec<TransactionOutputs> {
let funding_seen_before = self.funding_seen_onchain;
let txn_matched = self.filter_block(txdata);
@@ -5950,7 +5923,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
);
log_info!(logger, "Channel closed by funding output spend in txid {txid}");
if !self.funding_spend_seen {
- self.push_monitor_event(MonitorEvent::CommitmentTxConfirmed(()), entropy_source);
+ self.push_monitor_event(MonitorEvent::CommitmentTxConfirmed(()));
}
self.funding_spend_seen = true;
@@ -6025,7 +5998,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
break;
}
}
- self.is_resolving_htlc_output(&tx, height, &block_hash, logger, entropy_source);
+ self.is_resolving_htlc_output(&tx, height, &block_hash, logger);
// Note that if the funding transaction (or some arbitrary dependent of the funding
// transaction or some HTLC transaction) spends to the `destination_script` or
@@ -6040,12 +6013,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
if should_broadcast_commitment {
let (mut claimables, mut outputs) =
- self.generate_claimable_outpoints_and_watch_outputs(None, false, entropy_source);
+ self.generate_claimable_outpoints_and_watch_outputs(None, false);
claimable_outpoints.append(&mut claimables);
watch_outputs.append(&mut outputs);
}
- self.block_confirmed(height, block_hash, txn_matched, watch_outputs, claimable_outpoints, &broadcaster, &fee_estimator, logger, entropy_source)
+ self.block_confirmed(height, block_hash, txn_matched, watch_outputs, claimable_outpoints, &broadcaster, &fee_estimator, logger)
}
/// Update state for new block(s)/transaction(s) confirmed. Note that the caller must update
@@ -6057,7 +6030,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
/// `conf_height` should be set to the height at which any new transaction(s)/block(s) were
/// confirmed at, even if it is not the current best height.
#[rustfmt::skip]
- fn block_confirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ fn block_confirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&mut self,
conf_height: u32,
conf_hash: BlockHash,
@@ -6067,7 +6040,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
broadcaster: &B,
fee_estimator: &LowerBoundedFeeEstimator<F>,
logger: &WithContext<L>,
- entropy_source: &ES,
) -> Vec<TransactionOutputs> {
log_trace!(logger, "Processing {} matched transactions for block at height {}.", txn_matched.len(), conf_height);
debug_assert!(self.best_block.height >= conf_height);
@@ -6078,7 +6050,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
if let Some(payment_hash) = should_broadcast {
let reason = ClosureReason::HTLCsTimedOut { payment_hash: Some(payment_hash) };
let (mut new_outpoints, mut new_outputs) =
- self.generate_claimable_outpoints_and_watch_outputs(Some(reason), false, entropy_source);
+ self.generate_claimable_outpoints_and_watch_outputs(Some(reason), false);
if !self.is_manual_broadcast || self.funding_seen_onchain {
claimable_outpoints.append(&mut new_outpoints);
watch_outputs.append(&mut new_outputs);
@@ -6133,7 +6105,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
payment_preimage: None,
source,
htlc_value_satoshis,
- }), entropy_source);
+ }));
self.htlcs_resolved_on_chain.push(IrrevocablyResolvedHTLC {
commitment_tx_output_idx,
resolving_txid: Some(entry.txid),
@@ -6242,7 +6214,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
payment_preimage: None,
payment_hash: htlc.payment_hash,
htlc_value_satoshis: htlc.amount_msat / 1000,
- }), entropy_source);
+ }));
}
}
}
@@ -6281,9 +6253,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
}
#[rustfmt::skip]
- fn blocks_disconnected<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
- &mut self, fork_point: BlockLocator, broadcaster: B, fee_estimator: F, logger: &WithContext<L>,
- entropy_source: &ES,
+ fn blocks_disconnected<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
+ &mut self, fork_point: BlockLocator, broadcaster: B, fee_estimator: F, logger: &WithContext<L>
) {
let new_height = fork_point.height;
log_trace!(logger, "Block(s) disconnected to height {}", new_height);
@@ -6328,20 +6299,19 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
// Only attempt to broadcast the new commitment after the `block_disconnected` call above so that
// it doesn't get removed from the set of pending claims.
if should_broadcast_commitment {
- self.queue_latest_holder_commitment_txn_for_broadcast(&broadcaster, &bounded_fee_estimator, logger, true, entropy_source);
+ self.queue_latest_holder_commitment_txn_for_broadcast(&broadcaster, &bounded_fee_estimator, logger, true);
}
self.best_block = fork_point;
}
#[rustfmt::skip]
- fn transaction_unconfirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger, ES: EntropySource>(
+ fn transaction_unconfirmed<B: BroadcasterInterface, F: FeeEstimator, L: Logger>(
&mut self,
txid: &Txid,
broadcaster: B,
fee_estimator: &LowerBoundedFeeEstimator<F>,
logger: &WithContext<L>,
- entropy_source: &ES,
) {
let mut removed_height = None;
for entry in self.onchain_events_awaiting_threshold_conf.iter() {
@@ -6391,7 +6361,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
// Only attempt to broadcast the new commitment after the `transaction_unconfirmed` call above so
// that it doesn't get removed from the set of pending claims.
if should_broadcast_commitment {
- self.queue_latest_holder_commitment_txn_for_broadcast(&broadcaster, fee_estimator, logger, true, entropy_source);
+ self.queue_latest_holder_commitment_txn_for_broadcast(&broadcaster, fee_estimator, logger, true);
}
}
@@ -6536,9 +6506,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
/// Check if any transaction broadcasted is resolving HTLC output by a success or timeout on a holder
/// or counterparty commitment tx, if so send back the source, preimage if found and payment_hash of resolved HTLC
#[rustfmt::skip]
- fn is_resolving_htlc_output<L: Logger, ES: EntropySource>(
+ fn is_resolving_htlc_output<L: Logger>(
&mut self, tx: &Transaction, height: u32, block_hash: &BlockHash, logger: &WithContext<L>,
- entropy_source: &ES,
) {
let funding_spent = get_confirmed_funding_scope!(self);
@@ -6730,7 +6699,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
payment_preimage: Some(payment_preimage),
payment_hash,
htlc_value_satoshis: amount_msat / 1000,
- }), entropy_source);
+ }));
}
} else {
self.onchain_events_awaiting_threshold_conf.retain(|ref entry| {
@@ -6831,44 +6800,33 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
}
}
-impl<
- Signer: EcdsaChannelSigner,
- T: BroadcasterInterface,
- F: FeeEstimator,
- L: Logger,
- ES: EntropySource,
- > chain::Listen for (ChannelMonitor<Signer>, T, F, L, ES)
+impl<Signer: EcdsaChannelSigner, T: BroadcasterInterface, F: FeeEstimator, L: Logger> chain::Listen
+ for (ChannelMonitor<Signer>, T, F, L)
{
fn filtered_block_connected(&self, header: &Header, txdata: &TransactionData, height: u32) {
- self.0.block_connected(header, txdata, height, &self.1, &self.2, &self.3, &self.4);
+ self.0.block_connected(header, txdata, height, &self.1, &self.2, &self.3);
}
fn blocks_disconnected(&self, fork_point: BlockLocator) {
- self.0.blocks_disconnected(fork_point, &self.1, &self.2, &self.3, &self.4);
+ self.0.blocks_disconnected(fork_point, &self.1, &self.2, &self.3);
}
}
-impl<
- Signer: EcdsaChannelSigner,
- M,
- T: BroadcasterInterface,
- F: FeeEstimator,
- L: Logger,
- ES: EntropySource,
- > chain::Confirm for (M, T, F, L, ES)
+impl<Signer: EcdsaChannelSigner, M, T: BroadcasterInterface, F: FeeEstimator, L: Logger>
+ chain::Confirm for (M, T, F, L)
where
M: Deref<Target = ChannelMonitor<Signer>>,
{
fn transactions_confirmed(&self, header: &Header, txdata: &TransactionData, height: u32) {
- self.0.transactions_confirmed(header, txdata, height, &self.1, &self.2, &self.3, &self.4);
+ self.0.transactions_confirmed(header, txdata, height, &self.1, &self.2, &self.3);
}
fn transaction_unconfirmed(&self, txid: &Txid) {
- self.0.transaction_unconfirmed(txid, &self.1, &self.2, &self.3, &self.4);
+ self.0.transaction_unconfirmed(txid, &self.1, &self.2, &self.3);
}
fn best_block_updated(&self, header: &Header, height: u32) {
- self.0.best_block_updated(header, height, &self.1, &self.2, &self.3, &self.4);
+ self.0.best_block_updated(header, height, &self.1, &self.2, &self.3);
}
fn get_relevant_txids(&self) -> Vec<(Txid, u32, Option<BlockHash>)> {
@@ -7565,7 +7523,7 @@ mod tests {
let broadcaster = TestBroadcaster::with_blocks(Arc::clone(&nodes[1].blocks));
assert!(
- pre_update_monitor.update_monitor(&replay_update, &&broadcaster, &&chanmon_cfgs[1].fee_estimator, &nodes[1].logger, &nodes[1].keys_manager)
+ pre_update_monitor.update_monitor(&replay_update, &&broadcaster, &&chanmon_cfgs[1].fee_estimator, &nodes[1].logger)
.is_err());
// Even though we error'd on the first update, we should still have generated an HTLC claim
### lightning/src/ln/functional_tests.rs
@@ -10078,7 +10078,6 @@ fn do_test_manual_broadcast_skips_commitment_until_funding(
&nodes[0].tx_broadcaster,
&nodes[0].fee_estimator,
&nodes[0].logger,
- &nodes[0].keys_manager,
);
} else {
mine_transaction(&nodes[0], &funding_tx);
### lightning/src/ln/monitor_tests.rs
@@ -339,8 +339,7 @@ fn archive_monitor_with_pending_closure_event() {
// Broadcast nodes[1]'s commitment transaction via the `ChannelMonitor` directly, so that the
// only indication of the closure the `ChannelManager` will ever get is the `MonitorEvent`.
get_monitor!(nodes[1], chan_id).broadcast_latest_holder_commitment_txn(
- &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger,
- &nodes[1].keys_manager,
+ &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger
);
let commitment_tx = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
assert_eq!(commitment_tx.len(), 1);
@@ -3246,8 +3245,7 @@ fn do_test_monitor_claims_with_random_signatures(keyed_anchors: bool, p2a_anchor
};
get_monitor!(closing_node, chan_id).broadcast_latest_holder_commitment_txn(
- &closing_node.tx_broadcaster, &closing_node.fee_estimator, &closing_node.logger,
- &closing_node.keys_manager,
+ &closing_node.tx_broadcaster, &closing_node.fee_estimator, &closing_node.logger
);
if keyed_anchors || p2a_anchor {
handle_bump_close_event(&closing_node);
@@ -3405,7 +3403,7 @@ fn test_update_replay_panics() {
// Update `monitor` until there's just one normal updates, an FC update, and a post-FC claim
// update pending
for update in updates.drain(..updates.len() - 4) {
- monitor.update_monitor(&update, &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger, &nodes[1].keys_manager).unwrap();
+ monitor.update_monitor(&update, &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger).unwrap();
}
assert_eq!(updates.len(), 4);
assert!(matches!(updates[1].updates[0], ChannelMonitorUpdateStep::ChannelForceClosed { .. }));
@@ -3415,31 +3413,31 @@ fn test_update_replay_panics() {
// Ensure applying the force-close update skipping the last normal update fails
let poisoned_monitor = monitor.clone();
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
- let _ = poisoned_monitor.update_monitor(&updates[1], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger, &nodes[1].keys_manager);
+ let _ = poisoned_monitor.update_monitor(&updates[1], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger);
// We should panic, rather than returning an error here.
})).unwrap_err();
// Then apply the last normal and force-close update and make sure applying the preimage
// updates out-of-order fails.
- monitor.update_monitor(&updates[0], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger, &nodes[1].keys_manager).unwrap();
- monitor.update_monitor(&updates[1], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger, &nodes[1].keys_manager).unwrap();
+ monitor.update_monitor(&updates[0], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger).unwrap();
+ monitor.update_monitor(&updates[1], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger).unwrap();
let poisoned_monitor = monitor.clone();
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
- let _ = poisoned_monitor.update_monitor(&updates[3], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger, &nodes[1].keys_manager);
+ let _ = poisoned_monitor.update_monitor(&updates[3], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger);
// We should panic, rather than returning an error here.
})).unwrap_err();
// Make sure re-applying the force-close update fails
let poisoned_monitor = monitor.clone();
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
- let _ = poisoned_monitor.update_monitor(&updates[1], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger, &nodes[1].keys_manager);
+ let _ = poisoned_monitor.update_monitor(&updates[1], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger);
// We should panic, rather than returning an error here.
})).unwrap_err();
// ...and finally ensure that applying all the updates succeeds.
- monitor.update_monitor(&updates[2], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger, &nodes[1].keys_manager).unwrap();
- monitor.update_monitor(&updates[3], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger, &nodes[1].keys_manager).unwrap();
+ monitor.update_monitor(&updates[2], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger).unwrap();
+ monitor.update_monitor(&updates[3], &nodes[1].tx_broadcaster, &nodes[1].fee_estimator, &nodes[1].logger).unwrap();
}
#[test]
### lightning/src/util/persist.rs
@@ -1543,23 +1543,17 @@ impl<
for (update_name, update_res) in MultiResultFuturePoller::new(update_futures).await {
let update = update_res?;
monitor
- .update_monitor(
- &update,
- &self.broadcaster,
- &self.fee_estimator,
- &self.logger,
- &self.entropy_source,
- )
+ .update_monitor(&update, &self.broadcaster, &self.fee_estimator, &self.logger)
.map_err(|e| {
- log_error!(
- self.logger,
- "Monitor update failed. monitor: {} update: {} reason: {:?}",
- monitor_key,
- update_name.as_str(),
- e
- );
- io::Error::new(io::ErrorKind::Other, "Monitor update failed")
- })?;
+ log_error!(
+ self.logger,
+ "Monitor update failed. monitor: {} update: {} reason: {:?}",
+ monitor_key,
+ update_name.as_str(),
+ e
+ );
+ io::Error::new(io::ErrorKind::Other, "Monitor update failed")
+ })?;
}
Ok(Some((best_block, monitor)))
}Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.