Skip to content

Commit

Permalink
Merge pull request #1551 from get10101/fix/load-persisted-dlc-chain-m…
Browse files Browse the repository at this point in the history
…onitor

Load persisted `rust-dlc` `ChainMonitor` whenever possible
  • Loading branch information
luckysori authored Nov 3, 2023
2 parents f553126 + a94abfa commit 118f472
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

- Allow to drain on-chain wallet by sending amount `0`.
- Load persisted `rust-dlc` `ChainMonitor` on restart.

## [1.4.4] - 2023-10-28

Expand Down
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions crates/ln-dlc-node/src/node/dlc_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use dlc_manager::channel::signed_channel::SignedChannel;
use dlc_manager::channel::signed_channel::SignedChannelState;
use dlc_manager::channel::Channel;
use dlc_manager::Oracle;
use dlc_manager::Storage;
use dlc_manager::SystemTimeProvider;
use dlc_sled_storage_provider::SledStorageProvider;
use p2pd_oracle_client::P2PDOracleClient;
Expand Down Expand Up @@ -39,6 +40,15 @@ pub fn build(
let oracle_pubkey = p2pdoracle.get_public_key();
let oracles = HashMap::from([(oracle_pubkey, p2pdoracle)]);

// FIXME: We need to do this to ensure that we can upgrade `Node`s from LDK 0.0.114 to 0.0.116.
// We should remove this workaround as soon as possible.
if let Err(e) = storage.get_chain_monitor() {
tracing::error!("Failed to load DLC ChainMonitor from storage: {e:#}");

tracing::info!("Overwriting old DLC ChainMonitor with empty one to be able to proceed");
storage.persist_chain_monitor(&dlc_manager::chain_monitor::ChainMonitor::new(0))?;
}

DlcManager::new(
ln_dlc_wallet.clone(),
ln_dlc_wallet,
Expand Down

0 comments on commit 118f472

Please sign in to comment.