diff --git a/.gitignore b/.gitignore index 708ea83..e0ad3e6 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ silentdragonlite.pro.user.4.10-pre1 silentdragonlite silentdragonlite_plugin_import.cpp silentdragonlite_resource.rc +SilentDragonLite \ No newline at end of file diff --git a/lib/Cargo.lock b/lib/Cargo.lock index feee5e8..089d4ac 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -149,18 +149,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bellman" version = "0.1.0" -source = "git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc#caaee693c47c2ee9ecd1e1546b8fe3c714f342bc" +source = "git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37" dependencies = [ "bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "blake2s_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "ff 0.4.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "group 0.1.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "group 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "pairing 0.14.2 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -424,17 +424,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ff" version = "0.4.0" -source = "git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc#caaee693c47c2ee9ecd1e1546b8fe3c714f342bc" +source = "git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff_derive 0.3.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "ff_derive 0.3.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ff_derive" version = "0.3.0" -source = "git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc#caaee693c47c2ee9ecd1e1546b8fe3c714f342bc" +source = "git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37" dependencies = [ "num-bigint 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -575,9 +575,9 @@ dependencies = [ [[package]] name = "group" version = "0.1.0" -source = "git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc#caaee693c47c2ee9ecd1e1546b8fe3c714f342bc" +source = "git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37" dependencies = [ - "ff 0.4.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "ff 0.4.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -996,11 +996,11 @@ dependencies = [ [[package]] name = "pairing" version = "0.14.2" -source = "git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc#caaee693c47c2ee9ecd1e1546b8fe3c714f342bc" +source = "git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", - "group 0.1.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "ff 0.4.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", + "group 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1177,7 +1177,7 @@ version = "0.1.0" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=44f64181143be9b3747b54580943017b85d93cd7)", + "silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad)", ] [[package]] @@ -1640,21 +1640,21 @@ dependencies = [ [[package]] name = "silentdragonlitelib" version = "0.1.0" -source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=44f64181143be9b3747b54580943017b85d93cd7#44f64181143be9b3747b54580943017b85d93cd7" +source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad#7efa024660cbe08e7eadf2524134e153c89c51ad" dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bellman 0.1.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "bellman 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "ff 0.4.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "json 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log4rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "pairing 0.14.2 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "prost 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "prost-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1672,9 +1672,9 @@ dependencies = [ "tonic-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "webpki 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)", "webpki-roots 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_client_backend 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", - "zcash_primitives 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", - "zcash_proofs 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "zcash_client_backend 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", + "zcash_primitives 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", + "zcash_proofs 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", ] [[package]] @@ -2383,34 +2383,34 @@ dependencies = [ [[package]] name = "zcash_client_backend" version = "0.0.0" -source = "git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc#caaee693c47c2ee9ecd1e1546b8fe3c714f342bc" +source = "git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37" dependencies = [ "bech32 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "bs58 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "ff 0.4.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "pairing 0.14.2 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "protobuf 2.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf-codegen-pure 2.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_primitives 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "zcash_primitives 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", ] [[package]] name = "zcash_primitives" version = "0.0.0" -source = "git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc#caaee693c47c2ee9ecd1e1546b8fe3c714f342bc" +source = "git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "blake2s_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crypto_api_chachapoly 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "ff 0.4.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "fpe 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "pairing 0.14.2 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2422,15 +2422,15 @@ dependencies = [ [[package]] name = "zcash_proofs" version = "0.0.0" -source = "git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc#caaee693c47c2ee9ecd1e1546b8fe3c714f342bc" +source = "git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37" dependencies = [ - "bellman 0.1.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "bellman 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", - "pairing 0.14.2 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "ff 0.4.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", + "pairing 0.14.2 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", "rand_os 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_primitives 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", + "zcash_primitives 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", ] [metadata] @@ -2455,7 +2455,7 @@ dependencies = [ "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" "checksum bech32 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cdcf67bb7ba7797a081cd19009948ab533af7c355d5caf1d08c777582d351e9c" -"checksum bellman 0.1.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" +"checksum bellman 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "" "checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" @@ -2491,8 +2491,8 @@ dependencies = [ "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "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/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" -"checksum ff_derive 0.3.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" +"checksum ff 0.4.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "" +"checksum ff_derive 0.3.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "" "checksum filetime 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d" "checksum fixedbitset 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" "checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" @@ -2510,7 +2510,7 @@ dependencies = [ "checksum futures-util 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c3f8c59707f898b8b6f0b54c2aef5408ae90a560b7bf0fbf1b95b3c652b0171" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -"checksum group 0.1.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" +"checksum group 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "" "checksum h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9433d71e471c1736fd5a61b671fc0b148d7a2992f666c958d03cd8feb3b88d1" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" @@ -2557,7 +2557,7 @@ dependencies = [ "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" -"checksum pairing 0.14.2 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" +"checksum pairing 0.14.2 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" @@ -2630,7 +2630,7 @@ dependencies = [ "checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" "checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" -"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=44f64181143be9b3747b54580943017b85d93cd7)" = "" +"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad)" = "" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" @@ -2706,6 +2706,6 @@ dependencies = [ "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/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" -"checksum zcash_primitives 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" -"checksum zcash_proofs 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" +"checksum zcash_client_backend 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "" +"checksum zcash_primitives 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "" +"checksum zcash_proofs 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index d0ee847..65c97ad 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" -silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "44f64181143be9b3747b54580943017b85d93cd7" } +silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "7efa024660cbe08e7eadf2524134e153c89c51ad" } diff --git a/res/silentdragonlite_es.qm b/res/silentdragonlite_es.qm index 9dad8df..91f9ffd 100644 Binary files a/res/silentdragonlite_es.qm and b/res/silentdragonlite_es.qm differ diff --git a/res/silentdragonlite_es.ts b/res/silentdragonlite_es.ts index 293ef07..84db05c 100644 --- a/res/silentdragonlite_es.ts +++ b/res/silentdragonlite_es.ts @@ -6,12 +6,12 @@ Label - + Etiqueta Address - + Dirección @@ -19,12 +19,12 @@ Address - + Dirección Amount - + Cantidad @@ -32,12 +32,12 @@ SilentDragonLite - + DragónSilenciosoLigero Starting Up - + Iniciando @@ -45,29 +45,30 @@ Wallet Password - + Contraseña de billetera Your wallet is encrypted. Please enter your wallet password - + Su billetera está encriptada. +Ingrese la contraseña de su billetera Wallet Decryption Failed - + Error de descifrado de billetera Please enter a valid password - + Ingrese una contraseña válida Failed to unlock wallet - + Error al desbloquear la billetera @@ -75,27 +76,27 @@ Please enter your wallet password Form - + Formulario Restore wallet from seed - + Restaurar billetera desde semilla Restore an existing wallet, using the 24-word seed. - + Restaurar una billetera existente, usando la semilla de 24 palabras. Create a new Wallet - + Crear una nueva billetera Create a new wallet with a randomly generated seed. - + Crear una nueva billetera con una semilla generada aleatoriamente. @@ -103,83 +104,83 @@ Please enter your wallet password Balance - + Saldo Summary - + Resumen Shielded - + Blindado Notarized - + Notarizado Transparent - + Transparente Total - + Total Your node is still syncing, balances may not be updated. - + Su nodo todavía se está sincronizando, los saldos pueden no actualizarse. Some transactions are not yet confirmed. Balances may change. - + Algunas transacciones aún no están confirmadas. Los saldos pueden cambiar. Total notarized funds available: - + Total de fondos notariales disponibles: Next Address - + Siguiente dirección Your node is still syncing, balances may not be updated - + Su nodo todavía se está sincronizando, los saldos pueden no actualizarse Address Balances - + Saldos de direcciones SilentDragonLite - + DragónSilenciosoLigero Send - + Enviar Send To - + Enviar a Recipient - + Destinatario @@ -188,13 +189,13 @@ Please enter your wallet password Address - + Dirección Address Book - + Libreta de direcciones @@ -202,12 +203,12 @@ Please enter your wallet password Amount - + Cantidad Max Available - + Máx. disponible @@ -215,73 +216,73 @@ Please enter your wallet password Memo - + Nota Add Recipient - + Agregar destinatario Recurring payment - + Pago recurrente Every month, starting 12-May-2012, for 6 payments - + Todos los meses, a partir del 12 de mayo de 2012, para 6 pagos Edit Schedule - + Editar horario Miner Fee - + Tarifa de minero 0 - + 0 Cancel - + Cancelar Receive - + Recibir Address Type - + Tipo de dirección z-Addr - + z-Direc t-Addr - + t-Direcc Information about Hush - + Información sobre Hush <html><head/><body><p align="center"><span style=" font-weight:600;">Hush Blockchain Information</span></p></body></html> - + <html><cabeza/><cuerpo><palign="centro"><estilo Span=" peso de fuente: 600;"> Información de la cadena de bloques de Hush</span></p></cuerpo></html> @@ -297,128 +298,128 @@ Please enter your wallet password <html><head/><body><p align="center">|</p></body></html> - + <html><cabeza/><cuerpo><palign="centro">El|</p></cuerpo></html> Difficulty - + Dificultad Last Notarized Block - + Último bloque notario Total Supply - + Suministro Total Longestchain - + Cadena más larga View All Addresses - + Ver todas las direcciones Label - + Etiqueta Update Label - + Actualizar etiqueta Address balance - + Saldo de dirección Optional - + Opcional Export Private Key - + Exportar clave privada Transactions - + Transacciones Version hushlightd - + Versión hushlightd BlockHeight - + AlturaDelBloque Supply zAddr - + Suministro zDirecc Supply tAddr - + Suministro tDirecc <html><head/><body><p align="center"><span style=" font-weight:600;">Hush Market Information</span></p></body></html> - + <html><head/><body><p align="center"><span style=" font-weight:600;">Información de mercado de Hush</span></p></body></html> Market Cap - + Capitalización de mercado Volume on Exchanges - + Volumen en intercambios <html><head/><body><p align="center">This is a Lightwallet, you cant mine with it!</p></body></html> - + <html><cabeza/><cuerpo><palign="centro">Esta es una Billetera Light,¡no puedes minar con ella!</p></cuerpo></html> &Send DenioD Feedback - + Enviar comentarios de DenioD &Export seed phrase - + Exportar frase semilla Encrypt Wallet - + Encriptar billetera Remove Wallet Encryption - + Eliminar encriptado de billetera Rescan - + Volver a escanear @@ -434,433 +435,434 @@ Please enter your wallet password Loading... - + Cargando... Next Halving - + Siguiente reducción a la mitad Vendor - + Proveedor &File - + Archivo &Help - + Ayuda &Apps - + Aplicaciones &Edit - + Editar E&xit - + E&xit &About - + Sobre &Settings - + Configuraciones Ctrl+P - + Ctrl+P &Hush Discord - + Discord de Hush &Hush Website - + Pagina web de Hush Check github.com for &updates - + Compruebe github.com para & actualizaciones &Export all private keys - + Exportar todas las claves privadas Address &book - + Libro Ctrl+B - + Ctrl+B Export transactions - + Transacciones de exportación Pay hush &URI... - + Paga con Hush &URI... Connect mobile &app - + Conectar móvil &Aplicación Ctrl+M - + Ctrl+M &Recurring Payments - + &Pagos recurrentes Request hush... - + Solicitar Hush… File a bug... - + Archivar un error... Copy txid - + Copiar txid View tx on block explorer - + Ver en el explorador de bloques Refresh - + Actualizar Restart - + Reiniciar Please restart Silentdragonlite to have the theme apply - + Reinicie Dragón silencioso ligero para que se aplique el tema This change can take a few seconds. - + Este cambio puede tardar unos segundos. Some feedback about SilentDragonlite or Hush... - + Algunos comentarios sobre Dragón silencioso ligero o Hush ... or SilentDragonLite - + o Dragón silencioso ligero Send DenioD some private and shielded feedback about - + Enviar DenioD algunos comentarios privados y protegidos sobre Paste HUSH URI - + Pegar URI HUSH Error paying HUSH URI - + Error al pagar HUSH URI URI should be of the form 'hush:<addr>?amt=x&memo=y - + URI debe tener la forma 'Hush:<Direct>?amt=x&nota=y Error - + Error Error exporting transactions, file was not saved - + Error al exportar transacciones, el archivo no se guardó Error getting private keys - + Error al obtener claves privadas Error loading private keys: - + Error al cargar claves privadas: These are all the private keys for all the addresses in your wallet - + Estas son todas las claves privadas para todas las direcciones en su billetera Private key for - + Clave privada para Save File - + Guardar archivo Wallet is already encrypted - + La billetera ya está encriptada Your wallet is already encrypted with a password. Please use 'Remove Wallet Encryption' if you want to remove the wallet encryption. - + Su billetera ya está encriptada con una contraseña. +Por favor use 'Eliminar la encriptacion de la billetera 'si desea eliminar el encriptado de billetera. Passwords don't match - + Contraseñas don't partido Error was: - + El error fue: Wallet Encrypted - + Billetera Encriptada Your wallet was successfully encrypted! The password will be needed to send funds or export private keys. - + ¡Su billetera fue encriptada con éxito! La contraseña será necesaria para enviar fondos o exportar claves privadas. Wallet Encryption Failed - + Encriptacion Wallet is not encrypted - + Error en el encriptado de billetera Your wallet is not encrypted with a password. - + Billetera no está encriptada Wallet Password - + Contraseña de billetera Please enter your wallet password - + Por favor ingrese la contraseña de su billetera Wallet Decryption Failed - + Error de descifrado de billetera Please enter a password to decrypt your wallet! - + ¡Ingrese una contraseña para descifrar su billetera! Wallet Encryption Removed - + Encriptacion de billetera eliminado Your wallet was successfully decrypted! You will no longer need a password to send funds or export private keys. - + ¡Su billetera fue descifrada con éxito! Ya no necesitará una contraseña para enviar fondos o exportar claves privadas. Copy block explorer link - + Copiar enlace del explorador de bloques Currency Change - + Cambio de moneda This is your wallet seed. Please back it up carefully and safely. - + Esta es la semilla de tu billetera. Haga una copia de seguridad con cuidado y seguridad. Unable to open file - + No se puede abrir el archivo Copy address - + Copiar dirección Copied to clipboard - + Copiado al portapapeles Get private key - + Obtener clave privada View on block explorer - + Ver en el explorador de bloques View Payment Request - + Ver solicitud de pago View Memo - + Ver Nota Reply to - + Responder a Created new t-Addr - + Creado nuevo t-Direcc Copy Address - + Copiar dirección Address has been previously used - + La dirección se ha utilizado previamente Address is unused - + La dirección no se utiliza Cannot support multiple addresses - + No puede soportar múltiples direcciones Recurring payments doesn't currently support multiple addresses - + Los pagos recurrentes no' Actualmente no admite varias direcciones Recipient - + Destinatario Only z-addresses can have memos - + Solo las direcciones z pueden tener notas Memos can only be used with z-addresses - + Las notas solo se pueden usar con direcciones z The memo field can only be used with a z-address. - + El campo nota solo se puede usar con una dirección z. doesn't look like a z-address - + no't parece una dirección z Please wait... - + Por favor espera... Computing your transaction - + Calculando su transacción Done! - + Listo! @@ -870,27 +872,31 @@ Have: %1 Need: %2 Note: Funds need 5 confirmations before they can be spent - + No hay suficientes fondos disponibles para enviar esta transacción +Tener:% 1 +Necesidad:% 2 + +Nota: Los fondos necesitan 5 confirmaciones antes de que puedan gastarse Transaction Error - + Error de transacción Recipient Address - + Dirección del destinatario is Invalid - + es inválido Amount for address '%1' is invalid! - + Cantidad para dirección '%1' es inválido! @@ -899,12 +905,12 @@ Note: Funds need 5 confirmations before they can be spent Memo - + Nota Include Reply Address - + Incluir dirección de respuesta @@ -912,7 +918,7 @@ Note: Funds need 5 confirmations before they can be spent Reply to - + Responder a @@ -920,32 +926,32 @@ Note: Funds need 5 confirmations before they can be spent Migration Turnstile - + Torniquete de migración Migration History - + Historial de migración Migrated Amount - + Cantidad migrada Unmigrated Amount - + Cantidad no emigrada Sprout -> Sapling migration enabled - + Brote -> Migración de Sapling habilitada If enabled, hushd will slowly migrate your Sprout shielded funds to your Sapling address. - + Si está habilitado, hushd migrará lentamente sus fondos protegidos de Sprout a su dirección de Sapling. @@ -953,53 +959,53 @@ Note: Funds need 5 confirmations before they can be spent Connect Mobile App - + Conectar aplicación móvil Scan this QRCode from your silentdragon companion app to connect your phone - + Escanee este código QR desde su aplicación complementaria Dragón silencioso para conectar su teléfono QR Code - + Código QR Connection String - + Cadena de conexión Allow connections over the internet via silentdragon wormhole - + Permitir conexiones a través de internet a través de agujero de gusano Dragón silencioso silentdragon Companion App - + Aplicación complementaria de Dragón silencioso Disconnect - + Desconectar TextLabel - + Etiqueta de texto Last seen: - + Visto por última vez: Connection type: - + Tipo de conexión: @@ -1007,17 +1013,17 @@ Note: Funds need 5 confirmations before they can be spent Form - + Formulario This is your new wallet's seed phrase. PLEASE BACK IT UP SECURELY. - + Esta es su nueva billetera 's frase de semilla. POR FAVOR HAGA UNA COPIA DE SEGURIDAD. 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 - + La frase semilla es la única forma de restaurar la billetera. Si olvida la frase semilla, NO HAY FORMA DE RESTAURAR SU BILLETERA Y LOS FONDOS en ella @@ -1025,17 +1031,17 @@ Note: Funds need 5 confirmations before they can be spent Error creating a wallet - + Error al crear una billetera Failed to save wallet - + Error al guardar la billetera Couldn't save the wallet - + Podría 't guardar la billetera @@ -1043,7 +1049,7 @@ Note: Funds need 5 confirmations before they can be spent Private Keys - + Claves privadas @@ -1051,257 +1057,259 @@ Note: Funds need 5 confirmations before they can be spent Pick - + Elegir Address or Label Error - + Dirección o error de etiqueta Address or Label cannot be empty - + La dirección o etiqueta no puede estar vacía Address Format Error - + Error de formato de dirección %1 doesn't seem to be a valid hush address. - + >% 1 no' parece ser una dirección de Hush válida. Label Error - + Error de etiqueta The label '%1' already exists. Please remove the existing label. - + La etiqueta '%1' ya existe. Elimine la etiqueta existente. Import Address Book - + Importar libreta de direcciones Unable to open file - + No se puede abrir el archivo Address Book Import Done - + Importación de libreta de direcciones realizada Imported %1 new Address book entries - + Importado% 1 nuevas entradas de la libreta de direcciones Copy address - + Copiar dirección Copied to clipboard - + Copiado al portapapeles Delete label - + Eliminar etiqueta Attempting to initialize library with - + Intentando inicializar la biblioteca con Using existing wallet. - + Utilizando la billetera existente. Create/restore wallet. - + Crear/restaurar billetera. Connection Error - + Error de conexión Transaction Error - + Error de transacción There was an error sending the transaction. The error was: - + Hubo un error al enviar la transacción. El error fue: No Connection - + Sin conexión There was an error connecting to hushd. The error was - + Hubo un error al conectarse a hushd. El error fue Tx - + Tx failed - + falló The transaction with id - + La transacción con id failed. The error was - + falló. El error fue Update Available - + Actualización disponible A new release v%1 is available! You have v%2. Would you like to visit the releases page? - + ¡Una nueva versión v% 1 está disponible! Tienes v% 2. + +¿Te gustaría visitar la página de lanzamientos? No updates available - + No hay actualizaciones disponibles You already have the latest release v%1 - + Ya tienes la última versión v% 1 Please wait for SilentDragonLite to exit - + Espere a que DragónSilenciosoLigero salga Waiting for hushd to exit - + Esperando a que hushd salga No hush price was available to convert from USD - + No había precio de Hush disponible para convertir desde USD View on block explorer - + Ver en el explorador de bloques View Error - + Ver Error Reported Error - + Error informado Are you sure you want to delete the recurring payment? - + ¿Está seguro de que desea eliminar el pago recurrente? All future payments will be cancelled. - + Todos los pagos futuros serán cancelados. Tx submitted (right click to copy) txid: - + Tx enviado (clic derecho para copiar) txid: Type - + Tipo Address - + Dirección Date/Time - + Fecha/Hora Confirmations - + Confirmaciones Amount - + Cantidad Connected directly - + Conectado directamente Connected over the internet via silentdragon wormhole service - + Conectado a través de Internet a través del servicio de agujero de gusano Dragón silencioso Node is still syncing. - + El nodo todavía se está sincronizando. No sapling or transparent addresses with enough balance to spend. - + Sin sapling o direcciones transparentes con saldo suficiente para gastar. @@ -1309,17 +1317,17 @@ Would you like to visit the releases page? Dialog - + Diálogo View - + Ver Delete - + Eliminar @@ -1327,37 +1335,37 @@ Would you like to visit the releases page? Amount - + Cantidad Schedule - + Horario Payments Left - + Pagos restantes Next Payment - + Próximo pago To - + A Every - + Cada None - + Ninguno @@ -1365,7 +1373,7 @@ Would you like to visit the releases page? Payments - + Pagos @@ -1373,48 +1381,48 @@ Would you like to visit the releases page? Date - + Fecha Status - + Estado Txid - + Not due yet - + Todavía no se debe Pending - + Pendiente Skipped - + Saltado Paid - + Pagado Error - + Error Unknown - + Desconocido @@ -1422,62 +1430,62 @@ Would you like to visit the releases page? Dialog - + Diálogo No payments will be processed. You can manually pay them from the Recurring Payments Dialog box - + No se procesarán pagos. Puede pagarlos manualmente desde el cuadro de diálogo Pagos periódicos Schedule - + Horario How should silentdragon proceed? - + ¿Cómo debe proceder Dragón silencioso? Pay All in 1 Tx - + Pagar todo en 1 Tx Only the latest pending payment will be processed. All previous pending payments will be skipped - + Solo se procesará el último pago pendiente. Todos los pagos pendientes anteriores se omitirán Pay Latest Only - + Pague solo la última Pay None - + No pagar All pending payments collected, added up and paid in a single transaction - + Todos los pagos pendientes recopilados, sumados y pagados en una sola transacción Description - + Descripción To - + A The following recurring payment has multiple payments pending - + El siguiente pago recurrente tiene varios pagos pendientes @@ -1485,92 +1493,92 @@ Would you like to visit the releases page? Payment Request - + Solicitud de pago AddressBook - + Libreta de direcciones Request From - + Solicitud de My Address - + Mi dirección Amount in - + Cantidad en z address - + dirección z Amount - + Cantidad The recipient will see this address in the "to" field when they pay your request. - + El destinatario verá esta dirección en el " a " campo cuando pagan su solicitud. Amount USD - + Cantidad USD Memo - + Nota TextLabel - + Etiqueta de texto Request payment from a Sapling address. You'll send a hush 0.0001 transaction to the address with a hush payment URI. The memo will be included in the transaction when the address pays you. - + Solicitar pago de una dirección de Sapling. Usted ' Enviaré una transacción de silencio 0.0001 a la dirección con un URI de pago de hush. La nota se incluirá en la transacción cuando la dirección le pague. Error paying hush URI - + Error al pagar Hush URI URI should be of the form 'hush:<addr>?amt=x&memo=y - + URI debe tener la forma ' Hush:<Direcc>?amt=x&nota=y Pay To - + Pagar a Pay - + Pagar You are paying a payment request. Your address will not be visible to the person requesting this payment. - + Estás pagando una solicitud de pago. Su dirección no será visible para la persona que solicita este pago. Can only request from Sapling addresses - + Solo puede solicitar direcciones de Sapling @@ -1578,32 +1586,32 @@ Would you like to visit the releases page? Form - + Formulario Please enter your 24-word seed below - + Ingrese su semilla de 24 palabras a continuación Wallet Seed - + Semilla de billetera Wallet Birthday - + Cumpleaños de billetera 0 - + 0 Wallet birthday is the block height at which the wallet had the first transaction. If you don't know this, you can leave it as "0" (It'll take longer to rescan) - + Cumpleaños de la billetera es la altura del bloque en el que la billetera realizó la primera transacción. Si no lo haces ' No sé esto, puede dejarlo como "0'(Se puede ' tomar más tiempo para volver a escanear) @@ -1612,37 +1620,37 @@ Would you like to visit the releases page? Failed to restore wallet - + Error al restaurar la billetera SilentDragonLite needs 24 words to restore wallet - + Dragón silencioso ligero necesita 24 palabras para restaurar la billetera Failed to parse wallet birthday - + Error al analizar el cumpleaños de la billetera Couldn't understand wallet birthday. This should be a block height from where to rescan the wallet. You can leave it as '0' if you don't know what it should be. - + Podría ' No entiendo el cumpleaños de la billetera. Esto debe ser una altura de bloque desde donde volver a escanear la billetera. Puedes dejarlo como ' 0 ' si no lo haces ' No sé lo que debería ser. Couldn't restore the wallet - + Podría 't restaurar la billetera Failed to save wallet - + Error al guardar la billetera Couldn't save the wallet - + Podría 't guardar la billetera @@ -1650,47 +1658,47 @@ Would you like to visit the releases page? Settings - + Configuración Lightwallet Server - + Billetera Servidor Light Options - + Opciones Connect to github on startup to check for updates - + Conéctese a github en el inicio para buscar actualizaciones Connect to the internet to fetch hush prices - + Conéctese a internet para obtener precios de Hush Check github for updates at startup - + Verifique github para actualizaciones al inicio Theme - + Tema default - + Predeterminado Connection - + Conexión @@ -1710,62 +1718,62 @@ Would you like to visit the releases page? Fetch hush prices - + Ir a buscar precios de Hush Currency - + Moneda AUD - + AUD BTC - + BTC CAD - + CAD CHF - + CHF CNY - + CNY EUR - + EUR GBP - + GBP INR - + INR RUB - + RUB USD - + USD @@ -1773,12 +1781,12 @@ Would you like to visit the releases page? All Addresses - + Todas las direcciones Export All Keys - + Exportar todas las claves @@ -1786,12 +1794,12 @@ Would you like to visit the releases page? Address - + Dirección Balance (%1) - + Saldo (% 1) @@ -1799,7 +1807,7 @@ Would you like to visit the releases page? About - + Acerca de @@ -1807,32 +1815,32 @@ Would you like to visit the releases page? Address Book - + Libreta de direcciones Add New Address - + Agregar nueva dirección Address (z-Addr or t-Addr) - + Dirección (z-Direcc o t-Direcc) Label - + Etiqueta Add to Address Book - + Agregar a la libreta de direcciones Import Address Book - + Importar libreta de direcciones @@ -1840,27 +1848,27 @@ Would you like to visit the releases page? Confirm Transaction - + Confirmar transacción To - + A Recurring Payment - + Pago Recurrente TextLabel - + Etiqueta de texto You are sending a transaction while your node is still syncing. This may not work. - + Está enviando una transacción mientras su nodo todavía se está sincronizando. Esto puede no funcionar. @@ -1868,52 +1876,52 @@ Would you like to visit the releases page? Configure hush.conf - + Configurar hush.conf Your hush node will be configured for you automatically - + Su nodo de Hush se configurará para usted automáticamente Show Advanced Configuration - + Mostrar configuración avanzada Allow connections to the internet to check for updates, get hush prices etc... - + Permitir conexiones a Internet para buscar actualizaciones, obtener precios de Hush, etc... Use custom datadir - + Usar datadir personalizado Choose directory - + Elija el directorio Please note that you'll need to already have a Tor service configured on port 9050 - + Tenga en cuenta que usted ' ya necesitará tener un servicio Tor configurado en el puerto 9050 Connect to the internet for updates and price feeds - + Conéctese a internet para actualizaciones y precios Please choose a directory to store your wallet.dat and blockchain - + Elija un directorio para almacenar su wallet.dat y cadena de bloques Connect over Tor - + Conectar a través de Tor @@ -1921,27 +1929,27 @@ Would you like to visit the releases page? Encrypt Your Wallet - + Encriptar su billetera Encryption Password: - + Encriptar Contraseña: Confirm Password: - + Confirmar contraseña: Passwords don't match - + Contraseñas don't no coincide WARNING: If you forget your password, the only way to recover the wallet is from the seed phrase. - + ADVERTENCIA: Si olvida su contraseña, la única forma de recuperar la billetera es desde la frase inicial. @@ -1949,47 +1957,47 @@ Would you like to visit the releases page? Edit Schedule - + Editar horario Payment Description - + Descripción del pago Schedule - + Horario Next Payment - + Próximo pago Amount - + Cantidad Memo - + Nota To - + A From - + Desde Number of payments - + Número de pagos diff --git a/silentdragon-lite.pro b/silentdragon-lite.pro index 68f2fea..cc9092d 100644 --- a/silentdragon-lite.pro +++ b/silentdragon-lite.pro @@ -132,7 +132,7 @@ TRANSLATIONS = res/silentdragonlite_es.ts \ res/silentdragonlite_tr.ts include(singleapplication/singleapplication.pri) -DEFINES += QAPPLICATION_CLASS=QApplication +DEFINES += QAPPLICATION_CLASS=QApplication _FORTIFY_SOURCE=2 QMAKE_INFO_PLIST = res/Info.plist diff --git a/src/DataStore.h b/src/DataStore.h new file mode 100644 index 0000000..19daa1b --- /dev/null +++ b/src/DataStore.h @@ -0,0 +1,58 @@ +#ifndef DATASTORE_H +#define DATASTORE_H + +#include +#include + +template +class DataStore +{ + private: + static bool instanced; + static DataStore* instance; + std::map data; + DataStore() + { + + } + + public: + static DataStore* getInstance() + { + if(!DataStore::instanced) + { + DataStore::instanced = true; + DataStore::instance = new DataStore(); + } + + return DataStore::instance; + } + + void clear(); + void setData(QString key, T value); + QString getData(QString key); + + ~DataStore() + { + DataStore::instanced = false; + } +}; + +template +void DataStore::clear() +{ + this->data.clear(); +} + +template +void DataStore::setData(QString key, T value) +{ + this->data[key] = value; +} + +template +QString DataStore::getData(QString key) +{ + return this->data[key]; +} +#endif \ No newline at end of file diff --git a/src/addressbook.cpp b/src/addressbook.cpp index 76d135c..a00a355 100644 --- a/src/addressbook.cpp +++ b/src/addressbook.cpp @@ -6,85 +6,99 @@ #include "controller.h" -AddressBookModel::AddressBookModel(QTableView *parent) - : QAbstractTableModel(parent) { +AddressBookModel::AddressBookModel(QTableView *parent) : QAbstractTableModel(parent) +{ headers << tr("Label") << tr("Address"); - this->parent = parent; loadData(); } -AddressBookModel::~AddressBookModel() { +AddressBookModel::~AddressBookModel() +{ saveData(); } -void AddressBookModel::saveData() { +void AddressBookModel::saveData() +{ // Save column positions - QSettings().setValue("addresstablegeometry", parent->horizontalHeader()->saveState()); + QSettings().setValue( + "addresstablegeometry", + parent->horizontalHeader()->saveState() + ); } -void AddressBookModel::loadData() { +void AddressBookModel::loadData() +{ labels = AddressBook::getInstance()->getAllAddressLabels(); - - parent->horizontalHeader()->restoreState(QSettings().value("addresstablegeometry").toByteArray()); + parent->horizontalHeader()->restoreState( + QSettings().value( + "addresstablegeometry" + ).toByteArray() + ); } -void AddressBookModel::addNewLabel(QString label, QString addr) { +void AddressBookModel::addNewLabel(QString label, QString addr) +{ //labels.push_back(QPair(label, addr)); AddressBook::getInstance()->addAddressLabel(label, addr); - labels.clear(); labels = AddressBook::getInstance()->getAllAddressLabels(); - dataChanged(index(0, 0), index(labels.size()-1, columnCount(index(0,0))-1)); layoutChanged(); } -void AddressBookModel::removeItemAt(int row) { +void AddressBookModel::removeItemAt(int row) +{ if (row >= labels.size()) return; - AddressBook::getInstance()->removeAddressLabel(labels[row].first, labels[row].second); - + AddressBook::getInstance()->removeAddressLabel(labels[row].first, labels[row].second); labels.clear(); labels = AddressBook::getInstance()->getAllAddressLabels(); - dataChanged(index(0, 0), index(labels.size()-1, columnCount(index(0,0))-1)); layoutChanged(); } -QPair AddressBookModel::itemAt(int row) { - if (row >= labels.size()) return QPair(); +QPair AddressBookModel::itemAt(int row) +{ + if (row >= labels.size()) + return QPair(); return labels.at(row); } -int AddressBookModel::rowCount(const QModelIndex&) const { +int AddressBookModel::rowCount(const QModelIndex&) const +{ return labels.size(); } -int AddressBookModel::columnCount(const QModelIndex&) const { +int AddressBookModel::columnCount(const QModelIndex&) const +{ return headers.size(); } -QVariant AddressBookModel::data(const QModelIndex &index, int role) const { - if (role == Qt::DisplayRole) { - switch(index.column()) { +QVariant AddressBookModel::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DisplayRole) + { + switch(index.column()) + { case 0: return labels.at(index.row()).first; case 1: return labels.at(index.row()).second; } } + return QVariant(); } -QVariant AddressBookModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { +QVariant AddressBookModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role == Qt::DisplayRole && orientation == Qt::Horizontal) return headers.at(section); - } return QVariant(); } @@ -93,28 +107,27 @@ QVariant AddressBookModel::headerData(int section, Qt::Orientation orientation, //=============== // AddressBook //=============== -void AddressBook::open(MainWindow* parent, QLineEdit* target) { +void AddressBook::open(MainWindow* parent, QLineEdit* target) +{ QDialog d(parent); Ui_addressBook ab; ab.setupUi(&d); Settings::saveRestore(&d); - QRegExpValidator v(QRegExp(Settings::labelRegExp), ab.label); ab.label->setValidator(&v); - AddressBookModel model(ab.addresses); ab.addresses->setModel(&model); // If there is no target, the we'll call the button "Ok", else "Pick" - if (target != nullptr) { + if (target != nullptr) ab.buttonBox->button(QDialogButtonBox::Ok)->setText(QObject::tr("Pick")); - } // Connect the dialog's closing to updating the label address completor QObject::connect(&d, &QDialog::finished, [=] (auto) { parent->updateLabels(); }); // If there is a target then make it the addr for the "Add to" button - if (target != nullptr && Settings::isValidAddress(target->text())) { + if (target != nullptr && Settings::isValidAddress(target->text())) + { ab.addr->setText(target->text()); ab.label->setFocus(); } @@ -124,26 +137,37 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { auto addr = ab.addr->text().trimmed(); QString newLabel = ab.label->text(); - if (addr.isEmpty() || newLabel.isEmpty()) { - QMessageBox::critical(parent, QObject::tr("Address or Label Error"), - QObject::tr("Address or Label cannot be empty"), QMessageBox::Ok); + if (addr.isEmpty() || newLabel.isEmpty()) + { + QMessageBox::critical( + parent, + QObject::tr("Address or Label Error"), + QObject::tr("Address or Label cannot be empty"), + QMessageBox::Ok + ); return; } // Test if address is valid. - if (!Settings::isValidAddress(addr)) { - QMessageBox::critical(parent, QObject::tr("Address Format Error"), - QObject::tr("%1 doesn't seem to be a valid hush address.") - .arg(addr), - QMessageBox::Ok); + if (!Settings::isValidAddress(addr)) + { + QMessageBox::critical( + parent, + QObject::tr("Address Format Error"), + QObject::tr("%1 doesn't seem to be a valid hush address.").arg(addr), + QMessageBox::Ok + ); return; } // Don't allow duplicate address labels. - if (!getInstance()->getAddressForLabel(newLabel).isEmpty()) { - QMessageBox::critical(parent, QObject::tr("Label Error"), - QObject::tr("The label '%1' already exists. Please remove the existing label.") - .arg(newLabel), - QMessageBox::Ok); + if (!getInstance()->getAddressForLabel(newLabel).isEmpty()) + { + QMessageBox::critical( + parent, + QObject::tr("Label Error"), + QObject::tr("The label '%1' already exists. Please remove the existing label.").arg(newLabel), + QMessageBox::Ok + ); return; } @@ -153,21 +177,30 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { // Import Button QObject::connect(ab.btnImport, &QPushButton::clicked, [&] () { // Get the import file name. - auto fileName = QFileDialog::getOpenFileUrl(&d, QObject::tr("Import Address Book"), QUrl(), - "CSV file (*.csv)"); + auto fileName = QFileDialog::getOpenFileUrl( + &d, QObject::tr("Import Address Book"), + QUrl(), + "CSV file (*.csv)" + ); if (fileName.isEmpty()) return; QFile file(fileName.toLocalFile()); - if (!file.open(QIODevice::ReadOnly)) { - QMessageBox::information(&d, QObject::tr("Unable to open file"), file.errorString()); + if (!file.open(QIODevice::ReadOnly)) + { + QMessageBox::information( + &d, + QObject::tr("Unable to open file"), + file.errorString() + ); return; } QTextStream in(&file); QString line; int numImported = 0; - while (in.readLineInto(&line)) { + while (in.readLineInto(&line)) + { QStringList items = line.split(","); if (items.size() != 2) continue; @@ -180,8 +213,11 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { numImported++; } - QMessageBox::information(&d, QObject::tr("Address Book Import Done"), - QObject::tr("Imported %1 new Address book entries").arg(numImported)); + QMessageBox::information( + &d, + QObject::tr("Address Book Import Done"), + QObject::tr("Imported %1 new Address book entries").arg(numImported) + ); }); auto fnSetTargetLabelAddr = [=] (QLineEdit* target, QString label, QString addr) { @@ -194,7 +230,8 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { if (!target) return; - if (index.row() < 0) return; + if (index.row() < 0) + return; QString lbl = model.itemAt(index.row()).first; QString addr = model.itemAt(index.row()).second; @@ -206,20 +243,19 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { ab.addresses->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(ab.addresses, &QTableView::customContextMenuRequested, [&] (QPoint pos) { QModelIndex index = ab.addresses->indexAt(pos); - - if (index.row() < 0) return; + if (index.row() < 0) + return; QString lbl = model.itemAt(index.row()).first; QString addr = model.itemAt(index.row()).second; QMenu menu(parent); - if (target != nullptr) { + if (target != nullptr) menu.addAction("Pick", [&] () { d.accept(); fnSetTargetLabelAddr(target, lbl, addr); }); - } menu.addAction(QObject::tr("Copy address"), [&] () { QGuiApplication::clipboard()->setText(addr); @@ -248,27 +284,30 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { //============= // AddressBook singleton class //============= -AddressBook* AddressBook::getInstance() { +AddressBook* AddressBook::getInstance() +{ if (!instance) instance = new AddressBook(); return instance; } -AddressBook::AddressBook() { +AddressBook::AddressBook() +{ readFromStorage(); } -void AddressBook::readFromStorage() { +void AddressBook::readFromStorage() +{ QFile file(AddressBook::writeableFile()); - if (file.exists()) { + if (file.exists()) + { allLabels.clear(); file.open(QIODevice::ReadOnly); QDataStream in(&file); // read the data serialized from the file QString version; in >> version >> allLabels; - file.close(); } @@ -282,7 +321,8 @@ void AddressBook::readFromStorage() { // } } -void AddressBook::writeToStorage() { +void AddressBook::writeToStorage() +{ QFile file(AddressBook::writeableFile()); file.open(QIODevice::ReadWrite | QIODevice::Truncate); QDataStream out(&file); // we will serialize the data into the file @@ -290,42 +330,44 @@ void AddressBook::writeToStorage() { file.close(); } -QString AddressBook::writeableFile() { +QString AddressBook::writeableFile() +{ auto filename = QStringLiteral("addresslabels.dat"); - auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); if (!dir.exists()) QDir().mkpath(dir.absolutePath()); - if (Settings::getInstance()->isTestnet()) { + if (Settings::getInstance()->isTestnet()) return dir.filePath("testnet-" % filename); - } else { + + else return dir.filePath(filename); - } } // Add a new address/label to the database -void AddressBook::addAddressLabel(QString label, QString address) { +void AddressBook::addAddressLabel(QString label, QString address) +{ Q_ASSERT(Settings::isValidAddress(address)); // First, remove any existing label // Iterate over the list and remove the label/address - for (int i=0; i < allLabels.size(); i++) { - if (allLabels[i].first == label) { + for (int i=0; i < allLabels.size(); i++) + if (allLabels[i].first == label) removeAddressLabel(allLabels[i].first, allLabels[i].second); - } - } allLabels.push_back(QPair(label, address)); writeToStorage(); } // Remove a new address/label from the database -void AddressBook::removeAddressLabel(QString label, QString address) { +void AddressBook::removeAddressLabel(QString label, QString address) +{ // Iterate over the list and remove the label/address - for (int i=0; i < allLabels.size(); i++) { - if (allLabels[i].first == label && allLabels[i].second == address) { + for (int i=0; i < allLabels.size(); i++) + { + if (allLabels[i].first == label && allLabels[i].second == address) + { allLabels.removeAt(i); writeToStorage(); return; @@ -333,10 +375,13 @@ void AddressBook::removeAddressLabel(QString label, QString address) { } } -void AddressBook::updateLabel(QString oldlabel, QString address, QString newlabel) { +void AddressBook::updateLabel(QString oldlabel, QString address, QString newlabel) +{ // Iterate over the list and update the label/address - for (int i = 0; i < allLabels.size(); i++) { - if (allLabels[i].first == oldlabel && allLabels[i].second == address) { + for (int i = 0; i < allLabels.size(); i++) + { + if (allLabels[i].first == oldlabel && allLabels[i].second == address) + { allLabels[i].first = newlabel; writeToStorage(); return; @@ -345,42 +390,46 @@ void AddressBook::updateLabel(QString oldlabel, QString address, QString newlabe } // Read all addresses -const QList>& AddressBook::getAllAddressLabels() { - if (allLabels.isEmpty()) { +const QList>& AddressBook::getAllAddressLabels() +{ + if (allLabels.isEmpty()) readFromStorage(); - } + return allLabels; } // Get the label for an address -QString AddressBook::getLabelForAddress(QString addr) { - for (auto i : allLabels) { +QString AddressBook::getLabelForAddress(QString addr) +{ + for (auto i : allLabels) if (i.second == addr) return i.first; - } return ""; } // Get the address for a label -QString AddressBook::getAddressForLabel(QString label) { - for (auto i: allLabels) { +QString AddressBook::getAddressForLabel(QString label) +{ + for (auto i: allLabels) if (i.first == label) return i.second; - } return ""; } -QString AddressBook::addLabelToAddress(QString addr) { +QString AddressBook::addLabelToAddress(QString addr) +{ QString label = AddressBook::getInstance()->getLabelForAddress(addr); if (!label.isEmpty()) return label + "/" + addr; + else return addr; } -QString AddressBook::addressFromAddressLabel(const QString& lblAddr) { +QString AddressBook::addressFromAddressLabel(const QString& lblAddr) +{ return lblAddr.trimmed().split("/").last(); } diff --git a/src/addresscombo.cpp b/src/addresscombo.cpp index 2fc7031..8f9b0b4 100644 --- a/src/addresscombo.cpp +++ b/src/addresscombo.cpp @@ -2,29 +2,31 @@ #include "addressbook.h" #include "settings.h" -AddressCombo::AddressCombo(QWidget* parent) : - QComboBox(parent) { -} +AddressCombo::AddressCombo(QWidget* parent): QComboBox(parent) +{} -QString AddressCombo::itemText(int i) { +QString AddressCombo::itemText(int i) +{ QString txt = QComboBox::itemText(i); return AddressBook::addressFromAddressLabel(txt.split("(")[0].trimmed()); } -QString AddressCombo::currentText() { +QString AddressCombo::currentText() +{ QString txt = QComboBox::currentText(); return AddressBook::addressFromAddressLabel(txt.split("(")[0].trimmed()); } -void AddressCombo::setCurrentText(const QString& text) { - for (int i=0; i < count(); i++) { - if (itemText(i) == text) { +void AddressCombo::setCurrentText(const QString& text) +{ + for (int i=0; i < count(); i++) + if (itemText(i) == text) QComboBox::setCurrentIndex(i); - } - } + } -void AddressCombo::addItem(const QString& text, CAmount bal) { +void AddressCombo::addItem(const QString& text, CAmount bal) +{ QString txt = AddressBook::addLabelToAddress(text); if (bal.toqint64() > 0) txt = txt % "(" % bal.toDecimalhushString() % ")"; @@ -32,7 +34,8 @@ void AddressCombo::addItem(const QString& text, CAmount bal) { QComboBox::addItem(txt); } -void AddressCombo::insertItem(int index, const QString& text, CAmount bal) { +void AddressCombo::insertItem(int index, const QString& text, CAmount bal) +{ QString txt = AddressBook::addLabelToAddress(text) % "(" % bal.toDecimalhushString() % ")"; QComboBox::insertItem(index, txt); diff --git a/src/balancestablemodel.cpp b/src/balancestablemodel.cpp index d0e2f0e..7843d10 100644 --- a/src/balancestablemodel.cpp +++ b/src/balancestablemodel.cpp @@ -3,9 +3,8 @@ #include "settings.h" #include "camount.h" -BalancesTableModel::BalancesTableModel(QObject *parent) - : QAbstractTableModel(parent) { -} +BalancesTableModel::BalancesTableModel(QObject *parent): QAbstractTableModel(parent) +{} void BalancesTableModel::setNewData(const QList zaddrs, const QList taddrs, const QMap balances, const QList outputs) @@ -29,21 +28,19 @@ void BalancesTableModel::setNewData(const QList zaddrs, const QList>(); std::for_each(balances.keyBegin(), balances.keyEnd(), [=, &anyz, &anyt] (auto keyIt) { modeldata->push_back(std::make_tuple(keyIt, balances.value(keyIt))); - if (Settings::isZAddress(keyIt)) { + if (Settings::isZAddress(keyIt)) anyz = true; - } else if (Settings::isTAddress(keyIt)) { + + else if (Settings::isTAddress(keyIt)) anyt = true; - } }); // Add all addresses that have no balances, if there are no existing addresses - if (!anyz && zaddrs.length() > 0) { + if (!anyz && zaddrs.length() > 0) modeldata->push_back(std::make_tuple(zaddrs[0], CAmount::fromqint64(0))); - } - if (!anyt && taddrs.length() > 0) { + if (!anyt && taddrs.length() > 0) modeldata->push_back(std::make_tuple(taddrs[0], CAmount::fromqint64(0))); - } // And then update the data dataChanged(index(0, 0), index(modeldata->size()-1, columnCount(index(0,0))-1)); @@ -53,19 +50,17 @@ void BalancesTableModel::setNewData(const QList zaddrs, const QListsize(); } @@ -76,25 +71,31 @@ int BalancesTableModel::columnCount(const QModelIndex&) const QVariant BalancesTableModel::data(const QModelIndex &index, int role) const { - if (loading) { - if (role == Qt::DisplayRole) + if (loading) + return (role == Qt::DisplayRole) ? "Loading..." : QVariant(); + /*if (role == Qt::DisplayRole) return "Loading..."; else - return QVariant(); - } + return QVariant();*/ - if (role == Qt::TextAlignmentRole && index.column() == 1) return QVariant(Qt::AlignRight | Qt::AlignVCenter); + if (role == Qt::TextAlignmentRole && index.column() == 1) + return QVariant(Qt::AlignRight | Qt::AlignVCenter); if (role == Qt::ForegroundRole) { // If any of the UTXOs for this address has zero confirmations, paint it in red const auto& addr = std::get<0>(modeldata->at(index.row())); - for (auto unconfirmedOutput : *unspentOutputs) { - if (unconfirmedOutput.address == addr && - (!unconfirmedOutput.spendable || unconfirmedOutput.pending)) { + for (auto unconfirmedOutput : *unspentOutputs) + { + if ( + unconfirmedOutput.address == addr && + (!unconfirmedOutput.spendable || unconfirmedOutput.pending) + ) + { QBrush b; b.setColor(Qt::red); return b; } + } // Else, just return the default brush @@ -103,17 +104,21 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const return b; } - if (role == Qt::DisplayRole) { - switch (index.column()) { - case 0: return AddressBook::addLabelToAddress(std::get<0>(modeldata->at(index.row()))); - case 1: return std::get<1>(modeldata->at(index.row())).toDecimalhushString(); + if (role == Qt::DisplayRole) + { + switch (index.column()) + { + case 0: return AddressBook::addLabelToAddress(std::get<0>(modeldata->at(index.row()))); + case 1: return std::get<1>(modeldata->at(index.row())).toDecimalhushString(); } } - if(role == Qt::ToolTipRole) { - switch (index.column()) { - case 0: return AddressBook::addLabelToAddress(std::get<0>(modeldata->at(index.row()))); - case 1: return std::get<1>(modeldata->at(index.row())).toDecimalhushString(); + if(role == Qt::ToolTipRole) + { + switch (index.column()) + { + case 0: return AddressBook::addLabelToAddress(std::get<0>(modeldata->at(index.row()))); + case 1: return std::get<1>(modeldata->at(index.row())).toDecimalhushString(); } } @@ -123,11 +128,13 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const QVariant BalancesTableModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::TextAlignmentRole && section == 1) { + if (role == Qt::TextAlignmentRole && section == 1) + { return QVariant(Qt::AlignRight | Qt::AlignVCenter); } - if (role == Qt::FontRole) { + if (role == Qt::FontRole) + { QFont f; f.setBold(true); return f; @@ -136,13 +143,16 @@ QVariant BalancesTableModel::headerData(int section, Qt::Orientation orientation if (role != Qt::DisplayRole) return QVariant(); - if (orientation == Qt::Horizontal) { - switch (section) { - case 0: return tr("Address"); - case 1: return tr("Amount"); - default: return QVariant(); + if (orientation == Qt::Horizontal) + { + switch (section) + { + case 0: return tr("Address"); + case 1: return tr("Amount"); + default: return QVariant(); } } + return QVariant(); } diff --git a/src/camount.cpp b/src/camount.cpp index 9e78381..28823e4 100644 --- a/src/camount.cpp +++ b/src/camount.cpp @@ -1,204 +1,230 @@ #include "camount.h" #include "settings.h" - #include "precompiled.h" const int NUMPLACES = 8; const qint64 COIN = 100000000; -double CAmount::toDecimalDouble() const { +double CAmount::toDecimalDouble() const +{ return static_cast(this->amount) / COIN; } -QString CAmount::toDecimalString() const { - if (amount < 0) { +QString CAmount::toDecimalString() const +{ + if (amount < 0) + { CAmount negative(-1 * this->amount); return "-" + negative.toDecimalString(); } int wholePart = amount / COIN; int decimalPart = amount % COIN; - QString r = QString::number(wholePart); - if (decimalPart > 0) { + if (decimalPart > 0) + { QString decimalPartStr = QString::number(decimalPart); r = r + "." + decimalPartStr.rightJustified(NUMPLACES, '0'); - // Trim tailing 0s - while (r.right(1) == "0") { + while (r.right(1) == "0") r = r.left(r.length() - 1); - } + } return r; } -QString CAmount::toDecimalUSDString() const { - double dblAmount = static_cast(this->amount) / COIN; +double CAmount::getDblAmount() const +{ + return static_cast(this->amount) / COIN; +} + +QString CAmount::toDecimalUSDString() const +{ double price = Settings::getInstance()->getZECPrice(); - - return "$ " + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); + return "$ " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2); } -QString CAmount::toDecimalEURString() const { - double dblAmount = static_cast(this->amount) / COIN; +QString CAmount::toDecimalEURString() const +{ double price = Settings::getInstance()->getEURPrice(); - - return QLocale(QLocale::German).toString(dblAmount*price, 'f', 2) + " €"; + return QLocale(QLocale::German).toString(this->getDblAmount() * price, 'f', 2) + " €"; } -QString CAmount::toDecimalBTCString() const { - double dblAmount = static_cast(this->amount) / COIN; + +QString CAmount::toDecimalBTCString() const +{ double price = Settings::getInstance()->getBTCPrice(); - - return "BTC " + QLocale(QLocale::English).toString(dblAmount*price, 'f', 9); + return "BTC " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 9); } -QString CAmount::toDecimalCNYString() const { - double dblAmount = static_cast(this->amount) / COIN; + +QString CAmount::toDecimalCNYString() const +{ double price = Settings::getInstance()->getCNYPrice(); - - return "¥ /元 " + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); + return "¥ /元 " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2); } -QString CAmount::toDecimalRUBString() const { - double dblAmount = static_cast(this->amount) / COIN; +QString CAmount::toDecimalRUBString() const +{ double price = Settings::getInstance()->getRUBPrice(); - - return "₽ " + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); + return "₽ " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2); } -QString CAmount::toDecimalCADString() const { - double dblAmount = static_cast(this->amount) / COIN; + +QString CAmount::toDecimalCADString() const +{ double price = Settings::getInstance()->getCADPrice(); - - return "$ " + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); + return "$ " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2); } -QString CAmount::toDecimalSGDString() const { - double dblAmount = static_cast(this->amount) / COIN; + +QString CAmount::toDecimalSGDString() const +{ double price = Settings::getInstance()->getSGDPrice(); - - return "$ " + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); + return "$ " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2); } -QString CAmount::toDecimalCHFString() const { - double dblAmount = static_cast(this->amount) / COIN; + +QString CAmount::toDecimalCHFString() const +{ double price = Settings::getInstance()->getCHFPrice(); - - return "CHF " + QLocale(QLocale::German).toString(dblAmount*price, 'f', 2); + return "CHF " + QLocale(QLocale::German).toString(this->getDblAmount() * price, 'f', 2); } -QString CAmount::toDecimalINRString() const { - double dblAmount = static_cast(this->amount) / COIN; + +QString CAmount::toDecimalINRString() const +{ double price = Settings::getInstance()->getINRPrice(); - - return "₹ " + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); + return "₹ " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2); } -QString CAmount::toDecimalGBPString() const { - double dblAmount = static_cast(this->amount) / COIN; +QString CAmount::toDecimalGBPString() const +{ double price = Settings::getInstance()->getGBPPrice(); - - return "£ " + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); + return "£ " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2); } -QString CAmount::toDecimalAUDString() const { - double dblAmount = static_cast(this->amount) / COIN; +QString CAmount::toDecimalAUDString() const +{ double price = Settings::getInstance()->getAUDPrice(); - - return " $" + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); + return " $" + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2); } -QString CAmount::toDecimalhushString() const { +QString CAmount::toDecimalhushString() const +{ return this->toDecimalString() % " " % Settings::getTokenName(); } -QString CAmount::toDecimalhushUSDString() const { +QString CAmount::toDecimalhushUSDString() const +{ auto usdString = this->toDecimalUSDString(); if (!usdString.isEmpty()) return this->toDecimalhushString() % " (" % usdString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushEURString() const { +QString CAmount::toDecimalhushEURString() const +{ auto eurString = this->toDecimalEURString(); if (!eurString.isEmpty()) return this->toDecimalhushString() % " (" % eurString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushBTCString() const { +QString CAmount::toDecimalhushBTCString() const +{ auto btcString = this->toDecimalBTCString(); if (!btcString.isEmpty()) return this->toDecimalhushString() % " (" % btcString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushCNYString() const { +QString CAmount::toDecimalhushCNYString() const +{ auto cnyString = this->toDecimalCNYString(); if (!cnyString.isEmpty()) return this->toDecimalhushString() % " (" % cnyString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushRUBString() const { +QString CAmount::toDecimalhushRUBString() const +{ auto rubString = this->toDecimalRUBString(); if (!rubString.isEmpty()) return this->toDecimalhushString() % " (" % rubString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushCADString() const { +QString CAmount::toDecimalhushCADString() const +{ auto cadString = this->toDecimalCADString(); if (!cadString.isEmpty()) return this->toDecimalhushString() % " (" % cadString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushSGDString() const { +QString CAmount::toDecimalhushSGDString() const +{ auto sgdString = this->toDecimalSGDString(); if (!sgdString.isEmpty()) return this->toDecimalhushString() % " (" % sgdString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushCHFString() const { +QString CAmount::toDecimalhushCHFString() const +{ auto chfString = this->toDecimalCHFString(); if (!chfString.isEmpty()) return this->toDecimalhushString() % " (" % chfString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushINRString() const { +QString CAmount::toDecimalhushINRString() const +{ auto inrString = this->toDecimalINRString(); if (!inrString.isEmpty()) return this->toDecimalhushString() % " (" % inrString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushGBPString() const { +QString CAmount::toDecimalhushGBPString() const +{ auto gbpString = this->toDecimalGBPString(); if (!gbpString.isEmpty()) return this->toDecimalhushString() % " (" % gbpString % ")"; + else return this->toDecimalhushString(); } -QString CAmount::toDecimalhushAUDString() const { +QString CAmount::toDecimalhushAUDString() const +{ auto audString = this->toDecimalAUDString(); if (!audString.isEmpty()) return this->toDecimalhushString() % " (" % audString % ")"; + else return this->toDecimalhushString(); } -CAmount CAmount::fromDecimalString(QString decimalString) { +CAmount CAmount::fromDecimalString(QString decimalString) +{ auto amtParts = decimalString.split("."); qint64 r = amtParts[0].toULongLong() * COIN; - if (amtParts.length() == 2) { + if (amtParts.length() == 2) + { auto trailingZeros = QString("0").repeated(NUMPLACES - amtParts[1].length()); r += QString(amtParts[1] + trailingZeros).toULongLong(); } diff --git a/src/camount.h b/src/camount.h index 2063903..7319849 100644 --- a/src/camount.h +++ b/src/camount.h @@ -26,6 +26,7 @@ public: double toDecimalDouble() const; QString toDecimalString() const; + double getDblAmount() const; QString toDecimalUSDString() const; QString toDecimalEURString() const; QString toDecimalBTCString() const; diff --git a/src/connection.cpp b/src/connection.cpp index fae8cef..99666ac 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -5,42 +5,47 @@ #include "firsttimewizard.h" #include "ui_createhushconfdialog.h" #include "controller.h" - - #include "../lib/silentdragonlitelib.h" - #include "precompiled.h" using json = nlohmann::json; -ConnectionLoader::ConnectionLoader(MainWindow* main, Controller* rpc) { +ConnectionLoader::ConnectionLoader(MainWindow* main, Controller* rpc) +{ this->main = main; this->rpc = rpc; - d = new QDialog(main); connD = new Ui_ConnectionDialog(); connD->setupUi(d); QPixmap logo(":/img/res/logobig.gif"); - connD->topIcon->setBasePixmap(logo.scaled(256, 256, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - + connD->topIcon->setBasePixmap( + logo.scaled( + 256, + 256, + Qt::KeepAspectRatio, + Qt::SmoothTransformation + ) + ); isSyncing = new QAtomicInteger(); } -ConnectionLoader::~ConnectionLoader() { +ConnectionLoader::~ConnectionLoader() +{ delete isSyncing; delete connD; delete d; } -void ConnectionLoader::loadConnection() { +void ConnectionLoader::loadConnection() +{ QTimer::singleShot(1, [=]() { this->doAutoConnect(); }); if (!Settings::getInstance()->isHeadless()) d->exec(); } -void ConnectionLoader::doAutoConnect() { +void ConnectionLoader::doAutoConnect() +{ qDebug() << "Doing autoconnect"; - auto config = std::shared_ptr(new ConnectionConfig()); config->dangerous = true; config->server = Settings::getInstance()->getSettings().server; @@ -49,16 +54,24 @@ void ConnectionLoader::doAutoConnect() { main->logger->write(QObject::tr("Attempting to initialize library with ") + config->server); // Check to see if there's an existing wallet - if (litelib_wallet_exists(Settings::getDefaultChainName().toStdString().c_str())) { + if (litelib_wallet_exists(Settings::getDefaultChainName().toStdString().c_str())) + { main->logger->write(QObject::tr("Using existing wallet.")); - char* resp = litelib_initialize_existing(config->dangerous, config->server.toStdString().c_str()); + char* resp = litelib_initialize_existing( + config->dangerous, + config->server.toStdString().c_str() + ); QString response = litelib_process_response(resp); - if (response.toUpper().trimmed() != "OK") { + if (response.toUpper().trimmed() != "OK") + { showError(response); return; } - } else { + + } + else + { main->logger->write(QObject::tr("Create/restore wallet.")); createOrRestore(config->dangerous, config->server); d->show(); @@ -72,7 +85,6 @@ void ConnectionLoader::doAutoConnect() { // If success, set the connection main->logger->write("Connection is online."); connection->setInfo(reply); - isSyncing = new QAtomicInteger(); isSyncing->store(true); @@ -80,10 +92,8 @@ void ConnectionLoader::doAutoConnect() { syncTimer = new QTimer(main); connection->doRPCWithDefaultErrorHandling("sync", "", [=](auto) { isSyncing->store(false); - // Cancel the timer syncTimer->deleteLater(); - // When sync is done, set the connection this->doRPCSetConnection(connection); }); @@ -94,10 +104,13 @@ void ConnectionLoader::doAutoConnect() { if (isSyncing != nullptr && isSyncing->load()) { // Get the sync status connection->doRPC("syncstatus", "", [=](json reply) { - if (isSyncing != nullptr && reply.find("synced_blocks") != reply.end()) { + if (isSyncing != nullptr && reply.find("synced_blocks") != reply.end()) + { qint64 synced = reply["synced_blocks"].get(); qint64 total = reply["total_blocks"].get(); - me->showInformation("Synced " + QString::number(synced) + " / " + QString::number(total)); + me->showInformation( + "Synced " + QString::number(synced) + " / " + QString::number(total) + ); } }, [=](QString err) { @@ -114,104 +127,110 @@ void ConnectionLoader::doAutoConnect() { }); } -void ConnectionLoader::createOrRestore(bool dangerous, QString server) { +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) { +void ConnectionLoader::doRPCSetConnection(Connection* conn) +{ qDebug() << "Connectionloader finished, setting connection"; rpc->setConnection(conn); - d->accept(); - QTimer::singleShot(1, [=]() { delete this; }); } -Connection* ConnectionLoader::makeConnection(std::shared_ptr config) { +Connection* ConnectionLoader::makeConnection(std::shared_ptr config) +{ return new Connection(main, config); } // Update the UI with the status -void ConnectionLoader::showInformation(QString info, QString detail) { +void ConnectionLoader::showInformation(QString info, QString detail) +{ connD->status->setText(info); connD->statusDetail->setText(detail); - } /** * Show error will close the loading dialog and show an error. */ -void ConnectionLoader::showError(QString explanation) { +void ConnectionLoader::showError(QString explanation) +{ rpc->noConnection(); - - QMessageBox::critical(main, QObject::tr("Connection Error"), explanation, QMessageBox::Ok); + QMessageBox::critical( + main, + QObject::tr("Connection Error"), + explanation, + QMessageBox::Ok + ); d->close(); } -QString litelib_process_response(char* resp) { +QString litelib_process_response(char* resp) +{ char* resp_copy = new char[strlen(resp) + 1]; - strcpy(resp_copy, resp); + //a safer version of strcpy + strncpy(resp_copy, resp, strlen(resp)+1); litelib_rust_free_string(resp); - QString reply = QString::fromStdString(resp_copy); memset(resp_copy, '-', strlen(resp_copy)); delete[] resp_copy; - return reply; } /*********************************************************************************** * Connection, Executor and Callback Class ************************************************************************************/ -void Executor::run() { +void Executor::run() +{ char* resp = litelib_execute(this->cmd.toStdString().c_str(), this->args.toStdString().c_str()); - QString reply = litelib_process_response(resp); - //qDebug() << "RPC Reply=" << reply; - auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false); - if (parsed.is_discarded() || parsed.is_null()) { + auto parsed = json::parse( + reply.toStdString().c_str(), + nullptr, + false + ); + if (parsed.is_discarded() || parsed.is_null()) emit handleError(reply); - } else { + + else emit responseReady(parsed); - } } -void Callback::processRPCCallback(json resp) { +void Callback::processRPCCallback(json resp) +{ this->cb(resp); - // Destroy self delete this; } -void Callback::processError(QString resp) { +void Callback::processError(QString resp) +{ this->errCb(resp); - // Destroy self delete this; } -Connection::Connection(MainWindow* m, std::shared_ptr conf) { +Connection::Connection(MainWindow* m, std::shared_ptr conf) +{ this->config = conf; this->main = m; - // Register the JSON type as a type that can be passed between signals and slots. qRegisterMetaType("json"); } -void Connection::doRPC(const QString cmd, const QString args, const std::function& cb, - const std::function& errCb) { - if (shutdownInProgress) { +void Connection::doRPC(const QString cmd, const QString args, const std::function& cb, const std::function& errCb) +{ + if (shutdownInProgress) // Ignoring RPC because shutdown in progress return; - } //qDebug() << "Doing RPC: " << cmd; @@ -223,24 +242,27 @@ void Connection::doRPC(const QString cmd, const QString args, const std::functio QObject::connect(runner, &Executor::responseReady, c, &Callback::processRPCCallback); QObject::connect(runner, &Executor::handleError, c, &Callback::processError); - QThreadPool::globalInstance()->start(runner); } -void Connection::doRPCWithDefaultErrorHandling(const QString cmd, const QString args, const std::function& cb) { +void Connection::doRPCWithDefaultErrorHandling(const QString cmd, const QString args, const std::function& cb) +{ doRPC(cmd, args, cb, [=] (QString err) { this->showTxError(err); }); -} +} -void Connection::doRPCIgnoreError(const QString cmd, const QString args, const std::function& cb) { +void Connection::doRPCIgnoreError(const QString cmd, const QString args, const std::function& cb) +{ doRPC(cmd, args, cb, [=] (auto) { // Ignored error handling }); } -void Connection::showTxError(const QString& error) { - if (error.isNull()) return; +void Connection::showTxError(const QString& error) +{ + if (error.isNull()) + return; // Prevent multiple dialog boxes from showing, because they're all called async static bool shown = false; @@ -248,14 +270,19 @@ void Connection::showTxError(const QString& error) { return; shown = true; - QMessageBox::critical(main, QObject::tr("Transaction Error"), QObject::tr("There was an error sending the transaction. The error was:") + "\n\n" - + error, QMessageBox::StandardButton::Ok); + QMessageBox::critical( + main, + QObject::tr("Transaction Error"), + QObject::tr("There was an error sending the transaction. The error was:") + "\n\n" + error, + QMessageBox::StandardButton::Ok + ); shown = false; } /** * Prevent all future calls from going through */ -void Connection::shutdown() { +void Connection::shutdown() +{ shutdownInProgress = true; } diff --git a/src/controller.cpp b/src/controller.cpp index 851905b..18a158e 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -5,11 +5,16 @@ #include "version.h" #include "camount.h" #include "websockets.h" - +#include "DataStore.h" +template<> +DataStore* DataStore::instance = nullptr; +template<> +bool DataStore::instanced = false; using json = nlohmann::json; -Controller::Controller(MainWindow* main) { +Controller::Controller(MainWindow* main) +{ auto cl = new ConnectionLoader(main, this); // Execute the load connection async, so we can set up the rest of RPC properly. @@ -49,24 +54,23 @@ Controller::Controller(MainWindow* main) { zrpc = new LiteInterface(); } -Controller::~Controller() { +Controller::~Controller() +{ delete timer; delete txTimer; - delete transactionsTableModel; delete balancesTableModel; - delete model; delete zrpc; } - // Called when a connection to hushd is available. -void Controller::setConnection(Connection* c) { - if (c == nullptr) return; +void Controller::setConnection(Connection* c) +{ + if (c == nullptr) + return; this->zrpc->setConnection(c); - ui->statusBar->showMessage(""); // If we're allowed to get the Hush Price, get the prices @@ -81,473 +85,102 @@ void Controller::setConnection(Connection* c) { // where we need to immediately refresh refresh(true); -// Create Sietch zdust addr at startup. - zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); + // Create Sietch zdust addr at startup. + // Using DataStore singelton, to store the data outside of lambda, bing bada boom :D + for(uint8_t i = 0; i < 10; i++) + { + zrpc->createNewSietchZaddr( [=] (json reply) { + QString zdust = QString::fromStdString(reply.get()[0]); + DataStore::getInstance()->setData("Sietch" + QString(i), zdust.toUtf8()); + }); } - - } ); - -zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch1.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch2.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch3.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch4.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch5.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch6.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch7.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch8.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch9.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - - } ); } // Build the RPC JSON Parameters for this tx -void Controller::fillTxJsonParams(json& allRecepients, Tx tx) { +void Controller::fillTxJsonParams(json& allRecepients, Tx tx) +{ Q_ASSERT(allRecepients.is_array()); - // Construct the JSON params - json rec = json::object(); - json dust = json::object(); - json dust1 = json::object(); - json dust2 = json::object(); - json dust3 = json::object(); - json dust4 = json::object(); - json dust5 = json::object(); - json dust6 = json::object(); - json dust7 = json::object(); - json dust8 = json::object(); - json dust9 = json::object(); + // Construct the JSON params + json rec = json::object(); -// Create Sietch zdust addr again to not use it twice. - zrpc->createNewSietchZaddr( [=] (json reply) { - - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - } ); + //creating the JSON dust parameters in a std::vector to iterate over there during tx + std::vector dust(10); + dust.resize(10, json::object()); -zrpc->createNewSietchZaddr( [=] (json reply) { - - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch1.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - } ); - zrpc->createNewSietchZaddr( [=] (json reply) { - - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch2.txt"); - QFile file(path); -QString zdust = QString::fromStdString(reply.get()[0]); -if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); + // Create Sietch zdust addr again to not use it twice. + // Using DataStore singelton, to store the data outside of lambda, bing bada boom :D + for(uint8_t i = 0; i < 10; i++) + { + zrpc->createNewSietchZaddr( [=] (json reply) { + QString zdust = QString::fromStdString(reply.get()[0]); + DataStore::getInstance()->setData(QString("Sietch") + QString(i), zdust.toUtf8()); + } ); } - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch3.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - } ); - zrpc->createNewSietchZaddr( [=] (json reply) { - - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch4.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch5.txt"); - QFile file(path); -QString zdust = QString::fromStdString(reply.get()[0]); -if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); + // Set sietch zdust addr to json. + // Using DataStore singelton, to store the data into the dusts, bing bada boom :D + for(uint8_t i = 0; i < 10; i++) + { + dust.at(i)["address"] = DataStore::getInstance()->getData(QString("Sietch" + QString(i))).toStdString(); } - } ); - zrpc->createNewSietchZaddr( [=] (json reply) { + DataStore::getInstance()->clear(); // clears the datastore - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch6.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); + // Dust amt/memo, construct the JSON + for(uint8_t i = 0; i < 10; i++) + { + dust.at(i)["amount"] = 0; + dust.at(i)["memo"] = ""; + } - } ); - - zrpc->createNewSietchZaddr( [=] (json reply) { - - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch7.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - } ); - zrpc->createNewSietchZaddr( [=] (json reply) { - - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch8.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); - if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - } ); - zrpc->createNewSietchZaddr( [=] (json reply) { - - QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch9.txt"); - QFile file(path); - QString zdust = QString::fromStdString(reply.get()[0]); -if(!file.open(QIODevice::WriteOnly)){ - file.close(); - } else { - QTextStream out(&file); out << zdust.toUtf8(); - file.close(); - } - } ); - -// Set sietch zdust addr to json. - - QString path= (QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)) + QString("/Sietch.txt"); - QFile inputFile(path); - if (inputFile.open(QIODevice::ReadOnly)) -{ - QTextStream in(&inputFile); - while (!in.atEnd()) - { - QString line = in.readLine(); - dust["address"] = line.toStdString(); - } - inputFile.close(); -} - - -QString path1= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch1.txt"); -QFile inputFile1(path1); -if (inputFile1.open(QIODevice::ReadOnly)) -{ - QTextStream in(&inputFile1); - while (!in.atEnd()) - { - QString line = in.readLine(); - QString zdust = line; - - dust1["address"] = zdust.toStdString(); - } - inputFile1.close(); -} - - QString path2= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch2.txt"); - QFile inputFile2(path2); -if (inputFile2.open(QIODevice::ReadOnly)) -{ - QTextStream in(&inputFile2); - while (!in.atEnd()) - { - QString line = in.readLine(); - dust2["address"] = line.toStdString(); - } - inputFile2.close(); -} - -QString path3= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch3.txt"); -QFile inputFile3(path3); -if (inputFile3.open(QIODevice::ReadOnly)) -{ - QTextStream in(&inputFile3); - while (!in.atEnd()) - { - QString line = in.readLine(); - dust3["address"] = line.toStdString(); - } - inputFile3.close(); -} - - QString path4= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch4.txt"); - QFile inputFile4(path4); - if (inputFile4.open(QIODevice::ReadOnly)) - { - QTextStream in(&inputFile4); - while (!in.atEnd()) - { - QString line = in.readLine(); - dust4["address"] = line.toStdString(); - } - inputFile4.close(); - } - -QString path5= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch5.txt"); -QFile inputFile5(path5); -if (inputFile5.open(QIODevice::ReadOnly)) -{ - QTextStream in(&inputFile5); - while (!in.atEnd()) - { - QString line = in.readLine(); - dust5["address"] = line.toStdString(); - } - inputFile5.close(); -} - -QString path6= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch6.txt"); -QFile inputFile6(path6); -if (inputFile6.open(QIODevice::ReadOnly)) -{ - QTextStream in(&inputFile6); - while (!in.atEnd()) - { - QString line = in.readLine(); - dust6["address"] = line.toStdString(); - } - inputFile6.close(); -} - -QString path7= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch7.txt"); -QFile inputFile7(path7); -if (inputFile7.open(QIODevice::ReadOnly)) -{ - QTextStream in(&inputFile7); - while (!in.atEnd()) - { - QString line = in.readLine(); - dust7["address"] = line.toStdString(); - } - inputFile7.close(); -} - - QString path8= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch8.txt"); - QFile inputFile8(path8); - if (inputFile8.open(QIODevice::ReadOnly)) - { - QTextStream in(&inputFile8); - while (!in.atEnd()) - { - QString line = in.readLine(); - dust8["address"] = line.toStdString(); - } - inputFile.close(); - } - - QString path9= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch9.txt"); - QFile inputFile9(path9); - if (inputFile9.open(QIODevice::ReadOnly)) -{ - QTextStream in(&inputFile9); - while (!in.atEnd()) - { - QString line = in.readLine(); - dust9["address"] = line.toStdString(); - } - inputFile9.close(); -} - -// Dust amt/memo, construct the JSON - dust["amount"] = 0; - dust["memo"] = ""; - dust1["amount"] = 0; - dust1["memo"] = ""; - dust2["amount"] = 0; - dust2["memo"] = ""; - dust3["amount"] = 0; - dust3["memo"] = ""; - dust4["amount"] = 0; - dust4["memo"] = ""; - dust5["amount"] = 0; - dust5["memo"] = ""; - dust6["amount"] = 0; - dust6["memo"] = ""; - dust7["amount"] = 0; - dust7["memo"] = ""; - dust8["amount"] = 0; - dust8["memo"] = ""; - dust9["amount"] = 0; - dust9["memo"] = ""; - -// For each addr/amt/memo, construct the JSON and also build the confirm dialog box - - for (int i=0; i < tx.toAddrs.size(); i++) { + + // For each addr/amt/memo, construct the JSON and also build the confirm dialog box + for (int i=0; i < tx.toAddrs.size(); i++) + { auto toAddr = tx.toAddrs[i]; - - rec["address"] = toAddr.addr.toStdString(); - rec["amount"] = toAddr.amount.toqint64(); + rec["address"] = toAddr.addr.toStdString(); + rec["amount"] = toAddr.amount.toqint64(); if (Settings::isZAddress(toAddr.addr) && !toAddr.memo.trimmed().isEmpty()) - rec["memo"] = toAddr.memo.toStdString(); + rec["memo"] = toAddr.memo.toStdString(); - allRecepients.push_back(rec) ; + allRecepients.push_back(rec) ; } - int decider = qrand() % ((100 + 1)-1)+ 1;// random int between 1 and 100 - - //50% chance of adding another zdust, shuffle. - + int decider = qrand() % ((100 + 1)-1)+ 1;// random int between 1 and 100 + //50% chance of adding another zdust, shuffle. - if(decider % 4 == 3) { - allRecepients.insert(std::begin(allRecepients),{dust,dust1,dust2,dust3,dust4,dust5,dust6,dust7,dust8}) ; + if(decider % 4 == 3) + allRecepients.insert(std::begin(allRecepients), { + dust.at(0), + dust.at(1), + dust.at(2), + dust.at(3), + dust.at(4), + dust.at(5), + dust.at(6), + dust.at(7), + dust.at(8) + }) ; // std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device()); - - }else { - allRecepients.insert(std::begin(allRecepients),{dust,dust1,dust2,dust3,dust4,dust5,dust6,dust7,dust8,dust9}) ; - // std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device()); - } - - - - + else + allRecepients.insert(std::begin(allRecepients), { + dust.at(0), + dust.at(1), + dust.at(2), + dust.at(3), + dust.at(4), + dust.at(5), + dust.at(6), + dust.at(7), + dust.at(8), + dust.at(9) + }); + // std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device()); } -void Controller::noConnection() { +void Controller::noConnection() +{ QIcon i = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); main->statusIcon->setPixmap(i.pixmap(16, 16)); main->statusIcon->setToolTip(""); @@ -576,21 +209,23 @@ void Controller::noConnection() { } /// This will refresh all the balance data from hushd -void Controller::refresh(bool force) { +void Controller::refresh(bool force) +{ if (!zrpc->haveConnection()) return noConnection(); getInfoThenRefresh(force); } -void Controller::processInfo(const json& info) { +void Controller::processInfo(const json& info) +{ // Testnet? QString chainName; - if (!info["chain_name"].is_null()) { + if (!info["chain_name"].is_null()) + { chainName = QString::fromStdString(info["chain_name"].get()); Settings::getInstance()->setTestnet(chainName == "test"); - }; - + } QString version = QString::fromStdString(info["version"].get()); Settings::getInstance()->sethushdVersion(version); @@ -600,7 +235,8 @@ void Controller::processInfo(const json& info) { main->disableRecurring(); } -void Controller::getInfoThenRefresh(bool force) { +void Controller::getInfoThenRefresh(bool force) +{ if (!zrpc->haveConnection()) return noConnection(); @@ -608,39 +244,66 @@ void Controller::getInfoThenRefresh(bool force) { zrpc->fetchInfo([=] (const json& reply) { prevCallSucceeded = true; - int curBlock = reply["latest_block_height"].get(); int longestchain = reply["longestchain"].get(); int notarized = reply["notarized"].get(); int difficulty = reply["difficulty"].get(); int blocks_until_halving= 340000 - curBlock; - int halving_days = - (blocks_until_halving * 150) / (60*60*24) ; + int halving_days = (blocks_until_halving * 150) / (60*60*24) ; bool doUpdate = force || (model->getLatestBlock() != curBlock); model->setLatestBlock(curBlock); - - if (Settings::getInstance()->get_currency_name() == "EUR" || Settings::getInstance()->get_currency_name() == "CHF" || Settings::getInstance()->get_currency_name() == "RUB") { - ui->blockHeight->setText("Block: " + QLocale(QLocale::German).toString(curBlock)); - ui->last_notarized->setText("Block: " + QLocale(QLocale::German).toString(notarized)); - ui->longestchain->setText("Block: " + QLocale(QLocale::German).toString(longestchain)); - ui->difficulty->setText(QLocale(QLocale::German).toString(difficulty)); - ui->halvingTime->setText((QLocale(QLocale::German).toString(blocks_until_halving)) + " Blocks or , " + (QLocale(QLocale::German).toString(halving_days) + " days" )); + if ( + Settings::getInstance()->get_currency_name() == "EUR" || + Settings::getInstance()->get_currency_name() == "CHF" || + Settings::getInstance()->get_currency_name() == "RUB" + ) + { + ui->blockHeight->setText( + "Block: " + QLocale(QLocale::German).toString(curBlock) + ); + ui->last_notarized->setText( + "Block: " + QLocale(QLocale::German).toString(notarized) + ); + ui->longestchain->setText( + "Block: " + QLocale(QLocale::German).toString(longestchain) + ); + ui->difficulty->setText( + QLocale(QLocale::German).toString(difficulty) + ); + ui->halvingTime->setText( + (QLocale(QLocale::German).toString(blocks_until_halving)) + + " Blocks or , " + (QLocale(QLocale::German).toString(halving_days) + " days" ) + ); } - else { - ui->blockHeight->setText("Block: " + QLocale(QLocale::English).toString(curBlock)); - ui->last_notarized->setText("Block: " + QLocale(QLocale::English).toString(notarized)); - ui->longestchain->setText("Block: " + QLocale(QLocale::English).toString(longestchain)); - ui->difficulty->setText(QLocale(QLocale::English).toString(difficulty)); - ui->halvingTime->setText((QLocale(QLocale::English).toString(blocks_until_halving)) + " Blocks or , " + (QLocale(QLocale::English).toString(halving_days) + " days" )); - + else + { + ui->blockHeight->setText( + "Block: " + QLocale(QLocale::English).toString(curBlock) + ); + ui->last_notarized->setText( + "Block: " + QLocale(QLocale::English).toString(notarized) + ); + ui->longestchain->setText( + "Block: " + QLocale(QLocale::English).toString(longestchain) + ); + ui->difficulty->setText( + QLocale(QLocale::English).toString(difficulty) + ); + ui->halvingTime->setText( + (QLocale(QLocale::English).toString(blocks_until_halving)) + + " Blocks or , " + (QLocale(QLocale::English).toString(halving_days) + " days" ) + ); } - - ui->Version->setText(QString::fromStdString(reply["version"].get())); - ui->Vendor->setText(QString::fromStdString(reply["vendor"].get())); - - - main->logger->write(QString("Refresh. curblock ") % QString::number(curBlock) % ", update=" % (doUpdate ? "true" : "false") ); + ui->Version->setText( + QString::fromStdString(reply["version"].get()) + ); + ui->Vendor->setText( + QString::fromStdString(reply["vendor"].get()) + ); + main->logger->write( + QString("Refresh. curblock ") % QString::number(curBlock) % ", update=" % (doUpdate ? "true" : "false") + ); // Connected, so display checkmark. auto tooltip = Settings::getInstance()->getSettings().server + "\n" + @@ -651,99 +314,194 @@ void Controller::getInfoThenRefresh(bool force) { // use currency ComboBox as input - if (Settings::getInstance()->get_currency_name() == "USD") { - double price = Settings::getInstance()->getZECPrice(); - double volume = Settings::getInstance()->getUSDVolume(); - double cap = Settings::getInstance()->getUSDCAP(); - main->statusLabel->setText(" HUSH/USD=$ " + (QLocale(QLocale::English).toString(price,'f', 2))); - ui->volumeExchange->setText(" $ " + (QLocale(QLocale::English).toString(volume,'f', 2))); - ui->marketcapTab->setText(" $ " + (QLocale(QLocale::English).toString(cap,'f', 2))); + if (Settings::getInstance()->get_currency_name() == "USD") + { + double price = Settings::getInstance()->getZECPrice(); + double volume = Settings::getInstance()->getUSDVolume(); + double cap = Settings::getInstance()->getUSDCAP(); + main->statusLabel->setText( + " HUSH/USD=$ " + (QLocale(QLocale::English).toString(price,'f', 2)) + ); + ui->volumeExchange->setText( + " $ " + (QLocale(QLocale::English).toString(volume,'f', 2)) + ); + ui->marketcapTab->setText( + " $ " + (QLocale(QLocale::English).toString(cap,'f', 2)) + ); - } else if (Settings::getInstance()->get_currency_name() == "EUR") { - double price = Settings::getInstance()->getEURPrice(); - double volume = Settings::getInstance()->getEURVolume(); - double cap = Settings::getInstance()->getEURCAP(); - main->statusLabel->setText("HUSH/EUR "+(QLocale(QLocale::German).toString(price,'f', 2))+ " €"); - ui->volumeExchange->setText(QLocale(QLocale::German).toString(volume,'f', 2)+ " €"); - ui->marketcapTab->setText(QLocale(QLocale::German).toString(cap,'f', 2)+ " €"); + } + else if (Settings::getInstance()->get_currency_name() == "EUR") + { + double price = Settings::getInstance()->getEURPrice(); + double volume = Settings::getInstance()->getEURVolume(); + double cap = Settings::getInstance()->getEURCAP(); + main->statusLabel->setText( + "HUSH/EUR "+(QLocale(QLocale::German).toString(price,'f', 2))+ " €" + ); + ui->volumeExchange->setText( + QLocale(QLocale::German).toString(volume,'f', 2)+ " €" + ); + ui->marketcapTab->setText( + QLocale(QLocale::German).toString(cap,'f', 2)+ " €" + ); - } else if (Settings::getInstance()->get_currency_name() == "BTC") { - double price = Settings::getInstance()->getBTCPrice(); - double volume = Settings::getInstance()->getBTCVolume(); - double cap = Settings::getInstance()->getBTCCAP(); - main->statusLabel->setText(" HUSH/BTC=BTC " + (QLocale(QLocale::English).toString(price, 'f',8))); - ui->volumeExchange->setText(" BTC " + (QLocale(QLocale::English).toString(volume, 'f',8))); - ui->marketcapTab->setText(" BTC " + (QLocale(QLocale::English).toString(cap, 'f',8))); + } + else if (Settings::getInstance()->get_currency_name() == "BTC") + { + double price = Settings::getInstance()->getBTCPrice(); + double volume = Settings::getInstance()->getBTCVolume(); + double cap = Settings::getInstance()->getBTCCAP(); + main->statusLabel->setText( + " HUSH/BTC=BTC " + (QLocale(QLocale::English).toString(price, 'f',8)) + ); + ui->volumeExchange->setText( + " BTC " + (QLocale(QLocale::English).toString(volume, 'f',8)) + ); + ui->marketcapTab->setText( + " BTC " + (QLocale(QLocale::English).toString(cap, 'f',8)) + ); - } else if (Settings::getInstance()->get_currency_name() == "CNY") { - double price = Settings::getInstance()->getCNYPrice(); - double volume = Settings::getInstance()->getCNYVolume(); - double cap = Settings::getInstance()->getCNYCAP(); - main->statusLabel->setText(" HUSH/CNY=¥ /元 " + (QLocale(QLocale::Chinese).toString(price,'f', 2))); - ui->volumeExchange->setText(" ¥ /元 " + (QLocale(QLocale::Chinese).toString(volume,'f', 2))); - ui->marketcapTab->setText(" ¥ /元 " + (QLocale(QLocale::Chinese).toString(cap,'f', 2))); + } + else if (Settings::getInstance()->get_currency_name() == "CNY") + { + double price = Settings::getInstance()->getCNYPrice(); + double volume = Settings::getInstance()->getCNYVolume(); + double cap = Settings::getInstance()->getCNYCAP(); + main->statusLabel->setText( + " HUSH/CNY=¥ /元 " + (QLocale(QLocale::Chinese).toString(price,'f', 2)) + ); + ui->volumeExchange->setText( + " ¥ /元 " + (QLocale(QLocale::Chinese).toString(volume,'f', 2)) + ); + ui->marketcapTab->setText( + " ¥ /元 " + (QLocale(QLocale::Chinese).toString(cap,'f', 2)) + ); - } else if (Settings::getInstance()->get_currency_name() == "RUB") { - double price = Settings::getInstance()->getRUBPrice(); - double volume = Settings::getInstance()->getRUBVolume(); - double cap = Settings::getInstance()->getRUBCAP(); - main->statusLabel->setText(" HUSH/RUB=₽ " + (QLocale(QLocale::German).toString(price,'f', 2))); - ui->volumeExchange->setText(" ₽ " + (QLocale(QLocale::German).toString(volume,'f', 2))); - ui->marketcapTab->setText(" ₽ " + (QLocale(QLocale::German).toString(cap,'f', 2))); + } + else if (Settings::getInstance()->get_currency_name() == "RUB") + { + double price = Settings::getInstance()->getRUBPrice(); + double volume = Settings::getInstance()->getRUBVolume(); + double cap = Settings::getInstance()->getRUBCAP(); + main->statusLabel->setText( + " HUSH/RUB=₽ " + (QLocale(QLocale::German).toString(price,'f', 2)) + ); + ui->volumeExchange->setText( + " ₽ " + (QLocale(QLocale::German).toString(volume,'f', 2)) + ); + ui->marketcapTab->setText( + " ₽ " + (QLocale(QLocale::German).toString(cap,'f', 2)) + ); - } else if (Settings::getInstance()->get_currency_name() == "CAD") { - double price = Settings::getInstance()->getCADPrice(); - double volume = Settings::getInstance()->getCADVolume(); - double cap = Settings::getInstance()->getCADCAP(); - main->statusLabel->setText(" HUSH/CAD=$ " + (QLocale(QLocale::English).toString(price,'f', 2))); - ui->volumeExchange->setText(" $ " + (QLocale(QLocale::English).toString(volume,'f', 2))); - ui->marketcapTab->setText(" $ " + (QLocale(QLocale::English).toString(cap,'f', 2))); + } + else if (Settings::getInstance()->get_currency_name() == "CAD") + { + double price = Settings::getInstance()->getCADPrice(); + double volume = Settings::getInstance()->getCADVolume(); + double cap = Settings::getInstance()->getCADCAP(); + main->statusLabel->setText( + " HUSH/CAD=$ " + (QLocale(QLocale::English).toString(price,'f', 2)) + ); + ui->volumeExchange->setText( + " $ " + (QLocale(QLocale::English).toString(volume,'f', 2)) + ); + ui->marketcapTab->setText( + " $ " + (QLocale(QLocale::English).toString(cap,'f', 2)) + ); - } else if (Settings::getInstance()->get_currency_name() == "SGD") { - double price = Settings::getInstance()->getSGDPrice(); - double volume = Settings::getInstance()->getSGDVolume(); - double cap = Settings::getInstance()->getSGDCAP(); - main->statusLabel->setText(" HUSH/SGD=$ " + (QLocale(QLocale::English).toString(price,'f', 2))); - ui->volumeExchange->setText(" $ " + (QLocale(QLocale::English).toString(volume,'f', 2))); - ui->marketcapTab->setText(" $ " + (QLocale(QLocale::English).toString(cap,'f', 2))); + } + else if (Settings::getInstance()->get_currency_name() == "SGD") + { + double price = Settings::getInstance()->getSGDPrice(); + double volume = Settings::getInstance()->getSGDVolume(); + double cap = Settings::getInstance()->getSGDCAP(); + main->statusLabel->setText( + " HUSH/SGD=$ " + (QLocale(QLocale::English).toString(price,'f', 2)) + ); + ui->volumeExchange->setText( + " $ " + (QLocale(QLocale::English).toString(volume,'f', 2)) + ); + ui->marketcapTab->setText( + " $ " + (QLocale(QLocale::English).toString(cap,'f', 2)) + ); - } else if (Settings::getInstance()->get_currency_name() == "CHF") { - double price = Settings::getInstance()->getCHFPrice(); - double volume = Settings::getInstance()->getCHFVolume(); - double cap = Settings::getInstance()->getCHFCAP(); - main->statusLabel->setText(" HUSH/CHF= " + (QLocale(QLocale::German).toString(price,'f', 2))+ " CHF"); - ui->volumeExchange->setText(QLocale(QLocale::German).toString(volume,'f', 2)+ " CHF"); - ui->marketcapTab->setText(QLocale(QLocale::German).toString(cap,'f', 2)+ " CHF"); + } + else if (Settings::getInstance()->get_currency_name() == "CHF") + { + double price = Settings::getInstance()->getCHFPrice(); + double volume = Settings::getInstance()->getCHFVolume(); + double cap = Settings::getInstance()->getCHFCAP(); + main->statusLabel->setText( + " HUSH/CHF= " + (QLocale(QLocale::German).toString(price,'f', 2))+ " CHF" + ); + ui->volumeExchange->setText( + QLocale(QLocale::German).toString(volume,'f', 2)+ " CHF" + ); + ui->marketcapTab->setText( + QLocale(QLocale::German).toString(cap,'f', 2)+ " CHF" + ); - } else if (Settings::getInstance()->get_currency_name() == "INR") { - double price = Settings::getInstance()->getINRPrice(); - double volume = Settings::getInstance()->getINRVolume(); - double cap = Settings::getInstance()->getINRCAP(); - main->statusLabel->setText(" HUSH/INR=₹ " + (QLocale(QLocale::English).toString(price,'f', 2))); - ui->volumeExchange->setText(" ₹ " + (QLocale(QLocale::English).toString(volume,'f', 2))); - ui->marketcapTab->setText(" ₹ " + (QLocale(QLocale::English).toString(cap,'f', 2))); + } + else if (Settings::getInstance()->get_currency_name() == "INR") + { + double price = Settings::getInstance()->getINRPrice(); + double volume = Settings::getInstance()->getINRVolume(); + double cap = Settings::getInstance()->getINRCAP(); + main->statusLabel->setText( + " HUSH/INR=₹ " + (QLocale(QLocale::English).toString(price,'f', 2)) + ); + ui->volumeExchange->setText( + " ₹ " + (QLocale(QLocale::English).toString(volume,'f', 2)) + ); + ui->marketcapTab->setText( + " ₹ " + (QLocale(QLocale::English).toString(cap,'f', 2)) + ); - } else if (Settings::getInstance()->get_currency_name() == "GBP") { - double price = Settings::getInstance()->getGBPPrice(); - double volume = Settings::getInstance()->getGBPVolume(); - double cap = Settings::getInstance()->getGBPCAP(); - main->statusLabel->setText(" HUSH/GBP=£ " + (QLocale(QLocale::English).toString(price,'f', 2))); - ui->volumeExchange->setText(" £ " + (QLocale(QLocale::English).toString(volume,'f', 2))); - ui->marketcapTab->setText(" £ " + (QLocale(QLocale::English).toString(cap,'f', 2))); + } + else if (Settings::getInstance()->get_currency_name() == "GBP") + { + double price = Settings::getInstance()->getGBPPrice(); + double volume = Settings::getInstance()->getGBPVolume(); + double cap = Settings::getInstance()->getGBPCAP(); + main->statusLabel->setText( + " HUSH/GBP=£ " + (QLocale(QLocale::English).toString(price,'f', 2)) + ); + ui->volumeExchange->setText( + " £ " + (QLocale(QLocale::English).toString(volume,'f', 2)) + ); + ui->marketcapTab->setText( + " £ " + (QLocale(QLocale::English).toString(cap,'f', 2)) + ); - }else if (Settings::getInstance()->get_currency_name() == "AUD") { - double price = Settings::getInstance()->getAUDPrice(); - double volume = Settings::getInstance()->getAUDVolume(); - double cap = Settings::getInstance()->getAUDCAP(); - main->statusLabel->setText(" HUSH/AUD=$ " + (QLocale(QLocale::English).toString(price,'f', 2))); - ui->volumeExchange->setText(" $ " + (QLocale(QLocale::English).toString(volume,'f', 2))); - ui->marketcapTab->setText(" $ " + (QLocale(QLocale::English).toString(cap,'f', 2))); - - } else { - main->statusLabel->setText(" HUSH/USD=$" + QString::number(Settings::getInstance()->getZECPrice(),'f',2 )); - ui->volumeExchange->setText(" $ " + QString::number((double) Settings::getInstance()->getUSDVolume() ,'f',2)); - ui->marketcapTab->setText(" $ " + QString::number((double) Settings::getInstance()->getUSDCAP() ,'f',2)); - } + } + else if (Settings::getInstance()->get_currency_name() == "AUD") + { + double price = Settings::getInstance()->getAUDPrice(); + double volume = Settings::getInstance()->getAUDVolume(); + double cap = Settings::getInstance()->getAUDCAP(); + main->statusLabel->setText( + " HUSH/AUD=$ " + (QLocale(QLocale::English).toString(price,'f', 2)) + ); + ui->volumeExchange->setText( + " $ " + (QLocale(QLocale::English).toString(volume,'f', 2)) + ); + ui->marketcapTab->setText( + " $ " + (QLocale(QLocale::English).toString(cap,'f', 2)) + ); + + } + else + { + main->statusLabel->setText( + " HUSH/USD=$" + QString::number(Settings::getInstance()->getZECPrice(),'f',2 ) + ); + ui->volumeExchange->setText( + " $ " + QString::number((double) Settings::getInstance()->getUSDVolume() ,'f',2) + ); + ui->marketcapTab->setText( + " $ " + QString::number((double) Settings::getInstance()->getUSDCAP() ,'f',2) + ); + } main->statusLabel->setToolTip(tooltip); main->statusIcon->setPixmap(i.pixmap(16, 16)); main->statusIcon->setToolTip(tooltip); @@ -754,29 +512,34 @@ void Controller::getInfoThenRefresh(bool force) { zrpc->fetchWalletEncryptionStatus([=] (const json& reply) { bool isEncrypted = reply["encrypted"].get(); bool isLocked = reply["locked"].get(); - model->setEncryptionStatus(isEncrypted, isLocked); }); // Get the total supply and render it with thousand decimal zrpc->fetchSupply([=] (const json& reply) { - - int supply = reply["supply"].get(); - int zfunds = reply["zfunds"].get(); - int total = reply["total"].get(); + int supply = reply["supply"].get(); + int zfunds = reply["zfunds"].get(); + int total = reply["total"].get(); + if ( + Settings::getInstance()->get_currency_name() == "EUR" || + Settings::getInstance()->get_currency_name() == "CHF" || + Settings::getInstance()->get_currency_name() == "RUB" + ) + { + ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply)+ " Hush")); + ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds)+ " Hush")); + ui->supply_total->setText((QLocale(QLocale::German).toString(total)+ " Hush")); + } + else + { + ui->supply_taddr->setText("Hush " + (QLocale(QLocale::English).toString(supply))); + ui->supply_zaddr->setText("Hush " +(QLocale(QLocale::English).toString(zfunds))); + ui->supply_total->setText("Hush " +(QLocale(QLocale::English).toString(total))); + } - if (Settings::getInstance()->get_currency_name() == "EUR" || Settings::getInstance()->get_currency_name() == "CHF" || Settings::getInstance()->get_currency_name() == "RUB") { - ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply)+ " Hush")); - ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds)+ " Hush")); - ui->supply_total->setText((QLocale(QLocale::German).toString(total)+ " Hush"));} - else{ - ui->supply_taddr->setText("Hush " + (QLocale(QLocale::English).toString(supply))); - ui->supply_zaddr->setText("Hush " +(QLocale(QLocale::English).toString(zfunds))); - ui->supply_total->setText("Hush " +(QLocale(QLocale::English).toString(total)));} + }); - - }); - - if ( doUpdate ) { + if ( doUpdate ) + { // Something changed, so refresh everything. refreshBalances(); refreshAddresses(); // This calls refreshZSentTransactions() and refreshReceivedZTrans() @@ -788,10 +551,15 @@ void Controller::getInfoThenRefresh(bool force) { // Prevent multiple dialog boxes, because these are called async static bool shown = false; - if (!shown && prevCallSucceeded) { // show error only first time + if (!shown && prevCallSucceeded) // show error only first time + { shown = true; - QMessageBox::critical(main, QObject::tr("Connection Error"), QObject::tr("There was an error connecting to hushd. The error was") + ": \n\n" - + err, QMessageBox::StandardButton::Ok); + QMessageBox::critical( + main, + QObject::tr("Connection Error"), + QObject::tr("There was an error connecting to hushd. The error was") + ": \n\n"+ err, + QMessageBox::StandardButton::Ok + ); shown = false; } @@ -799,32 +567,31 @@ void Controller::getInfoThenRefresh(bool force) { }); } -void Controller::refreshAddresses() { +void Controller::refreshAddresses() +{ if (!zrpc->haveConnection()) return noConnection(); auto newzaddresses = new QList(); auto newtaddresses = new QList(); - - zrpc->fetchAddresses([=] (json reply) { auto zaddrs = reply["z_addresses"].get(); - for (auto& it : zaddrs) { + for (auto& it : zaddrs) + { auto addr = QString::fromStdString(it.get()); newzaddresses->push_back(addr); } model->replaceZaddresses(newzaddresses); - auto taddrs = reply["t_addresses"].get(); - for (auto& it : taddrs) { + for (auto& it : taddrs) + { auto addr = QString::fromStdString(it.get()); if (Settings::isTAddress(addr)) newtaddresses->push_back(addr); } model->replaceTaddresses(newtaddresses); - // Refresh the sent and received txs from all these z-addresses refreshTransactions(); }); @@ -832,17 +599,23 @@ void Controller::refreshAddresses() { } // Function to create the data model and update the views, used below. -void Controller::updateUI(bool anyUnconfirmed) { +void Controller::updateUI(bool anyUnconfirmed) +{ ui->unconfirmedWarning->setVisible(anyUnconfirmed); - // Update balances model data, which will update the table too - balancesTableModel->setNewData(model->getAllZAddresses(), model->getAllTAddresses(), model->getAllBalances(), model->getUTXOs()); + balancesTableModel->setNewData( + model->getAllZAddresses(), + model->getAllTAddresses(), + model->getAllBalances(), + model->getUTXOs() + ); }; // Function to process reply of the listunspent and z_listunspent API calls, used below. void Controller::processUnspent(const json& reply, QMap* balancesMap, QList* unspentOutputs) { auto processFn = [=](const json& array) { - for (auto& it : array) { + for (auto& it : array) + { QString qsAddr = QString::fromStdString(it["address"]); int block = it["created_in_block"].get(); QString txid = QString::fromStdString(it["created_in_txid"]); @@ -851,8 +624,11 @@ void Controller::processUnspent(const json& reply, QMap* balan bool spendable = it["unconfirmed_spent"].is_null() && it["spent"].is_null(); // TODO: Wait for 4 confirmations bool pending = !it["unconfirmed_spent"].is_null(); - unspentOutputs->push_back(UnspentOutput{ qsAddr, txid, amount, block, spendable, pending }); - if (spendable) { + unspentOutputs->push_back( + UnspentOutput{ qsAddr, txid, amount, block, spendable, pending } + ); + if (spendable) + { (*balancesMap)[qsAddr] = (*balancesMap)[qsAddr] + CAmount::fromqint64(it["value"].get()); } @@ -865,7 +641,8 @@ void Controller::processUnspent(const json& reply, QMap* balan processFn(reply["pending_utxos"].get()); }; -void Controller::updateUIBalances() { +void Controller::updateUIBalances() +{ CAmount balT = getModel()->getBalT(); CAmount balZ = getModel()->getBalZ(); CAmount balVerified = getModel()->getBalVerified(); @@ -876,112 +653,141 @@ void Controller::updateUIBalances() { CAmount balTotal = balT + balZ; CAmount balAvailable = balT + balVerified; - if (balZ < 0) { + if (balZ < 0) balZ = CAmount::fromqint64(0); - } // Balances table - ui->balSheilded ->setText(balZ.toDecimalhushString()); - ui->balVerified ->setText(balVerified.toDecimalhushString()); + ui->balSheilded->setText(balZ.toDecimalhushString()); + ui->balVerified->setText(balVerified.toDecimalhushString()); ui->balTransparent->setText(balT.toDecimalhushString()); - ui->balTotal ->setText(balTotal.toDecimalhushString()); + ui->balTotal->setText(balTotal.toDecimalhushString()); - if (Settings::getInstance()->get_currency_name() == "USD") { - ui->balSheilded ->setToolTip(balZ.toDecimalUSDString()); - ui->balVerified ->setToolTip(balVerified.toDecimalUSDString()); - ui->balTransparent->setToolTip(balT.toDecimalUSDString()); - ui->balTotal ->setToolTip(balTotal.toDecimalUSDString()); + if (Settings::getInstance()->get_currency_name() == "USD") + { + ui->balSheilded->setToolTip(balZ.toDecimalUSDString()); + ui->balVerified->setToolTip(balVerified.toDecimalUSDString()); + ui->balTransparent->setToolTip(balT.toDecimalUSDString()); + ui->balTotal->setToolTip(balTotal.toDecimalUSDString()); - } else if (Settings::getInstance()->get_currency_name() == "EUR") { - ui->balSheilded ->setToolTip(balZ.toDecimalEURString()); - ui->balVerified ->setToolTip(balVerified.toDecimalEURString()); - ui->balTransparent->setToolTip(balT.toDecimalEURString()); - ui->balTotal ->setToolTip(balTotal.toDecimalEURString()); + } + else if (Settings::getInstance()->get_currency_name() == "EUR") + { + ui->balSheilded->setToolTip(balZ.toDecimalEURString()); + ui->balVerified->setToolTip(balVerified.toDecimalEURString()); + ui->balTransparent->setToolTip(balT.toDecimalEURString()); + ui->balTotal->setToolTip(balTotal.toDecimalEURString()); + + } + else if (Settings::getInstance()->get_currency_name() == "BTC") + { + ui->balSheilded->setToolTip(balZ.toDecimalBTCString()); + ui->balVerified->setToolTip(balVerified.toDecimalBTCString()); + ui->balTransparent->setToolTip(balT.toDecimalBTCString()); + ui->balTotal->setToolTip(balTotal.toDecimalBTCString()); + } + else if (Settings::getInstance()->get_currency_name() == "CNY") + { + ui->balSheilded->setToolTip(balZ.toDecimalCNYString()); + ui->balVerified->setToolTip(balVerified.toDecimalCNYString()); + ui->balTransparent->setToolTip(balT.toDecimalCNYString()); + ui->balTotal->setToolTip(balTotal.toDecimalCNYString()); - } else if (Settings::getInstance()->get_currency_name() == "BTC") { - ui->balSheilded ->setToolTip(balZ.toDecimalBTCString()); - ui->balVerified ->setToolTip(balVerified.toDecimalBTCString()); - ui->balTransparent->setToolTip(balT.toDecimalBTCString()); - ui->balTotal ->setToolTip(balTotal.toDecimalBTCString()); - - } else if (Settings::getInstance()->get_currency_name() == "CNY") { - ui->balSheilded ->setToolTip(balZ.toDecimalCNYString()); - ui->balVerified ->setToolTip(balVerified.toDecimalCNYString()); - ui->balTransparent->setToolTip(balT.toDecimalCNYString()); - ui->balTotal ->setToolTip(balTotal.toDecimalCNYString()); + } + else if (Settings::getInstance()->get_currency_name() == "RUB") + { + ui->balSheilded->setToolTip(balZ.toDecimalRUBString()); + ui->balVerified->setToolTip(balVerified.toDecimalRUBString()); + ui->balTransparent->setToolTip(balT.toDecimalRUBString()); + ui->balTotal->setToolTip(balTotal.toDecimalRUBString()); - } else if (Settings::getInstance()->get_currency_name() == "RUB") { - ui->balSheilded ->setToolTip(balZ.toDecimalRUBString()); - ui->balVerified ->setToolTip(balVerified.toDecimalRUBString()); - ui->balTransparent->setToolTip(balT.toDecimalRUBString()); - ui->balTotal ->setToolTip(balTotal.toDecimalRUBString()); + } + else if (Settings::getInstance()->get_currency_name() == "CAD") + { + ui->balSheilded->setToolTip(balZ.toDecimalCADString()); + ui->balVerified->setToolTip(balVerified.toDecimalCADString()); + ui->balTransparent->setToolTip(balT.toDecimalCADString()); + ui->balTotal->setToolTip(balTotal.toDecimalCADString()); - } else if (Settings::getInstance()->get_currency_name() == "CAD") { - ui->balSheilded ->setToolTip(balZ.toDecimalCADString()); - ui->balVerified ->setToolTip(balVerified.toDecimalCADString()); - ui->balTransparent->setToolTip(balT.toDecimalCADString()); - ui->balTotal ->setToolTip(balTotal.toDecimalCADString()); + } + else if (Settings::getInstance()->get_currency_name() == "SGD") + { + ui->balSheilded->setToolTip(balZ.toDecimalSGDString()); + ui->balVerified->setToolTip(balVerified.toDecimalSGDString()); + ui->balTransparent->setToolTip(balT.toDecimalSGDString()); + ui->balTotal->setToolTip(balTotal.toDecimalSGDString()); - } else if (Settings::getInstance()->get_currency_name() == "SGD") { - ui->balSheilded ->setToolTip(balZ.toDecimalSGDString()); - ui->balVerified ->setToolTip(balVerified.toDecimalSGDString()); - ui->balTransparent->setToolTip(balT.toDecimalSGDString()); - ui->balTotal ->setToolTip(balTotal.toDecimalSGDString()); + } + else if (Settings::getInstance()->get_currency_name() == "CHF") + { + ui->balSheilded->setToolTip(balZ.toDecimalCHFString()); + ui->balVerified->setToolTip(balVerified.toDecimalCHFString()); + ui->balTransparent->setToolTip(balT.toDecimalCHFString()); + ui->balTotal->setToolTip(balTotal.toDecimalCHFString()); - } else if (Settings::getInstance()->get_currency_name() == "CHF") { - ui->balSheilded ->setToolTip(balZ.toDecimalCHFString()); - ui->balVerified ->setToolTip(balVerified.toDecimalCHFString()); - ui->balTransparent->setToolTip(balT.toDecimalCHFString()); - ui->balTotal ->setToolTip(balTotal.toDecimalCHFString()); + } + else if (Settings::getInstance()->get_currency_name() == "INR") + { + ui->balSheilded->setToolTip(balZ.toDecimalINRString()); + ui->balVerified->setToolTip(balVerified.toDecimalINRString()); + ui->balTransparent->setToolTip(balT.toDecimalINRString()); + ui->balTotal->setToolTip(balTotal.toDecimalINRString()); - } else if (Settings::getInstance()->get_currency_name() == "INR") { - ui->balSheilded ->setToolTip(balZ.toDecimalINRString()); - ui->balVerified ->setToolTip(balVerified.toDecimalINRString()); - ui->balTransparent->setToolTip(balT.toDecimalINRString()); - ui->balTotal ->setToolTip(balTotal.toDecimalINRString()); + } + else if (Settings::getInstance()->get_currency_name() == "GBP") + { + ui->balSheilded ->setToolTip(balZ.toDecimalGBPString()); + ui->balVerified ->setToolTip(balVerified.toDecimalGBPString()); + ui->balTransparent->setToolTip(balT.toDecimalGBPString()); + ui->balTotal ->setToolTip(balTotal.toDecimalGBPString()); - } else if (Settings::getInstance()->get_currency_name() == "GBP") { - ui->balSheilded ->setToolTip(balZ.toDecimalGBPString()); - ui->balVerified ->setToolTip(balVerified.toDecimalGBPString()); - ui->balTransparent->setToolTip(balT.toDecimalGBPString()); - ui->balTotal ->setToolTip(balTotal.toDecimalGBPString()); - - } else if (Settings::getInstance()->get_currency_name() == "AUD") { - ui->balSheilded ->setToolTip(balZ.toDecimalAUDString()); - ui->balVerified ->setToolTip(balVerified.toDecimalAUDString()); - ui->balTransparent->setToolTip(balT.toDecimalAUDString()); - ui->balTotal ->setToolTip(balTotal.toDecimalAUDString()); + } + else if (Settings::getInstance()->get_currency_name() == "AUD") + { + ui->balSheilded ->setToolTip(balZ.toDecimalAUDString()); + ui->balVerified ->setToolTip(balVerified.toDecimalAUDString()); + ui->balTransparent->setToolTip(balT.toDecimalAUDString()); + ui->balTotal ->setToolTip(balTotal.toDecimalAUDString()); } // Send tab ui->txtAvailablehush->setText(balAvailable.toDecimalhushString()); - if (Settings::getInstance()->get_currency_name() == "USD") { + if (Settings::getInstance()->get_currency_name() == "USD") ui->txtAvailableUSD->setText(balAvailable.toDecimalUSDString()); - } else if (Settings::getInstance()->get_currency_name() == "EUR") { + + else if (Settings::getInstance()->get_currency_name() == "EUR") ui->txtAvailableUSD->setText(balAvailable.toDecimalEURString()); - } else if (Settings::getInstance()->get_currency_name() == "BTC") { + + else if (Settings::getInstance()->get_currency_name() == "BTC") ui->txtAvailableUSD->setText(balAvailable.toDecimalBTCString()); - } else if (Settings::getInstance()->get_currency_name() == "CNY") { + + else if (Settings::getInstance()->get_currency_name() == "CNY") ui->txtAvailableUSD->setText(balAvailable.toDecimalCNYString()); - } else if (Settings::getInstance()->get_currency_name() == "RUB") { + + else if (Settings::getInstance()->get_currency_name() == "RUB") ui->txtAvailableUSD->setText(balAvailable.toDecimalRUBString()); - } else if (Settings::getInstance()->get_currency_name() == "CAD") { + + else if (Settings::getInstance()->get_currency_name() == "CAD") ui->txtAvailableUSD->setText(balAvailable.toDecimalCADString()); - } else if (Settings::getInstance()->get_currency_name() == "SGD") { - ui->txtAvailableUSD->setText(balAvailable.toDecimalSGDString()); - } else if (Settings::getInstance()->get_currency_name() == "CHF") { + + else if (Settings::getInstance()->get_currency_name() == "SGD") + ui->txtAvailableUSD->setText(balAvailable.toDecimalSGDString()); + + else if (Settings::getInstance()->get_currency_name() == "CHF") ui->txtAvailableUSD->setText(balAvailable.toDecimalCHFString()); - } else if (Settings::getInstance()->get_currency_name() == "INR") { - ui->txtAvailableUSD->setText(balAvailable.toDecimalINRString()); - } else if (Settings::getInstance()->get_currency_name() == "GBP") { - ui->txtAvailableUSD->setText(balAvailable.toDecimalGBPString()); - } else if (Settings::getInstance()->get_currency_name() == "AUD") { + + else if (Settings::getInstance()->get_currency_name() == "INR") + ui->txtAvailableUSD->setText(balAvailable.toDecimalINRString()); + + else if (Settings::getInstance()->get_currency_name() == "GBP") + ui->txtAvailableUSD->setText(balAvailable.toDecimalGBPString()); + + else if (Settings::getInstance()->get_currency_name() == "AUD") ui->txtAvailableUSD->setText(balAvailable.toDecimalAUDString()); - } } -void Controller::refreshBalances() { +void Controller::refreshBalances() +{ if (!zrpc->haveConnection()) return noConnection(); @@ -1001,7 +807,6 @@ void Controller::refreshBalances() { // This is for the datamodel CAmount balAvailable = balT + balVerified; model->setAvailableBalance(balAvailable); - updateUIBalances(); }); @@ -1019,10 +824,13 @@ void Controller::refreshBalances() { model->replaceUTXOs(newUnspentOutputs); // Find if any output is not spendable or is pending - bool anyUnconfirmed = std::find_if(newUnspentOutputs->constBegin(), newUnspentOutputs->constEnd(), - [=](const UnspentOutput& u) -> bool { - return !u.spendable || u.pending; - }) != newUnspentOutputs->constEnd(); + bool anyUnconfirmed = std::find_if( + newUnspentOutputs->constBegin(), + newUnspentOutputs->constEnd(), + [=](const UnspentOutput& u) -> bool { + return !u.spendable || u.pending; + } + ) != newUnspentOutputs->constEnd(); updateUI(anyUnconfirmed); @@ -1030,46 +838,45 @@ void Controller::refreshBalances() { }); } -void Controller::refreshTransactions() { +void Controller::refreshTransactions() +{ if (!zrpc->haveConnection()) return noConnection(); zrpc->fetchTransactions([=] (json reply) { QList txdata; - for (auto& it : reply.get()) { + for (auto& it : reply.get()) + { QString address; CAmount total_amount; QList items; long confirmations; - if (it.find("unconfirmed") != it.end() && it["unconfirmed"].get()) { + if (it.find("unconfirmed") != it.end() && it["unconfirmed"].get()) confirmations = 0; - } else { + else confirmations = model->getLatestBlock() - it["block_height"].get() + 1; - } auto txid = QString::fromStdString(it["txid"]); auto datetime = it["datetime"].get(); // First, check if there's outgoing metadata - if (!it["outgoing_metadata"].is_null()) { - - for (auto o: it["outgoing_metadata"].get()) { - - QString address; - + if (!it["outgoing_metadata"].is_null()) + { + for (auto o: it["outgoing_metadata"].get()) + { + QString address; address = QString::fromStdString(o["address"]); - + // Sent items are -ve CAmount amount = CAmount::fromqint64(-1* o["value"].get()); // Check for Memos QString memo; - if (!o["memo"].is_null()) { + if (!o["memo"].is_null()) memo = QString::fromStdString(o["memo"]); - } items.push_back(TransactionItemDetail{address, amount, memo}); total_amount = total_amount + amount; @@ -1079,41 +886,51 @@ void Controller::refreshTransactions() { // Concat all the addresses QList addresses; - for (auto item : items) { - - if (item.amount == 0 ) { - - } else { - addresses.push_back(item.address); - - address = addresses.join(","); } + for (auto item : items) + { + if (item.amount == 0 ) + { + } + else + { + addresses.push_back(item.address); + address = addresses.join(","); + } - } + } } - txdata.push_back(TransactionItem{ - "send", datetime, address, txid,confirmations, items - }); - } else { + txdata.push_back( + TransactionItem{"send", datetime, address, txid,confirmations, items} + ); + + } + else + { // Incoming Transaction address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"])); model->markAddressUsed(address); - QString memo; - if (!it["memo"].is_null()) { + if (!it["memo"].is_null()) memo = QString::fromStdString(it["memo"]); - } - items.push_back(TransactionItemDetail{ - address, - CAmount::fromqint64(it["amount"].get()), - memo - }); + items.push_back( + TransactionItemDetail{ + address, + CAmount::fromqint64(it["amount"].get()), + memo + } + ); TransactionItem tx{ - "Receive", datetime, address, txid,confirmations, items + "Receive", + datetime, + address, + txid, + confirmations, + items }; txdata.push_back(tx); @@ -1124,13 +941,17 @@ void Controller::refreshTransactions() { // Calculate the total unspent amount that's pending. This will need to be // shown in the UI so the user can keep track of pending funds CAmount totalPending; - for (auto txitem : txdata) { - if (txitem.confirmations == 0) { - for (auto item: txitem.items) { + for (auto txitem : txdata) + { + if (txitem.confirmations == 0) + { + for (auto item: txitem.items) + { totalPending = totalPending + item.amount; } } } + getModel()->setTotalPending(totalPending); // Update UI Balance @@ -1142,15 +963,24 @@ void Controller::refreshTransactions() { } // If the wallet is encrpyted and locked, we need to unlock it -void Controller::unlockIfEncrypted(std::function cb, std::function error) { +void Controller::unlockIfEncrypted(std::function cb, std::function error) +{ auto encStatus = getModel()->getEncryptionStatus(); - if (encStatus.first && encStatus.second) { + if (encStatus.first && encStatus.second) + { // Wallet is encrypted and locked. Ask for the password and unlock. - QString password = QInputDialog::getText(main, main->tr("Wallet Password"), - main->tr("Your wallet is encrypted.\nPlease enter your wallet password"), QLineEdit::Password); + QString password = QInputDialog::getText( + main, + main->tr("Wallet Password"), + main->tr("Your wallet is encrypted.\nPlease enter your wallet password"), + QLineEdit::Password + ); - if (password.isEmpty()) { - QMessageBox::critical(main, main->tr("Wallet Decryption Failed"), + if (password.isEmpty()) + { + QMessageBox::critical( + main, + main->tr("Wallet Decryption Failed"), main->tr("Please enter a valid password"), QMessageBox::Ok ); @@ -1159,20 +989,28 @@ void Controller::unlockIfEncrypted(std::function cb, std::functionunlockWallet(password, [=](json reply) { - if (isJsonResultSuccess(reply)) { + if (isJsonResultSuccess(reply)) + { cb(); // Refresh the wallet so the encryption status is now in sync. refresh(true); - } else { - QMessageBox::critical(main, main->tr("Wallet Decryption Failed"), + } + else + { + QMessageBox::critical( + main, + main->tr("Wallet Decryption Failed"), QString::fromStdString(reply["error"].get()), QMessageBox::Ok ); error(); } }); - } else { + + } + else + { // Not locked, so just call the function cb(); } @@ -1182,18 +1020,25 @@ void Controller::unlockIfEncrypted(std::function cb, std::functionstatusBar->showMessage(Settings::txidStatusMessage + " " + txid); }, [=] (QString opid, QString errStr) { - ui->statusBar->showMessage(QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000); + ui->statusBar->showMessage( + QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000 + ); if (!opid.isEmpty()) errStr = QObject::tr("The transaction with id ") % opid % QObject::tr(" failed. The error was") + ":\n\n" + errStr; - QMessageBox::critical(main, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok); + QMessageBox::critical( + main, + QObject::tr("Transaction Error"), + errStr, + QMessageBox::Ok + ); } ); } @@ -1202,7 +1047,8 @@ void Controller::executeStandardUITransaction(Tx tx) { // Execute a transaction! void Controller::executeTransaction(Tx tx, const std::function submitted, - const std::function error) { + const std::function error) +{ unlockIfEncrypted([=] () { // First, create the json params json params = json::array(); @@ -1210,9 +1056,12 @@ void Controller::executeTransaction(Tx tx, std::cout << std::setw(2) << params << std::endl; zrpc->sendTransaction(QString::fromStdString(params.dump()), [=](const json& reply) { - if (reply.find("txid") == reply.end()) { + if (reply.find("txid") == reply.end()) + { error("", "Couldn't understand Response: " + QString::fromStdString(reply.dump())); - } else { + } + else + { QString txid = QString::fromStdString(reply["txid"].get()); submitted(txid); } @@ -1226,7 +1075,8 @@ void Controller::executeTransaction(Tx tx, } -void Controller::checkForUpdate(bool silent) { +void Controller::checkForUpdate(bool silent) +{ if (!zrpc->haveConnection()) return noConnection(); @@ -1242,13 +1092,14 @@ void Controller::checkForUpdate(bool silent) { reply->deleteLater(); manager->deleteLater(); - try { - if (reply->error() == QNetworkReply::NoError) { - + try + { + if (reply->error() == QNetworkReply::NoError) + { auto releases = QJsonDocument::fromJson(reply->readAll()).array(); QVersionNumber maxVersion(0, 0, 0); - - for (QJsonValue rel : releases) { + for (QJsonValue rel : releases) + { if (!rel.toObject().contains("tag_name")) continue; @@ -1256,7 +1107,8 @@ void Controller::checkForUpdate(bool silent) { if (tag.startsWith("v")) tag = tag.right(tag.length() - 1); - if (!tag.isEmpty()) { + if (!tag.isEmpty()) + { auto v = QVersionNumber::fromString(tag); if (v > maxVersion) maxVersion = v; @@ -1267,24 +1119,34 @@ void Controller::checkForUpdate(bool silent) { // Get the max version that the user has hidden updates for QSettings s; - auto maxHiddenVersion = QVersionNumber::fromString(s.value("update/lastversion", "0.0.0").toString()); + auto maxHiddenVersion = QVersionNumber::fromString( + s.value("update/lastversion", "0.0.0" + ).toString()); qDebug() << "Version check: Current " << currentVersion << ", Available " << maxVersion; - if (maxVersion > currentVersion && (!silent || maxVersion > maxHiddenVersion)) { + if (maxVersion > currentVersion && (!silent || maxVersion > maxHiddenVersion)) + { auto ans = QMessageBox::information(main, QObject::tr("Update Available"), QObject::tr("A new release v%1 is available! You have v%2.\n\nWould you like to visit the releases page?") .arg(maxVersion.toString()) .arg(currentVersion.toString()), QMessageBox::Yes, QMessageBox::Cancel); - if (ans == QMessageBox::Yes) { + if (ans == QMessageBox::Yes) + { QDesktopServices::openUrl(QUrl("https://github.com/MyHush/SilentDragonLite/releases")); - } else { + } + else + { // If the user selects cancel, don't bother them again for this version s.setValue("update/lastversion", maxVersion.toString()); } - } else { - if (!silent) { + + } + else + { + if (!silent) + { QMessageBox::information(main, QObject::tr("No updates available"), QObject::tr("You already have the latest release v%1") .arg(currentVersion.toString())); @@ -1292,7 +1154,8 @@ void Controller::checkForUpdate(bool silent) { } } } - catch (...) { + catch (...) + { // If anything at all goes wrong, just set the price to 0 and move on. qDebug() << QString("Caught something nasty"); } @@ -1300,7 +1163,8 @@ void Controller::checkForUpdate(bool silent) { } // Get the hush->USD price from coinmarketcap using their API -void Controller::refreshZECPrice() { +void Controller::refreshZECPrice() +{ if (!zrpc->haveConnection()) return noConnection(); @@ -1309,22 +1173,22 @@ void Controller::refreshZECPrice() { QNetworkRequest req; req.setUrl(cmcURL); - QNetworkAccessManager *manager = new QNetworkAccessManager(this->main); QNetworkReply *reply = manager->get(req); - QObject::connect(reply, &QNetworkReply::finished, [=] { reply->deleteLater(); manager->deleteLater(); - try { - if (reply->error() != QNetworkReply::NoError) { + try + { + if (reply->error() != QNetworkReply::NoError) + { auto parsed = json::parse(reply->readAll(), nullptr, false); - if (!parsed.is_discarded() && !parsed["error"]["message"].is_null()) { + if (!parsed.is_discarded() && !parsed["error"]["message"].is_null()) qDebug() << QString::fromStdString(parsed["error"]["message"]); - } else { + else qDebug() << reply->errorString(); - } + Settings::getInstance()->setZECPrice(0); Settings::getInstance()->setEURPrice(0); Settings::getInstance()->setBTCPrice(0); @@ -1358,15 +1222,14 @@ void Controller::refreshZECPrice() { Settings::getInstance()->setCHFCAP(0); Settings::getInstance()->setGBPCAP(0); Settings::getInstance()->setAUDCAP(0); - return; } qDebug() << "No network errors"; - auto all = reply->readAll(); auto parsed = json::parse(all, nullptr, false); - if (parsed.is_discarded()) { + if (parsed.is_discarded()) + { Settings::getInstance()->setZECPrice(0); Settings::getInstance()->setEURPrice(0); Settings::getInstance()->setBTCPrice(0); @@ -1402,266 +1265,268 @@ void Controller::refreshZECPrice() { Settings::getInstance()->setAUDCAP(0); return; } - qDebug() << "Parsed JSON"; - const json& item = parsed.get(); const json& hush = item["hush"].get(); - if (hush["usd"] >= 0) { + if (hush["usd"] >= 0) + { qDebug() << "Found hush key in price json"; - qDebug() << "HUSH = $" << QString::number((double)hush["usd"]); Settings::getInstance()->setZECPrice( hush["usd"] ); } + if (hush["eur"] >= 0) { - qDebug() << "HUSH = €" << QString::number((double)hush["eur"]); Settings::getInstance()->setEURPrice(hush["eur"]); } + if (hush["btc"] >= 0) { - qDebug() << "HUSH = BTC" << QString::number((double)hush["btc"]); Settings::getInstance()->setBTCPrice( hush["btc"]); } + if (hush["cny"] >= 0) - { qDebug() << "HUSH = CNY" << QString::number((double)hush["cny"]); Settings::getInstance()->setCNYPrice( hush["cny"]); } + if (hush["rub"] >= 0) { qDebug() << "HUSH = RUB" << QString::number((double)hush["rub"]); Settings::getInstance()->setRUBPrice( hush["rub"]); } - if (hush["cad"] >= 0) - + + if (hush["cad"] >= 0) { qDebug() << "HUSH = CAD" << QString::number((double)hush["cad"]); Settings::getInstance()->setCADPrice( hush["cad"]); } + if (hush["sgd"] >= 0) { - qDebug() << "HUSH = SGD" << QString::number((double)hush["sgd"]); Settings::getInstance()->setSGDPrice( hush["sgd"]); } + if (hush["chf"] >= 0) { - qDebug() << "HUSH = CHF" << QString::number((double)hush["chf"]); Settings::getInstance()->setCHFPrice( hush["chf"]); } + if (hush["inr"] >= 0) - { - + { qDebug() << "HUSH = INR" << QString::number((double)hush["inr"]); Settings::getInstance()->setINRPrice( hush["inr"]); } + if (hush["gbp"] >= 0) { - qDebug() << "HUSH = GBP" << QString::number((double)hush["gbp"]); Settings::getInstance()->setGBPPrice( hush["gbp"]); } + if (hush["aud"] >= 0) { - qDebug() << "HUSH = AUD" << QString::number((double)hush["aud"]); Settings::getInstance()->setAUDPrice( hush["aud"]); } - if (hush["btc_24h_vol"] >= 0) - { - + + if (hush["btc_24h_vol"] >= 0) + { qDebug() << "HUSH = usd_24h_vol" << QString::number((double)hush["usd_24h_vol"]); Settings::getInstance()->setUSDVolume( hush["usd_24h_vol"]); } - if (hush["btc_24h_vol"] >= 0) - { - + + if (hush["btc_24h_vol"] >= 0) + { qDebug() << "HUSH = euro_24h_vol" << QString::number((double)hush["eur_24h_vol"]); Settings::getInstance()->setEURVolume( hush["eur_24h_vol"]); } - if (hush["btc_24h_vol"] >= 0) - { - + + if (hush["btc_24h_vol"] >= 0) + { qDebug() << "HUSH = btc_24h_vol" << QString::number((double)hush["btc_24h_vol"]); Settings::getInstance()->setBTCVolume( hush["btc_24h_vol"]); } - if (hush["cny_24h_vol"] >= 0) - { - + + if (hush["cny_24h_vol"] >= 0) + { qDebug() << "HUSH = cny_24h_vol" << QString::number((double)hush["cny_24h_vol"]); Settings::getInstance()->setCNYVolume( hush["cny_24h_vol"]); } - if (hush["rub_24h_vol"] >= 0) - { - + + if (hush["rub_24h_vol"] >= 0) + { qDebug() << "HUSH = rub_24h_vol" << QString::number((double)hush["rub_24h_vol"]); Settings::getInstance()->setRUBVolume( hush["rub_24h_vol"]); } - if (hush["cad_24h_vol"] >= 0) + + if (hush["cad_24h_vol"] >= 0) { - qDebug() << "HUSH = cad_24h_vol" << QString::number((double)hush["cad_24h_vol"]); Settings::getInstance()->setCADVolume( hush["cad_24h_vol"]); } - if (hush["sgd_24h_vol"] >= 0) - { - + + if (hush["sgd_24h_vol"] >= 0) + { qDebug() << "HUSH = sgd_24h_vol" << QString::number((double)hush["sgd_24h_vol"]); Settings::getInstance()->setSGDVolume( hush["sgd_24h_vol"]); } - if (hush["chf_24h_vol"] >= 0) - { - + + if (hush["chf_24h_vol"] >= 0) + { qDebug() << "HUSH = chf_24h_vol" << QString::number((double)hush["chf_24h_vol"]); Settings::getInstance()->setCHFVolume( hush["chf_24h_vol"]); } - if (hush["inr_24h_vol"] >= 0) - { - + + if (hush["inr_24h_vol"] >= 0) + { qDebug() << "HUSH = inr_24h_vol" << QString::number((double)hush["inr_24h_vol"]); Settings::getInstance()->setINRVolume( hush["inr_24h_vol"]); } - if (hush["gbp_24h_vol"] >= 0) - { - + + if (hush["gbp_24h_vol"] >= 0) + { qDebug() << "HUSH = gbp_24h_vol" << QString::number((double)hush["gbp_24h_vol"]); Settings::getInstance()->setGBPVolume( hush["gbp_24h_vol"]); } - if (hush["aud_24h_vol"] >= 0) - { - + + if (hush["aud_24h_vol"] >= 0) + { qDebug() << "HUSH = aud_24h_vol" << QString::number((double)hush["aud_24h_vol"]); Settings::getInstance()->setAUDVolume( hush["aud_24h_vol"]); } - if (hush["usd_market_cap"] >= 0) - { - + + if (hush["usd_market_cap"] >= 0) + { qDebug() << "HUSH = usd_market_cap" << QString::number((double)hush["usd_market_cap"]); Settings::getInstance()->setUSDCAP( hush["usd_market_cap"]); } - if (hush["eur_market_cap"] >= 0) - { - + + if (hush["eur_market_cap"] >= 0) + { qDebug() << "HUSH = eur_market_cap" << QString::number((double)hush["eur_market_cap"]); Settings::getInstance()->setEURCAP( hush["eur_market_cap"]); } - if (hush["btc_market_cap"] >= 0) - { - + + if (hush["btc_market_cap"] >= 0) + { qDebug() << "HUSH = btc_market_cap" << QString::number((double)hush["btc_market_cap"]); Settings::getInstance()->setBTCCAP( hush["btc_market_cap"]); } - if (hush["cny_market_cap"] >= 0) - { - + + if (hush["cny_market_cap"] >= 0) + { qDebug() << "HUSH = cny_market_cap" << QString::number((double)hush["cny_market_cap"]); Settings::getInstance()->setCNYCAP( hush["cny_market_cap"]); } - if (hush["rub_market_cap"] >= 0) - { - + + if (hush["rub_market_cap"] >= 0) + { qDebug() << "HUSH = rub_market_cap" << QString::number((double)hush["rub_market_cap"]); Settings::getInstance()->setRUBCAP( hush["rub_market_cap"]); } - if (hush["cad_market_cap"] >= 0) - { - + + if (hush["cad_market_cap"] >= 0) + { qDebug() << "HUSH = cad_market_cap" << QString::number((double)hush["cad_market_cap"]); Settings::getInstance()->setCADCAP( hush["cad_market_cap"]); } - if (hush["sgd_market_cap"] >= 0) - { - + + if (hush["sgd_market_cap"] >= 0) + { qDebug() << "HUSH = sgd_market_cap" << QString::number((double)hush["sgd_market_cap"]); Settings::getInstance()->setSGDCAP( hush["sgd_market_cap"]); } - if (hush["chf_market_cap"] >= 0) - { - + + if (hush["chf_market_cap"] >= 0) + { qDebug() << "HUSH = chf_market_cap" << QString::number((double)hush["chf_market_cap"]); Settings::getInstance()->setCHFCAP( hush["chf_market_cap"]); } - if (hush["inr_market_cap"] >= 0) - { - + + if (hush["inr_market_cap"] >= 0) + { qDebug() << "HUSH = inr_market_cap" << QString::number((double)hush["inr_market_cap"]); Settings::getInstance()->setINRCAP( hush["inr_market_cap"]); } - if (hush["gbp_market_cap"] >= 0) - { - + + if (hush["gbp_market_cap"] >= 0) + { qDebug() << "HUSH = gbp_market_cap" << QString::number((double)hush["gbp_market_cap"]); Settings::getInstance()->setGBPCAP( hush["gbp_market_cap"]); } - if (hush["aud_market_cap"] >= 0) - { - + + if (hush["aud_market_cap"] >= 0) + { qDebug() << "HUSH = aud_market_cap" << QString::number((double)hush["aud_market_cap"]); Settings::getInstance()->setAUDCAP( hush["aud_market_cap"]); } + return; - } catch (const std::exception& e) { + } + catch (const std::exception& e) + { // If anything at all goes wrong, just set the price to 0 and move on. qDebug() << QString("Caught something nasty: ") << e.what(); } // If nothing, then set the price to 0; - Settings::getInstance()->setZECPrice(0); - Settings::getInstance()->setEURPrice(0); - Settings::getInstance()->setBTCPrice(0); - Settings::getInstance()->setCNYPrice(0); - Settings::getInstance()->setRUBPrice(0); - Settings::getInstance()->setCADPrice(0); - Settings::getInstance()->setSGDPrice(0); - Settings::getInstance()->setCHFPrice(0); - Settings::getInstance()->setGBPPrice(0); - Settings::getInstance()->setAUDPrice(0); - Settings::getInstance()->setINRPrice(0); - Settings::getInstance()->setBTCVolume(0); - Settings::getInstance()->setUSDVolume(0); - Settings::getInstance()->setEURVolume(0); - Settings::getInstance()->setBTCVolume(0); - Settings::getInstance()->setCNYVolume(0); - Settings::getInstance()->setRUBVolume(0); - Settings::getInstance()->setCADVolume(0); - Settings::getInstance()->setINRVolume(0); - Settings::getInstance()->setSGDVolume(0); - Settings::getInstance()->setCHFVolume(0); - Settings::getInstance()->setGBPVolume(0); - Settings::getInstance()->setAUDVolume(0); - Settings::getInstance()->setUSDCAP(0); - Settings::getInstance()->setEURCAP(0); - Settings::getInstance()->setBTCCAP(0); - Settings::getInstance()->setCNYCAP(0); - Settings::getInstance()->setRUBCAP(0); - Settings::getInstance()->setCADCAP(0); - Settings::getInstance()->setINRCAP(0); - Settings::getInstance()->setSGDCAP(0); - Settings::getInstance()->setCHFCAP(0); - Settings::getInstance()->setGBPCAP(0); - Settings::getInstance()->setAUDCAP(0); + Settings::getInstance()->setZECPrice(0); + Settings::getInstance()->setEURPrice(0); + Settings::getInstance()->setBTCPrice(0); + Settings::getInstance()->setCNYPrice(0); + Settings::getInstance()->setRUBPrice(0); + Settings::getInstance()->setCADPrice(0); + Settings::getInstance()->setSGDPrice(0); + Settings::getInstance()->setCHFPrice(0); + Settings::getInstance()->setGBPPrice(0); + Settings::getInstance()->setAUDPrice(0); + Settings::getInstance()->setINRPrice(0); + Settings::getInstance()->setBTCVolume(0); + Settings::getInstance()->setUSDVolume(0); + Settings::getInstance()->setEURVolume(0); + Settings::getInstance()->setBTCVolume(0); + Settings::getInstance()->setCNYVolume(0); + Settings::getInstance()->setRUBVolume(0); + Settings::getInstance()->setCADVolume(0); + Settings::getInstance()->setINRVolume(0); + Settings::getInstance()->setSGDVolume(0); + Settings::getInstance()->setCHFVolume(0); + Settings::getInstance()->setGBPVolume(0); + Settings::getInstance()->setAUDVolume(0); + Settings::getInstance()->setUSDCAP(0); + Settings::getInstance()->setEURCAP(0); + Settings::getInstance()->setBTCCAP(0); + Settings::getInstance()->setCNYCAP(0); + Settings::getInstance()->setRUBCAP(0); + Settings::getInstance()->setCADCAP(0); + Settings::getInstance()->setINRCAP(0); + Settings::getInstance()->setSGDCAP(0); + Settings::getInstance()->setCHFCAP(0); + Settings::getInstance()->setGBPCAP(0); + Settings::getInstance()->setAUDCAP(0); }); } -void Controller::shutdownhushd() { +void Controller::shutdownhushd() +{ // Save the wallet and exit the lightclient library cleanly. - if (zrpc->haveConnection()) { + if (zrpc->haveConnection()) + { QDialog d(main); Ui_ConnectionDialog connD; connD.setupUi(&d); connD.topIcon->setBasePixmap(QIcon(":/icons/res/icon.ico").pixmap(256, 256)); connD.status->setText(QObject::tr("Please wait for SilentDragonLite to exit")); connD.statusDetail->setText(QObject::tr("Waiting for hushd to exit")); - bool finished = false; - zrpc->saveWallet([&] (json) { if (!finished) d.accept(); @@ -1676,8 +1541,10 @@ void Controller::shutdownhushd() { /** * Get a Sapling address from the user's wallet */ -QString Controller::getDefaultSaplingAddress() { - for (QString addr: model->getAllZAddresses()) { +QString Controller::getDefaultSaplingAddress() +{ + for (QString addr: model->getAllZAddresses()) + { if (Settings::getInstance()->isSaplingAddress(addr)) return addr; } @@ -1685,13 +1552,12 @@ QString Controller::getDefaultSaplingAddress() { return QString(); } -QString Controller::getDefaultTAddress() { +QString Controller::getDefaultTAddress() +{ if (model->getAllTAddresses().length() > 0) return model->getAllTAddresses().at(0); + else return QString(); + } - - - - diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f6cca77..5352a95 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -463,6 +463,7 @@ void MainWindow::setupSettingsModal() { // List of default servers settings.cmbServer->addItem("https://lite.myhush.org"); + settings.cmbServer->addItem("rnhk4pwlsbaqzx7wcqfy47lijf2opklstaukq35reiz5rn76crfqpjqd.onion:9067"); // Load current values into the dialog