From 9656c8e7907c6e88eae4003a2e759c548dffb51d Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Thu, 2 Nov 2023 16:35:41 +1100 Subject: [PATCH] Load ChainMonitor in (DLC) Manager constructor if possible Otherwise we forget about all the registered transactions on restart, which can lead to loss of funds. --- dlc-manager/src/manager.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dlc-manager/src/manager.rs b/dlc-manager/src/manager.rs index 9614da1f..8cda0681 100644 --- a/dlc-manager/src/manager.rs +++ b/dlc-manager/src/manager.rs @@ -174,6 +174,10 @@ where time: T, fee_estimator: F, ) -> Result { + let chain_monitor = store + .get_chain_monitor()? + .unwrap_or(ChainMonitor::new(blockchain.get_blockchain_height()?)); + Ok(Manager { secp: secp256k1_zkp::Secp256k1::new(), wallet, @@ -181,7 +185,7 @@ where oracles, time, fee_estimator, - chain_monitor: Mutex::new(ChainMonitor::new(blockchain.get_blockchain_height()?)), + chain_monitor: Mutex::new(chain_monitor), blockchain, }) }