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