Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make lib komodefi compatible #8

Merged
merged 43 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
07ebc40
save dev state — added mm2_ext modules to sqlite_client and backend
borngraced Aug 14, 2023
d1158fe
save dev state — create async fn version of data_api functions
borngraced Aug 22, 2023
8819ec2
save dev state — modified async BlockSource trait
borngraced Aug 22, 2023
c3ab476
use aync-ware mutex
borngraced Aug 22, 2023
924c418
save dev state — ported wallet_Write and Read
borngraced Aug 25, 2023
3b1122b
save dev state — impl inner fn for WalletDbAsync
borngraced Aug 25, 2023
34799ce
save dev state — impl for_path fn for WalletDbAsync
borngraced Aug 25, 2023
9d2c681
save dev state — make BlockSource Send
borngraced Aug 25, 2023
329e249
save dev state — finish modification
borngraced Aug 27, 2023
ecb0295
save dev state — finish modification
borngraced Aug 27, 2023
624ed96
save dev state — minor changes
borngraced Aug 27, 2023
e473d79
save dev state — zcash extras
borngraced Aug 27, 2023
7fa620c
Merge remote-tracking branch 'origin/mm2_extras' into mm2_extras
borngraced Aug 27, 2023
bafac3a
make NoteRef not Copy
borngraced Aug 31, 2023
3c21128
move ShieldedOutput
borngraced Aug 31, 2023
5d5d822
fix review notes and add doc comments
borngraced Sep 5, 2023
d3d81c9
Revert "move ShieldedOutput"
borngraced Sep 5, 2023
8c12241
async init
borngraced Sep 7, 2023
e89819f
move WalletShieldedOutput
borngraced Sep 7, 2023
0c20210
make fake_compact_block and fake_compact_block_spending public
borngraced Sep 14, 2023
3d07af9
move fake_compact_block and fake_compact_block_spending public
borngraced Sep 14, 2023
9837e10
minor changes
borngraced Sep 14, 2023
6ab22ea
copy decrypt_and_store_transaction and create_spend_to_address as async
borngraced Sep 15, 2023
8f4b5e1
make db initializations async
borngraced Sep 15, 2023
809fc70
minor changes
borngraced Sep 18, 2023
985d47d
rename module
borngraced Sep 18, 2023
becd9d0
remove unused
borngraced Sep 18, 2023
ef13898
make LocalTxProver field pub
borngraced Sep 19, 2023
1901f09
move NoteId structure
borngraced Sep 25, 2023
bde9aab
fix review notes
borngraced Oct 5, 2023
37623e3
update time crate
borngraced Oct 6, 2023
496d255
fix review notes
borngraced Oct 11, 2023
af14c33
remove redundancy
borngraced Oct 11, 2023
99998ef
minor fix
borngraced Oct 11, 2023
cf057b9
change `zcash_extra` edition to 2018
borngraced Oct 11, 2023
7039054
delete NoteId from sqlite crate
borngraced Oct 11, 2023
b381253
remove redundancy crate decl
borngraced Oct 27, 2023
04e7b51
fix review notes
borngraced Nov 1, 2023
1b20142
fix review notes
borngraced Nov 1, 2023
97a64ea
make LocalTxProver fields private
borngraced Nov 2, 2023
cfbe0a0
fix sql init module review notes
borngraced Nov 2, 2023
faed2b8
remove decrypt_and_store_transaction
borngraced Nov 2, 2023
8c97f56
fix review notes
borngraced Nov 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"zcash_client_backend",
"zcash_client_sqlite",
"zcash_extensions",
"zcash_extras",
"zcash_history",
"zcash_primitives",
"zcash_proofs",
Expand Down
13 changes: 12 additions & 1 deletion zcash_client_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ license = "MIT OR Apache-2.0"
edition = "2018"

[dependencies]
async-trait = "0.1.52"
bech32 = "0.9.1"
bls12_381 = "0.3.1"
bs58 = { version = "0.4", features = ["check"] }
Expand All @@ -27,10 +28,15 @@ proptest = { version = "0.10.1", optional = true }
protobuf = "2.20"
rand_core = "0.5.1"
subtle = "2.2.3"
time = "0.3"
zcash_note_encryption = { version = "0.0", path = "../components/zcash_note_encryption" }
zcash_primitives = { version = "0.5", path = "../zcash_primitives" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
time = "0.3.20"

[target.'cfg(target_arch = "wasm32")'.dependencies]
time = { version = "0.3.20", features = ["wasm-bindgen"]}

[build-dependencies]
protobuf-codegen-pure = "2.20"

Expand All @@ -40,8 +46,13 @@ rand_core = "0.5.1"
rand_xorshift = "0.2"
tempfile = "3.1.0"
zcash_client_sqlite = { version = "0.3", path = "../zcash_client_sqlite" }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
zcash_proofs = { version = "0.5", path = "../zcash_proofs" }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
zcash_proofs = { version = "0.5", path = "../zcash_proofs", default-features = false, features = ["local-prover"]}

[features]
test-dependencies = ["proptest", "zcash_primitives/test-dependencies"]

Expand Down
8 changes: 5 additions & 3 deletions zcash_client_backend/src/data_api/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
//! Functions for scanning the chain and extracting relevant information.
use std::fmt::Debug;

use zcash_primitives::consensus::NetworkUpgrade;
use zcash_primitives::transaction::Transaction;
use zcash_primitives::{
consensus::{self, BranchId, NetworkUpgrade},
consensus::{self, BranchId},
memo::MemoBytes,
sapling::prover::TxProver,
transaction::{
builder::Builder,
components::{amount::DEFAULT_FEE, Amount},
Transaction,
},
zip32::{ExtendedFullViewingKey, ExtendedSpendingKey},
};

use crate::data_api::ReceivedTransaction;
use crate::{
address::RecipientAddress,
data_api::{error::Error, ReceivedTransaction, SentTransaction, WalletWrite},
data_api::{error::Error, SentTransaction, WalletWrite},
decrypt_transaction,
wallet::{AccountId, OvkPolicy},
};
Expand Down Expand Up @@ -220,7 +222,7 @@
builder.add_sapling_output(ovk, to.clone(), value, memo.clone())
}

RecipientAddress::Transparent(to) => builder.add_transparent_output(&to, value),

Check warning on line 225 in zcash_client_backend/src/data_api/wallet.rs

View workflow job for this annotation

GitHub Actions / Clippy (nightly)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> zcash_client_backend/src/data_api/wallet.rs:225:77 | 225 | RecipientAddress::Transparent(to) => builder.add_transparent_output(&to, value), | ^^^ help: change this to: `to` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-W clippy::needless-borrow` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_borrow)]`
}
.map_err(Error::Builder)?;

Expand Down
5 changes: 4 additions & 1 deletion zcash_client_sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ license = "MIT OR Apache-2.0"
edition = "2018"

[dependencies]
async-trait = "0.1.52"
bech32 = "0.9.1"
bs58 = { version = "0.4", features = ["check"] }
ff = "0.8"
Expand All @@ -22,8 +23,10 @@ protobuf = "2.20"
rand_core = "0.5.1"
rusqlite = { version = "0.28", features = ["time"] }
libsqlite3-sys= { version = "0.25.2", features = ["bundled"] }
time = "0.3"
time = "0.3.20"
tokio = { version = "1.20", features = ["rt", "rt-multi-thread"] }
zcash_client_backend = { version = "0.5", path = "../zcash_client_backend" }
zcash_extras = { version = "0.1", path = "../zcash_extras" }
zcash_primitives = { version = "0.5", path = "../zcash_primitives" }

[dev-dependencies]
Expand Down
6 changes: 2 additions & 4 deletions zcash_client_sqlite/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@ mod tests {
chain::{scan_cached_blocks, validate_chain},
error::{ChainInvalid, Error},
};
use zcash_extras::{fake_compact_block, fake_compact_block_spending};

use crate::{
chain::init::init_cache_database,
error::SqliteClientError,
tests::{
self, fake_compact_block, fake_compact_block_spending, insert_into_cache,
sapling_activation_height,
},
tests::{self, insert_into_cache, sapling_activation_height},
wallet::{
get_balance,
init::{init_accounts_table, init_wallet_db},
Expand Down
56 changes: 56 additions & 0 deletions zcash_client_sqlite/src/for_async/init.rs
shamardy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use crate::error::SqliteClientError;
use crate::for_async::{async_blocking, WalletDbAsync};
use crate::wallet;
use zcash_primitives::block::BlockHash;
use zcash_primitives::consensus;
use zcash_primitives::consensus::BlockHeight;
use zcash_primitives::zip32::ExtendedFullViewingKey;

pub async fn init_wallet_db<P: consensus::Parameters + 'static>(
wdb: &WalletDbAsync<P>,
) -> Result<(), rusqlite::Error>
where
P: Clone + Send + Sync,
{
let wdb = wdb.inner();
async_blocking(move || {
let wdb = wdb.lock().unwrap();
wallet::init::init_wallet_db(&wdb)
})
.await
}

pub async fn init_accounts_table<P: consensus::Parameters + 'static>(
wdb: &WalletDbAsync<P>,
extfvks: &[ExtendedFullViewingKey],
) -> Result<(), SqliteClientError>
where
P: Clone + Send + Sync,
{
let wdb = wdb.inner();
let extfvks = extfvks.to_vec();
async_blocking(move || {
let wdb = wdb.lock().unwrap();
wallet::init::init_accounts_table(&wdb, &extfvks)
})
.await
}

pub async fn init_blocks_table<P: consensus::Parameters + 'static>(
wdb: &WalletDbAsync<P>,
height: BlockHeight,
hash: BlockHash,
time: u32,
sapling_tree: &[u8],
) -> Result<(), SqliteClientError>
where
P: Clone + Send + Sync,
{
let wdb = wdb.inner();
let sapling_tree = sapling_tree.to_vec();
async_blocking(move || {
let wdb = wdb.lock().unwrap();
wallet::init::init_blocks_table(&wdb, height, hash, time, &sapling_tree)
})
.await
}
Loading
Loading