From 9c4ef3e0194e6e56e1cc45f155b3e9df3d8a2207 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Thu, 24 Oct 2019 11:17:22 -0700 Subject: [PATCH] Wire up new seed page for wizard --- lib/Cargo.lock | 117 ++++++++++++++++++++++++++++++++++---- lib/Cargo.toml | 2 +- lib/src/lib.rs | 48 +++++++++++++++- lib/zecwalletlitelib.h | 13 +++-- src/connection.cpp | 43 ++++++++++---- src/connection.h | 2 + src/controller.cpp | 2 +- src/firsttimewizard.cpp | 122 ++++++++++++++++++++++++++++++++++++++++ src/firsttimewizard.h | 50 ++++++++++++++++ src/mainwindow.h | 4 +- src/newseed.ui | 63 +++++++++++++++++++++ src/newwallet.ui | 85 ++++++++++++++++++++++++++++ src/precompiled.h | 2 + src/restoreseed.ui | 53 +++++++++++++++++ src/settings.cpp | 2 +- src/settings.h | 2 + zecwallet-lite.pro | 5 ++ 17 files changed, 581 insertions(+), 34 deletions(-) create mode 100644 src/firsttimewizard.cpp create mode 100644 src/firsttimewizard.h create mode 100644 src/newseed.ui create mode 100644 src/newwallet.ui create mode 100644 src/restoreseed.ui diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 8b7d65d..4326aef 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -414,6 +414,17 @@ dependencies = [ "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "filetime" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fixedbitset" version = "0.1.9" @@ -647,6 +658,30 @@ name = "libc" version = "0.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "libflate" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rle-decode-fast 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libsodium-sys" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libflate 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "linked-hash-map" version = "0.5.2" @@ -914,6 +949,11 @@ dependencies = [ "fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pkg-config" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "ppv-lite86" version = "0.2.5" @@ -1011,7 +1051,7 @@ version = "0.1.0" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=e3a0fd2dea59c0cf6434148bf77fef84830cce02)", + "zecwalletlitelib 0.1.0", ] [[package]] @@ -1245,6 +1285,11 @@ dependencies = [ "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rle-decode-fast" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rust-argon2" version = "0.5.1" @@ -1429,6 +1474,16 @@ name = "smallvec" version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "sodiumoxide" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libsodium-sys 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "spin" version = "0.5.2" @@ -1511,6 +1566,22 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "take_mut" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "tar" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "filetime 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tempfile" version = "3.1.0" @@ -1801,7 +1872,7 @@ dependencies = [ [[package]] name = "tower-grpc" version = "0.1.1" -source = "git+https://github.com/tower-rs/tower-grpc#5308ec0d3433dd8c22cafd0ca37456824dff827e" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1829,7 +1900,7 @@ dependencies = [ [[package]] name = "tower-h2" version = "0.1.0" -source = "git+https://github.com/tower-rs/tower-h2#0865040d699697bbaf1c3b77b3f256b72f98cdf4" +source = "git+https://github.com/tower-rs/tower-h2?rev=0865040d699697bbaf1c3b77b3f256b72f98cdf4#0865040d699697bbaf1c3b77b3f256b72f98cdf4" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1901,7 +1972,7 @@ dependencies = [ [[package]] name = "tower-request-modifier" version = "0.1.0" -source = "git+https://github.com/tower-rs/tower-http#cb393c933f5167f934abde9d4f902e44d9ea2d50" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2030,6 +2101,11 @@ name = "untrusted" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "vcpkg" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "walkdir" version = "2.2.9" @@ -2118,6 +2194,14 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "xattr" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "yaml-rust" version = "0.4.3" @@ -2182,7 +2266,6 @@ dependencies = [ [[package]] name = "zecwalletlitelib" version = "0.1.0" -source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=e3a0fd2dea59c0cf6434148bf77fef84830cce02#e3a0fd2dea59c0cf6434148bf77fef84830cce02" dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bellman 0.1.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)", @@ -2207,13 +2290,14 @@ dependencies = [ "rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "secp256k1 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sodiumoxide 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-rustls 0.10.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-grpc 0.1.1 (git+https://github.com/tower-rs/tower-grpc)", + "tower-grpc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tower-grpc-build 0.1.0 (git+https://github.com/tower-rs/tower-grpc)", - "tower-h2 0.1.0 (git+https://github.com/tower-rs/tower-h2)", - "tower-request-modifier 0.1.0 (git+https://github.com/tower-rs/tower-http)", + "tower-h2 0.1.0 (git+https://github.com/tower-rs/tower-h2?rev=0865040d699697bbaf1c3b77b3f256b72f98cdf4)", + "tower-request-modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tower-service 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tower-util 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2276,6 +2360,7 @@ dependencies = [ "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum ff 0.4.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "" "checksum ff_derive 0.3.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "" +"checksum filetime 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd7380b54ced79dda72ecc35cc4fbbd1da6bba54afaa37e96fd1c2a308cd469" "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" "checksum flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" @@ -2305,6 +2390,8 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum libflate 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "d9135df43b1f5d0e333385cb6e7897ecd1a43d7d11b91ac003f4d2c2d2401fdd" +"checksum libsodium-sys 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1c344ff12b90ef8fa1f0fffacd348c1fd041db331841fec9eab23fdb991f5e73" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" @@ -2334,6 +2421,7 @@ dependencies = [ "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" +"checksum pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0" @@ -2370,6 +2458,7 @@ dependencies = [ "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" "checksum ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a" +"checksum rle-decode-fast 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" "checksum rust-embed 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8defb88737955626d62a4c7d90e2acf552a79b2f5bd7526cd46697f2d98eb45c" "checksum rust-embed-impl 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d88346d83619c94beddba4f2ffee53c4cd006afd44c303182c7bcc8b6abe5ae" @@ -2393,6 +2482,7 @@ dependencies = [ "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" +"checksum sodiumoxide 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585232e78a4fc18133eef9946d3080befdf68b906c51b621531c37e91787fa2b" "checksum spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" "checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" @@ -2403,6 +2493,8 @@ dependencies = [ "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" +"checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" +"checksum tar 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "b3196bfbffbba3e57481b6ea32249fbaf590396a52505a2615adbb79d9d826d3" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" @@ -2426,15 +2518,15 @@ dependencies = [ "checksum tower 0.1.1 (git+https://github.com/tower-rs/tower)" = "" "checksum tower-buffer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7b83e1ccf5b23dd109dd6ae2c07b8e2beec7a51a21f29da2dba576317370e0" "checksum tower-discover 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "73a7632286f78164d65d18fd0e570307acde9362489aa5c8c53e6315cc2bde47" -"checksum tower-grpc 0.1.1 (git+https://github.com/tower-rs/tower-grpc)" = "" +"checksum tower-grpc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddd833a116f724984a09ff25c27ea5d0b9a65d301f48048e366f8f3c6081c2cb" "checksum tower-grpc-build 0.1.0 (git+https://github.com/tower-rs/tower-grpc)" = "" -"checksum tower-h2 0.1.0 (git+https://github.com/tower-rs/tower-h2)" = "" +"checksum tower-h2 0.1.0 (git+https://github.com/tower-rs/tower-h2?rev=0865040d699697bbaf1c3b77b3f256b72f98cdf4)" = "" "checksum tower-http 0.1.0 (git+https://github.com/tower-rs/tower-http)" = "" "checksum tower-http-util 0.1.0 (git+https://github.com/tower-rs/tower-http)" = "" "checksum tower-layer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ddf07e10c07dcc8f41da6de036dc66def1a85b70eb8a385159e3908bb258328" "checksum tower-limit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d990c5b6c0e4e192db8cf3dacaafefe1278962d0ec45dc84421175db32d33f0" "checksum tower-load-shed 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04fbaf5bfb63d84204db87b9b2aeec61549613f2bbb8706dcc36f5f3ea8cd769" -"checksum tower-request-modifier 0.1.0 (git+https://github.com/tower-rs/tower-http)" = "" +"checksum tower-request-modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f6af257a01ba5f7a5c6190a70220cceebe832fa836e689cb8f73cb0e53112af5" "checksum tower-retry 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09e80588125061f276ed2a7b0939988b411e570a2dbb2965b1382ef4f71036f7" "checksum tower-service 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc0c98637d23732f8de6dfd16494c9f1559c3b9e20b4a46462c8f9b9e827bfa" "checksum tower-timeout 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c06bbc2fbd056f810940a8c6f0cc194557d36da3c22999a755a7a6612447da9" @@ -2451,6 +2543,7 @@ dependencies = [ "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" +"checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" "checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" "checksum webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4f7e1cd7900a3a6b65a3e8780c51a3e6b59c0e2c55c6dc69578c288d69f7d082" @@ -2463,8 +2556,8 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +"checksum xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c" "checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" "checksum zcash_client_backend 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "" "checksum zcash_primitives 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "" "checksum zcash_proofs 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "" -"checksum zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=e3a0fd2dea59c0cf6434148bf77fef84830cce02)" = "" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index e65a82b..fa78c8b 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -11,4 +11,4 @@ crate-type = ["staticlib"] [dependencies] libc = "0.2.58" lazy_static = "1.4.0" -zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "e3a0fd2dea59c0cf6434148bf77fef84830cce02" } \ No newline at end of file +zecwalletlitelib = { path = "../../lightwallet/lightwalletclient/lib/" } \ No newline at end of file diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 5fdc116..1bf53ba 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -25,14 +25,15 @@ pub extern fn litelib_wallet_exists(chain_name: *const c_char) -> bool { CStr::from_ptr(chain_name).to_string_lossy().into_owned() }; - let config = LightClientConfig::create_unconnected(chain_name_str); + let config = LightClientConfig::create_unconnected(chain_name_str, None); + println!("Wallet exists: {}", config.wallet_exists()); config.wallet_exists() } -// Initialize a new lightclient and store its value +/// Create a new wallet and return the seed for the newly created wallet. #[no_mangle] -pub extern fn litelib_initialze_existing(dangerous: bool, server: *const c_char) -> *mut c_char { +pub extern fn litelib_initialize_new(dangerous: bool, server: *const c_char) -> *mut c_char { let server_str = unsafe { assert!(!server.is_null()); @@ -48,6 +49,47 @@ pub extern fn litelib_initialze_existing(dangerous: bool, server: *const c_char) } }; + let lightclient = match LightClient::new(&config, latest_block_height) { + Ok(l) => l, + Err(e) => { + let e_str = CString::new(format!("Error: {}", e)).unwrap(); + return e_str.into_raw(); + } + }; + + let seed = match lightclient.do_seed_phrase() { + Ok(s) => s.dump(), + Err(e) => { + let e_str = CString::new(format!("Error: {}", e)).unwrap(); + return e_str.into_raw(); + } + }; + + LIGHTCLIENT.lock().unwrap().replace(Some(lightclient)); + + // Return the wallet's seed + let s_str = CString::new(seed).unwrap(); + return s_str.into_raw(); +} + +// Initialize a new lightclient and store its value +#[no_mangle] +pub extern fn litelib_initialize_existing(dangerous: bool, server: *const c_char) -> *mut c_char { + let server_str = unsafe { + assert!(!server.is_null()); + + CStr::from_ptr(server).to_string_lossy().into_owned() + }; + + let server = LightClientConfig::get_server_or_default(Some(server_str)); + let (config, _latest_block_height) = match LightClientConfig::create(server, dangerous) { + Ok((c, h)) => (c, h), + Err(e) => { + let e_str = CString::new(format!("Error: {}", e)).unwrap(); + return e_str.into_raw(); + } + }; + let lightclient = match LightClient::read_from_disk(&config) { Ok(l) => l, Err(e) => { diff --git a/lib/zecwalletlitelib.h b/lib/zecwalletlitelib.h index de1345d..c5bb4ed 100644 --- a/lib/zecwalletlitelib.h +++ b/lib/zecwalletlitelib.h @@ -5,13 +5,18 @@ extern "C" { #endif -extern bool litelib_wallet_exists (const char* chain_name); -extern char * litelib_initialze_existing (bool dangerous, const char* server); -extern char * litelib_execute (const char* s, const char* args); -extern void litelib_rust_free_string (char* s); +extern bool litelib_wallet_exists (const char* chain_name); +extern char * litelib_initialize_new (bool dangerous, const char* server); +extern char * litelib_initialize_existing (bool dangerous, const char* server); +extern char * litelib_execute (const char* s, const char* args); +extern void litelib_rust_free_string (char* s); #ifdef __cplusplus } #endif +// This is a function implemented in connection.cpp that will process a string response from +// the litelib and turn into into a QString in a memory-safe way. +QString litelib_process_response(char* resp); + #endif \ No newline at end of file diff --git a/src/connection.cpp b/src/connection.cpp index a078608..9f9a223 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -2,9 +2,11 @@ #include "mainwindow.h" #include "settings.h" #include "ui_connection.h" +#include "firsttimewizard.h" #include "ui_createzcashconfdialog.h" #include "controller.h" + #include "../lib/zecwalletlitelib.h" #include "precompiled.h" @@ -42,7 +44,15 @@ void ConnectionLoader::doAutoConnect() { // Initialize the library main->logger->write(QObject::tr("Attempting to initialize")); - litelib_initialze_existing(config->dangerous, config->server.toStdString().c_str()); + + // Check to see if there's an existing wallet + if (litelib_wallet_exists(Settings::getChainName().toStdString().c_str())) { + main->logger->write(QObject::tr("Using existing wallet.")); + litelib_initialize_existing(config->dangerous, config->server.toStdString().c_str()); + } else { + main->logger->write(QObject::tr("Create/restore wallet.")); + createOrRestore(config->dangerous, config->server); + } auto connection = makeConnection(config); @@ -54,6 +64,16 @@ void ConnectionLoader::doAutoConnect() { }, [=](auto err) {}); } +void ConnectionLoader::createOrRestore(bool dangerous, QString server) { + // Close the startup dialog, since we'll be showing the wizard + d->hide(); + + // Create a wizard + FirstTimeWizard wizard(dangerous, server); + + wizard.exec(); +} + void ConnectionLoader::doRPCSetConnection(Connection* conn) { rpc->setConnection(conn); @@ -94,15 +114,7 @@ void ConnectionLoader::showError(QString explanation) { d->close(); } - - -/*********************************************************************************** - * Connection, Executor and Callback Class - ************************************************************************************/ -void Executor::run() { - char* resp = litelib_execute(this->cmd.toStdString().c_str(), this->args.toStdString().c_str()); - - // Copy the string, since we need to return this back to rust +QString litelib_process_response(char* resp) { char* resp_copy = new char[strlen(resp) + 1]; strcpy(resp_copy, resp); litelib_rust_free_string(resp); @@ -111,6 +123,17 @@ void Executor::run() { memset(resp_copy, '-', strlen(resp_copy)); delete[] resp_copy; + return reply; +} + +/*********************************************************************************** + * Connection, Executor and Callback Class + ************************************************************************************/ +void Executor::run() { + char* resp = litelib_execute(this->cmd.toStdString().c_str(), this->args.toStdString().c_str()); + + QString reply = litelib_process_response(resp); + qDebug() << "Reply=" << reply; auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false); if (parsed.is_discarded() || parsed.is_null()) { diff --git a/src/connection.h b/src/connection.h index ec865b7..34dd416 100644 --- a/src/connection.h +++ b/src/connection.h @@ -33,6 +33,8 @@ private: void doAutoConnect(); + void createOrRestore(bool dangerous, QString server); + void showError(QString explanation); void showInformation(QString info, QString detail = ""); diff --git a/src/controller.cpp b/src/controller.cpp index 0a78f56..dbc1cac 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -417,7 +417,7 @@ void Controller::executeTransaction(Tx tx, std::cout << std::setw(2) << params << std::endl; zrpc->sendTransaction(QString::fromStdString(params.dump()), [=](const json& reply) { - if (reply["result"].is_null() || reply["result"] != "success") { + if (reply.find("txid") == reply.end()) { error("", "Couldn't understand Response: " + QString::fromStdString(reply.dump())); } diff --git a/src/firsttimewizard.cpp b/src/firsttimewizard.cpp new file mode 100644 index 0000000..52fdff3 --- /dev/null +++ b/src/firsttimewizard.cpp @@ -0,0 +1,122 @@ +#include "firsttimewizard.h" + +#include "ui_newseed.h" +#include "ui_restoreseed.h" +#include "ui_newwallet.h" + +#include "../lib/zecwalletlitelib.h" + +using json = nlohmann::json; + +FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server) +{ + setWindowTitle("New wallet wizard"); + this->dangerous = dangerous; + this->server = server; + + // Create the pages + setPage(Page_NewOrRestore, new NewOrRestorePage(this)); + setPage(Page_New, new NewSeedPage(this)); + setPage(Page_Restore,new RestoreSeedPage(this)); +} + +int FirstTimeWizard::nextId() const { + switch (currentId()) { + case Page_NewOrRestore: + if (field("intro.new").toBool()) { + return Page_New; + } else { + return Page_Restore; + } + case Page_New: + case Page_Restore: + default: + return -1; + } +} + +NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent) { + setTitle("Create or Restore wallet."); + + QWidget* pageWidget = new QWidget(); + Ui_CreateWalletForm form; + form.setupUi(pageWidget); + + // Exclusive buttons + QObject::connect(form.radioNewWallet, &QRadioButton::clicked, [=](bool checked) { + if (checked) { + form.radioRestoreWallet->setChecked(false); + } + }); + + QObject::connect(form.radioRestoreWallet, &QRadioButton::clicked, [=](bool checked) { + if (checked) { + form.radioNewWallet->setChecked(false); + } + }); + form.radioNewWallet->setChecked(true); + + registerField("intro.new", form.radioNewWallet); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(pageWidget); + setLayout(layout); + setCommitPage(true); + setButtonText(QWizard::CommitButton, "Next"); +} + +NewSeedPage::NewSeedPage(FirstTimeWizard *parent) : QWizardPage(parent) { + setTitle("Your new wallet"); + + QWidget* pageWidget = new QWidget(); + Ui_NewSeedForm form; + form.setupUi(pageWidget); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(pageWidget); + + setLayout(layout); + + // Call the library to create a new wallet. + char* resp = litelib_initialize_new(parent->dangerous, parent->server.toStdString().c_str()); + QString reply = litelib_process_response(resp); + + auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false); + if (parsed.is_discarded() || parsed.is_null() || parsed.find("seed") == parsed.end()) { + form.txtSeed->setPlainText(tr("Error creating a wallet") + "\n" + reply); + } else { + QString seed = QString::fromStdString(parsed["seed"].get()); + form.txtSeed->setPlainText(seed); + } +} + +// Will be called just before closing. Make sure we can save the seed in the wallet +// before we allow the page to be closed +bool NewSeedPage::validatePage() { + char* resp = litelib_execute("save", ""); + QString reply = litelib_process_response(resp); + + auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false); + if (parsed.is_discarded() || parsed.is_null() || parsed.find("result") == parsed.end()) { + QMessageBox::warning(this, tr("Failed to save wallet"), + tr("Couldn't save the wallet. Error") + "\n" + reply, + QMessageBox::Ok); + return false; + } else { + return true; + } +} + + +RestoreSeedPage::RestoreSeedPage(FirstTimeWizard *parent) : QWizardPage(parent) { + setTitle("Restore wallet from seed"); + + QWidget* pageWidget = new QWidget(); + Ui_RestoreSeedForm form; + form.setupUi(pageWidget); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(pageWidget); + + setLayout(layout); +} \ No newline at end of file diff --git a/src/firsttimewizard.h b/src/firsttimewizard.h new file mode 100644 index 0000000..830fe42 --- /dev/null +++ b/src/firsttimewizard.h @@ -0,0 +1,50 @@ +#ifndef FIRSTTIMEWIZARD_H +#define FIRSTTIMEWIZARD_H + +#include "precompiled.h" + +class FirstTimeWizard: public QWizard +{ +public: + FirstTimeWizard(bool dangerous, QString server); + +protected: + int nextId() const; + +private: + enum { + Page_NewOrRestore, + Page_New, + Page_Restore + }; + + bool dangerous; + QString server; + + friend class NewOrRestorePage; + friend class NewSeedPage; + friend class RestoreSeedPage; +}; + +class NewOrRestorePage: public QWizardPage { +public: + NewOrRestorePage(FirstTimeWizard* parent); +}; + + +class NewSeedPage: public QWizardPage { +public: + NewSeedPage(FirstTimeWizard* parent); +protected: + bool validatePage(); +}; + + +class RestoreSeedPage: public QWizardPage { +public: + RestoreSeedPage(FirstTimeWizard* parent); +}; + + + +#endif // FIRSTTIMEWIZARD_H diff --git a/src/mainwindow.h b/src/mainwindow.h index ca6432d..6250cea 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -17,7 +17,7 @@ using json = nlohmann::json; // Struct used to hold destination info when sending a Tx. struct ToFields { QString addr; - double amount; + qint64 amount; QString memo; }; @@ -25,7 +25,7 @@ struct ToFields { struct Tx { QString fromAddr; QList toAddrs; - double fee; + qint64 fee; }; namespace Ui { diff --git a/src/newseed.ui b/src/newseed.ui new file mode 100644 index 0000000..ed5d9ae --- /dev/null +++ b/src/newseed.ui @@ -0,0 +1,63 @@ + + + NewSeedForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + This is your new wallet's seed phrase. PLEASE BACK IT UP SECURELY. + + + true + + + + + + + The seed phrase is the only way to restore the wallet. If you forget the seed phrase, THERE IS NO WAY TO RESTORE YOUR WALLET AND THE FUNDS in it + + + true + + + + + + + + 0 + 0 + + + + + + + + + + true + + + + + + + + + + + diff --git a/src/newwallet.ui b/src/newwallet.ui new file mode 100644 index 0000000..9cf34c5 --- /dev/null +++ b/src/newwallet.ui @@ -0,0 +1,85 @@ + + + CreateWalletForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + 0 + 0 + + + + + + + + + + Restore wallet from seed + + + + + + + Restore an existing wallet, using the 24-word seed. + + + true + + + + + + + + + + + 0 + 0 + + + + + + + + + + Create a new Wallet + + + + + + + Create a new wallet with a randomly generated seed. + + + true + + + + + + + + + + + diff --git a/src/precompiled.h b/src/precompiled.h index 79c4c8b..1826cda 100644 --- a/src/precompiled.h +++ b/src/precompiled.h @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/src/restoreseed.ui b/src/restoreseed.ui new file mode 100644 index 0000000..2169bcf --- /dev/null +++ b/src/restoreseed.ui @@ -0,0 +1,53 @@ + + + RestoreSeedForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Please enter your 24-word seed below + + + true + + + + + + + + 0 + 0 + + + + + + + + + + false + + + + + + + + + + + diff --git a/src/settings.cpp b/src/settings.cpp index 4ad21e0..18f9d9c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -316,7 +316,7 @@ bool Settings::removeFromZcashConf(QString confLocation, QString option) { } double Settings::getMinerFee() { - return 0.0001; + return 10000; } double Settings::getZboardAmount() { diff --git a/src/settings.h b/src/settings.h index 395349e..bf2425d 100644 --- a/src/settings.h +++ b/src/settings.h @@ -119,6 +119,8 @@ public: static bool addToZcashConf(QString confLocation, QString line); static bool removeFromZcashConf(QString confLocation, QString option); + static QString getChainName() { return QString("test"); } + static const QString labelRegExp; static const int updateSpeed = 20 * 1000; // 20 sec diff --git a/zecwallet-lite.pro b/zecwallet-lite.pro index 85c1c0a..50ec246 100644 --- a/zecwallet-lite.pro +++ b/zecwallet-lite.pro @@ -36,6 +36,7 @@ UI_DIR = src CONFIG += c++14 SOURCES += \ + src/firsttimewizard.cpp \ src/main.cpp \ src/mainwindow.cpp \ src/balancestablemodel.cpp \ @@ -62,6 +63,7 @@ SOURCES += \ src/liteinterface.cpp HEADERS += \ + src/firsttimewizard.h \ src/mainwindow.h \ src/precompiled.h \ src/balancestablemodel.h \ @@ -91,7 +93,10 @@ HEADERS += \ FORMS += \ src/mainwindow.ui \ src/migration.ui \ + src/newseed.ui \ + src/newwallet.ui \ src/recurringpayments.ui \ + src/restoreseed.ui \ src/settings.ui \ src/about.ui \ src/confirm.ui \