Skip to content

Commit

Permalink
WIP: f BDK: Account for the new BDK persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Sep 4, 2024
1 parent 42bdef1 commit 3a9d8e9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ pub(crate) const LATEST_RGS_SYNC_TIMESTAMP_KEY: &str = "latest_rgs_sync_timestam
pub(crate) const LATEST_NODE_ANN_BCAST_TIMESTAMP_PRIMARY_NAMESPACE: &str = "";
pub(crate) const LATEST_NODE_ANN_BCAST_TIMESTAMP_SECONDARY_NAMESPACE: &str = "";
pub(crate) const LATEST_NODE_ANN_BCAST_TIMESTAMP_KEY: &str = "latest_node_ann_bcast_timestamp";

/// The BDK wallet state will be persisted under this prefix.
pub(crate) const BDK_WALLET_PERSISTENCE_PRIMARY_NAMESPACE: &str = "bdk_wallet_changesets";
pub(crate) const BDK_WALLET_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";
27 changes: 26 additions & 1 deletion src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::logger::{log_error, log_info, log_trace, Logger};

use crate::config::BDK_WALLET_SYNC_TIMEOUT_SECS;
use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
use crate::types::DynStore;
use crate::Error;

use lightning::chain::chaininterface::BroadcasterInterface;
Expand All @@ -15,13 +16,14 @@ use lightning::sign::{
};

use lightning::util::message_signing;
use lightning::util::persist::KVStore;
use lightning_invoice::RawBolt11Invoice;

use bdk::blockchain::EsploraBlockchain;
use bdk::{SignOptions, SyncOptions};
use bdk_chain::ChainPosition;
use bdk_wallet::KeychainKind;
use bdk_wallet::Wallet as BdkWallet;
use bdk_wallet::{ChangeSet, KeychainKind, WalletPersister};

use bitcoin::blockdata::constants::WITNESS_SCALE_FACTOR;
use bitcoin::blockdata::locktime::absolute::LockTime;
Expand Down Expand Up @@ -643,3 +645,26 @@ where
Ok(address.script_pubkey())
}
}

pub(crate) struct KVStoreWalletPersister {
kv_store: Arc<DynStore>,
highest_changeset_index: u64,
}

impl KVStoreWalletPersister {
pub(crate) fn new(kv_store: Arc<DynStore>) -> Self {
let highest_changeset_index = 0;
Self { kv_store, highest_changeset_index }
}
}

impl WalletPersister for KVStoreWalletPersister {
type Error = ();

fn initialize(persister: &mut Self) -> Result<ChangeSet, Self::Error> {
Err(())
}
fn persist(persister: &mut Self, changeset: &ChangeSet) -> Result<(), Self::Error> {
Err(())
}
}

0 comments on commit 3a9d8e9

Please sign in to comment.