@@ -1331,6 +1331,29 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1331
1331
header, txdata, height, broadcaster, fee_estimator, logger)
1332
1332
}
1333
1333
1334
+ /// Processes a transaction that was reorganized out of the chain.
1335
+ ///
1336
+ /// Used instead of [`block_disconnected`] by clients that are notified of transactions rather
1337
+ /// than blocks. May be called before or after [`update_best_block`] for transactions in the
1338
+ /// corresponding block. See [`update_best_block`] for further calling expectations.
1339
+ ///
1340
+ /// [`block_disconnected`]: Self::block_disconnected
1341
+ /// [`update_best_block`]: Self::update_best_block
1342
+ pub fn transaction_unconfirmed < B : Deref , F : Deref , L : Deref > (
1343
+ & self ,
1344
+ txid : & Txid ,
1345
+ broadcaster : B ,
1346
+ fee_estimator : F ,
1347
+ logger : L ,
1348
+ ) where
1349
+ B :: Target : BroadcasterInterface ,
1350
+ F :: Target : FeeEstimator ,
1351
+ L :: Target : Logger ,
1352
+ {
1353
+ self . inner . lock ( ) . unwrap ( ) . transaction_unconfirmed (
1354
+ txid, broadcaster, fee_estimator, logger) ;
1355
+ }
1356
+
1334
1357
/// Updates the monitor with the current best chain tip, returning new outputs to watch. See
1335
1358
/// [`block_connected`] for details.
1336
1359
///
@@ -1339,10 +1362,14 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1339
1362
/// block.
1340
1363
///
1341
1364
/// Must be called after new blocks become available for the most recent block. Intermediary
1342
- /// blocks, however, may be safely skipped.
1365
+ /// blocks, however, may be safely skipped. For a chain reorganization, must either be:
1366
+ /// * called at at the fork point and then again for the most recent block -- intermediary
1367
+ /// blocks may be skipped as before -- or
1368
+ /// * not called in favor of calling [`transaction_unconfirmed`] for any affected transactions.
1343
1369
///
1344
1370
/// [`block_connected`]: Self::block_connected
1345
1371
/// [`transactions_confirmed`]: Self::transactions_confirmed
1372
+ /// [`transaction_unconfirmed`]: Self::transaction_unconfirmed
1346
1373
pub fn update_best_block < B : Deref , F : Deref , L : Deref > (
1347
1374
& self ,
1348
1375
header : & BlockHeader ,
@@ -2293,6 +2320,21 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2293
2320
self . best_block = BestBlock :: new ( header. prev_blockhash , height - 1 ) ;
2294
2321
}
2295
2322
2323
+ fn transaction_unconfirmed < B : Deref , F : Deref , L : Deref > (
2324
+ & mut self ,
2325
+ txid : & Txid ,
2326
+ broadcaster : B ,
2327
+ fee_estimator : F ,
2328
+ logger : L ,
2329
+ ) where
2330
+ B :: Target : BroadcasterInterface ,
2331
+ F :: Target : FeeEstimator ,
2332
+ L :: Target : Logger ,
2333
+ {
2334
+ self . onchain_events_waiting_threshold_conf . retain ( |ref entry| entry. txid != * txid) ;
2335
+ self . onchain_tx_handler . transaction_unconfirmed ( txid, broadcaster, fee_estimator, logger) ;
2336
+ }
2337
+
2296
2338
/// Filters a block's `txdata` for transactions spending watched outputs or for any child
2297
2339
/// transactions thereof.
2298
2340
fn filter_block < ' a > ( & self , txdata : & TransactionData < ' a > ) -> Vec < & ' a Transaction > {
0 commit comments