diff --git a/core/lib/Cargo.toml b/core/lib/Cargo.toml index 6894d5e9..1f0b2c2d 100644 --- a/core/lib/Cargo.toml +++ b/core/lib/Cargo.toml @@ -10,3 +10,10 @@ miniscript = { version = "0.12" } serde = { version = "^1.0", features = ["derive"] } serde_json = { version = "^1.0" } base64 = "^0.11" + +# Optional dependencies +sled = { version = "0.31.0", optional = true } + +[features] +default = ["sled"] +key-value-db = ["sled"] diff --git a/core/lib/src/database/keyvalue.rs b/core/lib/src/database/keyvalue.rs new file mode 100644 index 00000000..f04e9fbd --- /dev/null +++ b/core/lib/src/database/keyvalue.rs @@ -0,0 +1,390 @@ +use std::borrow::Borrow; +use std::convert::{From, TryInto}; + +use sled::{Batch, Db, IVec, Tree}; + +use bitcoin::consensus::encode::{deserialize, serialize}; +use bitcoin::hash_types::Txid; +use bitcoin::util::bip32::{ChildNumber, DerivationPath}; +use bitcoin::{OutPoint, Script, Transaction, TxOut}; + +use crate::database::{BatchDatabase, BatchOperations, Database}; +use crate::error::Error; +use crate::types::*; + +// TODO: rename mod to Sled? + +// path -> script p{i,e} -> script +// script -> path s