@@ -1899,32 +1899,40 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1899
1899
self . holder_tx_signed = true ;
1900
1900
let commitment_tx = self . onchain_tx_handler . get_fully_signed_holder_tx ( & self . funding_redeemscript ) ;
1901
1901
let txid = commitment_tx. txid ( ) ;
1902
- let mut res = vec ! [ commitment_tx] ;
1902
+ let mut holder_transactions = vec ! [ commitment_tx] ;
1903
1903
for htlc in self . current_holder_commitment_tx . htlc_outputs . iter ( ) {
1904
1904
if let Some ( vout) = htlc. 0 . transaction_output_index {
1905
1905
let preimage = if !htlc. 0 . offered {
1906
1906
if let Some ( preimage) = self . payment_preimages . get ( & htlc. 0 . payment_hash ) { Some ( preimage. clone ( ) ) } else {
1907
1907
// We can't build an HTLC-Success transaction without the preimage
1908
1908
continue ;
1909
1909
}
1910
+ } else if htlc. 0 . cltv_expiry > self . best_block . height ( ) + 1 {
1911
+ // Don't broadcast HTLC-Timeout transactions immediately as they don't meet the
1912
+ // current locktime requirements on-chain. We will broadcast them in
1913
+ // `block_confirmed` when `would_broadcast_at_height` returns true.
1914
+ // Note that we add + 1 as transactions are broadcastable when they can be
1915
+ // confirmed in the next block.
1916
+ continue ;
1910
1917
} else { None } ;
1911
1918
if let Some ( htlc_tx) = self . onchain_tx_handler . get_fully_signed_htlc_tx (
1912
1919
& :: bitcoin:: OutPoint { txid, vout } , & preimage) {
1913
- res . push ( htlc_tx) ;
1920
+ holder_transactions . push ( htlc_tx) ;
1914
1921
}
1915
1922
}
1916
1923
}
1917
1924
// 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.
1918
1925
// The data will be re-generated and tracked in check_spend_holder_transaction if we get a confirmation.
1919
- return res ;
1926
+ holder_transactions
1920
1927
}
1921
1928
1922
1929
#[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
1930
+ /// Note that this includes possibly-locktimed-in-the-future transactions!
1923
1931
fn unsafe_get_latest_holder_commitment_txn < L : Deref > ( & mut self , logger : & L ) -> Vec < Transaction > where L :: Target : Logger {
1924
1932
log_trace ! ( logger, "Getting signed copy of latest holder commitment transaction!" ) ;
1925
1933
let commitment_tx = self . onchain_tx_handler . get_fully_signed_copy_holder_tx ( & self . funding_redeemscript ) ;
1926
1934
let txid = commitment_tx. txid ( ) ;
1927
- let mut res = vec ! [ commitment_tx] ;
1935
+ let mut holder_transactions = vec ! [ commitment_tx] ;
1928
1936
for htlc in self . current_holder_commitment_tx . htlc_outputs . iter ( ) {
1929
1937
if let Some ( vout) = htlc. 0 . transaction_output_index {
1930
1938
let preimage = if !htlc. 0 . offered {
@@ -1935,11 +1943,11 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1935
1943
} else { None } ;
1936
1944
if let Some ( htlc_tx) = self . onchain_tx_handler . unsafe_get_fully_signed_htlc_tx (
1937
1945
& :: bitcoin:: OutPoint { txid, vout } , & preimage) {
1938
- res . push ( htlc_tx) ;
1946
+ holder_transactions . push ( htlc_tx) ;
1939
1947
}
1940
1948
}
1941
1949
}
1942
- return res
1950
+ holder_transactions
1943
1951
}
1944
1952
1945
1953
pub fn block_connected < B : Deref , F : Deref , L : Deref > ( & mut self , header : & BlockHeader , txdata : & TransactionData , height : u32 , broadcaster : B , fee_estimator : F , logger : L ) -> Vec < TransactionOutputs >
0 commit comments