diff --git a/Cargo.lock b/Cargo.lock index c41dbb74..8eaf0317 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -555,17 +555,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "grin_api" version = "1.1.0" -source = "git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0#2e72ed91f3d1616d9c553e97d489bc2e6b4032b1" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_chain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_p2p 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_pool 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_store 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", + "grin_chain 1.1.0", + "grin_core 1.1.0", + "grin_p2p 1.1.0", + "grin_pool 1.1.0", + "grin_store 1.1.0", + "grin_util 1.1.0", "http 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-rustls 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -587,7 +586,6 @@ dependencies = [ [[package]] name = "grin_chain" version = "1.1.0" -source = "git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0#2e72ed91f3d1616d9c553e97d489bc2e6b4032b1" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -595,10 +593,10 @@ dependencies = [ "croaring 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_keychain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_store 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", + "grin_core 1.1.0", + "grin_keychain 1.1.0", + "grin_store 1.1.0", + "grin_util 1.1.0", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -610,7 +608,6 @@ dependencies = [ [[package]] name = "grin_core" version = "1.1.0" -source = "git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0#2e72ed91f3d1616d9c553e97d489bc2e6b4032b1" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -619,8 +616,8 @@ dependencies = [ "enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_keychain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", + "grin_keychain 1.1.0", + "grin_util 1.1.0", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -636,12 +633,11 @@ dependencies = [ [[package]] name = "grin_keychain" version = "1.1.0" -source = "git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0#2e72ed91f3d1616d9c553e97d489bc2e6b4032b1" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", + "grin_util 1.1.0", "hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -658,15 +654,14 @@ dependencies = [ [[package]] name = "grin_p2p" version = "1.1.0" -source = "git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0#2e72ed91f3d1616d9c553e97d489bc2e6b4032b1" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_store 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", + "grin_core 1.1.0", + "grin_store 1.1.0", + "grin_util 1.1.0", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -678,16 +673,15 @@ dependencies = [ [[package]] name = "grin_pool" version = "1.1.0" -source = "git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0#2e72ed91f3d1616d9c553e97d489bc2e6b4032b1" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_keychain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_store 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", + "grin_core 1.1.0", + "grin_keychain 1.1.0", + "grin_store 1.1.0", + "grin_util 1.1.0", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -711,15 +705,14 @@ dependencies = [ [[package]] name = "grin_store" version = "1.1.0" -source = "git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0#2e72ed91f3d1616d9c553e97d489bc2e6b4032b1" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "croaring 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", + "grin_core 1.1.0", + "grin_util 1.1.0", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -731,7 +724,6 @@ dependencies = [ [[package]] name = "grin_util" version = "1.1.0" -source = "git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0#2e72ed91f3d1616d9c553e97d489bc2e6b4032b1" dependencies = [ "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -758,17 +750,12 @@ dependencies = [ "ctrlc 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_api 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_chain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_keychain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_store 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", "grin_wallet_api 1.1.0", "grin_wallet_config 1.1.0", "grin_wallet_controller 1.1.0", "grin_wallet_impls 1.1.0", "grin_wallet_libwallet 1.1.0", + "grin_wallet_util 1.1.0", "linefeed 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "prettytable-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -783,19 +770,14 @@ dependencies = [ "easy-jsonrpc 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_api 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_chain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_keychain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_store 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", "grin_wallet_config 1.1.0", "grin_wallet_impls 1.1.0", "grin_wallet_libwallet 1.1.0", + "grin_wallet_util 1.1.0", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -803,8 +785,7 @@ name = "grin_wallet_config" version = "1.1.0" dependencies = [ "dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", + "grin_wallet_util 1.1.0", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -820,15 +801,11 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_api 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_chain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_keychain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", "grin_wallet_api 1.1.0", "grin_wallet_config 1.1.0", "grin_wallet_impls 1.1.0", "grin_wallet_libwallet 1.1.0", + "grin_wallet_util 1.1.0", "hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "prettytable-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -842,7 +819,7 @@ dependencies = [ "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-retry 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -854,14 +831,9 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_api 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_chain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_keychain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_store 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", "grin_wallet_config 1.1.0", "grin_wallet_libwallet 1.1.0", + "grin_wallet_util 1.1.0", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -871,7 +843,7 @@ dependencies = [ "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-retry 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -882,18 +854,33 @@ dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_keychain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_store 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", - "grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)", "grin_wallet_config 1.1.0", + "grin_wallet_util 1.1.0", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "grin_wallet_util" +version = "1.1.0" +dependencies = [ + "dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "grin_api 1.1.0", + "grin_chain 1.1.0", + "grin_core 1.1.0", + "grin_keychain 1.1.0", + "grin_store 1.1.0", + "grin_util 1.1.0", + "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -970,11 +957,11 @@ dependencies = [ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1356,7 +1343,7 @@ dependencies = [ [[package]] name = "nom" -version = "4.2.2" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2154,7 +2141,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 4.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2214,13 +2201,13 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2248,7 +2235,7 @@ dependencies = [ "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2256,16 +2243,16 @@ dependencies = [ [[package]] name = "tokio-current-thread" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-executor" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2279,7 +2266,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2305,7 +2292,7 @@ dependencies = [ "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-sync 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2363,7 +2350,7 @@ dependencies = [ [[package]] name = "tokio-threadpool" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2374,7 +2361,7 @@ dependencies = [ "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2385,7 +2372,7 @@ dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2526,7 +2513,7 @@ dependencies = [ [[package]] name = "uuid" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2751,15 +2738,7 @@ dependencies = [ "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "591f8be1674b421644b6c030969520bc3fa12114d2eb467471982ed3e9584e71" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" -"checksum grin_api 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)" = "" -"checksum grin_chain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)" = "" -"checksum grin_core 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)" = "" -"checksum grin_keychain 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)" = "" -"checksum grin_p2p 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)" = "" -"checksum grin_pool 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)" = "" "checksum grin_secp256k1zkp 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "75e9a265f3eeea4c204470f7262e2c6fe18f3d8ddf5fb24340cb550ac4f909c5" -"checksum grin_store 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)" = "" -"checksum grin_util 1.1.0 (git+https://github.com/mimblewimble/grin?branch=milestone/1.1.0)" = "" "checksum h2 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "910a5e7be6283a9c91b3982fa5188368c8719cce2a3cf3b86048673bf9d9c36b" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "733e1b3ac906631ca01ebb577e9bb0f5e37a454032b9036b5eaea4013ed6f99a" @@ -2807,7 +2786,7 @@ dependencies = [ "checksum nix 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0d95c5fa8b641c10ad0b8887454ebaafa3c92b5cd5350f8fc693adafd178e7b" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b" -"checksum nom 4.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22293d25d3f33a8567cc8a1dc20f40c7eeb761ce83d0fcca059858580790cac3" +"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" "checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" "checksum num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cf4825417e1e1406b3782a8ce92f4d53f26ec055e3622e1881ca8e9f5f9e08db" "checksum num-bigint 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "e63899ad0da84ce718c14936262a41cee2c79c981fc0a0e7c7beb47d5a07e8c1" @@ -2910,8 +2889,8 @@ dependencies = [ "checksum tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6e93c78d23cc61aa245a8acd2c4a79c4d7fa7fb5c3ca90d5737029f043a84895" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" "checksum tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "aeeffbbb94209023feaef3c196a41cbcdafa06b4a6f893f68779bb5e53796f71" -"checksum tokio-current-thread 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c756b04680eea21902a46fca4e9f410a2332c04995af590e07ff262e2193a9a3" -"checksum tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30c6dbf2d1ad1de300b393910e8a3aa272b724a400b6531da03eed99e329fbf0" +"checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" +"checksum tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "83ea44c6c0773cc034771693711c35c677b4b5a4b21b9e7071704c54de7d555e" "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" @@ -2920,7 +2899,7 @@ dependencies = [ "checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" "checksum tokio-sync 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fda385df506bf7546e70872767f71e81640f1f251bdf2fd8eb81a0eaec5fe022" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -"checksum tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "742e511f6ce2298aeb86fc9ea0d8df81c2388c6ebae3dc8a7316e8c9df0df801" +"checksum tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ec5759cf26cf9659555f36c431b515e3d05f66831741c85b4b5d5dfb9cf1323c" "checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" @@ -2940,7 +2919,7 @@ dependencies = [ "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363" -"checksum uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0238db0c5b605dd1cf51de0f21766f97fba2645897024461d6a00c036819a768" +"checksum uuid 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "600ef8213e9f8a0ac1f876e470e90780ae0478eabce7f76aff41b0f4ef0fd5c0" "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" diff --git a/Cargo.toml b/Cargo.toml index adc3106c..18ae432c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ name = "grin-wallet" path = "src/bin/grin-wallet.rs" [workspace] -members = ["api", "config", "controller", "impls", "libwallet"] +members = ["api", "config", "controller", "impls", "libwallet", "util"] exclude = ["integration"] [dependencies] @@ -35,12 +35,7 @@ grin_wallet_libwallet = { path = "./libwallet", version = "1.1.0" } grin_wallet_controller = { path = "./controller", version = "1.1.0" } grin_wallet_config = { path = "./config", version = "1.1.0" } -grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_api = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_store = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } +grin_wallet_util = { path = "./util", version = "1.1.0" } [build-dependencies] built = "0.3" diff --git a/api/Cargo.toml b/api/Cargo.toml index 1a5bb0f4..7d369f75 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -23,12 +23,7 @@ grin_wallet_libwallet = { path = "../libwallet", version = "1.1.0" } grin_wallet_config = { path = "../config", version = "1.1.0" } grin_wallet_impls = { path = "../impls", version = "1.1.0" } -grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_api = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_store = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } +grin_wallet_util = { path = "../util", version = "1.1.0" } [dev-dependencies] serde_json = "1" diff --git a/api/src/foreign.rs b/api/src/foreign.rs index 6da5412a..bcfa6065 100644 --- a/api/src/foreign.rs +++ b/api/src/foreign.rs @@ -46,6 +46,8 @@ where /// Wallet, contains its keychain (TODO: Split these up into 2 traits /// perhaps) pub wallet: Arc>, + /// Flag to normalize some output during testing. Can mostly be ignored. + pub doctest_mode: bool, phantom: PhantomData, phantom_c: PhantomData, } @@ -57,19 +59,20 @@ where K: Keychain, { /// Create new API instance - pub fn new(wallet_in: Arc>) -> Box { - Box::new(Foreign { + pub fn new(wallet_in: Arc>) -> Self { + Foreign { wallet: wallet_in, + doctest_mode: false, phantom: PhantomData, phantom_c: PhantomData, - }) + } } /// Build a new (potential) coinbase transaction in the wallet pub fn build_coinbase(&self, block_fees: &BlockFees) -> Result { let mut w = self.wallet.lock(); w.open_with_credentials()?; - let res = foreign::build_coinbase(&mut *w, block_fees); + let res = foreign::build_coinbase(&mut *w, block_fees, self.doctest_mode); w.close()?; res } @@ -88,7 +91,7 @@ where ) -> Result<(), Error> { let mut w = self.wallet.lock(); w.open_with_credentials()?; - let res = foreign::receive_tx(&mut *w, slate, dest_acct_name, message, false); + let res = foreign::receive_tx(&mut *w, slate, dest_acct_name, message, self.doctest_mode); w.close()?; res } diff --git a/api/src/foreign_rpc.rs b/api/src/foreign_rpc.rs index 2966b5e7..2a999b29 100644 --- a/api/src/foreign_rpc.rs +++ b/api/src/foreign_rpc.rs @@ -31,28 +31,45 @@ pub trait ForeignRpc { ``` # grin_wallet_api::doctest_helper_json_rpc_foreign_assert_response!( + # r#" { "jsonrpc": "2.0", "method": "build_coinbase", + "id": 1, "params": [ { "fees": 0, "height": 0, "key_id": null } - ], - "id": 1 - }, + ] + } + # "# + # , + # r#" { + "id": 1, "jsonrpc": "2.0", "result": { - "Err": { - "CallbackImpl": "Error opening wallet" + "Ok": { + "kernel": { + "excess": "08dfe86d732f2dd24bac36aa7502685221369514197c26d33fac03041d47e4b490", + "excess_sig": "1b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f4f0471a33b6465cdb9e72b635f5611aa6c89ebd51aeee038f69b4cc598a02fe0", + "features": "Coinbase", + "fee": "0", + "lock_height": "0" + }, + "key_id": "0300000000000000000000000400000000", + "output": { + "commit": "08fe198e525a5937d0c5d01fa354394d2679be6df5d42064a0f7550c332fce3d9d", + "features": "Coinbase", + "proof": "9166dc13a374a50d99f16ddfb228ce6010ea22d1676de755c34123402b5a8e68871b37d716c14e07be14ceb0771cca62a302358aa82922fa87f1387cff3a4507027f04f3fcf54ed16bd97e40a06c6f969139188daca366bb78ccbc7ff0203de62e30077f8b4a8b314901666205d24ca93d54581aa082e37c370e178dea267ff11fa4669756a31c026348255108c4de4b7abe3636ebdd67f25387c9c2868d16fab9209ebee6d19c6395eaf313da67f164d8e997ed97de9478ddb24c34d8a0dcedc24c5d0a9d1c9f15de3264323fc768271d7981b1e2ae1e59675537115fdcd1ea7d60a7bd276865698d1c1598b7c22a1a6e212db4d0a0ba98706a746f63f2d8460a9d28b4e8a7d2ad1f531b32046e2285a034c2d49f7896026fa186f9665766ae158435157f94bd31b8ebf5c0637a9d72036348c1d1fb70659b6ca5e64427a9eb51569074311e970316fd370373149067a0781cd49cc450e80e14a84f9818ae8caf6c02877f15ab11397d60309249658e5a03f49354dce3873118be6f43ca436aa81165ca44d624fd6f504b8d186bca2ef7e3c5ff2b85db86b29ddd0fb58173960caf2b437c8190511685303ab0eb1b5a757e1509529063a145f5242350edb8e1a1807f505866fdb5689fd39d4595cf5084d30a1ba2af882969bf64aecad342926b16930a3d93781dcebc839b7bf5762146e0016c502aad33d24c9e708c810505bd9c6648bd8303ddbbe5c5cf82eb420784223182e1b59286249e38458c885f089e9211b3aafe7c6f85097878679775287423ebca7557cd3be9e44bb454c6b1914b9012e100d601d7a2ecb0c2a07b5e6f0c293b671e45a425d97169eb793834a40a0a64277e68b2809ca4556eed7d130c2ea973021fda08a01c771111b1cc12b647029fe19f1018486a0ef82bbe5ca7ff484c71d52f3238766d771eaf4204793809dc27" + } } - }, - "id": 1 + } } - # ); + # "# + # , 4, false); ``` */ fn build_coinbase(&self, block_fees: &BlockFees) -> Result; @@ -64,95 +81,228 @@ pub trait ForeignRpc { ``` # grin_wallet_api::doctest_helper_json_rpc_foreign_assert_response!( + # r#" { "jsonrpc": "2.0", "method": "verify_slate_messages", - "params": [ - { - "version_info": { - "version": 2, - "orig_version": 2, - "min_compat_version": 0 - }, - "amount": 0, - "fee": 0, - "height": 0, - "id": "414bad48-3386-4fa7-8483-72384c886ba3", - "lock_height": 0, + "id": 1, + "params": [ { + "amount": "6000000000", + "fee": "8000000", + "height": "4", + "id": "0436430c-2b02-624c-2032-570501212b00", + "lock_height": "4", "num_participants": 2, - "participant_data": [], + "participant_data": [ + { + "id": "0", + "message": "my message", + "message_sig": "1b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f756f655333250204644c1cb169e7a78f21b57437930db91e808f39be58134c1d", + "part_sig": null, + "public_blind_excess": "034b4df2f0558b73ea72a1ca5c4ab20217c66bbe0829056fca7abe76888e9349ee", + "public_nonce": "031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f" + } + ], "tx": { "body": { - "inputs": [], - "kernels": [], - "outputs": [] + "inputs": [ + { + "commit": "08e1da9e6dc4d6e808a718b2f110a991dd775d65ce5ae408a4e1f002a4961aa9e7", + "features": "Coinbase" + } + ], + "kernels": [ + { + "excess": "000000000000000000000000000000000000000000000000000000000000000000", + "excess_sig": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "features": "HeightLocked", + "fee": "8000000", + "lock_height": "4" + } + ], + "outputs": [ + { + "commit": "094be57c91787fc2033d5d97fae099f1a6ddb37ea48370f1a138f09524c767fdd3", + "features": "Plain", + "proof": "2a42e9e902b70ce44e1fccb14de87ee0a97100bddf12c6bead1b9c5f4eb60300f29c13094fa12ffeee238fb4532b18f6b61cf51b23c1c7e1ad2e41560dc27edc0a2b9e647a0b3e4e806fced5b65e61d0f1f5197d3e2285c632d359e27b6b9206b2caffea4f67e0c7a2812e7a22c134b98cf89bd43d9f28b8bec25cce037a0ac5b1ae8f667e54e1250813a5263004486b4465ad4e641ab2b535736ea26535a11013564f08f483b7dab1c2bcc3ee38eadf2f7850eff7e3459a4bbabf9f0cf6c50d0c0a4120565cd4a2ce3e354c11721cd695760a24c70e0d5a0dfc3c5dcd51dfad6de2c237a682f36dc0b271f21bb3655e5333016aaa42c2efa1446e5f3c0a79ec417c4d30f77556951cb0f05dbfafb82d9f95951a9ea241fda2a6388f73ace036b98acce079f0e4feebccc96290a86dcc89118a901210b245f2d114cf94396e4dbb461e82aa26a0581389707957968c7cdc466213bb1cd417db207ef40c05842ab67a01a9b96eb1430ebc26e795bb491258d326d5174ad549401059e41782121e506744af8af9d8e493644a87d613600888541cbbe538c625883f3eb4aa3102c5cfcc25de8e97af8927619ce6a731b3b8462d51d993066b935b0648d2344ad72e4fd70f347fbd81041042e5ea31cc7b2e3156a920b80ecba487b950ca32ca95fae85b759c936246ecf441a9fdd95e8fee932d6782cdec686064018c857efc47fb4b2a122600d5fdd79af2486f44df7e629184e1c573bc0a9b3feb40b190ef2861a1ab45e2ac2201b9cd42e495deea247269820ed32389a2810ad6c0f9a296d2a2d9c54089fed50b7f5ecfcd33ab9954360e1d7f5598c32128cfcf2a1d8bf14616818da8a5343bfa88f0eedf392e9d4ab1ace1b60324129cd4852c2e27813a9cf71a6ae6229a4fcecc1a756b3e664c5f50af333082616815a3bec8fc0b75b8e4e767d719" + } + ] }, - "offset": "0000000000000000000000000000000000000000000000000000000000000000" + "offset": "d202964900000000d302964900000000d402964900000000d502964900000000" + }, + "version_info": { + "min_compat_version": 0, + "orig_version": 2, + "version": 2 } } - ], - "id": 1 - }, + ] + } + # "# + # , + # r#" { "jsonrpc": "2.0", + "id": 1, "result": { "Ok": null - }, - "id": 1 + } } - # ); + # "# + # ,1 ,false); ``` */ fn verify_slate_messages(&self, slate: &Slate) -> Result<(), ErrorKind>; /** - Networked version of [Foreign::receive_tx](struct.Foreign.html#method.receive_tx). + Networked version of [Foreign::receive_tx](struct.Foreign.html#method.receive_tx). # Json rpc example - ```ignore //TODO: No idea why this isn't expanding properly, check as we adjust the API + ``` # grin_wallet_api::doctest_helper_json_rpc_foreign_assert_response!( + # r#" { "jsonrpc": "2.0", "method": "receive_tx", + "id": 1, "params": [ { - "version_info": { - "version": 2, - "orig_version": 2, - "min_compat_version": 0 - }, - "amount": 0, - "fee": 0, - "height": 0, - "id": "414bad48-3386-4fa7-8483-72384c886ba3", - "lock_height": 0, - "num_participants": 2, - "participant_data": [], - "tx": { - "body": { - "inputs": [], - "kernels": [], - "outputs": [] - }, - "offset": "0000000000000000000000000000000000000000000000000000000000000000" + "version_info": { + "version": 2, + "orig_version": 2, + "min_compat_version": 0 + }, + "num_participants": 2, + "id": "0436430c-2b02-624c-2032-570501212b00", + "tx": { + "offset": "d202964900000000d302964900000000d402964900000000d502964900000000", + "body": { + "inputs": [ + { + "features": "Coinbase", + "commit": "087df32304c5d4ae8b2af0bc31e700019d722910ef87dd4eec3197b80b207e3045" + }, + { + "features": "Coinbase", + "commit": "08e1da9e6dc4d6e808a718b2f110a991dd775d65ce5ae408a4e1f002a4961aa9e7" + } + ], + "outputs": [ + { + "features": "Plain", + "commit": "0812276cc788e6870612296d926cba9f0e7b9810670710b5a6e6f1ba006d395774", + "proof": "dcff6175390c602bfa92c2ffd1a9b2d84dcc9ea941f6f317bdd0f875244ef23e696fd17c71df79760ce5ce1a96aab1d15dd057358dc835e972febeb86d50ccec0dad7cfe0246d742eb753cf7b88c045d15bc7123f8cf7155647ccf663fca92a83c9a65d0ed756ea7ebffd2cac90c380a102ed9caaa355d175ed0bf58d3ac2f5e909d6c447dfc6b605e04925c2b17c33ebd1908c965a5541ea5d2ed45a0958e6402f89d7a56df1992e036d836e74017e73ccad5cb3a82b8e139e309792a31b15f3ffd72ed033253428c156c2b9799458a25c1da65b719780a22de7fe7f437ae2fccd22cf7ea357ab5aa66a5ef7d71fb0dc64aa0b5761f68278062bb39bb296c787e4cabc5e2a2933a416ce1c9a9696160386449c437e9120f7bb26e5b0e74d1f2e7d5bcd7aafb2a92b87d1548f1f911fb06af7bd6cc13cee29f7c9cb79021aed18186272af0e9d189ec107c81a8a3aeb4782b0d950e4881aa51b776bb6844b25bce97035b48a9bdb2aea3608687bcdd479d4fa998b5a839ff88558e4a29dff0ed13b55900abb5d439b70793d902ae9ad34587b18c919f6b875c91d14deeb1c373f5e76570d59a6549758f655f1128a54f162dfe8868e1587028e26ad91e528c5ae7ee9335fa58fb59022b5de29d80f0764a9917390d46db899acc6a5b416e25ecc9dccb7153646addcc81cadb5f0078febc7e05d7735aba494f39ef05697bbcc9b47b2ccc79595d75fc13c80678b5e237edce58d731f34c05b1ddcaa649acf2d865bbbc3ceda10508bcdd29d0496744644bf1c3516f6687dfeef5649c7dff90627d642739a59d91a8d1d0c4dc55d74a949e1074427664b467992c9e0f7d3af9d6ea79513e8946ddc0d356bac49878e64e6a95b0a30214214faf2ce317fa622ff3266b32a816e10a18e6d789a5da1f23e67b4f970a68a7bcd9e18825ee274b0483896a40" + } + ], + "kernels": [ + { + "features": "Plain", + "fee": "7000000", + "lock_height": "0", + "excess": "000000000000000000000000000000000000000000000000000000000000000000", + "excess_sig": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + } + ] } }, - null, - null - ], - "id": 1 - }, - { - "jsonrpc": "2.0", - "result": { - "Err": { - "CallbackImpl": "Error opening wallet" - } + "amount": "60000000000", + "fee": "7000000", + "height": "5", + "lock_height": "0", + "participant_data": [ + { + "id": "0", + "public_blind_excess": "033ac2158fa0077f087de60c19d8e431753baa5b63b6e1477f05a2a6e7190d4592", + "public_nonce": "031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f", + "part_sig": null, + "message": null, + "message_sig": null + } + ] }, - "id": 1 + null, + "Thanks, Yeastplume" + ] } - # ); + # "# + # , + # r#" + { + "id": 1, + "jsonrpc": "2.0", + "result": { + "Ok": { + "amount": "60000000000", + "fee": "7000000", + "height": "5", + "id": "0436430c-2b02-624c-2032-570501212b00", + "lock_height": "0", + "num_participants": 2, + "participant_data": [ + { + "id": "0", + "message": null, + "message_sig": null, + "part_sig": null, + "public_blind_excess": "033ac2158fa0077f087de60c19d8e431753baa5b63b6e1477f05a2a6e7190d4592", + "public_nonce": "031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f" + }, + { + "id": "1", + "message": "Thanks, Yeastplume", + "message_sig": "1b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078ff97f43f2eda0f695161ba23dc48db7a1bcbd7f131f1e21bdb4e1ad1eb2f1a130", + "part_sig": "1b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078ffc965b05962362aee43e5264bd3fd0f26dbd7092cfe070069e26d2df28bd352b", + "public_blind_excess": "038fe0443243dab173c068ef5fa891b242d2b5eb890ea09475e6e381170442ee16", + "public_nonce": "031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f" + } + ], + "tx": { + "body": { + "inputs": [ + { + "commit": "087df32304c5d4ae8b2af0bc31e700019d722910ef87dd4eec3197b80b207e3045", + "features": "Coinbase" + }, + { + "commit": "08e1da9e6dc4d6e808a718b2f110a991dd775d65ce5ae408a4e1f002a4961aa9e7", + "features": "Coinbase" + } + ], + "kernels": [ + { + "excess": "000000000000000000000000000000000000000000000000000000000000000000", + "excess_sig": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "features": "Plain", + "fee": "7000000", + "lock_height": "0" + } + ], + "outputs": [ + { + "commit": "084ee97defa8c37124d4c69baa753e2532535faa81f79ea5e0489db25297d5beb8", + "features": "Plain", + "proof": "bffb26e7df4bf753f4d8e810c67fb5106b1746c1870f5cb96585537eb8e2f66b372ed05fd35ae18c6e8515cd9f2aaae85d5a7655361c6a8573e20fbdfdda6e0a0b25817fc0db23dc25297382af379659d846bd8044f807c467722708d3a3797b84fceb09eb29f11c77b79c7c93c578d06d95b58d845930531e5cac6346d1373ee1c5db69c14d0aa1a9c22e187dc346156c468540ad166a04902d3faf357ed31a50775d274913ccc9ba976ca3977e18f383b20f0cd02a0866b7b44847bfbba35c099f5eba9c9747cad961033321925f3e0ad43e357aaecc50989bbbcb5b44ead58fe359c59903530c58bf1c9a6f9fb120a3492e835fabc01bb8b31b52b15ace4785a08c3ea9a82bd15c41c744544286b114b1be733fa6237300cf2dc99e8af6f8557bd9a083ba59cc1a500bdfba228b53785a7fdbf576f7dce035769058bc7644041ec5731485e5641eac5c75a6eb57e4abc287b0be8eab77c7e8a5122ee8d49f02f103a3af6fe38b8fcecd1aa9bb342b3e110f4003ee6c771ed93401ca3438dcf0d751a36dbb7a7a45d32709525686f3d2e5f542c747c9c745fe50cd789a0aa55419934afff363044d3c3f5f7669ebb9f2245b449bfdc4e09dfb1661552485107afbd9a2b571a0647b1fc330089a65e4b5df07f58f1a9c11c3da51d56cd854f227c5111d25ca8c4bec4bb0fbcb4a23fc3288418423dd0649d731b6a6c08851954ea920046ce67a4114d35c3876c25361e7a99474aa04354a4ed0555f9bef527d902fbb0d1d5c2b42f5eea5ced359005121167f9908729939dba610cdabca41f714e144ab148faec77f4d70566287671e6786459bd7d16787a24e12f2328b9faab1c7ac80a916d2f83f12a7351a2bedff610d33dfb2df7d8e57b68fb4a5dcc0d8e4fa807b2077877aa96ba7bc22e627a4f6a308d3abc091f56d518258f073cc1b70ef81" + }, + { + "commit": "0812276cc788e6870612296d926cba9f0e7b9810670710b5a6e6f1ba006d395774", + "features": "Plain", + "proof": "dcff6175390c602bfa92c2ffd1a9b2d84dcc9ea941f6f317bdd0f875244ef23e696fd17c71df79760ce5ce1a96aab1d15dd057358dc835e972febeb86d50ccec0dad7cfe0246d742eb753cf7b88c045d15bc7123f8cf7155647ccf663fca92a83c9a65d0ed756ea7ebffd2cac90c380a102ed9caaa355d175ed0bf58d3ac2f5e909d6c447dfc6b605e04925c2b17c33ebd1908c965a5541ea5d2ed45a0958e6402f89d7a56df1992e036d836e74017e73ccad5cb3a82b8e139e309792a31b15f3ffd72ed033253428c156c2b9799458a25c1da65b719780a22de7fe7f437ae2fccd22cf7ea357ab5aa66a5ef7d71fb0dc64aa0b5761f68278062bb39bb296c787e4cabc5e2a2933a416ce1c9a9696160386449c437e9120f7bb26e5b0e74d1f2e7d5bcd7aafb2a92b87d1548f1f911fb06af7bd6cc13cee29f7c9cb79021aed18186272af0e9d189ec107c81a8a3aeb4782b0d950e4881aa51b776bb6844b25bce97035b48a9bdb2aea3608687bcdd479d4fa998b5a839ff88558e4a29dff0ed13b55900abb5d439b70793d902ae9ad34587b18c919f6b875c91d14deeb1c373f5e76570d59a6549758f655f1128a54f162dfe8868e1587028e26ad91e528c5ae7ee9335fa58fb59022b5de29d80f0764a9917390d46db899acc6a5b416e25ecc9dccb7153646addcc81cadb5f0078febc7e05d7735aba494f39ef05697bbcc9b47b2ccc79595d75fc13c80678b5e237edce58d731f34c05b1ddcaa649acf2d865bbbc3ceda10508bcdd29d0496744644bf1c3516f6687dfeef5649c7dff90627d642739a59d91a8d1d0c4dc55d74a949e1074427664b467992c9e0f7d3af9d6ea79513e8946ddc0d356bac49878e64e6a95b0a30214214faf2ce317fa622ff3266b32a816e10a18e6d789a5da1f23e67b4f970a68a7bcd9e18825ee274b0483896a40" + } + ] + }, + "offset": "d202964900000000d302964900000000d402964900000000d502964900000000" + }, + "version_info": { + "min_compat_version": 0, + "orig_version": 2, + "version": 2 + } + } + } + } + # "# + # , 5, true); ``` */ fn receive_tx( @@ -194,52 +344,124 @@ where } } +/// helper to set up a real environment to run integrated doctests +pub fn run_doctest_foreign( + request: serde_json::Value, + test_dir: &str, + blocks_to_mine: u64, + init_tx: bool, +) -> Result, String> { + use crate::{Foreign, ForeignRpc}; + use easy_jsonrpc::Handler; + use grin_wallet_impls::test_framework::{self, LocalWalletClient, WalletProxy}; + use grin_wallet_libwallet::api_impl; + use grin_wallet_util::grin_keychain::ExtKeychain; + + use crate::core::global; + use crate::core::global::ChainTypes; + use grin_wallet_util::grin_util as util; + + use std::fs; + use std::thread; + + util::init_test_logger(); + let _ = fs::remove_dir_all(test_dir); + global::set_mining_mode(ChainTypes::AutomatedTesting); + + let mut wallet_proxy: WalletProxy = WalletProxy::new(test_dir); + let chain = wallet_proxy.chain.clone(); + + let rec_phrase_1 = + "fat twenty mean degree forget shell check candy immense awful \ + flame next during february bulb bike sun wink theory day kiwi embrace peace lunch"; + let client1 = LocalWalletClient::new("wallet1", wallet_proxy.tx.clone()); + let wallet1 = test_framework::create_wallet( + &format!("{}/wallet1", test_dir), + client1.clone(), + Some(rec_phrase_1), + ); + wallet_proxy.add_wallet("wallet1", client1.get_send_instance(), wallet1.clone()); + + let rec_phrase_2 = + "hour kingdom ripple lunch razor inquiry coyote clay stamp mean \ + sell finish magic kid tiny wage stand panther inside settle feed song hole exile"; + let client2 = LocalWalletClient::new("wallet2", wallet_proxy.tx.clone()); + let wallet2 = test_framework::create_wallet( + &format!("{}/wallet2", test_dir), + client2.clone(), + Some(rec_phrase_2), + ); + wallet_proxy.add_wallet("wallet2", client2.get_send_instance(), wallet2.clone()); + + // Set the wallet proxy listener running + thread::spawn(move || { + if let Err(e) = wallet_proxy.run() { + error!("Wallet Proxy error: {}", e); + } + }); + + // Mine a few blocks to wallet 1 so there's something to send + for _ in 0..blocks_to_mine { + let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 1 as usize, false); + //update local outputs after each block, so transaction IDs stay consistent + let mut w = wallet1.lock(); + w.open_with_credentials().unwrap(); + let (wallet_refreshed, _) = + api_impl::owner::retrieve_summary_info(&mut *w, true, 1).unwrap(); + assert!(wallet_refreshed); + w.close().unwrap(); + } + + if init_tx { + let amount = 60_000_000_000; + let mut w = wallet1.lock(); + w.open_with_credentials().unwrap(); + let slate = api_impl::owner::initiate_tx( + &mut *w, None, // account + amount, // amount + 2, // minimum confirmations + 500, // max outputs + 1, // num change outputs + true, // select all outputs + None, None, true, + ) + .unwrap(); + println!("INIT SLATE"); + // Spit out slate for input to finalize_tx + println!("{}", serde_json::to_string_pretty(&slate).unwrap()); + } + + let mut api_foreign = Foreign::new(wallet1.clone()); + api_foreign.doctest_mode = true; + let foreign_api = &api_foreign as &dyn ForeignRpc; + Ok(foreign_api.handle_request(request)) +} + #[doc(hidden)] #[macro_export] macro_rules! doctest_helper_json_rpc_foreign_assert_response { - ($request:tt, $expected_response:tt) => { - // create temporary wallet, run jsonrpc request on api of wallet, delete wallet, return + ($request:expr, $expected_response:expr, $blocks_to_mine:expr, $init_tx:expr) => { + // create temporary wallet, run jsonrpc request on owner api of wallet, delete wallet, return // json response. // In order to prevent leaking tempdirs, This function should not panic. - fn rpc_owner_result( - request: serde_json::Value, - ) -> Result, String> { - use easy_jsonrpc::Handler; - use grin_keychain::ExtKeychain; - use grin_util::Mutex; - use grin_wallet_api::{Foreign, ForeignRpc}; - use grin_wallet_config::WalletConfig; - use grin_wallet_impls::{HTTPNodeClient, LMDBBackend}; - use grin_wallet_libwallet::types::WalletBackend; - use serde_json; - use std::sync::Arc; - use tempfile::tempdir; + use grin_wallet_api::run_doctest_foreign; + use serde_json; + use serde_json::Value; + use tempfile::tempdir; - let dir = tempdir().map_err(|e| format!("{:#?}", e))?; - { - let mut wallet_config = WalletConfig::default(); - wallet_config.data_file_dir = dir - .path() - .to_str() - .ok_or("Failed to convert tmpdir path to string.".to_owned())? - .to_owned(); - let node_client = - HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None); - let wallet: Arc>> = - Arc::new(Mutex::new( - LMDBBackend::new(wallet_config.clone(), "", node_client) - .map_err(|e| format!("{:#?}", e))?, - )); - let api_foreign = *Foreign::new(wallet); - let foreign_api = &api_foreign as &dyn ForeignRpc; - Ok(foreign_api.handle_request(request)) - } - } + let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap(); + let dir = dir + .path() + .to_str() + .ok_or("Failed to convert tmpdir path to string.".to_owned()) + .unwrap(); - let response = rpc_owner_result(serde_json::json!($request)) + let request_val: Value = serde_json::from_str($request).unwrap(); + let expected_response: Value = serde_json::from_str($expected_response).unwrap(); + + let response = run_doctest_foreign(request_val, dir, $blocks_to_mine, $init_tx) .unwrap() .unwrap(); - let expected_response = serde_json::json!($expected_response); if response != expected_response { panic!( diff --git a/api/src/lib.rs b/api/src/lib.rs index d1b97346..f4920b3a 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -22,10 +22,9 @@ #![deny(unused_mut)] #![warn(missing_docs)] -extern crate grin_core as core; -extern crate grin_keychain as keychain; -extern crate grin_store as store; -extern crate grin_util as util; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_util as util; extern crate grin_wallet_libwallet as libwallet; extern crate failure_derive; @@ -43,4 +42,5 @@ pub use crate::foreign_rpc::ForeignRpc; pub use crate::owner::Owner; pub use crate::owner_rpc::OwnerRpc; -pub use crate::owner_rpc::run_doctest; +pub use crate::foreign_rpc::run_doctest_foreign; +pub use crate::owner_rpc::run_doctest_owner; diff --git a/api/src/owner.rs b/api/src/owner.rs index 548b3e67..f97588bb 100644 --- a/api/src/owner.rs +++ b/api/src/owner.rs @@ -81,8 +81,8 @@ where /// /// # Example /// ``` - /// use grin_keychain as keychain; - /// use grin_util as util; + /// use grin_wallet_util::grin_keychain as keychain; + /// use grin_wallet_util::grin_util as util; /// use grin_wallet_api as api; /// use grin_wallet_config as config; /// use grin_wallet_impls as impls; @@ -946,12 +946,12 @@ where #[macro_export] macro_rules! doctest_helper_setup_doc_env { ($wallet:ident, $wallet_config:ident) => { - use grin_keychain as keychain; - use grin_util as util; use grin_wallet_api as api; use grin_wallet_config as config; use grin_wallet_impls as impls; use grin_wallet_libwallet as libwallet; + use grin_wallet_util::grin_keychain as keychain; + use grin_wallet_util::grin_util as util; use keychain::ExtKeychain; use tempfile::tempdir; diff --git a/api/src/owner_rpc.rs b/api/src/owner_rpc.rs index 1d4b2ae7..7fb5a179 100644 --- a/api/src/owner_rpc.rs +++ b/api/src/owner_rpc.rs @@ -22,7 +22,7 @@ use crate::libwallet::types::{ AcctPathMapping, NodeClient, OutputCommitMapping, TxEstimation, TxLogEntry, WalletBackend, WalletInfo, }; -use crate::libwallet::{api_impl, ErrorKind}; +use crate::libwallet::ErrorKind; use crate::Owner; use easy_jsonrpc; @@ -1171,7 +1171,7 @@ where } /// helper to set up a real environment to run integrated doctests -pub fn run_doctest( +pub fn run_doctest_owner( request: serde_json::Value, test_dir: &str, blocks_to_mine: u64, @@ -1181,12 +1181,13 @@ pub fn run_doctest( ) -> Result, String> { use crate::{Owner, OwnerRpc}; use easy_jsonrpc::Handler; - use grin_keychain::ExtKeychain; use grin_wallet_impls::test_framework::{self, LocalWalletClient, WalletProxy}; + use grin_wallet_libwallet::api_impl; + use grin_wallet_util::grin_keychain::ExtKeychain; use crate::core::global; use crate::core::global::ChainTypes; - use grin_util as util; + use grin_wallet_util::grin_util as util; use std::fs; use std::thread; @@ -1289,7 +1290,7 @@ macro_rules! doctest_helper_json_rpc_owner_assert_response { // create temporary wallet, run jsonrpc request on owner api of wallet, delete wallet, return // json response. // In order to prevent leaking tempdirs, This function should not panic. - use grin_wallet_api::run_doctest; + use grin_wallet_api::run_doctest_owner; use serde_json; use serde_json::Value; use tempfile::tempdir; @@ -1304,7 +1305,7 @@ macro_rules! doctest_helper_json_rpc_owner_assert_response { let request_val: Value = serde_json::from_str($request).unwrap(); let expected_response: Value = serde_json::from_str($expected_response).unwrap(); - let response = run_doctest( + let response = run_doctest_owner( request_val, dir, $blocks_to_mine, diff --git a/config/Cargo.toml b/config/Cargo.toml index ee596505..4e0e787c 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -16,8 +16,7 @@ serde_derive = "1" toml = "0.4" dirs = "1.0.3" -grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } +grin_wallet_util = { path = "../util", version = "1.1.0" } [dev-dependencies] pretty_assertions = "0.5.1" diff --git a/config/src/config.rs b/config/src/config.rs index c9b1dc71..9aa47b2b 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -27,11 +27,9 @@ use toml; use crate::comments::insert_comments; use crate::core::global; -use crate::types::{ - ConfigError, GlobalWalletConfig, GlobalWalletConfigMembers, -}; -use crate::util::LoggingConfig; use crate::types::WalletConfig; +use crate::types::{ConfigError, GlobalWalletConfig, GlobalWalletConfigMembers}; +use crate::util::LoggingConfig; /// Wallet configuration file name pub const WALLET_CONFIG_FILE_NAME: &'static str = "grin-wallet.toml"; diff --git a/config/src/lib.rs b/config/src/lib.rs index b801137d..22517945 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -23,8 +23,8 @@ #[macro_use] extern crate serde_derive; -use grin_core as core; -use grin_util as util; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_util as util; mod comments; pub mod config; diff --git a/controller/Cargo.toml b/controller/Cargo.toml index fdb390cc..947e8dfd 100644 --- a/controller/Cargo.toml +++ b/controller/Cargo.toml @@ -31,13 +31,9 @@ uuid = { version = "0.7", features = ["serde", "v4"] } url = "1.7.0" chrono = { version = "0.4.4", features = ["serde"] } +grin_wallet_util = { path = "../util", version = "1.1.0" } + grin_wallet_api = { path = "../api", version = "1.1.0" } grin_wallet_impls = { path = "../impls", version = "1.1.0" } grin_wallet_libwallet = { path = "../libwallet", version = "1.1.0" } grin_wallet_config = { path = "../config", version = "1.1.0" } - -grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_api = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } diff --git a/controller/src/command.rs b/controller/src/command.rs index bb45f309..b54a1d22 100644 --- a/controller/src/command.rs +++ b/controller/src/command.rs @@ -138,7 +138,7 @@ pub fn listen(config: &WalletConfig, args: &ListenArgs, g_args: &GlobalArgs) -> )?; let listen_addr = params.get("api_listen_addr").unwrap(); let tls_conf = match params.get("certificate") { - Some(s) => Some(grin_api::TLSConfig::new( + Some(s) => Some(TLSConfig::new( s.to_owned(), params.get("private_key").unwrap().to_owned(), )), diff --git a/controller/src/controller.rs b/controller/src/controller.rs index 565564d4..664953bd 100644 --- a/controller/src/controller.rs +++ b/controller/src/controller.rs @@ -684,7 +684,7 @@ where } fn handle_request(&self, req: Request) -> WalletResponseFuture { - let api = *Foreign::new(self.wallet.clone()); + let api = Foreign::new(self.wallet.clone()); match req .uri() .path() diff --git a/controller/src/lib.rs b/controller/src/lib.rs index 1bcffea8..c78e9ea5 100644 --- a/controller/src/lib.rs +++ b/controller/src/lib.rs @@ -20,14 +20,14 @@ extern crate prettytable; #[macro_use] extern crate log; use failure; -use grin_api as api; -extern crate grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use grin_wallet_api as apiwallet; +use grin_wallet_config as config; use grin_wallet_impls as impls; use grin_wallet_libwallet as libwallet; -extern crate grin_wallet_config as config; +use grin_wallet_util::grin_api as api; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_util as util; pub mod command; pub mod controller; diff --git a/controller/tests/accounts.rs b/controller/tests/accounts.rs index 7f613848..bb5ed546 100644 --- a/controller/tests/accounts.rs +++ b/controller/tests/accounts.rs @@ -17,12 +17,13 @@ extern crate log; extern crate grin_wallet_controller as wallet; extern crate grin_wallet_impls as impls; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_util as util; + use self::core::global; use self::core::global::ChainTypes; use self::keychain::{ExtKeychain, Keychain}; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use grin_wallet_libwallet as libwallet; use impls::test_framework::{self, LocalWalletClient, WalletProxy}; use std::fs; diff --git a/controller/tests/check.rs b/controller/tests/check.rs index 8cad79e1..d539b5ef 100644 --- a/controller/tests/check.rs +++ b/controller/tests/check.rs @@ -17,13 +17,14 @@ extern crate log; extern crate grin_wallet_controller as wallet; extern crate grin_wallet_impls as impls; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_util as util; + use self::core::consensus; use self::core::global; use self::core::global::ChainTypes; use self::keychain::ExtKeychain; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use grin_wallet_libwallet as libwallet; use impls::test_framework::{self, LocalWalletClient, WalletProxy}; use impls::FileWalletCommAdapter; diff --git a/controller/tests/file.rs b/controller/tests/file.rs index 06cc1abd..e1c1863e 100644 --- a/controller/tests/file.rs +++ b/controller/tests/file.rs @@ -17,12 +17,13 @@ extern crate log; extern crate grin_wallet_controller as wallet; extern crate grin_wallet_impls as impls; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_util as util; + use self::core::global; use self::core::global::ChainTypes; use self::keychain::ExtKeychain; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use grin_wallet_libwallet as libwallet; use impls::test_framework::{self, LocalWalletClient, WalletProxy}; use impls::FileWalletCommAdapter; diff --git a/controller/tests/repost.rs b/controller/tests/repost.rs index 6f1d96d0..9b786b66 100644 --- a/controller/tests/repost.rs +++ b/controller/tests/repost.rs @@ -18,13 +18,14 @@ extern crate grin_wallet_controller as wallet; extern crate grin_wallet_impls as impls; extern crate grin_wallet_libwallet as libwallet; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_util as util; + use self::core::global; use self::core::global::ChainTypes; use self::keychain::ExtKeychain; use self::libwallet::slate::Slate; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use impls::test_framework::{self, LocalWalletClient, WalletProxy}; use impls::FileWalletCommAdapter; use std::fs; diff --git a/controller/tests/restore.rs b/controller/tests/restore.rs index 951c2177..265543eb 100644 --- a/controller/tests/restore.rs +++ b/controller/tests/restore.rs @@ -18,14 +18,15 @@ extern crate grin_wallet_controller as wallet; extern crate grin_wallet_impls as impls; extern crate grin_wallet_libwallet as libwallet; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_util as util; + use self::core::global; use self::core::global::ChainTypes; use self::keychain::{ExtKeychain, Identifier, Keychain}; use self::libwallet::slate::Slate; use self::libwallet::types::AcctPathMapping; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use impls::test_framework::{self, LocalWalletClient, WalletProxy}; use std::fs; use std::sync::atomic::Ordering; diff --git a/controller/tests/self_send.rs b/controller/tests/self_send.rs index 8543cb60..ce257134 100644 --- a/controller/tests/self_send.rs +++ b/controller/tests/self_send.rs @@ -17,12 +17,13 @@ extern crate log; extern crate grin_wallet_controller as wallet; extern crate grin_wallet_impls as impls; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_util as util; + use self::core::global; use self::core::global::ChainTypes; use self::keychain::ExtKeychain; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use grin_wallet_libwallet as libwallet; use impls::test_framework::{self, LocalWalletClient, WalletProxy}; use std::fs; diff --git a/controller/tests/transaction.rs b/controller/tests/transaction.rs index 66c88029..db5e62fe 100644 --- a/controller/tests/transaction.rs +++ b/controller/tests/transaction.rs @@ -18,15 +18,16 @@ extern crate grin_wallet_controller as wallet; extern crate grin_wallet_impls as impls; extern crate grin_wallet_libwallet as libwallet; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_util as util; + use self::core::core::transaction; use self::core::global; use self::core::global::ChainTypes; use self::keychain::ExtKeychain; use self::libwallet::slate::Slate; use self::libwallet::types::OutputStatus; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use impls::test_framework::{self, LocalWalletClient, WalletProxy}; use std::fs; use std::thread; diff --git a/impls/Cargo.toml b/impls/Cargo.toml index f79b0789..6eca1630 100644 --- a/impls/Cargo.toml +++ b/impls/Cargo.toml @@ -27,12 +27,7 @@ tokio-retry = "0.1" uuid = { version = "0.7", features = ["serde", "v4"] } chrono = { version = "0.4.4", features = ["serde"] } +grin_wallet_util = { path = "../util", version = "1.1.0" } + grin_wallet_libwallet = { path = "../libwallet", version = "1.1.0" } grin_wallet_config = { path = "../config", version = "1.1.0" } - -grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_api = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_store = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } diff --git a/impls/src/lib.rs b/impls/src/lib.rs index d375cecb..697f0d71 100644 --- a/impls/src/lib.rs +++ b/impls/src/lib.rs @@ -22,12 +22,13 @@ use blake2_rfc as blake2; extern crate serde_derive; #[macro_use] extern crate log; -extern crate grin_core as core; -use grin_api as api; -use grin_keychain as keychain; -use grin_store as store; -use grin_util as util; use grin_wallet_libwallet as libwallet; +use grin_wallet_util::grin_api as api; +use grin_wallet_util::grin_chain as chain; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; +use grin_wallet_util::grin_store as store; +use grin_wallet_util::grin_util as util; extern crate grin_wallet_config as config; mod adapters; diff --git a/impls/src/test_framework/mod.rs b/impls/src/test_framework/mod.rs index dd22343f..485d14b9 100644 --- a/impls/src/test_framework/mod.rs +++ b/impls/src/test_framework/mod.rs @@ -12,25 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -use self::chain::Chain; -use self::core::core::{OutputFeatures, OutputIdentifier, Transaction}; -use self::core::{consensus, global, pow, ser}; -use self::util::secp::pedersen; -use self::util::Mutex; +use crate::api; +use crate::chain; +use crate::chain::Chain; use crate::config::WalletConfig; +use crate::core; +use crate::core::core::{OutputFeatures, OutputIdentifier, Transaction}; +use crate::core::{consensus, global, pow}; +use crate::keychain; use crate::libwallet; use crate::libwallet::api_impl::{foreign, owner}; use crate::libwallet::types::{ BlockFees, CbData, NodeClient, WalletBackend, WalletInfo, WalletInst, }; use crate::lmdb_wallet::LMDBBackend; +use crate::util; +use crate::util::secp::pedersen; +use crate::util::Mutex; use crate::WalletSeed; use chrono::Duration; -use grin_api as api; -use grin_chain as chain; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use std::sync::Arc; use std::thread; @@ -79,15 +79,11 @@ fn get_outputs_by_pmmr_index_local( pub fn add_block_with_reward(chain: &Chain, txs: Vec<&Transaction>, reward: CbData) { let prev = chain.head_header().unwrap(); let next_header_info = consensus::next_difficulty(1, chain.difficulty_iter()); - let out_bin = util::from_hex(reward.output).unwrap(); - let kern_bin = util::from_hex(reward.kernel).unwrap(); - let output = ser::deserialize(&mut &out_bin[..]).unwrap(); - let kernel = ser::deserialize(&mut &kern_bin[..]).unwrap(); let mut b = core::core::Block::new( &prev, txs.into_iter().cloned().collect(), next_header_info.clone().difficulty, - (output, kernel), + (reward.output, reward.kernel), ) .unwrap(); b.header.timestamp = prev.timestamp + Duration::seconds(60); @@ -128,7 +124,7 @@ where let coinbase_tx = { let mut w = wallet.lock(); w.open_with_credentials()?; - let res = foreign::build_coinbase(&mut *w, &block_fees)?; + let res = foreign::build_coinbase(&mut *w, &block_fees, false)?; w.close()?; res }; diff --git a/impls/src/test_framework/testclient.rs b/impls/src/test_framework/testclient.rs index 1e2be6ae..d8104861 100644 --- a/impls/src/test_framework/testclient.rs +++ b/impls/src/test_framework/testclient.rs @@ -16,27 +16,24 @@ //! so that wallet API can be fully exercised //! Operates directly on a chain instance -use self::chain::types::NoopAdapter; -use self::chain::Chain; -use self::core::core::verifier_cache::LruVerifierCache; -use self::core::core::Transaction; -use self::core::global::{set_mining_mode, ChainTypes}; -use self::core::{pow, ser}; -use self::keychain::Keychain; -use self::util::secp::pedersen; -use self::util::secp::pedersen::Commitment; -use self::util::{Mutex, RwLock, StopState}; +use crate::api; +use crate::chain::types::NoopAdapter; +use crate::chain::Chain; use crate::config::WalletConfig; +use crate::core::core::verifier_cache::LruVerifierCache; +use crate::core::core::Transaction; +use crate::core::global::{set_mining_mode, ChainTypes}; +use crate::core::{pow, ser}; +use crate::keychain::Keychain; use crate::libwallet::api_impl::foreign; use crate::libwallet::slate::Slate; use crate::libwallet::types::*; +use crate::util; +use crate::util::secp::pedersen; +use crate::util::secp::pedersen::Commitment; +use crate::util::{Mutex, RwLock, StopState}; use crate::{libwallet, WalletCommAdapter}; use failure::ResultExt; -use grin_api as api; -use grin_chain as chain; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use serde_json; use std::collections::HashMap; use std::marker::PhantomData; diff --git a/libwallet/Cargo.toml b/libwallet/Cargo.toml index bc7dd710..d7ae689f 100644 --- a/libwallet/Cargo.toml +++ b/libwallet/Cargo.toml @@ -24,10 +24,7 @@ uuid = { version = "0.7", features = ["serde", "v4"] } chrono = { version = "0.4.4", features = ["serde"] } lazy_static = "1" -grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } -grin_store = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } +grin_wallet_util = { path = "../util", version = "1.1.0" } [dev-dependencies] grin_wallet_config = { path = "../config", version = "1.1.0" } diff --git a/libwallet/src/api_impl/foreign.rs b/libwallet/src/api_impl/foreign.rs index a4eeb924..133131fa 100644 --- a/libwallet/src/api_impl/foreign.rs +++ b/libwallet/src/api_impl/foreign.rs @@ -14,8 +14,8 @@ //! Generic implementation of owner API functions +use crate::grin_keychain::Keychain; use crate::internal::{tx, updater}; -use crate::keychain::Keychain; use crate::slate::Slate; use crate::types::{BlockFees, CbData, NodeClient, TxLogEntryType, WalletBackend}; use crate::{Error, ErrorKind}; @@ -23,13 +23,17 @@ use crate::{Error, ErrorKind}; const USER_MESSAGE_MAX_LEN: usize = 256; /// Build a coinbase transaction -pub fn build_coinbase(w: &mut T, block_fees: &BlockFees) -> Result +pub fn build_coinbase( + w: &mut T, + block_fees: &BlockFees, + test_mode: bool, +) -> Result where T: WalletBackend, C: NodeClient, K: Keychain, { - updater::build_coinbase(&mut *w, block_fees) + updater::build_coinbase(&mut *w, block_fees, test_mode) } /// verify slate messages @@ -61,7 +65,13 @@ where None => w.parent_key_id(), }; // Don't do this multiple times - let tx = updater::retrieve_txs(&mut *w, None, Some(slate.id), Some(&parent_key_id), false)?; + let tx = updater::retrieve_txs( + &mut *w, + None, + Some(slate.id), + Some(&parent_key_id), + use_test_rng, + )?; for t in &tx { if t.tx_type == TxLogEntryType::TxReceived { return Err(ErrorKind::TransactionAlreadyReceived(slate.id.to_string()).into()); diff --git a/libwallet/src/api_impl/owner.rs b/libwallet/src/api_impl/owner.rs index 9b591fb1..71e9e0b4 100644 --- a/libwallet/src/api_impl/owner.rs +++ b/libwallet/src/api_impl/owner.rs @@ -16,12 +16,13 @@ use uuid::Uuid; -use crate::core::core::hash::Hashed; -use crate::core::core::Transaction; -use crate::core::ser; +use crate::grin_core::core::hash::Hashed; +use crate::grin_core::core::Transaction; +use crate::grin_core::ser; +use crate::grin_util; +use crate::grin_keychain::{Identifier, Keychain}; use crate::internal::{keys, selection, tx, updater}; -use crate::keychain::{Identifier, Keychain}; use crate::slate::Slate; use crate::types::{ AcctPathMapping, NodeClient, OutputCommitMapping, TxEstimation, TxLogEntry, TxWrapper, @@ -305,7 +306,7 @@ pub fn post_tx(client: &C, tx: &Transaction, fluff: bool) -> Result<(), Error where C: NodeClient, { - let tx_hex = util::to_hex(ser::ser_vec(tx).unwrap()); + let tx_hex = grin_util::to_hex(ser::ser_vec(tx).unwrap()); let res = client.post_tx(&TxWrapper { tx_hex: tx_hex }, fluff); if let Err(e) = res { error!("api: post_tx: failed with error: {}", e); diff --git a/libwallet/src/error.rs b/libwallet/src/error.rs index 4e450a4e..38a25d9b 100644 --- a/libwallet/src/error.rs +++ b/libwallet/src/error.rs @@ -14,10 +14,11 @@ //! Error types for libwallet -use crate::core::core::{committed, transaction}; -use crate::core::libtx; -use crate::keychain; -use crate::util::secp; +use crate::grin_core::core::{committed, transaction}; +use crate::grin_core::libtx; +use crate::grin_keychain; +use crate::grin_store; +use crate::grin_util::secp; use failure::{Backtrace, Context, Fail}; use std::env; use std::fmt::{self, Display}; @@ -58,7 +59,7 @@ pub enum ErrorKind { /// Keychain error #[fail(display = "Keychain error")] - Keychain(keychain::Error), + Keychain(grin_keychain::Error), /// Transaction Error #[fail(display = "Transaction error")] @@ -90,7 +91,7 @@ pub enum ErrorKind { /// Other serialization errors #[fail(display = "Ser/Deserialization error")] - Deser(crate::core::ser::Error), + Deser(crate::grin_core::ser::Error), /// IO Error #[fail(display = "I/O error")] @@ -263,8 +264,8 @@ impl From for Error { } } -impl From for Error { - fn from(error: keychain::Error) -> Error { +impl From for Error { + fn from(error: grin_keychain::Error) -> Error { Error { inner: Context::new(ErrorKind::Keychain(error)), } @@ -272,7 +273,7 @@ impl From for Error { } impl From for Error { - fn from(error: crate::core::libtx::Error) -> Error { + fn from(error: crate::grin_core::libtx::Error) -> Error { Error { inner: Context::new(ErrorKind::LibTX(error.kind())), } @@ -287,8 +288,8 @@ impl From for Error { } } -impl From for Error { - fn from(error: crate::core::ser::Error) -> Error { +impl From for Error { + fn from(error: crate::grin_core::ser::Error) -> Error { Error { inner: Context::new(ErrorKind::Deser(error)), } @@ -311,8 +312,8 @@ impl From for Error { } } -impl From for Error { - fn from(error: store::Error) -> Error { +impl From for Error { + fn from(error: grin_store::Error) -> Error { Error::from(ErrorKind::Backend(format!("{}", error))) } } diff --git a/libwallet/src/internal/keys.rs b/libwallet/src/internal/keys.rs index 87c4f7a1..bc226f0c 100644 --- a/libwallet/src/internal/keys.rs +++ b/libwallet/src/internal/keys.rs @@ -14,7 +14,7 @@ //! Wallet key management functions use crate::error::{Error, ErrorKind}; -use crate::keychain::{ChildNumber, ExtKeychain, Identifier, Keychain}; +use crate::grin_keychain::{ChildNumber, ExtKeychain, Identifier, Keychain}; use crate::types::{AcctPathMapping, NodeClient, WalletBackend}; /// Get next available key in the wallet for a given parent diff --git a/libwallet/src/internal/restore.rs b/libwallet/src/internal/restore.rs index c911c6f0..661d4286 100644 --- a/libwallet/src/internal/restore.rs +++ b/libwallet/src/internal/restore.rs @@ -13,12 +13,12 @@ // limitations under the License. //! Functions to restore a wallet's outputs from just the master seed -use crate::core::global; -use crate::core::libtx::proof; +use crate::grin_core::global; +use crate::grin_core::libtx::proof; +use crate::grin_keychain::{ExtKeychain, Identifier, Keychain}; +use crate::grin_util::secp::{key::SecretKey, pedersen}; use crate::internal::{keys, updater}; -use crate::keychain::{ExtKeychain, Identifier, Keychain}; use crate::types::*; -use crate::util::secp::{key::SecretKey, pedersen}; use crate::Error; use std::collections::HashMap; diff --git a/libwallet/src/internal/selection.rs b/libwallet/src/internal/selection.rs index 2312958e..38d33af7 100644 --- a/libwallet/src/internal/selection.rs +++ b/libwallet/src/internal/selection.rs @@ -14,11 +14,11 @@ //! Selection of inputs for building transactions -use crate::core::core::amount_to_hr_string; -use crate::core::libtx::{build, tx_fee}; use crate::error::{Error, ErrorKind}; +use crate::grin_core::core::amount_to_hr_string; +use crate::grin_core::libtx::{build, tx_fee}; +use crate::grin_keychain::{Identifier, Keychain}; use crate::internal::keys; -use crate::keychain::{Identifier, Keychain}; use crate::slate::Slate; use crate::types::*; use std::collections::HashMap; diff --git a/libwallet/src/internal/tx.rs b/libwallet/src/internal/tx.rs index 287841bd..52165a0f 100644 --- a/libwallet/src/internal/tx.rs +++ b/libwallet/src/internal/tx.rs @@ -16,12 +16,12 @@ use uuid::Uuid; +use crate::grin_keychain::{Identifier, Keychain}; +use crate::grin_util::Mutex; use crate::internal::{selection, updater}; -use crate::keychain::{Identifier, Keychain}; use crate::slate::Slate; use crate::types::{Context, NodeClient, TxLogEntryType, WalletBackend}; use crate::{Error, ErrorKind}; -use util::Mutex; /// static for incrementing test UUIDs lazy_static! { @@ -186,7 +186,7 @@ where &context.sec_nonce, 1, message, - false, + use_test_rng, )?; // perform partial sig @@ -307,8 +307,8 @@ where #[cfg(test)] mod test { - use crate::core::libtx::build; - use crate::keychain::{ExtKeychain, ExtKeychainPath, Keychain}; + use crate::grin_core::libtx::build; + use crate::grin_keychain::{ExtKeychain, ExtKeychainPath, Keychain}; #[test] // demonstrate that input.commitment == referenced output.commitment diff --git a/libwallet/src/internal/updater.rs b/libwallet/src/internal/updater.rs index 8150b28b..c4ec7853 100644 --- a/libwallet/src/internal/updater.rs +++ b/libwallet/src/internal/updater.rs @@ -15,23 +15,22 @@ //! Utilities to check the status of all the outputs we have stored in //! the wallet storage and update them. -use failure::ResultExt; use std::collections::HashMap; use uuid::Uuid; -use crate::core::consensus::reward; -use crate::core::core::{Output, TxKernel}; -use crate::core::libtx::reward; -use crate::core::{global, ser}; -use crate::error::{Error, ErrorKind}; +use crate::error::Error; +use crate::grin_core::consensus::reward; +use crate::grin_core::core::{Output, TxKernel}; +use crate::grin_core::global; +use crate::grin_core::libtx::reward; +use crate::grin_keychain::{Identifier, Keychain}; +use crate::grin_util as util; +use crate::grin_util::secp::pedersen; use crate::internal::keys; -use crate::keychain::{Identifier, Keychain}; use crate::types::{ BlockFees, CbData, NodeClient, OutputCommitMapping, OutputData, OutputStatus, TxLogEntry, TxLogEntryType, WalletBackend, WalletInfo, }; -use crate::util; -use crate::util::secp::pedersen; /// Retrieve all of the outputs (doesn't attempt to update from node) pub fn retrieve_outputs( @@ -433,27 +432,19 @@ where pub fn build_coinbase( wallet: &mut T, block_fees: &BlockFees, + test_mode: bool, ) -> Result where T: WalletBackend, C: NodeClient, K: Keychain, { - let (out, kern, block_fees) = receive_coinbase(wallet, block_fees).context(ErrorKind::Node)?; - - let out_bin = ser::ser_vec(&out).context(ErrorKind::Node)?; - - let kern_bin = ser::ser_vec(&kern).context(ErrorKind::Node)?; - - let key_id_bin = match block_fees.key_id { - Some(key_id) => ser::ser_vec(&key_id).context(ErrorKind::Node)?, - None => vec![], - }; + let (out, kern, block_fees) = receive_coinbase(wallet, block_fees, test_mode)?; Ok(CbData { - output: util::to_hex(out_bin), - kernel: util::to_hex(kern_bin), - key_id: util::to_hex(key_id_bin), + output: out, + kernel: kern, + key_id: block_fees.key_id, }) } @@ -462,6 +453,7 @@ where pub fn receive_coinbase( wallet: &mut T, block_fees: &BlockFees, + test_mode: bool, ) -> Result<(Output, TxKernel, BlockFees), Error> where T: WalletBackend, @@ -513,7 +505,6 @@ where debug!("receive_coinbase: {:?}", block_fees); - let (out, kern) = reward::output(wallet.keychain(), &key_id, block_fees.fees).unwrap(); - /* .context(ErrorKind::Keychain)?; */ + let (out, kern) = reward::output(wallet.keychain(), &key_id, block_fees.fees, test_mode)?; Ok((out, kern, block_fees)) } diff --git a/libwallet/src/lib.rs b/libwallet/src/lib.rs index 72b7c956..23a6f2ac 100644 --- a/libwallet/src/lib.rs +++ b/libwallet/src/lib.rs @@ -22,11 +22,10 @@ #![deny(unused_mut)] #![warn(missing_docs)] -#[macro_use] -extern crate grin_core as core; -extern crate grin_keychain as keychain; -extern crate grin_store as store; -extern crate grin_util as util; +use grin_wallet_util::grin_core; +use grin_wallet_util::grin_keychain; +use grin_wallet_util::grin_store; +use grin_wallet_util::grin_util; use blake2_rfc as blake2; diff --git a/libwallet/src/slate.rs b/libwallet/src/slate.rs index 17284319..223b60c8 100644 --- a/libwallet/src/slate.rs +++ b/libwallet/src/slate.rs @@ -17,17 +17,19 @@ use crate::blake2::blake2b::blake2b; use crate::error::{Error, ErrorKind}; -use crate::keychain::{BlindSum, BlindingFactor, Keychain}; -use crate::util::secp; -use crate::util::secp::key::{PublicKey, SecretKey}; -use crate::util::secp::Signature; -use crate::util::RwLock; +use crate::grin_core::core::amount_to_hr_string; +use crate::grin_core::core::committed::Committed; +use crate::grin_core::core::transaction::{ + kernel_features, kernel_sig_msg, Transaction, Weighting, +}; +use crate::grin_core::core::verifier_cache::LruVerifierCache; +use crate::grin_core::libtx::{aggsig, build, secp_ser, tx_fee}; +use crate::grin_keychain::{BlindSum, BlindingFactor, Keychain}; +use crate::grin_util::secp; +use crate::grin_util::secp::key::{PublicKey, SecretKey}; +use crate::grin_util::secp::Signature; +use crate::grin_util::RwLock; use failure::ResultExt; -use grin_core::core::amount_to_hr_string; -use grin_core::core::committed::Committed; -use grin_core::core::transaction::{kernel_features, kernel_sig_msg, Transaction, Weighting}; -use grin_core::core::verifier_cache::LruVerifierCache; -use grin_core::libtx::{aggsig, build, secp_ser, tx_fee}; use rand::rngs::mock::StepRng; use rand::thread_rng; use serde_json; diff --git a/libwallet/src/slate_versions/v0.rs b/libwallet/src/slate_versions/v0.rs index f66b579f..4366ca3c 100644 --- a/libwallet/src/slate_versions/v0.rs +++ b/libwallet/src/slate_versions/v0.rs @@ -14,12 +14,12 @@ //! Contains V0 of the slate (grin 1.0.0) //! And methods to downgrade v1 to v0 -use crate::core::core::transaction::{KernelFeatures, OutputFeatures}; -use crate::keychain::BlindingFactor; -use crate::util::secp; -use crate::util::secp::key::PublicKey; -use crate::util::secp::pedersen::{Commitment, RangeProof}; -use crate::util::secp::Signature; +use crate::grin_core::core::transaction::{KernelFeatures, OutputFeatures}; +use crate::grin_keychain::BlindingFactor; +use crate::grin_util::secp; +use crate::grin_util::secp::key::PublicKey; +use crate::grin_util::secp::pedersen::{Commitment, RangeProof}; +use crate::grin_util::secp::Signature; use uuid::Uuid; #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/libwallet/src/slate_versions/v1.rs b/libwallet/src/slate_versions/v1.rs index 2e5144a1..ce3af02d 100644 --- a/libwallet/src/slate_versions/v1.rs +++ b/libwallet/src/slate_versions/v1.rs @@ -16,12 +16,13 @@ //! Changes from V0: //! * Addition of a version field to Slate struct -use crate::core::core::transaction::{KernelFeatures, OutputFeatures}; -use crate::keychain::BlindingFactor; -use crate::util::secp; -use crate::util::secp::key::PublicKey; -use crate::util::secp::pedersen::{Commitment, RangeProof}; -use crate::util::secp::Signature; +use crate::grin_core::core::transaction::{KernelFeatures, OutputFeatures}; +use crate::grin_core::map_vec; +use crate::grin_keychain::BlindingFactor; +use crate::grin_util::secp; +use crate::grin_util::secp::key::PublicKey; +use crate::grin_util::secp::pedersen::{Commitment, RangeProof}; +use crate::grin_util::secp::Signature; use uuid::Uuid; use crate::slate_versions::v0::{ diff --git a/libwallet/src/slate_versions/v2.rs b/libwallet/src/slate_versions/v2.rs index f762baed..1de35dac 100644 --- a/libwallet/src/slate_versions/v2.rs +++ b/libwallet/src/slate_versions/v2.rs @@ -35,14 +35,14 @@ //! orig_verion: u16, //! min_compat_version: u16 -use crate::core::core::transaction::{KernelFeatures, OutputFeatures}; - -use crate::core::libtx::secp_ser; -use crate::keychain::BlindingFactor; -use crate::util::secp; -use crate::util::secp::key::PublicKey; -use crate::util::secp::pedersen::{Commitment, RangeProof}; -use crate::util::secp::Signature; +use crate::grin_core::core::transaction::{KernelFeatures, OutputFeatures}; +use crate::grin_core::libtx::secp_ser; +use crate::grin_core::map_vec; +use crate::grin_keychain::BlindingFactor; +use crate::grin_util::secp; +use crate::grin_util::secp::key::PublicKey; +use crate::grin_util::secp::pedersen::{Commitment, RangeProof}; +use crate::grin_util::secp::Signature; use uuid::Uuid; use crate::slate_versions::v1::{ diff --git a/libwallet/src/types.rs b/libwallet/src/types.rs index 608ea53d..834f8b6f 100644 --- a/libwallet/src/types.rs +++ b/libwallet/src/types.rs @@ -15,15 +15,15 @@ //! Types and traits that should be provided by a wallet //! implementation -use crate::core::core::hash::Hash; -use crate::core::core::Transaction; -use crate::core::libtx::{aggsig, secp_ser}; -use crate::core::ser; use crate::error::{Error, ErrorKind}; -use crate::keychain::{Identifier, Keychain}; +use crate::grin_core::core::hash::Hash; +use crate::grin_core::core::{Output, Transaction, TxKernel}; +use crate::grin_core::libtx::{aggsig, secp_ser}; +use crate::grin_core::ser; +use crate::grin_keychain::{Identifier, Keychain}; +use crate::grin_util::secp::key::{PublicKey, SecretKey}; +use crate::grin_util::secp::{self, pedersen, Secp256k1}; use crate::slate::ParticipantMessages; -use crate::util::secp::key::{PublicKey, SecretKey}; -use crate::util::secp::{self, pedersen, Secp256k1}; use chrono::prelude::*; use failure::ResultExt; use serde; @@ -567,11 +567,11 @@ impl BlockFees { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct CbData { /// Output - pub output: String, + pub output: Output, /// Kernel - pub kernel: String, + pub kernel: TxKernel, /// Key Id - pub key_id: String, + pub key_id: Option, } /// a contained wallet info struct, so automated tests can parse wallet info diff --git a/libwallet/tests/libwallet.rs b/libwallet/tests/libwallet.rs index 1dcd5453..4ecf9179 100644 --- a/libwallet/tests/libwallet.rs +++ b/libwallet/tests/libwallet.rs @@ -12,15 +12,14 @@ // limitations under the License. //! core::libtx specific tests -use self::core::core::transaction; -use self::core::libtx::{aggsig, proof}; -use self::keychain::{BlindSum, BlindingFactor, ExtKeychain, ExtKeychainPath, Keychain}; -use self::util::secp; -use self::util::secp::key::{PublicKey, SecretKey}; -use grin_core as core; -use grin_keychain as keychain; -use grin_util as util; use grin_wallet_libwallet::types::Context; +use grin_wallet_util::grin_core::core::transaction; +use grin_wallet_util::grin_core::libtx::{aggsig, proof}; +use grin_wallet_util::grin_keychain::{ + BlindSum, BlindingFactor, ExtKeychain, ExtKeychainPath, Keychain, +}; +use grin_wallet_util::grin_util::secp; +use grin_wallet_util::grin_util::secp::key::{PublicKey, SecretKey}; use rand::thread_rng; fn kernel_sig_msg() -> secp::Message { diff --git a/src/bin/cmd/wallet_args.rs b/src/bin/cmd/wallet_args.rs index 51dbf516..b8500e01 100644 --- a/src/bin/cmd/wallet_args.rs +++ b/src/bin/cmd/wallet_args.rs @@ -18,13 +18,13 @@ use crate::util::{Mutex, ZeroingString}; /// Argument parsing and error handling for wallet commands use clap::ArgMatches; use failure::Fail; -use grin_core as core; -use grin_keychain as keychain; use grin_wallet_config::WalletConfig; use grin_wallet_controller::command; use grin_wallet_controller::{Error, ErrorKind}; use grin_wallet_impls::{instantiate_wallet, WalletSeed}; use grin_wallet_libwallet::types::{NodeClient, WalletInst}; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_keychain as keychain; use linefeed::terminal::Signal; use linefeed::{Interface, ReadResult}; use rpassword; diff --git a/src/bin/cmd/wallet_tests.rs b/src/bin/cmd/wallet_tests.rs index 57975938..db598e0e 100644 --- a/src/bin/cmd/wallet_tests.rs +++ b/src/bin/cmd/wallet_tests.rs @@ -15,23 +15,22 @@ #[cfg(test)] mod wallet_tests { use clap; - use grin_util as util; + use grin_wallet_util::grin_util as util; use grin_wallet_impls::test_framework::{self, LocalWalletClient, WalletProxy}; use clap::{App, ArgMatches}; - use grin_util::Mutex; use std::sync::Arc; use std::thread; use std::time::Duration; use std::{env, fs}; + use util::Mutex; - use grin_core::global; - use grin_core::global::ChainTypes; - use grin_keychain::ExtKeychain; use grin_wallet_config::{GlobalWalletConfig, WalletConfig}; use grin_wallet_impls::{LMDBBackend, WalletSeed}; use grin_wallet_libwallet::types::{WalletBackend, WalletInst}; + use grin_wallet_util::grin_core::global::{self, ChainTypes}; + use grin_wallet_util::grin_keychain::ExtKeychain; use super::super::wallet_args; diff --git a/src/bin/grin-wallet.rs b/src/bin/grin-wallet.rs index f7759e71..5f31dd73 100644 --- a/src/bin/grin-wallet.rs +++ b/src/bin/grin-wallet.rs @@ -22,10 +22,10 @@ extern crate log; use crate::core::global; use crate::util::init_logger; use clap::App; -use grin_api as api; -use grin_core as core; -use grin_util as util; use grin_wallet_config as config; +use grin_wallet_util::grin_api as api; +use grin_wallet_util::grin_core as core; +use grin_wallet_util::grin_util as util; use std::process::exit; mod cmd; diff --git a/util/Cargo.toml b/util/Cargo.toml new file mode 100644 index 00000000..52ff7251 --- /dev/null +++ b/util/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "grin_wallet_util" +version = "1.1.0" +authors = ["Grin Developers "] +description = "Util, for generic utilities and to re-export grin crates" +license = "Apache-2.0" +repository = "https://github.com/mimblewimble/grin" +keywords = [ "crypto", "grin", "mimblewimble" ] +workspace = ".." +edition = "2018" + +[dependencies] +rand = "0.5" +serde = "1" +serde_derive = "1" +toml = "0.4" +dirs = "1.0.3" + +grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } +grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } +grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } +grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } +grin_api = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } +grin_store = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" } + +# For local testing +#grin_core = { path = "../../grin/core", version= "1.1.0"} +#grin_keychain = { path = "../../grin/keychain", version= "1.1.0"} +#grin_chain = { path = "../../grin/chain", version= "1.1.0"} +#grin_util = { path = "../../grin/util", version= "1.1.0"} +#grin_api = { path = "../../grin/api", version= "1.1.0"} +#grin_store = { path = "../../grin/store", version= "1.1.0"} + +[dev-dependencies] +pretty_assertions = "0.5.1" diff --git a/util/src/lib.rs b/util/src/lib.rs new file mode 100644 index 00000000..45663e7b --- /dev/null +++ b/util/src/lib.rs @@ -0,0 +1,28 @@ +// Copyright 2018 The Grin Developers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Utilities and re-exports + +#![deny(non_upper_case_globals)] +#![deny(non_camel_case_types)] +#![deny(non_snake_case)] +#![deny(unused_mut)] +#![warn(missing_docs)] + +pub use grin_api; +pub use grin_chain; +pub use grin_core; +pub use grin_keychain; +pub use grin_store; +pub use grin_util;