From 9038c7424815b614ac056a6cff011ad7ca679043 Mon Sep 17 00:00:00 2001 From: yeastplume Date: Thu, 14 Feb 2019 10:52:16 +0000 Subject: [PATCH] full compilation, move tests into different directory --- Cargo.lock | 139 ++++++++++++++++++++++ Cargo.toml | 2 + libwallet/src/api.rs | 4 +- libwallet/src/error.rs | 2 - libwallet/src/internal/keys.rs | 2 +- libwallet/src/internal/restore.rs | 4 +- libwallet/src/internal/selection.rs | 2 +- libwallet/src/internal/tx.rs | 2 +- libwallet/src/internal/updater.rs | 2 +- libwallet/src/lib.rs | 2 +- libwallet/src/slate.rs | 2 +- libwallet/src/types.rs | 2 +- {tests => libwallet/tests}/libwallet.rs | 0 refwallet/src/lib.rs | 2 +- refwallet/src/types.rs | 2 +- {tests => refwallet/tests}/accounts.rs | 0 {tests => refwallet/tests}/check.rs | 0 {tests => refwallet/tests}/file.rs | 0 {tests => refwallet/tests}/repost.rs | 0 {tests => refwallet/tests}/restore.rs | 0 {tests => refwallet/tests}/self_send.rs | 0 {tests => refwallet/tests}/transaction.rs | 0 rustfmt.toml | 1 + src/bin/cmd/mod.rs | 2 +- src/bin/cmd/wallet.rs | 12 +- src/bin/cmd/wallet_args.rs | 5 +- src/bin/cmd/wallet_tests.rs | 30 ++--- src/bin/grin-wallet.rs | 107 ++++++----------- 28 files changed, 211 insertions(+), 115 deletions(-) rename {tests => libwallet/tests}/libwallet.rs (100%) rename {tests => refwallet/tests}/accounts.rs (100%) rename {tests => refwallet/tests}/check.rs (100%) rename {tests => refwallet/tests}/file.rs (100%) rename {tests => refwallet/tests}/repost.rs (100%) rename {tests => refwallet/tests}/restore.rs (100%) rename {tests => refwallet/tests}/self_send.rs (100%) rename {tests => refwallet/tests}/transaction.rs (100%) create mode 100644 rustfmt.toml diff --git a/Cargo.lock b/Cargo.lock index 4c85ba42..0f150e96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,6 +120,11 @@ dependencies = [ "which 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bitflags" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bitflags" version = "0.9.1" @@ -796,10 +801,12 @@ dependencies = [ "grin_core 1.1.0", "grin_keychain 1.1.0", "grin_libwallet 1.1.0", + "grin_refwallet 1.1.0", "grin_store 1.1.0", "grin_util 1.1.0", "grin_wallet_config 1.1.0", "hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1016,6 +1023,16 @@ dependencies = [ "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "linefeed" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "mortal 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "linked-hash-map" version = "0.4.2" @@ -1191,6 +1208,21 @@ dependencies = [ "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "mortal" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallstr 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "terminfo 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "msdos_time" version = "0.1.6" @@ -1210,6 +1242,19 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nix" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nix" version = "0.11.0" @@ -1235,6 +1280,15 @@ dependencies = [ "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nom" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num" version = "0.1.42" @@ -1445,6 +1499,40 @@ name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "phf" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "phf_codegen" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "phf_generator" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "phf_shared" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pkg-config" version = "0.3.14" @@ -1736,6 +1824,14 @@ name = "rustc-serialize" version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "rustc_version" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustc_version" version = "0.2.3" @@ -1799,6 +1895,11 @@ dependencies = [ "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "semver" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "semver" version = "0.9.0" @@ -1878,6 +1979,14 @@ name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "smallstr" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "smallvec" version = "0.6.8" @@ -1944,6 +2053,17 @@ dependencies = [ "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "terminfo" +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.0 (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)", +] + [[package]] name = "termion" version = "1.5.1" @@ -2313,6 +2433,11 @@ name = "vec_map" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "version_check" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "void" version = "1.0.2" @@ -2462,6 +2587,7 @@ dependencies = [ "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" "checksum bindgen 0.37.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1b25ab82877ea8fe6ce1ce1f8ac54361f0218bad900af9eb11803994bf67c221" +"checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" @@ -2534,6 +2660,7 @@ dependencies = [ "checksum liblmdb-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "feed38a3a580f60bf61aaa067b0ff4123395966839adeaf67258a9e50c4d2e49" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" "checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" +"checksum linefeed 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2abb5810ef55bb5f5f33b010cc280b3ab877764c902681efc7c8c95628004c" "checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" "checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e" "checksum lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "13416eee745b087c22934f35f1f24da22da41ba2a5ce197143d168ce055cc58d" @@ -2553,11 +2680,14 @@ dependencies = [ "checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +"checksum mortal 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26153280e6a955881f761354b130aa7838f9983836f3de438ac0a8f22cfab1ff" "checksum msdos_time 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aad9dfe950c057b1bfe9c1f2aa51583a8468ef2a5baba2ebbe06d775efeb7729" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17" +"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.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b30adc557058ce00c9d0d7cb3c6e0b5bc6f36e2e2eabe74b0ba726d194abd588" "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" @@ -2581,6 +2711,10 @@ dependencies = [ "checksum pbkdf2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0c09cddfbfc98de7f76931acf44460972edb4023eb14d0c6d4018800e552d8e0" "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" +"checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" +"checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" +"checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6" @@ -2614,6 +2748,7 @@ dependencies = [ "checksum rpassword 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37473170aedbe66ffa3ad3726939ba677d83c646ad4fd99e5b4bc38712f45ec" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" +"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustls 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "942b71057b31981152970d57399c25f72e27a6ee0d207a669d8304cabf44705b" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" @@ -2623,6 +2758,7 @@ dependencies = [ "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum sct 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb8f61f9e6eadd062a71c380043d28036304a4706b3c4dd001ff3387ed00745a" +"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "2e20fde37801e83c891a2dc4ebd3b81f0da4d1fb67a9e0a2a3b921e2536a58ee" @@ -2633,6 +2769,7 @@ dependencies = [ "checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +"checksum smallstr 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aa65bb4d5b2bbc90d36af64e29802f788aa614783fa1d0df011800ddcec6e8e" "checksum smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "88aea073965ab29f6edb5493faf96ad662fb18aa9eeb186a3b7057951605ed15" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b639411d0b9c738748b5397d5ceba08e648f4f1992231aa859af1a017f31f60b" @@ -2642,6 +2779,7 @@ dependencies = [ "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" +"checksum terminfo 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8e51065bafd2abe106b6036483b69d1741f4a1ec56ce8a2378de341637de689e" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" @@ -2681,6 +2819,7 @@ dependencies = [ "checksum uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363" "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" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" "checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3" diff --git a/Cargo.toml b/Cargo.toml index cff57ed3..9147a93b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ serde_derive = "1" serde_json = "1" log = "0.4" term = "0.5" +linefeed = "0.5" tokio = "= 0.1.11" tokio-core = "0.1" tokio-retry = "0.1" @@ -44,6 +45,7 @@ url = "1.7.0" chrono = { version = "0.4.4", features = ["serde"] } grin_libwallet = { path = "./libwallet", version = "1.1.0" } +grin_refwallet = { path = "./refwallet", version = "1.1.0" } grin_wallet_config = { path = "./config", version = "1.1.0" } grin_api = { path = "../grin/api", version = "1.1.0" } diff --git a/libwallet/src/api.rs b/libwallet/src/api.rs index 4962725e..4781988c 100644 --- a/libwallet/src/api.rs +++ b/libwallet/src/api.rs @@ -37,16 +37,16 @@ use uuid::Uuid; use crate::core::core::hash::Hashed; use crate::core::core::Transaction; use crate::core::ser; -use crate::keychain::{Identifier, Keychain}; use crate::internal::{keys, tx, updater}; +use crate::keychain::{Identifier, Keychain}; use crate::slate::Slate; use crate::types::{ AcctPathMapping, BlockFees, CbData, NodeClient, OutputData, OutputLockFn, TxLogEntry, TxLogEntryType, TxWrapper, WalletBackend, WalletInfo, }; -use crate::{Error, ErrorKind}; use crate::util; use crate::util::secp::{pedersen, ContextFlag, Secp256k1}; +use crate::{Error, ErrorKind}; const USER_MESSAGE_MAX_LEN: usize = 256; diff --git a/libwallet/src/error.rs b/libwallet/src/error.rs index 869f85b4..e0f51c6a 100644 --- a/libwallet/src/error.rs +++ b/libwallet/src/error.rs @@ -304,5 +304,3 @@ impl From for Error { Error::from(ErrorKind::Backend(format!("{}", error))) } } - - diff --git a/libwallet/src/internal/keys.rs b/libwallet/src/internal/keys.rs index cbbfebf2..87c4f7a1 100644 --- a/libwallet/src/internal/keys.rs +++ b/libwallet/src/internal/keys.rs @@ -13,8 +13,8 @@ // limitations under the License. //! Wallet key management functions -use crate::keychain::{ChildNumber, ExtKeychain, Identifier, Keychain}; use crate::error::{Error, ErrorKind}; +use crate::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 117c9041..8c7a84c8 100644 --- a/libwallet/src/internal/restore.rs +++ b/libwallet/src/internal/restore.rs @@ -15,11 +15,11 @@ use crate::core::global; use crate::core::libtx::proof; -use crate::keychain::{ExtKeychain, Identifier, Keychain}; use crate::internal::{keys, updater}; +use crate::keychain::{ExtKeychain, Identifier, Keychain}; use crate::types::*; -use crate::Error; use crate::util::secp::{key::SecretKey, pedersen}; +use crate::Error; use std::collections::HashMap; /// Utility struct for return values from below diff --git a/libwallet/src/internal/selection.rs b/libwallet/src/internal/selection.rs index fbe25d18..c41578f0 100644 --- a/libwallet/src/internal/selection.rs +++ b/libwallet/src/internal/selection.rs @@ -16,9 +16,9 @@ use crate::core::core::{amount_to_hr_string, Transaction}; use crate::core::libtx::{build, tx_fee}; -use crate::keychain::{Identifier, Keychain}; use crate::error::{Error, ErrorKind}; 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 510e3608..5ce9eac2 100644 --- a/libwallet/src/internal/tx.rs +++ b/libwallet/src/internal/tx.rs @@ -16,8 +16,8 @@ use uuid::Uuid; -use crate::keychain::{Identifier, Keychain}; use crate::internal::{selection, updater}; +use crate::keychain::{Identifier, Keychain}; use crate::slate::Slate; use crate::types::{Context, NodeClient, OutputLockFn, TxLogEntryType, WalletBackend}; use crate::{Error, ErrorKind}; diff --git a/libwallet/src/internal/updater.rs b/libwallet/src/internal/updater.rs index 61271fee..2c993b58 100644 --- a/libwallet/src/internal/updater.rs +++ b/libwallet/src/internal/updater.rs @@ -23,9 +23,9 @@ use crate::core::consensus::reward; use crate::core::core::{Output, TxKernel}; use crate::core::libtx::reward; use crate::core::{global, ser}; -use crate::keychain::{Identifier, Keychain}; use crate::error::{Error, ErrorKind}; use crate::internal::keys; +use crate::keychain::{Identifier, Keychain}; use crate::types::{ BlockFees, CbData, NodeClient, OutputData, OutputStatus, TxLogEntry, TxLogEntryType, WalletBackend, WalletInfo, diff --git a/libwallet/src/lib.rs b/libwallet/src/lib.rs index c710a928..5ef75a9f 100644 --- a/libwallet/src/lib.rs +++ b/libwallet/src/lib.rs @@ -26,8 +26,8 @@ extern crate grin_core as core; extern crate grin_keychain as keychain; -extern crate grin_util as util; extern crate grin_store as store; +extern crate grin_util as util; use blake2_rfc as blake2; diff --git a/libwallet/src/slate.rs b/libwallet/src/slate.rs index a6a37674..23124853 100644 --- a/libwallet/src/slate.rs +++ b/libwallet/src/slate.rs @@ -16,8 +16,8 @@ //! around during an interactive wallet exchange use crate::blake2::blake2b::blake2b; -use crate::keychain::{BlindSum, BlindingFactor, Keychain}; use crate::error::{Error, ErrorKind}; +use crate::keychain::{BlindSum, BlindingFactor, Keychain}; use crate::slate_versions::v0::SlateV0; use crate::util::secp; use crate::util::secp::key::{PublicKey, SecretKey}; diff --git a/libwallet/src/types.rs b/libwallet/src/types.rs index 4fe93156..11416d4f 100644 --- a/libwallet/src/types.rs +++ b/libwallet/src/types.rs @@ -19,8 +19,8 @@ use crate::core::core::hash::Hash; use crate::core::core::Transaction; use crate::core::libtx::aggsig; use crate::core::ser; -use crate::keychain::{Identifier, Keychain}; use crate::error::{Error, ErrorKind}; +use crate::keychain::{Identifier, Keychain}; use crate::slate::ParticipantMessages; use crate::util::secp::key::{PublicKey, SecretKey}; use crate::util::secp::{self, pedersen, Secp256k1}; diff --git a/tests/libwallet.rs b/libwallet/tests/libwallet.rs similarity index 100% rename from tests/libwallet.rs rename to libwallet/tests/libwallet.rs diff --git a/refwallet/src/lib.rs b/refwallet/src/lib.rs index 8fd6de7d..97258042 100644 --- a/refwallet/src/lib.rs +++ b/refwallet/src/lib.rs @@ -27,9 +27,9 @@ use failure; use grin_api as api; extern crate grin_core as core; use grin_keychain as keychain; +use grin_libwallet as libwallet; use grin_store as store; use grin_util as util; -use grin_libwallet as libwallet; extern crate grin_wallet_config as config; mod adapters; diff --git a/refwallet/src/types.rs b/refwallet/src/types.rs index 5b4dbb98..03e0d8fc 100644 --- a/refwallet/src/types.rs +++ b/refwallet/src/types.rs @@ -27,8 +27,8 @@ use ring::{digest, pbkdf2}; use crate::error::{Error, ErrorKind}; use crate::keychain::{mnemonic, Keychain}; use crate::util; -use failure::ResultExt; use config::WalletConfig; +use failure::ResultExt; pub const SEED_FILE: &'static str = "wallet.seed"; diff --git a/tests/accounts.rs b/refwallet/tests/accounts.rs similarity index 100% rename from tests/accounts.rs rename to refwallet/tests/accounts.rs diff --git a/tests/check.rs b/refwallet/tests/check.rs similarity index 100% rename from tests/check.rs rename to refwallet/tests/check.rs diff --git a/tests/file.rs b/refwallet/tests/file.rs similarity index 100% rename from tests/file.rs rename to refwallet/tests/file.rs diff --git a/tests/repost.rs b/refwallet/tests/repost.rs similarity index 100% rename from tests/repost.rs rename to refwallet/tests/repost.rs diff --git a/tests/restore.rs b/refwallet/tests/restore.rs similarity index 100% rename from tests/restore.rs rename to refwallet/tests/restore.rs diff --git a/tests/self_send.rs b/refwallet/tests/self_send.rs similarity index 100% rename from tests/self_send.rs rename to refwallet/tests/self_send.rs diff --git a/tests/transaction.rs b/refwallet/tests/transaction.rs similarity index 100% rename from tests/transaction.rs rename to refwallet/tests/transaction.rs diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 00000000..218e2032 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +hard_tabs = true diff --git a/src/bin/cmd/mod.rs b/src/bin/cmd/mod.rs index 0df1f5fc..26e932c8 100644 --- a/src/bin/cmd/mod.rs +++ b/src/bin/cmd/mod.rs @@ -17,5 +17,5 @@ mod wallet; mod wallet_args; mod wallet_tests; -pub use self::config::{config_command_server, config_command_wallet}; +pub use self::config::config_command_wallet; pub use self::wallet::{seed_exists, wallet_command}; diff --git a/src/bin/cmd/wallet.rs b/src/bin/cmd/wallet.rs index 31328ec7..c5f8d17d 100644 --- a/src/bin/cmd/wallet.rs +++ b/src/bin/cmd/wallet.rs @@ -15,7 +15,8 @@ use crate::cmd::wallet_args; use crate::config::GlobalWalletConfig; use clap::ArgMatches; -use grin_wallet::{self, HTTPNodeClient, WalletConfig, WalletSeed}; +use grin_refwallet::{self, HTTPNodeClient, WalletSeed}; +use grin_wallet_config::WalletConfig; use std::path::PathBuf; use std::thread; use std::time::Duration; @@ -30,7 +31,7 @@ pub fn _init_wallet_seed(wallet_config: WalletConfig, password: &str) { pub fn seed_exists(wallet_config: WalletConfig) -> bool { let mut data_file_dir = PathBuf::new(); data_file_dir.push(wallet_config.data_file_dir); - data_file_dir.push(grin_wallet::SEED_FILE); + data_file_dir.push(grin_refwallet::SEED_FILE); if data_file_dir.exists() { true } else { @@ -42,13 +43,6 @@ pub fn wallet_command(wallet_args: &ArgMatches<'_>, config: GlobalWalletConfig) // just get defaults from the global config let wallet_config = config.members.unwrap().wallet; - // web wallet http server must be started from here - // NB: Turned off for the time being - /*let _ = match wallet_args.subcommand() { - ("web", Some(_)) => start_webwallet_server(), - _ => {} - };*/ - let node_client = HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None); let res = wallet_args::wallet_command(wallet_args, wallet_config, node_client); diff --git a/src/bin/cmd/wallet_args.rs b/src/bin/cmd/wallet_args.rs index 4ae2f19d..acda1f5e 100644 --- a/src/bin/cmd/wallet_args.rs +++ b/src/bin/cmd/wallet_args.rs @@ -20,8 +20,9 @@ use clap::ArgMatches; use failure::Fail; use grin_core as core; use grin_keychain as keychain; -use grin_wallet::{command, instantiate_wallet, NodeClient, WalletConfig, WalletInst, WalletSeed}; -use grin_wallet::{Error, ErrorKind}; +use grin_refwallet::{command, instantiate_wallet, NodeClient, WalletInst, WalletSeed}; +use grin_refwallet::{Error, ErrorKind}; +use grin_wallet_config::WalletConfig; 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 189dffb5..a3407eb7 100644 --- a/src/bin/cmd/wallet_tests.rs +++ b/src/bin/cmd/wallet_tests.rs @@ -15,10 +15,10 @@ #[cfg(test)] mod wallet_tests { use clap; + use grin_refwallet; use grin_util as util; - use grin_wallet; - use grin_wallet::test_framework::{self, LocalWalletClient, WalletProxy}; + use grin_refwallet::test_framework::{self, LocalWalletClient, WalletProxy}; use clap::{App, ArgMatches}; use grin_util::Mutex; @@ -27,11 +27,11 @@ mod wallet_tests { use std::time::Duration; use std::{env, fs}; - use grin_config::GlobalWalletConfig; use grin_core::global; use grin_core::global::ChainTypes; use grin_keychain::ExtKeychain; - use grin_wallet::{LMDBBackend, WalletBackend, WalletConfig, WalletInst, WalletSeed}; + use grin_refwallet::{LMDBBackend, WalletBackend, WalletInst, WalletSeed}; + use grin_wallet_config::{GlobalWalletConfig, WalletConfig}; use super::super::wallet_args; @@ -49,7 +49,7 @@ mod wallet_tests { pub fn config_command_wallet( dir_name: &str, wallet_name: &str, - ) -> Result<(), grin_wallet::Error> { + ) -> Result<(), grin_refwallet::Error> { let mut current_dir; let mut default_config = GlobalWalletConfig::default(); current_dir = env::current_dir().unwrap_or_else(|e| { @@ -61,7 +61,7 @@ mod wallet_tests { let mut config_file_name = current_dir.clone(); config_file_name.push("grin-wallet.toml"); if config_file_name.exists() { - return Err(grin_wallet::ErrorKind::ArgumentError( + return Err(grin_refwallet::ErrorKind::ArgumentError( "grin-wallet.toml already exists in the target directory. Please remove it first" .to_owned(), ))?; @@ -124,7 +124,7 @@ mod wallet_tests { node_client: LocalWalletClient, passphrase: &str, account: &str, - ) -> Result>>, grin_wallet::Error> { + ) -> Result>>, grin_refwallet::Error> { wallet_config.chain_type = None; // First test decryption, so we can abort early if we have the wrong password let _ = WalletSeed::from_file(&wallet_config, passphrase)?; @@ -140,7 +140,7 @@ mod wallet_tests { wallet_name: &str, client: &LocalWalletClient, arg_vec: Vec<&str>, - ) -> Result { + ) -> Result { let args = app.clone().get_matches_from(arg_vec); let args = get_wallet_subcommand(test_dir, wallet_name, args.clone()); let mut config = initial_setup_wallet(test_dir, wallet_name); @@ -150,7 +150,7 @@ mod wallet_tests { } /// command line tests - fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet::Error> { + fn command_line_test_impl(test_dir: &str) -> Result<(), grin_refwallet::Error> { setup(test_dir); // Create a new proxy to simulate server and wallet responses let mut wallet_proxy: WalletProxy = @@ -158,7 +158,7 @@ mod wallet_tests { let chain = wallet_proxy.chain.clone(); // load app yaml. If it don't exist, just say so and exit - let yml = load_yaml!("../grin.yml"); + let yml = load_yaml!("../grin-wallet.yml"); let app = App::from_yaml(yml); // wallet init @@ -245,7 +245,7 @@ mod wallet_tests { // Mine a bit into wallet 1 so we have something to send // (TODO: Be able to stop listeners so we can test this better) let wallet1 = instantiate_wallet(config1.clone(), client1.clone(), "password", "default")?; - grin_wallet::controller::owner_single_use(wallet1.clone(), |api| { + grin_refwallet::controller::owner_single_use(wallet1.clone(), |api| { api.set_active_account("mining")?; Ok(()) })?; @@ -321,7 +321,7 @@ mod wallet_tests { let wallet1 = instantiate_wallet(config1.clone(), client1.clone(), "password", "default")?; // Check our transaction log, should have 10 entries - grin_wallet::controller::owner_single_use(wallet1.clone(), |api| { + grin_refwallet::controller::owner_single_use(wallet1.clone(), |api| { api.set_active_account("mining")?; let (refreshed, txs) = api.retrieve_txs(true, None, None)?; assert!(refreshed); @@ -349,7 +349,7 @@ mod wallet_tests { // check results in wallet 2 let wallet2 = instantiate_wallet(config2.clone(), client2.clone(), "password", "default")?; - grin_wallet::controller::owner_single_use(wallet2.clone(), |api| { + grin_refwallet::controller::owner_single_use(wallet2.clone(), |api| { api.set_active_account("account_1")?; let (_, wallet1_info) = api.retrieve_summary_info(true, 1)?; assert_eq!(wallet1_info.last_confirmed_height, bh); @@ -408,7 +408,7 @@ mod wallet_tests { // Check our transaction log, should have bh entries + one for the self receive let wallet1 = instantiate_wallet(config1.clone(), client1.clone(), "password", "default")?; - grin_wallet::controller::owner_single_use(wallet1.clone(), |api| { + grin_refwallet::controller::owner_single_use(wallet1.clone(), |api| { api.set_active_account("mining")?; let (refreshed, txs) = api.retrieve_txs(true, None, None)?; assert!(refreshed); @@ -443,7 +443,7 @@ mod wallet_tests { // Check our transaction log, should have bh entries + 2 for the self receives let wallet1 = instantiate_wallet(config1.clone(), client1.clone(), "password", "default")?; - grin_wallet::controller::owner_single_use(wallet1.clone(), |api| { + grin_refwallet::controller::owner_single_use(wallet1.clone(), |api| { api.set_active_account("mining")?; let (refreshed, txs) = api.retrieve_txs(true, None, None)?; assert!(refreshed); diff --git a/src/bin/grin-wallet.rs b/src/bin/grin-wallet.rs index 26c841c2..a00caa4f 100644 --- a/src/bin/grin-wallet.rs +++ b/src/bin/grin-wallet.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Main for building the binary of a Grin peer-to-peer node. +//! Main for building the binary of a Grin Reference Wallet #[macro_use] extern crate clap; @@ -23,9 +23,9 @@ use crate::core::global; use crate::util::init_logger; use clap::App; use grin_api as api; -use grin_wallet_config as config; use grin_core as core; use grin_util as util; +use grin_wallet_config as config; use std::process::exit; mod cmd; @@ -68,8 +68,6 @@ fn main() { fn real_main() -> i32 { let yml = load_yaml!("grin-wallet.yml"); let args = App::from_yaml(yml).get_matches(); - let mut wallet_config = None; - let mut node_config = None; let chain_type = if args.is_present("floonet") { global::ChainTypes::Floonet @@ -81,85 +79,48 @@ fn real_main() -> i32 { // Deal with configuration file creation match args.subcommand() { - ("wallet", Some(wallet_args)) => { - // wallet init command should spit out its config file then continue - // (if desired) - if let ("init", Some(init_args)) = wallet_args.subcommand() { - if init_args.is_present("here") { - cmd::config_command_wallet(&chain_type, config::WALLET_CONFIG_FILE_NAME); - } + // wallet init command should spit out its config file then continue + // (if desired) + ("init", Some(init_args)) => { + if init_args.is_present("here") { + cmd::config_command_wallet(&chain_type, config::WALLET_CONFIG_FILE_NAME); } } _ => {} } - // Load relevant config - match args.subcommand() { - // If it's a wallet command, try and load a wallet config file - ("wallet", Some(wallet_args)) => { - let mut w = config::initial_setup_wallet(&chain_type).unwrap_or_else(|e| { - panic!("Error loading wallet configuration: {}", e); - }); - if !cmd::seed_exists(w.members.as_ref().unwrap().wallet.clone()) { - if "init" == wallet_args.subcommand().0 || "recover" == wallet_args.subcommand().0 { - } else { - println!("Wallet seed file doesn't exist. Run `grin wallet init` first"); - exit(1); - } - } - let mut l = w.members.as_mut().unwrap().logging.clone().unwrap(); - l.tui_running = Some(false); - init_logger(Some(l)); - info!( - "Using wallet configuration file at {}", - w.config_file_path.as_ref().unwrap().to_str().unwrap() - ); - wallet_config = Some(w); - }, - // Otherwise load up the node config as usual - _ => { - } - } - - if let Some(mut config) = node_config.clone() { - let mut l = config.members.as_mut().unwrap().logging.clone().unwrap(); - let run_tui = config.members.as_mut().unwrap().server.run_tui; - if let Some(true) = run_tui { - l.log_to_stdout = false; - l.tui_running = Some(true); - } - init_logger(Some(l)); - - global::set_mining_mode(config.members.unwrap().server.clone().chain_type); - - if let Some(file_path) = &config.config_file_path { - info!( - "Using configuration file at {}", - file_path.to_str().unwrap() - ); + // Load relevant config, try and load a wallet config file + let mut w = config::initial_setup_wallet(&chain_type).unwrap_or_else(|e| { + panic!("Error loading wallet configuration: {}", e); + }); + if !cmd::seed_exists(w.members.as_ref().unwrap().wallet.clone()) { + if "init" == args.subcommand().0 || "recover" == args.subcommand().0 { } else { - info!("Node configuration file not found, using default"); + println!("Wallet seed file doesn't exist. Run `grin-wallet init` first"); + exit(1); } } + // Load logging config + let l = w.members.as_mut().unwrap().logging.clone().unwrap(); + init_logger(Some(l)); + info!( + "Using wallet configuration file at {}", + w.config_file_path.as_ref().unwrap().to_str().unwrap() + ); + log_build_info(); - // Execute subcommand - /*match args.subcommand() { - // server commands and options - ("server", Some(server_args)) => { - cmd::server_command(Some(server_args), node_config.unwrap()) - } + global::set_mining_mode( + w.members + .as_ref() + .unwrap() + .wallet + .chain_type + .as_ref() + .unwrap() + .clone(), + ); - // client commands and options - ("client", Some(client_args)) => cmd::client_command(client_args, node_config.unwrap()), - - // client commands and options - ("wallet", Some(wallet_args)) => cmd::wallet_command(wallet_args, wallet_config.unwrap()), - - // If nothing is specified, try to just use the config file instead - // this could possibly become the way to configure most things - // with most command line options being phased out - _ => cmd::server_command(None, node_config.unwrap()), - }*/ + cmd::wallet_command(&args, w) }