@@ -1353,10 +1353,13 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1353
1353
// *we* sign a holder commitment transaction, not when e.g. a watchtower broadcasts one of our
1354
1354
// holder commitment transactions.
1355
1355
if self . broadcasted_holder_revokable_script . is_some ( ) {
1356
- let ( claim_reqs, _) = self . get_broadcasted_holder_claims ( & self . current_holder_commitment_tx , 0 ) ;
1356
+ // Assume that the broadcasted commitment transaction confirmed in the current best
1357
+ // block. Even if not, its a reasonable metric for the bump criteria on the HTLC
1358
+ // transactions.
1359
+ let ( claim_reqs, _) = self . get_broadcasted_holder_claims ( & self . current_holder_commitment_tx , self . best_block . height ( ) ) ;
1357
1360
self . onchain_tx_handler . update_claims_view ( & Vec :: new ( ) , claim_reqs, self . best_block . height ( ) , self . best_block . height ( ) , broadcaster, fee_estimator, logger) ;
1358
1361
if let Some ( ref tx) = self . prev_holder_signed_commitment_tx {
1359
- let ( claim_reqs, _) = self . get_broadcasted_holder_claims ( & tx, 0 ) ;
1362
+ let ( claim_reqs, _) = self . get_broadcasted_holder_claims ( & tx, self . best_block . height ( ) ) ;
1360
1363
self . onchain_tx_handler . update_claims_view ( & Vec :: new ( ) , claim_reqs, self . best_block . height ( ) , self . best_block . height ( ) , broadcaster, fee_estimator, logger) ;
1361
1364
}
1362
1365
}
@@ -1724,7 +1727,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1724
1727
// Returns (1) `PackageTemplate`s that can be given to the OnChainTxHandler, so that the handler can
1725
1728
// broadcast transactions claiming holder HTLC commitment outputs and (2) a holder revokable
1726
1729
// script so we can detect whether a holder transaction has been seen on-chain.
1727
- fn get_broadcasted_holder_claims ( & self , holder_tx : & HolderSignedTx , height : u32 ) -> ( Vec < PackageTemplate > , Option < ( Script , PublicKey , PublicKey ) > ) {
1730
+ fn get_broadcasted_holder_claims ( & self , holder_tx : & HolderSignedTx , conf_height : u32 ) -> ( Vec < PackageTemplate > , Option < ( Script , PublicKey , PublicKey ) > ) {
1728
1731
let mut claim_requests = Vec :: with_capacity ( holder_tx. htlc_outputs . len ( ) ) ;
1729
1732
1730
1733
let redeemscript = chan_utils:: get_revokeable_redeemscript ( & holder_tx. revocation_key , self . on_holder_tx_csv , & holder_tx. delayed_payment_key ) ;
@@ -1743,7 +1746,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1743
1746
} ;
1744
1747
HolderHTLCOutput :: build_accepted ( payment_preimage, htlc. amount_msat )
1745
1748
} ;
1746
- let htlc_package = PackageTemplate :: build_package ( holder_tx. txid , transaction_output_index, PackageSolvingData :: HolderHTLCOutput ( htlc_output) , height , false , height ) ;
1749
+ let htlc_package = PackageTemplate :: build_package ( holder_tx. txid , transaction_output_index, PackageSolvingData :: HolderHTLCOutput ( htlc_output) , htlc . cltv_expiry , false , conf_height ) ;
1747
1750
claim_requests. push ( htlc_package) ;
1748
1751
}
1749
1752
}
@@ -2043,6 +2046,9 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2043
2046
self . pending_monitor_events . push ( MonitorEvent :: CommitmentTxBroadcasted ( self . funding_info . 0 ) ) ;
2044
2047
let commitment_tx = self . onchain_tx_handler . get_fully_signed_holder_tx ( & self . funding_redeemscript ) ;
2045
2048
self . holder_tx_signed = true ;
2049
+ // Because we're broadcasting a commitment transaction, we should construct the package
2050
+ // assuming it gets confirmed in the next block. Sadly, we have code which considers
2051
+ // "not yet confirmed" things as discardable, so we cannot do that here.
2046
2052
let ( mut new_outpoints, _) = self . get_broadcasted_holder_claims ( & self . current_holder_commitment_tx , self . best_block . height ( ) ) ;
2047
2053
let new_outputs = self . get_broadcasted_holder_watch_outputs ( & self . current_holder_commitment_tx , & commitment_tx) ;
2048
2054
if !new_outputs. is_empty ( ) {
0 commit comments