Skip to content

Commit a874519

Browse files
committed
feat(wallet): SQLite database.
1 parent 0d3f2eb commit a874519

7 files changed

Lines changed: 708 additions & 125 deletions

File tree

‎Cargo.lock‎

Lines changed: 81 additions & 105 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/floresta-electrum/src/electrum_protocol.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,8 @@ mod test {
956956
headers
957957
}
958958

959-
fn get_test_cache() -> Arc<AddressCache<KvDatabase>> {
960-
let test_id: u32 = rand::random();
961-
let cache = KvDatabase::new(format!("./tmp-db/{test_id}.floresta")).unwrap();
959+
fn get_test_cache() -> Arc<AddressCache<SqliteDatabase>> {
960+
let cache = SqliteDatabase::new_ephemeral().unwrap();
962961
let cache = AddressCache::new(cache);
963962

964963
// Inserting test transactions in the wallet

‎crates/floresta-node/src/florestad.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ impl Florestad {
716716
})
717717
}
718718

719-
fn load_wallet(data_dir: &String) -> Result<AddressCache<KvDatabase>, FlorestadError> {
719+
fn load_wallet(data_dir: &str) -> Result<AddressCache<SqliteDatabase>, FlorestadError> {
720720
let database =
721721
SqliteDatabase::new(data_dir).map_err(FlorestadError::CouldNotOpenSqLiteDatabase)?;
722722
Ok(AddressCache::new(database))

‎crates/floresta-watch-only/Cargo.toml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ readme.workspace = true # Floresta/README.md
1212

1313
[dependencies]
1414
bitcoin = { workspace = true, features = ["serde"] }
15-
kv = { workspace = true }
15+
rusqlite = { version = "0.38.0", optional = true, features = [ "bundled", "buildtime_bindgen" ] }
1616
serde = { workspace = true }
17-
serde_json = { workspace = true, features = ["alloc"] }
1817
tracing = { workspace = true }
1918

2019
# Local dependencies
@@ -23,10 +22,11 @@ floresta-common = { workspace = true, features = ["descriptors-no-std"] }
2322

2423
[dev-dependencies]
2524
rand = { workspace = true }
25+
rusqlite = { version = "0.38.0", features = [ "bundled", "buildtime_bindgen" ] }
2626

2727
[features]
28-
default = ["std"]
29-
memory-database = []
28+
default = ["std", "sqlite"]
29+
sqlite = ["dep:rusqlite"]
3030
# The default features in common are `std` and `descriptors-std` (which is a superset of `descriptors-no-std`)
3131
std = ["floresta-common/default", "serde/std"]
3232

0 commit comments

Comments
 (0)