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