@@ -919,10 +919,11 @@ impl Drop for BackgroundProcessor {
919
919
920
920
#[ cfg( all( feature = "std" , test) ) ]
921
921
mod tests {
922
- use bitcoin:: ScriptBuf ;
922
+ use bitcoin:: { ScriptBuf , Txid } ;
923
923
use bitcoin:: blockdata:: constants:: { genesis_block, ChainHash } ;
924
924
use bitcoin:: blockdata:: locktime:: absolute:: LockTime ;
925
925
use bitcoin:: blockdata:: transaction:: { Transaction , TxOut } ;
926
+ use bitcoin:: hashes:: Hash ;
926
927
use bitcoin:: network:: constants:: Network ;
927
928
use bitcoin:: secp256k1:: { SecretKey , PublicKey , Secp256k1 } ;
928
929
use lightning:: chain:: { BestBlock , Confirm , chainmonitor, Filter } ;
@@ -1731,6 +1732,21 @@ mod tests {
1731
1732
_ => panic ! ( "Unexpected status" ) ,
1732
1733
}
1733
1734
1735
+ // Check we still see the transaction as confirmed if we unconfirm any untracked
1736
+ // transaction. (We previously had a bug that would mark tracked transactions as
1737
+ // unconfirmed if any transaction at an unknown block height would be unconfirmed.)
1738
+ let unconf_txid = Txid :: from_slice ( & [ 0 ; 32 ] ) . unwrap ( ) ;
1739
+ nodes[ 0 ] . sweeper . transaction_unconfirmed ( & unconf_txid) ;
1740
+
1741
+ assert_eq ! ( nodes[ 0 ] . sweeper. tracked_spendable_outputs( ) . len( ) , 1 ) ;
1742
+ let tracked_output = nodes[ 0 ] . sweeper . tracked_spendable_outputs ( ) . first ( ) . unwrap ( ) . clone ( ) ;
1743
+ match tracked_output. status {
1744
+ OutputSpendStatus :: PendingThresholdConfirmations { latest_spending_tx, .. } => {
1745
+ assert_eq ! ( sweep_tx_2. txid( ) , latest_spending_tx. txid( ) ) ;
1746
+ }
1747
+ _ => panic ! ( "Unexpected status" ) ,
1748
+ }
1749
+
1734
1750
// Check we stop tracking the spendable outputs when one of the txs reaches
1735
1751
// ANTI_REORG_DELAY confirmations.
1736
1752
confirm_transaction_depth ( & mut nodes[ 0 ] , & sweep_tx_0, ANTI_REORG_DELAY ) ;
0 commit comments