Merge pull request #106 from MyHush/denio

Some improvements and updates
This commit is contained in:
Denio
2020-04-12 09:28:01 +02:00
committed by GitHub
15 changed files with 1615 additions and 1565 deletions

1
.gitignore vendored
View File

@@ -40,3 +40,4 @@ silentdragonlite.pro.user.4.10-pre1
silentdragonlite
silentdragonlite_plugin_import.cpp
silentdragonlite_resource.rc
SilentDragonLite

82
lib/Cargo.lock generated
View File

@@ -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)" = "<none>"
"checksum bellman 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "<none>"
"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)" = "<none>"
"checksum ff_derive 0.3.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "<none>"
"checksum ff 0.4.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "<none>"
"checksum ff_derive 0.3.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "<none>"
"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)" = "<none>"
"checksum group 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "<none>"
"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)" = "<none>"
"checksum pairing 0.14.2 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "<none>"
"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)" = "<none>"
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=7efa024660cbe08e7eadf2524134e153c89c51ad)" = "<none>"
"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)" = "<none>"
"checksum zcash_primitives 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "<none>"
"checksum zcash_proofs 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "<none>"
"checksum zcash_client_backend 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "<none>"
"checksum zcash_primitives 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "<none>"
"checksum zcash_proofs 0.0.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)" = "<none>"

View File

@@ -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" }

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -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

58
src/DataStore.h Normal file
View File

@@ -0,0 +1,58 @@
#ifndef DATASTORE_H
#define DATASTORE_H
#include <QString>
#include <map>
template <class T>
class DataStore
{
private:
static bool instanced;
static DataStore<T>* instance;
std::map<QString, T> data;
DataStore()
{
}
public:
static DataStore<T>* getInstance()
{
if(!DataStore<T>::instanced)
{
DataStore<T>::instanced = true;
DataStore<T>::instance = new DataStore<T>();
}
return DataStore<T>::instance;
}
void clear();
void setData(QString key, T value);
QString getData(QString key);
~DataStore()
{
DataStore<T>::instanced = false;
}
};
template <class T>
void DataStore<T>::clear()
{
this->data.clear();
}
template <class T>
void DataStore<T>::setData(QString key, T value)
{
this->data[key] = value;
}
template <class T>
QString DataStore<T>::getData(QString key)
{
return this->data[key];
}
#endif

View File

@@ -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<QString, QString>(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<QString, QString> AddressBookModel::itemAt(int row) {
if (row >= labels.size()) return QPair<QString, QString>();
QPair<QString, QString> AddressBookModel::itemAt(int row)
{
if (row >= labels.size())
return QPair<QString, QString>();
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<QString, QString>(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<QPair<QString, QString>>& AddressBook::getAllAddressLabels() {
if (allLabels.isEmpty()) {
const QList<QPair<QString, QString>>& 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();
}

View File

@@ -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);

View File

@@ -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<QString> zaddrs, const QList<QString> taddrs,
const QMap<QString, CAmount> balances, const QList<UnspentOutput> outputs)
@@ -29,21 +28,19 @@ void BalancesTableModel::setNewData(const QList<QString> zaddrs, const QList<QSt
modeldata = new QList<std::tuple<QString, CAmount>>();
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<QString> zaddrs, const QList<QSt
layoutChanged();
}
BalancesTableModel::~BalancesTableModel() {
BalancesTableModel::~BalancesTableModel()
{
delete modeldata;
delete unspentOutputs;
}
int BalancesTableModel::rowCount(const QModelIndex&) const
{
if (modeldata == nullptr) {
if (loading)
return 1;
else
return 0;
}
if (modeldata == nullptr)
return (loading) ? 1: 0;
return modeldata->size();
}
@@ -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();
}

View File

@@ -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<double>(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<double>(this->amount) / COIN;
double CAmount::getDblAmount() const
{
return static_cast<double>(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<double>(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<double>(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<double>(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<double>(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<double>(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<double>(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<double>(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<double>(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<double>(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<double>(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();
}

View File

@@ -26,6 +26,7 @@ public:
double toDecimalDouble() const;
QString toDecimalString() const;
double getDblAmount() const;
QString toDecimalUSDString() const;
QString toDecimalEURString() const;
QString toDecimalBTCString() const;

View File

@@ -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<bool>();
}
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<ConnectionConfig>(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<bool>();
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<json::number_unsigned_t>();
qint64 total = reply["total_blocks"].get<json::number_unsigned_t>();
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<ConnectionConfig> config) {
Connection* ConnectionLoader::makeConnection(std::shared_ptr<ConnectionConfig> 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<ConnectionConfig> conf) {
Connection::Connection(MainWindow* m, std::shared_ptr<ConnectionConfig> conf)
{
this->config = conf;
this->main = m;
// Register the JSON type as a type that can be passed between signals and slots.
qRegisterMetaType<json>("json");
}
void Connection::doRPC(const QString cmd, const QString args, const std::function<void(json)>& cb,
const std::function<void(QString)>& errCb) {
if (shutdownInProgress) {
void Connection::doRPC(const QString cmd, const QString args, const std::function<void(json)>& cb, const std::function<void(QString)>& 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<void(json)>& cb) {
void Connection::doRPCWithDefaultErrorHandling(const QString cmd, const QString args, const std::function<void(json)>& cb)
{
doRPC(cmd, args, cb, [=] (QString err) {
this->showTxError(err);
});
}
}
void Connection::doRPCIgnoreError(const QString cmd, const QString args, const std::function<void(json)>& cb) {
void Connection::doRPCIgnoreError(const QString cmd, const QString args, const std::function<void(json)>& 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;
}

File diff suppressed because it is too large Load Diff

View File

@@ -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