From c451c936a60a7a1c3d05685719b40d9cdf1ccb30 Mon Sep 17 00:00:00 2001 From: zancas Date: Fri, 17 Jan 2025 10:57:11 -0700 Subject: [PATCH 1/7] start helperizing parse_address (cherry picked from commit 399a1b6f117461df25632ecf1d140f9743c9b4b9) --- zingolib/src/commands.rs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index 672b28163..b5a77eef6 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -230,7 +230,7 @@ impl Command for ParseAddressCommand { indoc! {r#" Parse an address Usage: - parse_address [address] + parse_address
[orchard] Example parse_address tmSwk8bjXdCgBvpS8Kybk5nUyE21QFcDqre @@ -242,18 +242,28 @@ impl Command for ParseAddressCommand { } fn exec(&self, args: &[&str], _lightclient: &LightClient) -> String { + if args.len() > 2 { + return self.help().to_string(); + } + fn make_decoded_chain_pair( + address: &str, + ) -> Option<( + zcash_client_backend::address::Address, + crate::config::ChainType, + )> { + [ + crate::config::ChainType::Mainnet, + crate::config::ChainType::Testnet, + crate::config::ChainType::Regtest( + crate::config::RegtestNetwork::all_upgrades_active(), + ), + ] + .iter() + .find_map(|chain| Address::decode(chain, address).zip(Some(*chain))) + } match args.len() { 1 => json::stringify_pretty( - [ - crate::config::ChainType::Mainnet, - crate::config::ChainType::Testnet, - crate::config::ChainType::Regtest( - crate::config::RegtestNetwork::all_upgrades_active(), - ), - ] - .iter() - .find_map(|chain| Address::decode(chain, args[0]).zip(Some(chain))) - .map_or( + make_decoded_chain_pair(args[0]).map_or( object! { "status" => "Invalid address", "chain_name" => json::JsonValue::Null, From f1fad404acede15455a458fc0f144e78f01a9577 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 14 Jan 2025 21:48:40 -0700 Subject: [PATCH 2/7] resolve conflicts in cherry-pick --- Cargo.lock | 460 +++++++++-------- libtonode-tests/tests/chain_generics.rs | 1 + libtonode-tests/tests/sync.rs | 1 + zingolib/src/commands.rs | 658 +++++++++++++----------- zingolib/src/lib.rs | 1 + zingolib/src/lightclient.rs | 7 +- zingolib/src/lightclient/describe.rs | 49 +- zingolib/src/testutils.rs | 3 +- zingolib/src/testutils/lightclient.rs | 21 +- zingolib/src/testutils/macros.rs | 8 +- zingolib/src/wallet/data.rs | 2 +- 11 files changed, 661 insertions(+), 550 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0317df288..764656b84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,19 +103,20 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "append-only-vec" @@ -159,18 +160,18 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -187,9 +188,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-lc-rs" -version = "1.11.1" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f47bb8cc16b669d267eeccf585aea077d0882f4777b1c1f740217885d6e6e5a3" +checksum = "1ea835662a0af02443aa1396d39be523bbf8f11ee6fad20329607c480bea48c3" dependencies = [ "aws-lc-sys", "paste", @@ -198,16 +199,15 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.23.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2101df3813227bbaaaa0b04cd61c534c7954b22bd68d399b440be937dc63ff7" +checksum = "71b2ddd3ada61a305e1d8bb6c005d1eaa7d14d903681edfc400406d523a9b491" dependencies = [ "bindgen", "cc", "cmake", "dunce", "fs_extra", - "libc", "paste", ] @@ -232,8 +232,8 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper 1.0.2", - "tower 0.5.1", + "sync_wrapper", + "tower 0.5.2", "tower-layer", "tower-service", ] @@ -253,7 +253,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.2", + "sync_wrapper", "tower-layer", "tower-service", ] @@ -336,7 +336,7 @@ version = "0.69.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "cexpr", "clang-sys", "itertools 0.12.1", @@ -349,7 +349,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.90", + "syn 2.0.96", "which", ] @@ -385,18 +385,18 @@ dependencies = [ [[package]] name = "bit-set" -version = "0.5.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" dependencies = [ "bit-vec", ] [[package]] name = "bit-vec" -version = "0.6.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bitflags" @@ -406,9 +406,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "bitvec" @@ -509,9 +509,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.2" +version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" +checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" dependencies = [ "jobserver", "libc", @@ -559,9 +559,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -595,18 +595,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.21" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.21" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" dependencies = [ "anstream", "anstyle", @@ -616,9 +616,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "clipboard-win" @@ -653,7 +653,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f76990911f2267d837d9d0ad060aa63aaad170af40904b29461734c339030d4d" dependencies = [ "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -688,6 +688,15 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "core2" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239fa3ae9b63c2dc74bd3fa852d4792b8b305ae64eeede946265b6af62f1fff3" +dependencies = [ + "memchr", +] + [[package]] name = "cpufeatures" version = "0.2.16" @@ -699,18 +708,18 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -727,9 +736,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" @@ -770,7 +779,7 @@ dependencies = [ "tokio", "tonic", "tonic-build", - "tower 0.5.1", + "tower 0.5.2", "zcash_client_backend", "zcash_primitives", "zingo-netutils", @@ -866,7 +875,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -914,7 +923,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -962,9 +971,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fd-lock" @@ -1112,7 +1121,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -1175,7 +1184,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -1186,9 +1195,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "group" @@ -1223,18 +1232,20 @@ dependencies = [ [[package]] name = "halo2_gadgets" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126a150072b0c38c7b573fe3eaf0af944a7fed09e154071bf2436d3f016f7230" +checksum = "73a5e510d58a07d8ed238a5a8a436fe6c2c79e1bb2611f62688bc65007b4e6e7" dependencies = [ "arrayvec", "bitvec", "ff", "group", + "halo2_poseidon", "halo2_proofs", "lazy_static", "pasta_curves", "rand 0.8.5", + "sinsemilla", "subtle", "uint", ] @@ -1245,6 +1256,18 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47716fe1ae67969c5e0b2ef826f32db8c3be72be325e1aa3c1951d06b5575ec5" +[[package]] +name = "halo2_poseidon" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa3da60b81f02f9b33ebc6252d766f843291fb4d2247a07ae73d20b791fc56f" +dependencies = [ + "bitvec", + "ff", + "group", + "pasta_curves", +] + [[package]] name = "halo2_proofs" version = "0.3.0" @@ -1302,18 +1325,18 @@ dependencies = [ [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -1363,9 +1386,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -1384,9 +1407,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.3" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http", @@ -1587,7 +1610,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -1613,9 +1636,9 @@ dependencies = [ [[package]] name = "incrementalmerkletree" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d45063fbc4b0a37837f6bfe0445f269d13d730ad0aa3b5a7f74aa7bf27a0f4df" +checksum = "216c71634ac6f6ed13c2102d64354c0a04dcbdc30e31692c5972d3974d8b6d97" dependencies = [ "either", "proptest", @@ -1705,9 +1728,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.74" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", @@ -1759,9 +1782,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.167" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libloading" @@ -1785,7 +1808,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "libc", ] @@ -1821,9 +1844,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" @@ -1849,9 +1872,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" dependencies = [ "serde", ] @@ -1914,12 +1937,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memuse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2145869435ace5ea6ea3d35f59be559317ec9a0d04e1812d5f185a87b6d36f1a" -dependencies = [ - "nonempty", -] +checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" [[package]] name = "mime" @@ -1935,9 +1955,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ "adler2", ] @@ -2054,7 +2074,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -2069,9 +2088,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] @@ -2094,7 +2113,7 @@ version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "cfg-if", "foreign-types", "libc", @@ -2111,7 +2130,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -2140,17 +2159,20 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "orchard" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f18e997fa121de5c73e95cdc7e8512ae43b7de38904aeea5e5713cc48f3c0ba" +checksum = "02f7152474406422f572de163e0bc63b2126cdbfe17bc849efbbde36fcfe647e" dependencies = [ "aes", "bitvec", "blake2b_simd", + "core2", "ff", "fpe", + "getset", "group", "halo2_gadgets", + "halo2_poseidon", "halo2_proofs", "hex", "incrementalmerkletree", @@ -2161,6 +2183,7 @@ dependencies = [ "rand 0.8.5", "reddsa", "serde", + "sinsemilla", "subtle", "tracing", "visibility", @@ -2276,29 +2299,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -2349,12 +2372,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.25" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" dependencies = [ "proc-macro2", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -2376,27 +2399,27 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] [[package]] name = "proptest" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" +checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.6.0", + "bitflags 2.8.0", "lazy_static", "num-traits", "rand 0.8.5", @@ -2410,9 +2433,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" dependencies = [ "bytes", "prost-derive", @@ -2420,11 +2443,10 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" +checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b" dependencies = [ - "bytes", "heck", "itertools 0.13.0", "log", @@ -2435,28 +2457,28 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.90", + "syn 2.0.96", "tempfile", ] [[package]] name = "prost-derive" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" dependencies = [ "anyhow", "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] name = "prost-types" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" +checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" dependencies = [ "prost", ] @@ -2469,9 +2491,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -2621,11 +2643,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", ] [[package]] @@ -2679,9 +2701,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.9" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" dependencies = [ "base64 0.22.1", "bytes", @@ -2708,10 +2730,11 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.2", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", + "tower 0.5.2", "tower-service", "url", "wasm-bindgen", @@ -2764,7 +2787,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.90", + "syn 2.0.96", "walkdir", ] @@ -2792,22 +2815,22 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.41" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.23.19" +version = "0.23.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" +checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" dependencies = [ "aws-lc-rs", "log", @@ -2828,7 +2851,7 @@ dependencies = [ "openssl-probe", "rustls-pki-types", "schannel", - "security-framework 3.0.1", + "security-framework 3.2.0", ] [[package]] @@ -2842,9 +2865,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" [[package]] name = "rustls-webpki" @@ -2860,9 +2883,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "rusty-fork" @@ -2994,7 +3017,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -3003,11 +3026,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.0.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1415a607e92bec364ea2cf9264646dcce0f91e6d65281bd6f2819cca3bf39c8" +checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "core-foundation 0.10.0", "core-foundation-sys", "libc", @@ -3016,9 +3039,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.1" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -3026,9 +3049,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] @@ -3045,20 +3068,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", @@ -3117,7 +3140,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5f2390975ebfe8838f9e861f7a588123d49a7a7a0a08568ea831d8ad53fc9b4" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "either", "incrementalmerkletree", "tracing", @@ -3148,6 +3171,17 @@ dependencies = [ "libc", ] +[[package]] +name = "sinsemilla" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d268ae0ea06faafe1662e9967cd4f9022014f5eeb798e0c302c876df8b7af9c" +dependencies = [ + "group", + "pasta_curves", + "subtle", +] + [[package]] name = "slab" version = "0.4.9" @@ -3222,21 +3256,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.2" @@ -3254,7 +3282,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3263,7 +3291,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -3296,12 +3324,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", + "getrandom", "once_cell", "rustix", "windows-sys 0.59.0", @@ -3325,7 +3354,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3336,7 +3365,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", "test-case-core", ] @@ -3365,7 +3394,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3390,9 +3419,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "num-conv", @@ -3419,9 +3448,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" dependencies = [ "tinyvec_macros", ] @@ -3434,9 +3463,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -3452,13 +3481,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3473,20 +3502,19 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ "rustls", - "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" dependencies = [ "futures-core", "pin-project-lite", @@ -3495,9 +3523,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -3551,7 +3579,7 @@ dependencies = [ "prost-build", "prost-types", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3576,14 +3604,15 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 0.1.2", + "sync_wrapper", + "tokio", "tower-layer", "tower-service", ] @@ -3619,7 +3648,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3785,9 +3814,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "valuable" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "vcpkg" @@ -3809,7 +3838,7 @@ checksum = "d674d135b4a8c1d7e813e2f8d1c9a58308aee4a680323066025e53132218bd91" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3848,35 +3877,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.97" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.97" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.47" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", @@ -3887,9 +3916,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.97" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3897,28 +3926,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.97" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.97" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.74" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -4216,7 +4248,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", "synstructure", ] @@ -4317,9 +4349,9 @@ dependencies = [ [[package]] name = "zcash_note_encryption" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b4580cd6cee12e44421dac43169be8d23791650816bdb34e6ddfa70ac89c1c5" +checksum = "77efec759c3798b6e4d829fcc762070d9b229b0f13338c40bf993b7b609c2272" dependencies = [ "chacha20", "chacha20poly1305", @@ -4424,7 +4456,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -4444,7 +4476,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", "synstructure", ] @@ -4465,7 +4497,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -4487,7 +4519,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -4531,7 +4563,7 @@ dependencies = [ "thiserror", "tokio-rustls", "tonic", - "tower 0.5.1", + "tower 0.5.2", "webpki-roots 0.25.4", "zcash_client_backend", ] @@ -4646,9 +4678,9 @@ dependencies = [ [[package]] name = "zip32" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92022ac1e47c7b78f9cee29efac8a1a546e189506f3bb5ad46d525be7c519bf6" +checksum = "2e9943793abf9060b68e1889012dafbd5523ab5b125c0fcc24802d69182f2ac9" dependencies = [ "blake2b_simd", "memuse", diff --git a/libtonode-tests/tests/chain_generics.rs b/libtonode-tests/tests/chain_generics.rs index 86c094750..f203c19b8 100644 --- a/libtonode-tests/tests/chain_generics.rs +++ b/libtonode-tests/tests/chain_generics.rs @@ -6,6 +6,7 @@ use zingolib::testutils::{ proptest::proptest! { #![proptest_config(proptest::test_runner::Config::with_cases(4))] + #[ignore = "hangs"] #[test] fn single_sufficient_send_libtonode(send_value in 0..50_000u64, change_value in 0..10_000u64, sender_protocol in 1..2, receiver_pool in 0..2) { Runtime::new().unwrap().block_on(async { diff --git a/libtonode-tests/tests/sync.rs b/libtonode-tests/tests/sync.rs index e7537b687..6c1eb4326 100644 --- a/libtonode-tests/tests/sync.rs +++ b/libtonode-tests/tests/sync.rs @@ -49,6 +49,7 @@ async fn sync_mainnet_test() { dbg!(&wallet.sync_state); } +#[ignore = "hangs"] #[tokio::test] async fn sync_test() { tracing_subscriber::fmt().init(); diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index b5a77eef6..1cea893aa 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -3,6 +3,7 @@ use crate::data::proposal; use crate::wallet::keys::unified::UnifiedKeyStore; +use crate::wallet::MemoDownloadOption; use crate::{lightclient::LightClient, wallet}; use indoc::indoc; use json::object; @@ -125,15 +126,7 @@ impl Command for GetBirthdayCommand { } fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String { - RT.block_on(async move { - lightclient - .wallet - .lock() - .await - .get_birthday() - .await - .to_string() - }) + RT.block_on(async move { lightclient.wallet.get_birthday().await.to_string() }) } } @@ -161,13 +154,7 @@ impl Command for WalletKindCommand { } .pretty(4) } else { - match &lightclient - .wallet - .lock() - .await - .wallet_capability() - .unified_key_store - { + match &lightclient.wallet.wallet_capability().unified_key_store { UnifiedKeyStore::Spend(_) => object! { "kind" => "Loaded from unified spending key", "transparent" => true, @@ -195,34 +182,33 @@ impl Command for WalletKindCommand { } } -// FIXME: -// struct InterruptCommand {} -// impl Command for InterruptCommand { -// fn help(&self) -> &'static str { -// "Toggle the sync interrupt after batch flag." -// } -// fn short_help(&self) -> &'static str { -// "Toggle the sync interrupt after batch flag." -// } -// fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { -// match args.len() { -// 1 => RT.block_on(async move { -// match args[0] { -// "true" => { -// lightclient.interrupt_sync_after_batch(true).await; -// "true".to_string() -// } -// "false" => { -// lightclient.interrupt_sync_after_batch(false).await; -// "false".to_string() -// } -// _ => self.help().to_string(), -// } -// }), -// _ => self.help().to_string(), -// } -// } -// } +struct InterruptCommand {} +impl Command for InterruptCommand { + fn help(&self) -> &'static str { + "Toggle the sync interrupt after batch flag." + } + fn short_help(&self) -> &'static str { + "Toggle the sync interrupt after batch flag." + } + fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { + match args.len() { + 1 => RT.block_on(async move { + match args[0] { + "true" => { + lightclient.interrupt_sync_after_batch(true).await; + "true".to_string() + } + "false" => { + lightclient.interrupt_sync_after_batch(false).await; + "false".to_string() + } + _ => self.help().to_string(), + } + }), + _ => self.help().to_string(), + } + } +} struct ParseAddressCommand {} impl Command for ParseAddressCommand { @@ -230,7 +216,7 @@ impl Command for ParseAddressCommand { indoc! {r#" Parse an address Usage: - parse_address
[orchard] + parse_address
Example parse_address tmSwk8bjXdCgBvpS8Kybk5nUyE21QFcDqre @@ -242,7 +228,7 @@ impl Command for ParseAddressCommand { } fn exec(&self, args: &[&str], _lightclient: &LightClient) -> String { - if args.len() > 2 { + if args.len() > 1 { return self.help().to_string(); } fn make_decoded_chain_pair( @@ -261,62 +247,72 @@ impl Command for ParseAddressCommand { .iter() .find_map(|chain| Address::decode(chain, address).zip(Some(*chain))) } - match args.len() { - 1 => json::stringify_pretty( - make_decoded_chain_pair(args[0]).map_or( - object! { - "status" => "Invalid address", - "chain_name" => json::JsonValue::Null, - "address_kind" => json::JsonValue::Null, - }, - |(recipient_address, chain_name)| { - let chain_name_string = match chain_name { - crate::config::ChainType::Mainnet => "main", - crate::config::ChainType::Testnet => "test", - crate::config::ChainType::Regtest(_) => "regtest", - }; - match recipient_address { - Address::Sapling(_) => object! { - "status" => "success", - "chain_name" => chain_name_string, - "address_kind" => "sapling", - }, - Address::Transparent(_) => object! { - "status" => "success", - "chain_name" => chain_name_string, - "address_kind" => "transparent", - }, - Address::Unified(ua) => { - let mut receivers_available = vec![]; - if ua.orchard().is_some() { - receivers_available.push("orchard") - } - if ua.sapling().is_some() { - receivers_available.push("sapling") - } - if ua.transparent().is_some() { - receivers_available.push("transparent") - } - object! { - "status" => "success", - "chain_name" => chain_name_string, - "address_kind" => "unified", - "receivers_available" => receivers_available, - } - } - Address::Tex(_) => { - object! { - "status" => "success", - "chain_name" => chain_name_string, - "address_kind" => "tex", - } - } + if let Some((recipient_address, chain_name)) = make_decoded_chain_pair(args[0]) { + let chain_name_string = match chain_name { + crate::config::ChainType::Mainnet => "main", + crate::config::ChainType::Testnet => "test", + crate::config::ChainType::Regtest(_) => "regtest", + }; + match recipient_address { + Address::Sapling(_) => object! { + "status" => "success", + "chain_name" => chain_name_string, + "address_kind" => "sapling", + } + .to_string(), + Address::Transparent(_) => object! { + "status" => "success", + "chain_name" => chain_name_string, + "address_kind" => "transparent", + } + .to_string(), + Address::Tex(_) => object! { + "status" => "success", + "chain_name" => chain_name_string, + "address_kind" => "tex", + } + .to_string(), + Address::Unified(ua) => { + let mut receivers_available = vec![]; + if ua.orchard().is_some() { + receivers_available.push("orchard") + } + if ua.sapling().is_some() { + receivers_available.push("sapling") + } + if ua.transparent().is_some() { + receivers_available.push("transparent") + } + if ua.orchard().is_some() + && ua.sapling().is_some() + && ua.transparent().is_some() + { + object! { + "status" => "success", + "chain_name" => chain_name_string, + "address_kind" => "unified", + "receivers_available" => receivers_available, + "only_orchard_ua" => zcash_keys::address::UnifiedAddress::from_receivers(ua.orchard().cloned(), None, None).expect("To construct UA").encode(&chain_name), } - }, - ), - 4, - ), - _ => self.help().to_string(), + .to_string() + } else { + object! { + "status" => "success", + "chain_name" => chain_name_string, + "address_kind" => "unified", + "receivers_available" => receivers_available, + } + .to_string() + } + } + } + } else { + object! { + "status" => "Invalid address", + "chain_name" => json::JsonValue::Null, + "address_kind" => json::JsonValue::Null, + } + .to_string() } } } @@ -427,8 +423,36 @@ impl Command for SyncStatusCommand { "Get the sync status of the wallet" } - fn exec(&self, _args: &[&str], _lightclient: &LightClient) -> String { - todo!() + fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String { + RT.block_on(async move { + let status = lightclient.do_sync_status().await; + + let o = if status.in_progress { + object! { + "sync_id" => status.sync_id, + "in_progress" => status.in_progress, + "last_error" => status.last_error, + "start_block" => status.start_block, + "end_block" => status.end_block, + "synced_blocks" => status.blocks_done, + "trial_decryptions_blocks" => status.trial_dec_done, + "txn_scan_blocks" => status.txn_scan_done, + "witnesses_updated" => *status.witnesses_updated.values().min().unwrap_or(&0), + "total_blocks" => status.blocks_total, + "batch_num" => status.batch_num, + "batch_total" => status.batch_total, + "sync_interrupt" => lightclient.get_sync_interrupt().await + } + } else { + object! { + "sync_id" => status.sync_id, + "in_progress" => status.in_progress, + "last_error" => status.last_error, + + } + }; + o.pretty(2) + }) } } @@ -473,8 +497,13 @@ impl Command for RescanCommand { "Rescan the wallet, downloading and scanning all blocks and transactions" } - fn exec(&self, _args: &[&str], _lightclient: &LightClient) -> String { - todo!() + fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String { + RT.block_on(async move { + match lightclient.do_rescan().await { + Ok(j) => j.to_json().pretty(2), + Err(e) => e, + } + }) } } @@ -712,9 +741,9 @@ struct AddressCommand {} impl Command for AddressCommand { fn help(&self) -> &'static str { indoc! {r#" - List current addresses in the wallet + List current addresses in the wallet, shielded excludes t-addresses. Usage: - address + addresses [shielded|orchard] "#} } @@ -723,8 +752,29 @@ impl Command for AddressCommand { "List all addresses in the wallet" } - fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String { - RT.block_on(async move { lightclient.do_addresses().await.pretty(2) }) + fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { + use crate::lightclient::describe::UAReceivers; + match args.len() { + 0 => RT.block_on( + async move { lightclient.do_addresses(UAReceivers::All).await.pretty(2) }, + ), + 1 => match args[0] { + "shielded" => RT.block_on(async move { + lightclient + .do_addresses(UAReceivers::Shielded) + .await + .pretty(2) + }), + "orchard" => RT.block_on(async move { + lightclient + .do_addresses(UAReceivers::Orchard) + .await + .pretty(2) + }), + _ => self.help().to_string(), + }, + _ => self.help().to_string(), + } } } @@ -747,24 +797,16 @@ impl Command for ExportUfvkCommand { } fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String { - RT.block_on(async move { - let ufvk: UnifiedFullViewingKey = match (&lightclient - .wallet - .lock() - .await - .wallet_capability() - .unified_key_store) - .try_into() - { + let ufvk: UnifiedFullViewingKey = + match (&lightclient.wallet.wallet_capability().unified_key_store).try_into() { Ok(ufvk) => ufvk, Err(e) => return e.to_string(), }; - object! { - "ufvk" => ufvk.encode(&lightclient.config().chain), - "birthday" => lightclient.wallet.lock().await.get_birthday().await - } - .pretty(2) - }) + object! { + "ufvk" => ufvk.encode(&lightclient.config().chain), + "birthday" => RT.block_on(lightclient.wallet.get_birthday()) + } + .pretty(2) } } @@ -1458,147 +1500,145 @@ impl Command for SendsToAddressCommand { } } -// FIXME: -// struct SetOptionCommand {} -// impl Command for SetOptionCommand { -// fn help(&self) -> &'static str { -// indoc! {r#" -// Set a wallet option -// Usage: -// setoption = -// List of available options: -// download_memos : none | wallet | all - -// "#} -// } - -// fn short_help(&self) -> &'static str { -// "Set a wallet option" -// } - -// fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { -// if args.len() != 1 { -// return format!("Error: Need exactly 1 argument\n\n{}", self.help()); -// } - -// let option = args[0]; -// let values: Vec<&str> = option.split('=').collect(); - -// if values.len() != 2 { -// return "Error: Please set option value like: =".to_string(); -// } - -// let option_name = values[0]; -// let option_value = values[1]; - -// RT.block_on(async move { -// match option_name { -// "download_memos" => match option_value { -// "none" => { -// lightclient -// .wallet -// .set_download_memo(MemoDownloadOption::NoMemos) -// .await -// } -// "wallet" => { -// lightclient -// .wallet -// .set_download_memo(MemoDownloadOption::WalletMemos) -// .await -// } -// "all" => { -// lightclient -// .wallet -// .set_download_memo(MemoDownloadOption::AllMemos) -// .await -// } -// _ => { -// return format!( -// "Error: Couldn't understand {} value {}", -// option_name, option_value -// ) -// } -// }, -// "transaction_filter_threshold" => match option_value.parse() { -// Ok(number) => { -// lightclient -// .wallet -// .wallet_options -// .write() -// .await -// .transaction_size_filter = Some(number) -// } -// Err(e) => return format!("Error {e}, couldn't parse {option_value} as number"), -// }, -// _ => return format!("Error: Couldn't understand {}", option_name), -// } - -// let r = object! { -// "success" => true -// }; - -// r.pretty(2) -// }) -// } -// } - -// FIXME: -// struct GetOptionCommand {} -// impl Command for GetOptionCommand { -// fn help(&self) -> &'static str { -// indoc! {r#" -// Get a wallet option -// Argument is either "download_memos" and "transaction_filter_threshold" - -// Usage: -// getoption - -// "#} -// } - -// fn short_help(&self) -> &'static str { -// "Get a wallet option" -// } - -// fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { -// if args.len() != 1 { -// return format!("Error: Need exactly 1 argument\n\n{}", self.help()); -// } - -// let option_name = args[0]; - -// RT.block_on(async move { -// let value = match option_name { -// "download_memos" => match lightclient -// .wallet -// .wallet_options -// .read() -// .await -// .download_memos -// { -// MemoDownloadOption::NoMemos => "none".to_string(), -// MemoDownloadOption::WalletMemos => "wallet".to_string(), -// MemoDownloadOption::AllMemos => "all".to_string(), -// }, -// "transaction_filter_threshold" => lightclient -// .wallet -// .wallet_options -// .read() -// .await -// .transaction_size_filter -// .map(|filter| filter.to_string()) -// .unwrap_or("No filter".to_string()), -// _ => return format!("Error: Couldn't understand {}", option_name), -// }; - -// let r = object! { -// option_name => value -// }; - -// r.pretty(2) -// }) -// } -// } +struct SetOptionCommand {} +impl Command for SetOptionCommand { + fn help(&self) -> &'static str { + indoc! {r#" + Set a wallet option + Usage: + setoption = + List of available options: + download_memos : none | wallet | all + + "#} + } + + fn short_help(&self) -> &'static str { + "Set a wallet option" + } + + fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { + if args.len() != 1 { + return format!("Error: Need exactly 1 argument\n\n{}", self.help()); + } + + let option = args[0]; + let values: Vec<&str> = option.split('=').collect(); + + if values.len() != 2 { + return "Error: Please set option value like: =".to_string(); + } + + let option_name = values[0]; + let option_value = values[1]; + + RT.block_on(async move { + match option_name { + "download_memos" => match option_value { + "none" => { + lightclient + .wallet + .set_download_memo(MemoDownloadOption::NoMemos) + .await + } + "wallet" => { + lightclient + .wallet + .set_download_memo(MemoDownloadOption::WalletMemos) + .await + } + "all" => { + lightclient + .wallet + .set_download_memo(MemoDownloadOption::AllMemos) + .await + } + _ => { + return format!( + "Error: Couldn't understand {} value {}", + option_name, option_value + ) + } + }, + "transaction_filter_threshold" => match option_value.parse() { + Ok(number) => { + lightclient + .wallet + .wallet_options + .write() + .await + .transaction_size_filter = Some(number) + } + Err(e) => return format!("Error {e}, couldn't parse {option_value} as number"), + }, + _ => return format!("Error: Couldn't understand {}", option_name), + } + + let r = object! { + "success" => true + }; + + r.pretty(2) + }) + } +} + +struct GetOptionCommand {} +impl Command for GetOptionCommand { + fn help(&self) -> &'static str { + indoc! {r#" + Get a wallet option + Argument is either "download_memos" and "transaction_filter_threshold" + + Usage: + getoption + + "#} + } + + fn short_help(&self) -> &'static str { + "Get a wallet option" + } + + fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { + if args.len() != 1 { + return format!("Error: Need exactly 1 argument\n\n{}", self.help()); + } + + let option_name = args[0]; + + RT.block_on(async move { + let value = match option_name { + "download_memos" => match lightclient + .wallet + .wallet_options + .read() + .await + .download_memos + { + MemoDownloadOption::NoMemos => "none".to_string(), + MemoDownloadOption::WalletMemos => "wallet".to_string(), + MemoDownloadOption::AllMemos => "all".to_string(), + }, + "transaction_filter_threshold" => lightclient + .wallet + .wallet_options + .read() + .await + .transaction_size_filter + .map(|filter| filter.to_string()) + .unwrap_or("No filter".to_string()), + _ => return format!("Error: Couldn't understand {}", option_name), + }; + + let r = object! { + option_name => value + }; + + r.pretty(2) + }) + } +} struct HeightCommand {} impl Command for HeightCommand { @@ -1686,47 +1726,45 @@ impl Command for NewAddressCommand { } } -// TODO: implement notes command for sync feature -// FIXME: -// struct NotesCommand {} -// impl Command for NotesCommand { -// fn help(&self) -> &'static str { -// indoc! {r#" -// Show all shielded notes and transparent coins in this wallet -// Usage: -// notes [all] -// If you supply the "all" parameter, all previously spent shielded notes and transparent coins are also included -// "#} -// } - -// fn short_help(&self) -> &'static str { -// "Show all shielded notes and transparent coins in this wallet" -// } - -// fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { -// // Parse the args. -// if args.len() > 1 { -// return self.short_help().to_string(); -// } - -// // Make sure we can parse the amount -// let all_notes = if args.len() == 1 { -// match args[0] { -// "all" => true, -// a => { -// return format!( -// "Invalid argument \"{}\". Specify 'all' to include unspent notes", -// a -// ) -// } -// } -// } else { -// false -// }; - -// RT.block_on(async move { lightclient.do_list_notes(all_notes).await.pretty(2) }) -// } -// } +struct NotesCommand {} +impl Command for NotesCommand { + fn help(&self) -> &'static str { + indoc! {r#" + Show all shielded notes and transparent coins in this wallet + Usage: + notes [all] + If you supply the "all" parameter, all previously spent shielded notes and transparent coins are also included + "#} + } + + fn short_help(&self) -> &'static str { + "Show all shielded notes and transparent coins in this wallet" + } + + fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { + // Parse the args. + if args.len() > 1 { + return self.short_help().to_string(); + } + + // Make sure we can parse the amount + let all_notes = if args.len() == 1 { + match args[0] { + "all" => true, + a => { + return format!( + "Invalid argument \"{}\". Specify 'all' to include unspent notes", + a + ) + } + } + } else { + false + }; + + RT.block_on(async move { lightclient.do_list_notes(all_notes).await.pretty(2) }) + } +} struct QuitCommand {} impl Command for QuitCommand { @@ -1815,7 +1853,7 @@ pub fn get_commands() -> HashMap<&'static str, Box> { ("decryptmessage", Box::new(DecryptMessageCommand {})), ("parse_address", Box::new(ParseAddressCommand {})), ("parse_viewkey", Box::new(ParseViewKeyCommand {})), - // ("interrupt_sync_after_batch", Box::new(InterruptCommand {})), + ("interrupt_sync_after_batch", Box::new(InterruptCommand {})), ("changeserver", Box::new(ChangeServerCommand {})), ("rescan", Box::new(RescanCommand {})), ("clear", Box::new(ClearCommand {})), @@ -1825,7 +1863,7 @@ pub fn get_commands() -> HashMap<&'static str, Box> { ("addresses", Box::new(AddressCommand {})), ("height", Box::new(HeightCommand {})), ("sendprogress", Box::new(SendProgressCommand {})), - // ("setoption", Box::new(SetOptionCommand {})), + ("setoption", Box::new(SetOptionCommand {})), ("valuetransfers", Box::new(ValueTransfersCommand {})), ("transactions", Box::new(TransactionsCommand {})), ( @@ -1839,7 +1877,7 @@ pub fn get_commands() -> HashMap<&'static str, Box> { "memobytes_to_address", Box::new(MemoBytesToAddressCommand {}), ), - // ("getoption", Box::new(GetOptionCommand {})), + ("getoption", Box::new(GetOptionCommand {})), ("exportufvk", Box::new(ExportUfvkCommand {})), ("info", Box::new(InfoCommand {})), ("updatecurrentprice", Box::new(UpdateCurrentPriceCommand {})), @@ -1847,7 +1885,7 @@ pub fn get_commands() -> HashMap<&'static str, Box> { ("shield", Box::new(ShieldCommand {})), ("save", Box::new(DeprecatedNoCommand {})), ("quit", Box::new(QuitCommand {})), - // ("notes", Box::new(NotesCommand {})), + ("notes", Box::new(NotesCommand {})), ("new", Box::new(NewAddressCommand {})), ("defaultfee", Box::new(DefaultFeeCommand {})), ("seed", Box::new(SeedCommand {})), diff --git a/zingolib/src/lib.rs b/zingolib/src/lib.rs index f0064cdb2..7edf38837 100644 --- a/zingolib/src/lib.rs +++ b/zingolib/src/lib.rs @@ -4,6 +4,7 @@ //! Zingo backend code base //! Use this high level API to do things like submit transactions to the zcash blockchain +pub use lightclient::describe::UAReceivers; #[macro_use] extern crate rust_embed; diff --git a/zingolib/src/lightclient.rs b/zingolib/src/lightclient.rs index d6cb26faa..2665f9657 100644 --- a/zingolib/src/lightclient.rs +++ b/zingolib/src/lightclient.rs @@ -681,7 +681,10 @@ async fn get_recent_median_price_from_gemini() -> Result { #[cfg(test)] mod tests { - use crate::config::{ChainType, RegtestNetwork, ZingoConfig}; + use crate::{ + config::{ChainType, RegtestNetwork, ZingoConfig}, + lightclient::describe::UAReceivers, + }; use testvectors::seeds::CHIMNEY_BETTER_SEED; use tokio::runtime::Runtime; @@ -730,7 +733,7 @@ mod tests { // The first t address and z address should be derived Runtime::new().unwrap().block_on(async move { - let addresses = lc.do_addresses().await; + let addresses = lc.do_addresses(UAReceivers::All).await; assert_eq!( "zregtestsapling1etnl5s47cqves0g5hk2dx5824rme4xv4aeauwzp4d6ys3qxykt5sw5rnaqh9syxry8vgxr7x3x4" .to_string(), diff --git a/zingolib/src/lightclient/describe.rs b/zingolib/src/lightclient/describe.rs index eb1970ab0..699e47956 100644 --- a/zingolib/src/lightclient/describe.rs +++ b/zingolib/src/lightclient/describe.rs @@ -37,6 +37,11 @@ pub enum ValueTransferRecordingError { fn some_sum(a: Option, b: Option) -> Option { a.xor(b).or_else(|| a.zip(b).map(|(v, u)| v + u)) } +pub enum UAReceivers { + Orchard, + Shielded, + All, +} impl LightClient { /// Uses a query to select all notes across all transactions with specific properties and sum them pub async fn query_sum_value(&self, include_notes: OutputQuery) -> u64 { @@ -53,7 +58,7 @@ impl LightClient { /// TODO: Add Doc Comment Here! // todo use helpers - pub async fn do_addresses(&self) -> JsonValue { + pub async fn do_addresses(&self, subset: UAReceivers) -> JsonValue { let mut objectified_addresses = Vec::new(); for address in self .wallet @@ -63,18 +68,35 @@ impl LightClient { .addresses() .iter() { - let encoded_ua = address.encode(&self.config.chain); - let transparent = address + let local_address = match subset { + UAReceivers::Orchard => zcash_keys::address::UnifiedAddress::from_receivers( + address.orchard().copied(), + None, + None, + ) + .expect("To create a new address."), + UAReceivers::Shielded => zcash_keys::address::UnifiedAddress::from_receivers( + address.orchard().copied(), + address.sapling().copied(), + None, + ) + .expect("To create a new address."), + UAReceivers::All => address.clone(), + }; + let encoded_ua = local_address.encode(&self.config.chain); + let transparent = local_address .transparent() .map(|taddr| address_from_pubkeyhash(&self.config, *taddr)); - objectified_addresses.push(object! { - "address" => encoded_ua, - "receivers" => object!( - "transparent" => transparent, - "sapling" => address.sapling().map(|z_addr| encode_payment_address(self.config.chain.hrp_sapling_payment_address(), z_addr)), - "orchard_exists" => address.orchard().is_some(), + objectified_addresses.push( + object!{ + "address" => encoded_ua, + "receivers" => object!( + "transparent" => transparent, + "sapling" => local_address.sapling().map(|z_addr| encode_payment_address(self.config.chain.hrp_sapling_payment_address(), z_addr)), + "orchard_exists" => local_address.orchard().is_some() + ) + } ) - }) } JsonValue::Array(objectified_addresses) } @@ -426,8 +448,11 @@ impl LightClient { } /// TODO: doc comment - pub async fn value_transfers_json_string(&self) -> String { - json::JsonValue::from(self.sorted_value_transfers(true).await).pretty(2) + pub async fn value_transfers_json_string(&self, recent_vts_to_retrieve: usize) -> String { + let sorted_vts = self.sorted_value_transfers(true).await; + let total = sorted_vts.len(); + let subset = &sorted_vts.as_slice()[..recent_vts_to_retrieve]; + object! {"value_transfers" => subset, "total" => total}.to_string() } /// Provides a list of transaction summaries related to this wallet in order of blockheight diff --git a/zingolib/src/testutils.rs b/zingolib/src/testutils.rs index 6875da2a9..428316819 100644 --- a/zingolib/src/testutils.rs +++ b/zingolib/src/testutils.rs @@ -6,6 +6,7 @@ pub mod interrupts; pub mod scenarios; +use crate::lightclient::describe::UAReceivers; use crate::wallet::data::summaries::{ OrchardNoteSummary, SaplingNoteSummary, SpendSummary, TransactionSummary, TransactionSummaryInterface as _, TransparentCoinSummary, @@ -249,7 +250,7 @@ pub async fn send_value_between_clients_and_sync( ) -> Result { debug!( "recipient address is: {}", - &recipient.do_addresses().await[0]["address"] + &recipient.do_addresses(UAReceivers::All).await[0]["address"] ); let txid = lightclient::from_inputs::quick_send( sender, diff --git a/zingolib/src/testutils/lightclient.rs b/zingolib/src/testutils/lightclient.rs index 921ce7e6e..83b790549 100644 --- a/zingolib/src/testutils/lightclient.rs +++ b/zingolib/src/testutils/lightclient.rs @@ -1,6 +1,9 @@ //! This mod is mostly to take inputs, raw data amd convert it into lightclient actions //! (obviously) in a test environment. -use crate::{error::ZingoLibError, lightclient::LightClient}; +use crate::{ + error::ZingoLibError, + lightclient::{describe::UAReceivers, LightClient}, +}; use zcash_client_backend::{PoolType, ShieldedProtocol}; use zcash_primitives::transaction::TxId; @@ -18,15 +21,19 @@ pub async fn new_client_from_save_buffer( /// calling \[0] on json may panic? not sure -fv pub async fn get_base_address(client: &LightClient, pooltype: PoolType) -> String { match pooltype { - PoolType::Transparent => client.do_addresses().await[0]["receivers"]["transparent"] - .clone() - .to_string(), - PoolType::Shielded(ShieldedProtocol::Sapling) => client.do_addresses().await[0] - ["receivers"]["sapling"] + PoolType::Transparent => client.do_addresses(UAReceivers::All).await[0]["receivers"] + ["transparent"] .clone() .to_string(), + PoolType::Shielded(ShieldedProtocol::Sapling) => { + client.do_addresses(UAReceivers::All).await[0]["receivers"]["sapling"] + .clone() + .to_string() + } PoolType::Shielded(ShieldedProtocol::Orchard) => { - client.do_addresses().await[0]["address"].take().to_string() + client.do_addresses(UAReceivers::All).await[0]["address"] + .take() + .to_string() } } } diff --git a/zingolib/src/testutils/macros.rs b/zingolib/src/testutils/macros.rs index c033f79ea..765d39b22 100644 --- a/zingolib/src/testutils/macros.rs +++ b/zingolib/src/testutils/macros.rs @@ -5,13 +5,15 @@ macro_rules! get_base_address_macro { ($client:expr, $address_protocol:expr) => { match $address_protocol { - "unified" => $client.do_addresses().await[0]["address"] + "unified" => $client.do_addresses($crate::UAReceivers::All).await[0]["address"] .take() .to_string(), - "sapling" => $client.do_addresses().await[0]["receivers"]["sapling"] + "sapling" => $client.do_addresses($crate::UAReceivers::All).await[0]["receivers"] + ["sapling"] .clone() .to_string(), - "transparent" => $client.do_addresses().await[0]["receivers"]["transparent"] + "transparent" => $client.do_addresses($crate::UAReceivers::All).await[0]["receivers"] + ["transparent"] .clone() .to_string(), _ => "ERROR".to_string(), diff --git a/zingolib/src/wallet/data.rs b/zingolib/src/wallet/data.rs index bceec5944..bad1b5bb4 100644 --- a/zingolib/src/wallet/data.rs +++ b/zingolib/src/wallet/data.rs @@ -501,7 +501,7 @@ pub mod summaries { /// A value transfer is a note group abstraction. /// A group of all notes sent to a specific address in a transaction. - #[derive(PartialEq)] + #[derive(Clone, PartialEq)] pub struct ValueTransfer { txid: TxId, datetime: u64, From ade335370b2c5b6cdcde029a4f868f3bcf2f7b25 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 21 Jan 2025 22:07:26 -0700 Subject: [PATCH 3/7] resolve conflicts in commands.rs --- zingolib/src/commands.rs | 505 +++++++++++++++++++-------------------- 1 file changed, 249 insertions(+), 256 deletions(-) diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index 1cea893aa..6aaaa144c 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -3,7 +3,6 @@ use crate::data::proposal; use crate::wallet::keys::unified::UnifiedKeyStore; -use crate::wallet::MemoDownloadOption; use crate::{lightclient::LightClient, wallet}; use indoc::indoc; use json::object; @@ -126,7 +125,15 @@ impl Command for GetBirthdayCommand { } fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String { - RT.block_on(async move { lightclient.wallet.get_birthday().await.to_string() }) + RT.block_on(async move { + lightclient + .wallet + .lock() + .await + .get_birthday() + .await + .to_string() + }) } } @@ -154,7 +161,13 @@ impl Command for WalletKindCommand { } .pretty(4) } else { - match &lightclient.wallet.wallet_capability().unified_key_store { + match &lightclient + .wallet + .lock() + .await + .wallet_capability() + .unified_key_store + { UnifiedKeyStore::Spend(_) => object! { "kind" => "Loaded from unified spending key", "transparent" => true, @@ -182,33 +195,34 @@ impl Command for WalletKindCommand { } } -struct InterruptCommand {} -impl Command for InterruptCommand { - fn help(&self) -> &'static str { - "Toggle the sync interrupt after batch flag." - } - fn short_help(&self) -> &'static str { - "Toggle the sync interrupt after batch flag." - } - fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { - match args.len() { - 1 => RT.block_on(async move { - match args[0] { - "true" => { - lightclient.interrupt_sync_after_batch(true).await; - "true".to_string() - } - "false" => { - lightclient.interrupt_sync_after_batch(false).await; - "false".to_string() - } - _ => self.help().to_string(), - } - }), - _ => self.help().to_string(), - } - } -} +// FIXME: +// struct InterruptCommand {} +// impl Command for InterruptCommand { +// fn help(&self) -> &'static str { +// "Toggle the sync interrupt after batch flag." +// } +// fn short_help(&self) -> &'static str { +// "Toggle the sync interrupt after batch flag." +// } +// fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { +// match args.len() { +// 1 => RT.block_on(async move { +// match args[0] { +// "true" => { +// lightclient.interrupt_sync_after_batch(true).await; +// "true".to_string() +// } +// "false" => { +// lightclient.interrupt_sync_after_batch(false).await; +// "false".to_string() +// } +// _ => self.help().to_string(), +// } +// }), +// _ => self.help().to_string(), +// } +// } +// } struct ParseAddressCommand {} impl Command for ParseAddressCommand { @@ -423,36 +437,8 @@ impl Command for SyncStatusCommand { "Get the sync status of the wallet" } - fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String { - RT.block_on(async move { - let status = lightclient.do_sync_status().await; - - let o = if status.in_progress { - object! { - "sync_id" => status.sync_id, - "in_progress" => status.in_progress, - "last_error" => status.last_error, - "start_block" => status.start_block, - "end_block" => status.end_block, - "synced_blocks" => status.blocks_done, - "trial_decryptions_blocks" => status.trial_dec_done, - "txn_scan_blocks" => status.txn_scan_done, - "witnesses_updated" => *status.witnesses_updated.values().min().unwrap_or(&0), - "total_blocks" => status.blocks_total, - "batch_num" => status.batch_num, - "batch_total" => status.batch_total, - "sync_interrupt" => lightclient.get_sync_interrupt().await - } - } else { - object! { - "sync_id" => status.sync_id, - "in_progress" => status.in_progress, - "last_error" => status.last_error, - - } - }; - o.pretty(2) - }) + fn exec(&self, _args: &[&str], _lightclient: &LightClient) -> String { + todo!() } } @@ -497,13 +483,8 @@ impl Command for RescanCommand { "Rescan the wallet, downloading and scanning all blocks and transactions" } - fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String { - RT.block_on(async move { - match lightclient.do_rescan().await { - Ok(j) => j.to_json().pretty(2), - Err(e) => e, - } - }) + fn exec(&self, _args: &[&str], _lightclient: &LightClient) -> String { + todo!() } } @@ -797,16 +778,24 @@ impl Command for ExportUfvkCommand { } fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String { - let ufvk: UnifiedFullViewingKey = - match (&lightclient.wallet.wallet_capability().unified_key_store).try_into() { + RT.block_on(async move { + let ufvk: UnifiedFullViewingKey = match (&lightclient + .wallet + .lock() + .await + .wallet_capability() + .unified_key_store) + .try_into() + { Ok(ufvk) => ufvk, Err(e) => return e.to_string(), }; - object! { - "ufvk" => ufvk.encode(&lightclient.config().chain), - "birthday" => RT.block_on(lightclient.wallet.get_birthday()) - } - .pretty(2) + object! { + "ufvk" => ufvk.encode(&lightclient.config().chain), + "birthday" => lightclient.wallet.lock().await.get_birthday().await + } + .pretty(2) + }) } } @@ -1500,145 +1489,147 @@ impl Command for SendsToAddressCommand { } } -struct SetOptionCommand {} -impl Command for SetOptionCommand { - fn help(&self) -> &'static str { - indoc! {r#" - Set a wallet option - Usage: - setoption = - List of available options: - download_memos : none | wallet | all - - "#} - } - - fn short_help(&self) -> &'static str { - "Set a wallet option" - } - - fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { - if args.len() != 1 { - return format!("Error: Need exactly 1 argument\n\n{}", self.help()); - } - - let option = args[0]; - let values: Vec<&str> = option.split('=').collect(); - - if values.len() != 2 { - return "Error: Please set option value like: =".to_string(); - } - - let option_name = values[0]; - let option_value = values[1]; - - RT.block_on(async move { - match option_name { - "download_memos" => match option_value { - "none" => { - lightclient - .wallet - .set_download_memo(MemoDownloadOption::NoMemos) - .await - } - "wallet" => { - lightclient - .wallet - .set_download_memo(MemoDownloadOption::WalletMemos) - .await - } - "all" => { - lightclient - .wallet - .set_download_memo(MemoDownloadOption::AllMemos) - .await - } - _ => { - return format!( - "Error: Couldn't understand {} value {}", - option_name, option_value - ) - } - }, - "transaction_filter_threshold" => match option_value.parse() { - Ok(number) => { - lightclient - .wallet - .wallet_options - .write() - .await - .transaction_size_filter = Some(number) - } - Err(e) => return format!("Error {e}, couldn't parse {option_value} as number"), - }, - _ => return format!("Error: Couldn't understand {}", option_name), - } - - let r = object! { - "success" => true - }; - - r.pretty(2) - }) - } -} - -struct GetOptionCommand {} -impl Command for GetOptionCommand { - fn help(&self) -> &'static str { - indoc! {r#" - Get a wallet option - Argument is either "download_memos" and "transaction_filter_threshold" - - Usage: - getoption - - "#} - } - - fn short_help(&self) -> &'static str { - "Get a wallet option" - } - - fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { - if args.len() != 1 { - return format!("Error: Need exactly 1 argument\n\n{}", self.help()); - } - - let option_name = args[0]; - - RT.block_on(async move { - let value = match option_name { - "download_memos" => match lightclient - .wallet - .wallet_options - .read() - .await - .download_memos - { - MemoDownloadOption::NoMemos => "none".to_string(), - MemoDownloadOption::WalletMemos => "wallet".to_string(), - MemoDownloadOption::AllMemos => "all".to_string(), - }, - "transaction_filter_threshold" => lightclient - .wallet - .wallet_options - .read() - .await - .transaction_size_filter - .map(|filter| filter.to_string()) - .unwrap_or("No filter".to_string()), - _ => return format!("Error: Couldn't understand {}", option_name), - }; - - let r = object! { - option_name => value - }; - - r.pretty(2) - }) - } -} +// FIXME: +// struct SetOptionCommand {} +// impl Command for SetOptionCommand { +// fn help(&self) -> &'static str { +// indoc! {r#" +// Set a wallet option +// Usage: +// setoption = +// List of available options: +// download_memos : none | wallet | all + +// "#} +// } + +// fn short_help(&self) -> &'static str { +// "Set a wallet option" +// } + +// fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { +// if args.len() != 1 { +// return format!("Error: Need exactly 1 argument\n\n{}", self.help()); +// } + +// let option = args[0]; +// let values: Vec<&str> = option.split('=').collect(); + +// if values.len() != 2 { +// return "Error: Please set option value like: =".to_string(); +// } + +// let option_name = values[0]; +// let option_value = values[1]; + +// RT.block_on(async move { +// match option_name { +// "download_memos" => match option_value { +// "none" => { +// lightclient +// .wallet +// .set_download_memo(MemoDownloadOption::NoMemos) +// .await +// } +// "wallet" => { +// lightclient +// .wallet +// .set_download_memo(MemoDownloadOption::WalletMemos) +// .await +// } +// "all" => { +// lightclient +// .wallet +// .set_download_memo(MemoDownloadOption::AllMemos) +// .await +// } +// _ => { +// return format!( +// "Error: Couldn't understand {} value {}", +// option_name, option_value +// ) +// } +// }, +// "transaction_filter_threshold" => match option_value.parse() { +// Ok(number) => { +// lightclient +// .wallet +// .wallet_options +// .write() +// .await +// .transaction_size_filter = Some(number) +// } +// Err(e) => return format!("Error {e}, couldn't parse {option_value} as number"), +// }, +// _ => return format!("Error: Couldn't understand {}", option_name), +// } + +// let r = object! { +// "success" => true +// }; + +// r.pretty(2) +// }) +// } +// } + +// FIXME: +// struct GetOptionCommand {} +// impl Command for GetOptionCommand { +// fn help(&self) -> &'static str { +// indoc! {r#" +// Get a wallet option +// Argument is either "download_memos" and "transaction_filter_threshold" + +// Usage: +// getoption + +// "#} +// } + +// fn short_help(&self) -> &'static str { +// "Get a wallet option" +// } + +// fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { +// if args.len() != 1 { +// return format!("Error: Need exactly 1 argument\n\n{}", self.help()); +// } + +// let option_name = args[0]; + +// RT.block_on(async move { +// let value = match option_name { +// "download_memos" => match lightclient +// .wallet +// .wallet_options +// .read() +// .await +// .download_memos +// { +// MemoDownloadOption::NoMemos => "none".to_string(), +// MemoDownloadOption::WalletMemos => "wallet".to_string(), +// MemoDownloadOption::AllMemos => "all".to_string(), +// }, +// "transaction_filter_threshold" => lightclient +// .wallet +// .wallet_options +// .read() +// .await +// .transaction_size_filter +// .map(|filter| filter.to_string()) +// .unwrap_or("No filter".to_string()), +// _ => return format!("Error: Couldn't understand {}", option_name), +// }; + +// let r = object! { +// option_name => value +// }; + +// r.pretty(2) +// }) +// } +// } struct HeightCommand {} impl Command for HeightCommand { @@ -1726,45 +1717,47 @@ impl Command for NewAddressCommand { } } -struct NotesCommand {} -impl Command for NotesCommand { - fn help(&self) -> &'static str { - indoc! {r#" - Show all shielded notes and transparent coins in this wallet - Usage: - notes [all] - If you supply the "all" parameter, all previously spent shielded notes and transparent coins are also included - "#} - } - - fn short_help(&self) -> &'static str { - "Show all shielded notes and transparent coins in this wallet" - } - - fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { - // Parse the args. - if args.len() > 1 { - return self.short_help().to_string(); - } - - // Make sure we can parse the amount - let all_notes = if args.len() == 1 { - match args[0] { - "all" => true, - a => { - return format!( - "Invalid argument \"{}\". Specify 'all' to include unspent notes", - a - ) - } - } - } else { - false - }; - - RT.block_on(async move { lightclient.do_list_notes(all_notes).await.pretty(2) }) - } -} +// TODO: implement notes command for sync feature +// FIXME: +// struct NotesCommand {} +// impl Command for NotesCommand { +// fn help(&self) -> &'static str { +// indoc! {r#" +// Show all shielded notes and transparent coins in this wallet +// Usage: +// notes [all] +// If you supply the "all" parameter, all previously spent shielded notes and transparent coins are also included +// "#} +// } + +// fn short_help(&self) -> &'static str { +// "Show all shielded notes and transparent coins in this wallet" +// } + +// fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { +// // Parse the args. +// if args.len() > 1 { +// return self.short_help().to_string(); +// } + +// // Make sure we can parse the amount +// let all_notes = if args.len() == 1 { +// match args[0] { +// "all" => true, +// a => { +// return format!( +// "Invalid argument \"{}\". Specify 'all' to include unspent notes", +// a +// ) +// } +// } +// } else { +// false +// }; + +// RT.block_on(async move { lightclient.do_list_notes(all_notes).await.pretty(2) }) +// } +// } struct QuitCommand {} impl Command for QuitCommand { @@ -1853,7 +1846,7 @@ pub fn get_commands() -> HashMap<&'static str, Box> { ("decryptmessage", Box::new(DecryptMessageCommand {})), ("parse_address", Box::new(ParseAddressCommand {})), ("parse_viewkey", Box::new(ParseViewKeyCommand {})), - ("interrupt_sync_after_batch", Box::new(InterruptCommand {})), + // ("interrupt_sync_after_batch", Box::new(InterruptCommand {})), ("changeserver", Box::new(ChangeServerCommand {})), ("rescan", Box::new(RescanCommand {})), ("clear", Box::new(ClearCommand {})), @@ -1863,7 +1856,7 @@ pub fn get_commands() -> HashMap<&'static str, Box> { ("addresses", Box::new(AddressCommand {})), ("height", Box::new(HeightCommand {})), ("sendprogress", Box::new(SendProgressCommand {})), - ("setoption", Box::new(SetOptionCommand {})), + // ("setoption", Box::new(SetOptionCommand {})), ("valuetransfers", Box::new(ValueTransfersCommand {})), ("transactions", Box::new(TransactionsCommand {})), ( @@ -1877,7 +1870,7 @@ pub fn get_commands() -> HashMap<&'static str, Box> { "memobytes_to_address", Box::new(MemoBytesToAddressCommand {}), ), - ("getoption", Box::new(GetOptionCommand {})), + // ("getoption", Box::new(GetOptionCommand {})), ("exportufvk", Box::new(ExportUfvkCommand {})), ("info", Box::new(InfoCommand {})), ("updatecurrentprice", Box::new(UpdateCurrentPriceCommand {})), @@ -1885,7 +1878,7 @@ pub fn get_commands() -> HashMap<&'static str, Box> { ("shield", Box::new(ShieldCommand {})), ("save", Box::new(DeprecatedNoCommand {})), ("quit", Box::new(QuitCommand {})), - ("notes", Box::new(NotesCommand {})), + // ("notes", Box::new(NotesCommand {})), ("new", Box::new(NewAddressCommand {})), ("defaultfee", Box::new(DefaultFeeCommand {})), ("seed", Box::new(SeedCommand {})), From c3a092aa98b695459b8bb9e7c23e2bdc6dbfe58e Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 21 Jan 2025 22:10:20 -0700 Subject: [PATCH 4/7] make do_addresses use interface with argument --- libtonode-tests/tests/concrete.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libtonode-tests/tests/concrete.rs b/libtonode-tests/tests/concrete.rs index 45ce2f136..1d6aab25e 100644 --- a/libtonode-tests/tests/concrete.rs +++ b/libtonode-tests/tests/concrete.rs @@ -109,6 +109,7 @@ mod fast { lightclient::from_inputs, }, wallet::data::summaries::{SelfSendValueTransfer, SentValueTransfer, ValueTransferKind}, + UAReceivers, }; use super::*; @@ -995,7 +996,7 @@ mod fast { for code in ["o", "zo", "z"] { recipient.do_new_address(code).await.unwrap(); } - let addresses = recipient.do_addresses().await; + let addresses = recipient.do_addresses(UAReceivers::All).await; let address_5000_nonememo_tuples = addresses .members() .map(|ua| (ua["address"].as_str().unwrap(), 5_000, None)) @@ -1058,7 +1059,7 @@ mod fast { //Verify that 1 increment of diversification with a tz receiver set produces uregtest1m8un60u... UA let new_address = recipient1.do_new_address("tzo").await.unwrap(); - let ua_index_1 = recipient1.do_addresses().await[1].clone(); + let ua_index_1 = recipient1.do_addresses(UAReceivers::All).await[1].clone(); let ua_address_index_1 = ua_index_1["address"].clone().to_string(); assert_eq!(&new_address[0].to_string(), &ua_address_index_1); let sapling_index_1 = ua_index_1["receivers"]["sapling"].clone().to_string(); @@ -1272,6 +1273,7 @@ mod slow { assert_transaction_summary_exists, lightclient::{from_inputs, get_fees_paid_by_client}, }; + use zingolib::UAReceivers; use super::*; @@ -1676,7 +1678,7 @@ mod slow { // let list = recipient.do_list_transactions().await; // assert_eq!(list[0]["block_height"].as_u64().unwrap(), 4); // assert_eq!( - // recipient.do_addresses().await[0]["receivers"]["transparent"].to_string(), + // recipient.do_addresses(UAReceivers::All).await[0]["receivers"]["transparent"].to_string(), // recipient_taddr // ); // assert_eq!(list[0]["amount"].as_u64().unwrap(), value); @@ -2453,7 +2455,7 @@ mod slow { // // 3. Check the balance is correct, and we received the incoming transaction from ?outside? // let b = recipient.do_balance().await; - // let addresses = recipient.do_addresses().await; + // let addresses = recipient.do_addresses(UAReceivers::All).await; // assert_eq!(b.sapling_balance.unwrap(), value); // assert_eq!(b.unverified_sapling_balance.unwrap(), 0); // assert_eq!(b.spendable_sapling_balance.unwrap(), value); @@ -3093,7 +3095,7 @@ mod slow { .await; let seed_of_recipient_restored = { recipient_restored.do_sync(true).await.unwrap(); - let restored_addresses = recipient_restored.do_addresses().await; + let restored_addresses = recipient_restored.do_addresses(UAReceivers::All).await; assert_eq!( &restored_addresses[0]["address"], &original_recipient_address From f05ce54a02f99b34d4368b1b466c2fa793477058 Mon Sep 17 00:00:00 2001 From: zancas Date: Wed, 22 Jan 2025 20:12:42 -0700 Subject: [PATCH 5/7] exclude 0 arg case --- zingolib/src/commands.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index 6aaaa144c..564b47c90 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -242,7 +242,7 @@ impl Command for ParseAddressCommand { } fn exec(&self, args: &[&str], _lightclient: &LightClient) -> String { - if args.len() > 1 { + if args.len() > 1 || args.len() == 0 { return self.help().to_string(); } fn make_decoded_chain_pair( From deebe07e8c0f9f7e5bfacc21f5389d78a9750164 Mon Sep 17 00:00:00 2001 From: zancas Date: Wed, 22 Jan 2025 20:14:12 -0700 Subject: [PATCH 6/7] apply lint --- zingolib/src/commands.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index 564b47c90..e53895929 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -242,7 +242,7 @@ impl Command for ParseAddressCommand { } fn exec(&self, args: &[&str], _lightclient: &LightClient) -> String { - if args.len() > 1 || args.len() == 0 { + if args.len() > 1 || args.is_empty() { return self.help().to_string(); } fn make_decoded_chain_pair( From fc3d2302de5129322e43ae7e876addd1ea4ed73e Mon Sep 17 00:00:00 2001 From: zancas Date: Wed, 22 Jan 2025 20:22:16 -0700 Subject: [PATCH 7/7] include orchard_only_ua whenever possible. --- zingolib/src/commands.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index e53895929..952df956b 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -288,19 +288,14 @@ impl Command for ParseAddressCommand { .to_string(), Address::Unified(ua) => { let mut receivers_available = vec![]; - if ua.orchard().is_some() { - receivers_available.push("orchard") - } if ua.sapling().is_some() { receivers_available.push("sapling") } if ua.transparent().is_some() { receivers_available.push("transparent") } - if ua.orchard().is_some() - && ua.sapling().is_some() - && ua.transparent().is_some() - { + if ua.orchard().is_some() { + receivers_available.push("orchard"); object! { "status" => "success", "chain_name" => chain_name_string,