diff --git a/sdk-lib/Cargo.lock b/sdk-lib/Cargo.lock index 8f79b6d1..472e87be 100644 --- a/sdk-lib/Cargo.lock +++ b/sdk-lib/Cargo.lock @@ -77,6 +77,12 @@ dependencies = [ "log", ] +[[package]] +name = "anyhow" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" + [[package]] name = "arrayref" version = "0.3.6" @@ -170,7 +176,7 @@ dependencies = [ "hmac", "pbkdf2", "rand", - "sha2 0.9.9", + "sha2", "unicode-normalization", "zeroize", ] @@ -289,7 +295,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" dependencies = [ - "sha2 0.9.9", + "sha2", ] [[package]] @@ -465,7 +471,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.6", - "rand_core", "typenum", ] @@ -485,7 +490,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2099ef075418d7b252af69583c831cde749af9423c2a212dea8895e8ea78841" dependencies = [ - "petgraph", + "petgraph 0.4.13", ] [[package]] @@ -561,7 +566,7 @@ dependencies = [ [[package]] name = "equihash" version = "0.2.0" -source = "git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24#b3dc323876e07d990392855c30a2958d37750e24" +source = "git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab#c5d8484f1926a2cc53cd260808eb15be548212ab" dependencies = [ "blake2b_simd", "byteorder", @@ -570,7 +575,7 @@ dependencies = [ [[package]] name = "f4jumble" version = "0.1.0" -source = "git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24#b3dc323876e07d990392855c30a2958d37750e24" +source = "git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab#c5d8484f1926a2cc53cd260808eb15be548212ab" dependencies = [ "blake2b_simd", ] @@ -609,6 +614,15 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + [[package]] name = "ff" version = "0.12.1" @@ -626,6 +640,12 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "fpe" version = "0.5.1" @@ -736,13 +756,19 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashlink" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" dependencies = [ - "hashbrown", + "hashbrown 0.11.2", ] [[package]] @@ -769,6 +795,12 @@ dependencies = [ "ripemd160", ] +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -803,6 +835,16 @@ dependencies = [ "serde", ] +[[package]] +name = "indexmap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + [[package]] name = "inout" version = "0.1.3" @@ -812,6 +854,24 @@ dependencies = [ "generic-array 0.14.6", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.4" @@ -947,6 +1007,12 @@ dependencies = [ "adler", ] +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + [[package]] name = "nom" version = "7.1.1" @@ -1032,8 +1098,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "orchard" -version = "0.2.0" -source = "git+https://github.com/zcash/orchard.git?rev=4035a97d178f99bb889f4d7ed26c59378fa88961#4035a97d178f99bb889f4d7ed26c59378fa88961" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f06b263206a75a7d96ca75d46a3e9ca8eaf7ab7feea209749bb8b818d22f427" dependencies = [ "aes", "bitvec", @@ -1114,7 +1181,17 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" dependencies = [ - "fixedbitset", + "fixedbitset 0.1.9", +] + +[[package]] +name = "petgraph" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" +dependencies = [ + "fixedbitset 0.4.2", + "indexmap", ] [[package]] @@ -1146,6 +1223,16 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "prettyplease" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c142c0e46b57171fe0c528bee8c5b7569e80f0c17e377cd0e30ea57dbc11bb51" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro-hack" version = "0.5.19" @@ -1162,28 +1249,56 @@ dependencies = [ ] [[package]] -name = "protobuf" -version = "2.27.1" +name = "prost" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96" - -[[package]] -name = "protobuf-codegen" -version = "2.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aec1632b7c8f2e620343439a7dfd1f3c47b18906c4be58982079911482b5d707" +checksum = "399c3c31cdec40583bb68f0b18403400d01ec4289c383aa047560439952c4dd7" dependencies = [ - "protobuf", + "bytes", + "prost-derive", ] [[package]] -name = "protobuf-codegen-pure" -version = "2.27.1" +name = "prost-build" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f8122fdb18e55190c796b088a16bdb70cd7acdcd48f7a8b796b58c62e532cc6" +checksum = "7f835c582e6bd972ba8347313300219fed5bfa52caf175298d860b61ff6069bb" dependencies = [ - "protobuf", - "protobuf-codegen", + "bytes", + "heck", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph 0.6.2", + "prost", + "prost-types", + "regex", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7345d5f0e08c0536d7ac7229952590239e77abf0a0100a1b1d890add6ea96364" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dfaa718ad76a44b3415e6c4d53b17c8f99160dcb3a99b10470fce8ad43f6e3e" +dependencies = [ + "bytes", + "prost", ] [[package]] @@ -1325,6 +1440,15 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + [[package]] name = "ring" version = "0.16.20" @@ -1534,17 +1658,6 @@ dependencies = [ "opaque-debug 0.3.0", ] -[[package]] -name = "sha2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.5", -] - [[package]] name = "smallvec" version = "1.10.0" @@ -1656,6 +1769,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + [[package]] name = "thiserror" version = "1.0.37" @@ -1729,6 +1856,19 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tonic-build" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c6fd7c2581e36d63388a9e04c350c21beb7a8b059580b2e93993c526899ddc" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "quote", + "syn", +] + [[package]] name = "tracing" version = "0.1.37" @@ -1915,6 +2055,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +dependencies = [ + "either", + "libc", + "once_cell", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1979,8 +2130,8 @@ dependencies = [ [[package]] name = "zcash_address" -version = "0.1.0" -source = "git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24#b3dc323876e07d990392855c30a2958d37750e24" +version = "0.2.0" +source = "git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab#c5d8484f1926a2cc53cd260808eb15be548212ab" dependencies = [ "bech32", "bs58", @@ -1991,7 +2142,7 @@ dependencies = [ [[package]] name = "zcash_client_backend" version = "0.5.0" -source = "git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24#b3dc323876e07d990392855c30a2958d37750e24" +source = "git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab#c5d8484f1926a2cc53cd260808eb15be548212ab" dependencies = [ "base64", "bech32", @@ -2001,41 +2152,34 @@ dependencies = [ "crossbeam-channel", "group", "hdwallet", - "hex", - "jubjub", "memuse", "nom", "orchard", "percent-encoding", - "protobuf", - "protobuf-codegen-pure", - "rand_core", + "prost", "rayon", - "ripemd", - "secp256k1", "secrecy", - "sha2 0.10.6", "subtle", "time", + "tonic-build", "tracing", + "which", "zcash_address", "zcash_encoding", - "zcash_note_encryption 0.2.0 (git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24)", + "zcash_note_encryption 0.2.0 (git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab)", "zcash_primitives", ] [[package]] name = "zcash_client_sqlite" version = "0.3.0" -source = "git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24#b3dc323876e07d990392855c30a2958d37750e24" +source = "git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab#c5d8484f1926a2cc53cd260808eb15be548212ab" dependencies = [ - "bech32", "bs58", "group", "hdwallet", "jubjub", - "protobuf", - "rand_core", + "prost", "rusqlite", "schemer", "schemer-rusqlite", @@ -2048,8 +2192,8 @@ dependencies = [ [[package]] name = "zcash_encoding" -version = "0.1.0" -source = "git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24#b3dc323876e07d990392855c30a2958d37750e24" +version = "0.2.0" +source = "git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab#c5d8484f1926a2cc53cd260808eb15be548212ab" dependencies = [ "byteorder", "nonempty", @@ -2071,7 +2215,7 @@ dependencies = [ [[package]] name = "zcash_note_encryption" version = "0.2.0" -source = "git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24#b3dc323876e07d990392855c30a2958d37750e24" +source = "git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab#c5d8484f1926a2cc53cd260808eb15be548212ab" dependencies = [ "chacha20", "chacha20poly1305", @@ -2082,8 +2226,8 @@ dependencies = [ [[package]] name = "zcash_primitives" -version = "0.7.0" -source = "git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24#b3dc323876e07d990392855c30a2958d37750e24" +version = "0.8.1" +source = "git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab#c5d8484f1926a2cc53cd260808eb15be548212ab" dependencies = [ "aes", "bip0039", @@ -2091,9 +2235,7 @@ dependencies = [ "blake2b_simd", "blake2s_simd", "bls12_381", - "bs58", "byteorder", - "chacha20poly1305", "equihash", "ff", "fpe", @@ -2110,22 +2252,21 @@ dependencies = [ "rand_core", "ripemd", "secp256k1", - "sha2 0.9.9", + "sha2", "subtle", "zcash_address", "zcash_encoding", - "zcash_note_encryption 0.2.0 (git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24)", + "zcash_note_encryption 0.2.0 (git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab)", ] [[package]] name = "zcash_proofs" -version = "0.7.1" -source = "git+https://github.com/zcash/librustzcash.git?rev=b3dc323876e07d990392855c30a2958d37750e24#b3dc323876e07d990392855c30a2958d37750e24" +version = "0.8.0" +source = "git+https://github.com/zcash/librustzcash.git?rev=c5d8484f1926a2cc53cd260808eb15be548212ab#c5d8484f1926a2cc53cd260808eb15be548212ab" dependencies = [ "bellman", "blake2b_simd", "bls12_381", - "byteorder", "directories", "group", "jubjub", diff --git a/sdk-lib/Cargo.toml b/sdk-lib/Cargo.toml index 658436d9..8bdb2c94 100644 --- a/sdk-lib/Cargo.toml +++ b/sdk-lib/Cargo.toml @@ -21,22 +21,21 @@ log-panics = "2.0.0" schemer = "0.2" secp256k1 = "0.21" secrecy = "0.8" -zcash_address = "0.1" +zcash_address = "0.2" zcash_client_backend = { version = "0.5", features = ["transparent-inputs", "unstable"] } zcash_client_sqlite = { version = "0.3", features = ["transparent-inputs", "unstable"] } -zcash_primitives = "0.7" -zcash_proofs = "0.7" +zcash_primitives = "0.8" +zcash_proofs = "0.8" # Revision corresponds to the pending zcash_primitives 0.8.0. [patch.crates-io] -orchard = { git = "https://github.com/zcash/orchard.git", rev = "4035a97d178f99bb889f4d7ed26c59378fa88961" } schemer = { git = "https://github.com/aschampion/schemer.git", rev = "6726b60f43f72c6e24a18d31be0ec7d42829e5e1" } schemer-rusqlite = { git = "https://github.com/aschampion/schemer.git", rev = "6726b60f43f72c6e24a18d31be0ec7d42829e5e1" } -zcash_address = { git = 'https://github.com/zcash/librustzcash.git', rev='b3dc323876e07d990392855c30a2958d37750e24' } -zcash_client_backend = { git = 'https://github.com/zcash/librustzcash.git', rev='b3dc323876e07d990392855c30a2958d37750e24' } -zcash_client_sqlite = { git = 'https://github.com/zcash/librustzcash.git', rev='b3dc323876e07d990392855c30a2958d37750e24' } -zcash_primitives = { git = 'https://github.com/zcash/librustzcash.git', rev='b3dc323876e07d990392855c30a2958d37750e24' } -zcash_proofs = { git = 'https://github.com/zcash/librustzcash.git', rev='b3dc323876e07d990392855c30a2958d37750e24' } +zcash_address = { git = 'https://github.com/zcash/librustzcash.git', rev='c5d8484f1926a2cc53cd260808eb15be548212ab' } +zcash_client_backend = { git = 'https://github.com/zcash/librustzcash.git', rev='c5d8484f1926a2cc53cd260808eb15be548212ab' } +zcash_client_sqlite = { git = 'https://github.com/zcash/librustzcash.git', rev='c5d8484f1926a2cc53cd260808eb15be548212ab' } +zcash_primitives = { git = 'https://github.com/zcash/librustzcash.git', rev='c5d8484f1926a2cc53cd260808eb15be548212ab' } +zcash_proofs = { git = 'https://github.com/zcash/librustzcash.git', rev='c5d8484f1926a2cc53cd260808eb15be548212ab' } ## Uncomment this to test librustzcash changes locally #[patch.crates-io] diff --git a/sdk-lib/src/main/rust/lib.rs b/sdk-lib/src/main/rust/lib.rs index 69f82f96..99fdd37c 100644 --- a/sdk-lib/src/main/rust/lib.rs +++ b/sdk-lib/src/main/rust/lib.rs @@ -1264,6 +1264,34 @@ pub unsafe extern "C" fn Java_cash_z_ecc_android_sdk_jni_RustBackend_shieldToAdd let spend_params = utils::java_string_to_rust(&env, spend_params); let output_params = utils::java_string_to_rust(&env, output_params); + let min_confirmations = 0; + + let account = db_data + .get_account_for_ufvk(&usk.to_unified_full_viewing_key())? + .ok_or_else(|| format_err!("Spending key not recognized."))?; + + let from_addrs: Vec = db_data + .get_target_and_anchor_heights(min_confirmations) + .map_err(|e| format_err!("Error while fetching anchor height: {}", e)) + .and_then(|opt_anchor| { + opt_anchor + .map(|(_, h)| h) + .ok_or_else(|| format_err!("height not available; scan required.")) + }) + .and_then(|anchor| { + db_data + .get_transparent_balances(account, anchor) + .map_err(|e| { + format_err!( + "Error while fetching transparent balances for {:?}: {}", + account, + e + ) + }) + })? + .into_keys() + .collect(); + let memo = Memo::from_bytes(&memo_bytes).unwrap(); let prover = LocalTxProver::new(Path::new(&spend_params), Path::new(&output_params)); @@ -1273,8 +1301,9 @@ pub unsafe extern "C" fn Java_cash_z_ecc_android_sdk_jni_RustBackend_shieldToAdd &network, prover, &usk, + &from_addrs, &MemoBytes::from(&memo), - 0, + min_confirmations, ) .map_err(|e| format_err!("Error while shielding transaction: {}", e)) });