@@ -1562,28 +1562,30 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
15621562 self . inner . lock ( ) . unwrap ( ) . counterparty_node_id
15631563 }
15641564
1565- /// Used by [`ChannelManager`] deserialization to broadcast the latest holder state if its copy
1566- /// of the channel state was out-of-date.
1567- ///
1568- /// You may also use this to broadcast the latest local commitment transaction, either because
1565+ /// You may use this to broadcast the latest local commitment transaction, either because
15691566 /// a monitor update failed or because we've fallen behind (i.e. we've received proof that our
15701567 /// counterparty side knows a revocation secret we gave them that they shouldn't know).
15711568 ///
1572- /// Broadcasting these transactions in the second case is UNSAFE, as they allow counterparty
1569+ /// Broadcasting these transactions in this manner is UNSAFE, as they allow counterparty
15731570 /// side to punish you. Nevertheless you may want to broadcast them if counterparty doesn't
15741571 /// close channel with their commitment transaction after a substantial amount of time. Best
15751572 /// may be to contact the other node operator out-of-band to coordinate other options available
15761573 /// to you.
1577- ///
1578- /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1579- pub fn get_latest_holder_commitment_txn < L : Deref > ( & self , logger : & L ) -> Vec < Transaction >
1580- where L :: Target : Logger {
1574+ pub fn broadcast_latest_holder_commitment_txn < B : Deref , F : Deref , L : Deref > (
1575+ & self , broadcaster : & B , fee_estimator : & F , logger : & L
1576+ )
1577+ where
1578+ B :: Target : BroadcasterInterface ,
1579+ F :: Target : FeeEstimator ,
1580+ L :: Target : Logger
1581+ {
15811582 let mut inner = self . inner . lock ( ) . unwrap ( ) ;
1583+ let fee_estimator = LowerBoundedFeeEstimator :: new ( & * * fee_estimator) ;
15821584 let logger = WithChannelMonitor :: from_impl ( logger, & * inner) ;
1583- inner. get_latest_holder_commitment_txn ( & logger)
1585+ inner. queue_latest_holder_commitment_txn_for_broadcast ( broadcaster , & fee_estimator , & logger) ;
15841586 }
15851587
1586- /// Unsafe test-only version of get_latest_holder_commitment_txn used by our test framework
1588+ /// Unsafe test-only version of `broadcast_latest_holder_commitment_txn` used by our test framework
15871589 /// to bypass HolderCommitmentTransaction state update lockdown after signature and generate
15881590 /// revoked commitment transaction.
15891591 #[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
@@ -2855,7 +2857,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
28552857 } else if !self . holder_tx_signed {
28562858 log_error ! ( logger, "WARNING: You have a potentially-unsafe holder commitment transaction available to broadcast" ) ;
28572859 log_error ! ( logger, " in channel monitor for channel {}!" , & self . channel_id( ) ) ;
2858- log_error ! ( logger, " Read the docs for ChannelMonitor::get_latest_holder_commitment_txn and take manual action!" ) ;
2860+ log_error ! ( logger, " Read the docs for ChannelMonitor::broadcast_latest_holder_commitment_txn to take manual action!" ) ;
28592861 } else {
28602862 // If we generated a MonitorEvent::HolderForceClosed, the ChannelManager
28612863 // will still give us a ChannelForceClosed event with !should_broadcast, but we
@@ -3502,45 +3504,6 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35023504 }
35033505 }
35043506
3505- fn get_latest_holder_commitment_txn < L : Deref > (
3506- & mut self , logger : & WithChannelMonitor < L > ,
3507- ) -> Vec < Transaction > where L :: Target : Logger {
3508- log_debug ! ( logger, "Getting signed latest holder commitment transaction!" ) ;
3509- self . holder_tx_signed = true ;
3510- let commitment_tx = self . onchain_tx_handler . get_fully_signed_holder_tx ( & self . funding_redeemscript ) ;
3511- let txid = commitment_tx. txid ( ) ;
3512- let mut holder_transactions = vec ! [ commitment_tx] ;
3513- // When anchor outputs are present, the HTLC transactions are only valid once the commitment
3514- // transaction confirms.
3515- if self . onchain_tx_handler . channel_type_features ( ) . supports_anchors_zero_fee_htlc_tx ( ) {
3516- return holder_transactions;
3517- }
3518- for htlc in self . current_holder_commitment_tx . htlc_outputs . iter ( ) {
3519- if let Some ( vout) = htlc. 0 . transaction_output_index {
3520- let preimage = if !htlc. 0 . offered {
3521- if let Some ( preimage) = self . payment_preimages . get ( & htlc. 0 . payment_hash ) { Some ( preimage. clone ( ) ) } else {
3522- // We can't build an HTLC-Success transaction without the preimage
3523- continue ;
3524- }
3525- } else if htlc. 0 . cltv_expiry > self . best_block . height ( ) + 1 {
3526- // Don't broadcast HTLC-Timeout transactions immediately as they don't meet the
3527- // current locktime requirements on-chain. We will broadcast them in
3528- // `block_confirmed` when `should_broadcast_holder_commitment_txn` returns true.
3529- // Note that we add + 1 as transactions are broadcastable when they can be
3530- // confirmed in the next block.
3531- continue ;
3532- } else { None } ;
3533- if let Some ( htlc_tx) = self . onchain_tx_handler . get_fully_signed_htlc_tx (
3534- & :: bitcoin:: OutPoint { txid, vout } , & preimage) {
3535- holder_transactions. push ( htlc_tx) ;
3536- }
3537- }
3538- }
3539- // We throw away the generated waiting_first_conf data as we aren't (yet) confirmed and we don't actually know what the caller wants to do.
3540- // The data will be re-generated and tracked in check_spend_holder_transaction if we get a confirmation.
3541- holder_transactions
3542- }
3543-
35443507 #[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
35453508 /// Note that this includes possibly-locktimed-in-the-future transactions!
35463509 fn unsafe_get_latest_holder_commitment_txn < L : Deref > (
0 commit comments