From c42d5ddcff140fda10f5727bb9ddde796059f32a Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Tue, 10 Mar 2020 18:19:27 +0000 Subject: [PATCH] Make Transaction Field in V4 Slate Optional (#356) * make transaction field in V4 Slate optional * add mutable/non mutable version of tx getter * removal of mut references where not needed * remove more muts * update from master * update from master * test fixes --- Cargo.lock | 223 ++++++++++++++----------- api/src/foreign_rpc.rs | 4 +- api/src/owner.rs | 12 +- api/src/owner_rpc.rs | 10 +- api/src/types.rs | 8 +- controller/src/command.rs | 10 +- controller/src/controller.rs | 2 +- controller/tests/accounts.rs | 2 +- controller/tests/file.rs | 6 +- controller/tests/invoice.rs | 2 +- controller/tests/no_change.rs | 4 +- controller/tests/payment_proofs.rs | 2 +- controller/tests/repost.rs | 2 +- controller/tests/revert.rs | 19 ++- controller/tests/self_send.rs | 2 +- controller/tests/transaction.rs | 11 +- impls/src/adapters/file.rs | 4 +- impls/src/adapters/http.rs | 4 +- impls/src/backends/lmdb.rs | 2 +- impls/src/lifecycle/seed.rs | 10 +- impls/src/test_framework/mod.rs | 2 +- impls/src/test_framework/testclient.rs | 4 +- libwallet/src/api_impl/foreign.rs | 2 +- libwallet/src/error.rs | 8 + libwallet/src/internal/selection.rs | 5 +- libwallet/src/internal/tx.rs | 10 +- libwallet/src/internal/updater.rs | 4 +- libwallet/src/slate.rs | 89 +++++++--- libwallet/src/slate_versions/mod.rs | 10 +- libwallet/src/slate_versions/ser.rs | 8 +- libwallet/src/slate_versions/v4.rs | 28 +++- tests/common/mod.rs | 2 +- tests/owner_v3_init_secure.rs | 2 +- tests/owner_v3_lifecycle.rs | 2 +- util/src/ov3.rs | 2 +- 35 files changed, 312 insertions(+), 205 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f4fd8af1..8a61a49ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,7 +7,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "aho-corasick" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -79,7 +79,7 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -105,10 +105,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.44" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -116,7 +116,7 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", @@ -161,11 +161,11 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "which 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -240,7 +240,7 @@ name = "built" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -280,14 +280,6 @@ name = "bytes" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "c2-chacha" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cc" version = "1.0.50" @@ -311,7 +303,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chrono" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -375,11 +367,25 @@ dependencies = [ "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "core-foundation-sys" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "crc32fast" version = "1.2.0" @@ -548,7 +554,7 @@ dependencies = [ [[package]] name = "doc-comment" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -645,20 +651,20 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.44 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -771,7 +777,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -854,12 +860,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "grin_api" version = "4.0.0-alpha.1" -source = "git+https://github.com/mimblewimble/grin#ee5fe1ac63c1b383350ded855db2f44c5ce0f555" +source = "git+https://github.com/mimblewimble/grin#3bbf60ee92d789fc0a7e5b6f14db8131887ea92f" dependencies = [ "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "easy-jsonrpc-mw 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "grin_chain 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "grin_core 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", @@ -887,15 +893,15 @@ dependencies = [ [[package]] name = "grin_chain" version = "4.0.0-alpha.1" -source = "git+https://github.com/mimblewimble/grin#ee5fe1ac63c1b383350ded855db2f44c5ce0f555" +source = "git+https://github.com/mimblewimble/grin#3bbf60ee92d789fc0a7e5b6f14db8131887ea92f" dependencies = [ "bit-vec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "croaring 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "grin_core 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "grin_keychain 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "grin_store 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", @@ -910,15 +916,15 @@ dependencies = [ [[package]] name = "grin_core" version = "4.0.0-alpha.1" -source = "git+https://github.com/mimblewimble/grin#ee5fe1ac63c1b383350ded855db2f44c5ce0f555" +source = "git+https://github.com/mimblewimble/grin#3bbf60ee92d789fc0a7e5b6f14db8131887ea92f" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "croaring 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "grin_keychain 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "grin_util 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -936,7 +942,7 @@ dependencies = [ [[package]] name = "grin_keychain" version = "4.0.0-alpha.1" -source = "git+https://github.com/mimblewimble/grin#ee5fe1ac63c1b383350ded855db2f44c5ce0f555" +source = "git+https://github.com/mimblewimble/grin#3bbf60ee92d789fc0a7e5b6f14db8131887ea92f" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -958,10 +964,10 @@ dependencies = [ [[package]] name = "grin_p2p" version = "4.0.0-alpha.1" -source = "git+https://github.com/mimblewimble/grin#ee5fe1ac63c1b383350ded855db2f44c5ce0f555" +source = "git+https://github.com/mimblewimble/grin#3bbf60ee92d789fc0a7e5b6f14db8131887ea92f" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "grin_chain 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "grin_core 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", @@ -979,12 +985,12 @@ dependencies = [ [[package]] name = "grin_pool" version = "4.0.0-alpha.1" -source = "git+https://github.com/mimblewimble/grin#ee5fe1ac63c1b383350ded855db2f44c5ce0f555" +source = "git+https://github.com/mimblewimble/grin#3bbf60ee92d789fc0a7e5b6f14db8131887ea92f" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "grin_core 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "grin_keychain 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "grin_util 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", @@ -1012,12 +1018,12 @@ dependencies = [ [[package]] name = "grin_store" version = "4.0.0-alpha.1" -source = "git+https://github.com/mimblewimble/grin#ee5fe1ac63c1b383350ded855db2f44c5ce0f555" +source = "git+https://github.com/mimblewimble/grin#3bbf60ee92d789fc0a7e5b6f14db8131887ea92f" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "croaring 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "grin_core 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "grin_util 4.0.0-alpha.1 (git+https://github.com/mimblewimble/grin)", "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1032,9 +1038,9 @@ dependencies = [ [[package]] name = "grin_util" version = "4.0.0-alpha.1" -source = "git+https://github.com/mimblewimble/grin#ee5fe1ac63c1b383350ded855db2f44c5ce0f555" +source = "git+https://github.com/mimblewimble/grin#3bbf60ee92d789fc0a7e5b6f14db8131887ea92f" dependencies = [ - "backtrace 0.3.44 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "grin_secp256k1zkp 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1057,8 +1063,8 @@ dependencies = [ "built 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "easy-jsonrpc 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "grin_wallet_api 4.0.0-alpha.1", "grin_wallet_config 4.0.0-alpha.1", "grin_wallet_controller 4.0.0-alpha.1", @@ -1083,11 +1089,11 @@ name = "grin_wallet_api" version = "4.0.0-alpha.1" dependencies = [ "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "easy-jsonrpc-mw 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "grin_wallet_config 4.0.0-alpha.1", "grin_wallet_impls 4.0.0-alpha.1", "grin_wallet_libwallet 4.0.0-alpha.1", @@ -1119,10 +1125,10 @@ dependencies = [ name = "grin_wallet_controller" version = "4.0.0-alpha.1" dependencies = [ - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "easy-jsonrpc-mw 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "grin_wallet_api 4.0.0-alpha.1", "grin_wallet_config 4.0.0-alpha.1", @@ -1150,12 +1156,12 @@ version = "4.0.0-alpha.1" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "grin_wallet_config 4.0.0-alpha.1", "grin_wallet_libwallet 4.0.0-alpha.1", @@ -1184,10 +1190,10 @@ version = "4.0.0-alpha.1" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "grin_wallet_config 4.0.0-alpha.1", "grin_wallet_util 4.0.0-alpha.1", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1376,7 +1382,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.13.3 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1575,7 +1581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1724,7 +1730,7 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1734,8 +1740,8 @@ dependencies = [ "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2074,7 +2080,7 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2131,7 +2137,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2171,7 +2177,7 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2226,7 +2232,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2242,10 +2248,10 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2384,7 +2390,7 @@ name = "regex" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2576,6 +2582,17 @@ dependencies = [ "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "security-framework" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "security-framework-sys" version = "0.3.3" @@ -2584,6 +2601,15 @@ dependencies = [ "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "security-framework-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "semver" version = "0.1.20" @@ -2625,7 +2651,7 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2797,7 +2823,7 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2818,7 +2844,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2829,7 +2855,7 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "doc-comment 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2899,7 +2925,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2936,7 +2962,7 @@ name = "timer" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2977,7 +3003,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2997,7 +3023,7 @@ name = "tokio-tls" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3203,7 +3229,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3213,7 +3239,7 @@ name = "wasm-bindgen-macro" version = "0.2.59" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro-support 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3223,7 +3249,7 @@ version = "0.2.59" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3254,7 +3280,7 @@ dependencies = [ [[package]] name = "which" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3354,7 +3380,7 @@ dependencies = [ [metadata] "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" -"checksum aho-corasick 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d5e63fd144e18ba274ae7095c0197a870a7b9468abc801dd62f190d80817d2ec" +"checksum aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5" "checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" @@ -3368,8 +3394,8 @@ dependencies = [ "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum backtrace 0.3.44 (registry+https://github.com/rust-lang/crates.io-index)" = "e4036b9bf40f3cf16aba72a3d65e8a520fc4bafcdc7079aea8f848c58c5b5536" -"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" +"checksum backtrace 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)" = "ad235dabf00f36301792cfe82499880ba54c6486be094d1047b02bacb67c14e8" +"checksum backtrace-sys 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "e17b52e737c40a7d75abca20b29a19a0eb7ba9fc72c5a72dd282a0a3c2c0dc35" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" @@ -3390,18 +3416,19 @@ dependencies = [ "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" -"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" "checksum cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" +"checksum chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" "checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" "checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +"checksum core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" +"checksum core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum croaring 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "52e9057c1caf8e9debd6f938a12ff24028f3c7f85d24f502f46f3c9601905464" "checksum croaring-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b7d3b66d75dc466ec547604de0517eb4e1a51fd79a83eaff4409f81167dacdc8" @@ -3420,7 +3447,7 @@ dependencies = [ "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" "checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" -"checksum doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "923dea538cea0aa3025e8685b20d6ee21ef99c4f77e954a30febbaac5ec73a97" +"checksum doc-comment 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "807e5847c39ad6a11eac66de492ed1406f76a260eb8656e8740cad9eabc69c27" "checksum dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" "checksum easy-jsonrpc 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "07e05c6cb07c5bb6fdedd8de84a96c9e0aafc5a9d4e725b735ca5eddb770ae33" "checksum easy-jsonrpc-mw 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b1a91569d50e3bba3c9febb22ef54d78c6e8a8d8dd91ae859896c8ba05f4e3" @@ -3431,8 +3458,8 @@ dependencies = [ "checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" -"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" +"checksum failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" +"checksum failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" @@ -3518,7 +3545,7 @@ dependencies = [ "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" "checksum mortal 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26153280e6a955881f761354b130aa7838f9983836f3de438ac0a8f22cfab1ff" -"checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" +"checksum native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" "checksum nix 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0d95c5fa8b641c10ad0b8887454ebaafa3c92b5cd5350f8fc693adafd178e7b" @@ -3569,13 +3596,13 @@ dependencies = [ "checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" "checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" @@ -3614,7 +3641,9 @@ dependencies = [ "checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" "checksum sct 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" "checksum security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8ef2429d7cefe5fd28bd1d2ed41c944547d4ff84776f5935b456da44593a16df" +"checksum security-framework 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "97bbedbe81904398b6ebb054b3e912f99d55807125790f3198ac990d98def5b0" "checksum security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e31493fc37615debb8c5090a7aeb4a9730bc61e77ab10b9af59f1a202284f895" +"checksum security-framework-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "06fd2f23e31ef68dd2328cc383bd493142e46107a3a0e24f7d734e3f3b80fe4c" "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" @@ -3696,7 +3725,7 @@ dependencies = [ "checksum wasm-bindgen-shared 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "fc9f36ad51f25b0219a3d4d13b90eb44cd075dff8b6280cca015775d7acaddd8" "checksum web-sys 0.3.36 (registry+https://github.com/rust-lang/crates.io-index)" = "721c6263e2c66fd44501cc5efbfa2b7dfa775d13e4ea38c46299646ed1f9c70a" "checksum webpki 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef" -"checksum which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5475d47078209a02e60614f7ba5e645ef3ed60f771920ac1906d7c1cc65024c8" +"checksum which 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/api/src/foreign_rpc.rs b/api/src/foreign_rpc.rs index 31cbd4e23..b4795ffc1 100644 --- a/api/src/foreign_rpc.rs +++ b/api/src/foreign_rpc.rs @@ -562,14 +562,14 @@ where message, ) .map_err(|e| e.kind())?; - Ok(VersionedSlate::into_version(out_slate, version)) + Ok(VersionedSlate::into_version(out_slate, version).map_err(|e| e.kind())?) } fn finalize_invoice_tx(&self, in_slate: VersionedSlate) -> Result { let version = in_slate.version(); let out_slate = Foreign::finalize_invoice_tx(self, &Slate::from(in_slate)).map_err(|e| e.kind())?; - Ok(VersionedSlate::into_version(out_slate, version)) + Ok(VersionedSlate::into_version(out_slate, version).map_err(|e| e.kind())?) } } diff --git a/api/src/owner.rs b/api/src/owner.rs index e504bb0f3..d8f87989b 100644 --- a/api/src/owner.rs +++ b/api/src/owner.rs @@ -677,7 +677,7 @@ where }; if sa.post_tx { - self.post_tx(keychain_mask, &slate.tx, sa.fluff)?; + self.post_tx(keychain_mask, slate.tx_or_err()?, sa.fluff)?; } Ok(slate) } @@ -926,7 +926,7 @@ where ) -> Result { let mut w_lock = self.wallet_inst.lock(); let w = w_lock.lc_provider()?.wallet_inst()?; - owner::finalize_tx(&mut **w, keychain_mask, &slate) + owner::finalize_tx(&mut **w, keychain_mask, slate) } /// Posts a completed transaction to the listening node for validation and inclusion in a block @@ -976,7 +976,7 @@ where /// // Retrieve slate back from recipient /// // /// let res = api_owner.finalize_tx(None, &slate); - /// let res = api_owner.post_tx(None, &slate.tx, true); + /// let res = api_owner.post_tx(None, slate.tx_or_err().unwrap(), true); /// } /// ``` @@ -1598,10 +1598,8 @@ where let secp = secp_inst.lock(); return Ok(Some(SecretKey::from_slice( &secp, - &from_hex( - "d096b3cb75986b3b13f80b8f5243a9edf0af4c74ac37578c5a12cfb5b59b1868".to_owned(), - ) - .unwrap(), + &from_hex("d096b3cb75986b3b13f80b8f5243a9edf0af4c74ac37578c5a12cfb5b59b1868") + .unwrap(), )?)); } let mut w_lock = self.wallet_inst.lock(); diff --git a/api/src/owner_rpc.rs b/api/src/owner_rpc.rs index c584abead..4bf1bd6f4 100644 --- a/api/src/owner_rpc.rs +++ b/api/src/owner_rpc.rs @@ -2059,7 +2059,7 @@ where let slate = Owner::init_send_tx(self, (&token.keychain_mask).as_ref(), args) .map_err(|e| e.kind())?; let version = SlateVersion::V4; - Ok(VersionedSlate::into_version(slate, version)) + Ok(VersionedSlate::into_version(slate, version).map_err(|e| e.kind())?) } fn issue_invoice_tx( @@ -2070,7 +2070,7 @@ where let slate = Owner::issue_invoice_tx(self, (&token.keychain_mask).as_ref(), args) .map_err(|e| e.kind())?; let version = SlateVersion::V4; - Ok(VersionedSlate::into_version(slate, version)) + Ok(VersionedSlate::into_version(slate, version).map_err(|e| e.kind())?) } fn process_invoice_tx( @@ -2087,7 +2087,7 @@ where ) .map_err(|e| e.kind())?; let version = SlateVersion::V4; - Ok(VersionedSlate::into_version(out_slate, version)) + Ok(VersionedSlate::into_version(out_slate, version).map_err(|e| e.kind())?) } fn finalize_tx( @@ -2102,7 +2102,7 @@ where ) .map_err(|e| e.kind())?; let version = SlateVersion::V4; - Ok(VersionedSlate::into_version(out_slate, version)) + Ok(VersionedSlate::into_version(out_slate, version).map_err(|e| e.kind())?) } fn tx_lock_outputs( @@ -2527,7 +2527,7 @@ pub fn run_doctest_owner( } if payment_proof { - api_impl::owner::post_tx(&client1, &slate_outer.tx, true).unwrap(); + api_impl::owner::post_tx(&client1, slate_outer.tx_or_err().unwrap(), true).unwrap(); } if perform_tx && lock_tx && finalize_tx { diff --git a/api/src/types.rs b/api/src/types.rs index 49e2622e7..2da6a96f5 100644 --- a/api/src/types.rs +++ b/api/src/types.rs @@ -125,9 +125,9 @@ impl EncryptedBody { let mut to_decrypt = base64::decode(&self.body_enc).context(ErrorKind::APIEncryption( "EncryptedBody Dec: Encrypted request contains invalid Base64".to_string(), ))?; - let nonce = from_hex(self.nonce.clone()).context(ErrorKind::APIEncryption( - "EncryptedBody Dec: Invalid Nonce".to_string(), - ))?; + let nonce = from_hex(&self.nonce).map_err(|_| { + ErrorKind::APIEncryption("EncryptedBody Dec: Invalid Nonce".to_string()) + })?; if nonce.len() < 12 { return Err(ErrorKind::APIEncryption( "EncryptedBody Dec: Invalid Nonce length".to_string(), @@ -321,7 +321,7 @@ fn encrypted_request() -> Result<(), Error> { let secp_inst = static_secp_instance(); let secp = secp_inst.lock(); - let sec_key_bytes = from_hex(sec_key_str.to_owned()).unwrap(); + let sec_key_bytes = from_hex(sec_key_str).unwrap(); SecretKey::from_slice(&secp, &sec_key_bytes)? }; let req = serde_json::json!({ diff --git a/controller/src/command.rs b/controller/src/command.rs index 2c7777c75..ab476b616 100644 --- a/controller/src/command.rs +++ b/controller/src/command.rs @@ -374,7 +374,7 @@ where e })?; slate = api.finalize_tx(m, &slate)?; - let result = api.post_tx(m, &slate.tx, args.fluff); + let result = api.post_tx(m, slate.tx_or_err()?, args.fluff); match result { Ok(_) => { info!("Tx sent ok",); @@ -477,7 +477,7 @@ where error!("Error validating participant messages: {}", e); return Err(e); } - slate = api.finalize_invoice_tx(&mut slate)?; + slate = api.finalize_invoice_tx(&slate)?; Ok(()) })?; } else { @@ -486,14 +486,14 @@ where error!("Error validating participant messages: {}", e); return Err(e); } - slate = api.finalize_tx(m, &mut slate)?; + slate = api.finalize_tx(m, &slate)?; Ok(()) })?; } if !args.nopost { controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| { - let result = api.post_tx(m, &slate.tx, args.fluff); + let result = api.post_tx(m, slate.tx_or_err()?, args.fluff); match result { Ok(_) => { info!( @@ -798,7 +798,7 @@ where let slate = PathToSlate((&args.input).into()).get_tx()?; controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| { - api.post_tx(m, &slate.tx, args.fluff)?; + api.post_tx(m, slate.tx_or_err()?, args.fluff)?; info!("Posted transaction"); return Ok(()); })?; diff --git a/controller/src/controller.rs b/controller/src/controller.rs index 4f3eb25e0..8351ac28d 100644 --- a/controller/src/controller.rs +++ b/controller/src/controller.rs @@ -397,7 +397,7 @@ impl OwnerV3Helpers { /// Update the shared mask, in case of foreign API being run pub fn update_mask(mask: Arc>>, val: &serde_json::Value) { if let Some(key) = val["result"]["Ok"].as_str() { - let key_bytes = match from_hex(key.to_owned()) { + let key_bytes = match from_hex(key) { Ok(k) => k, Err(_) => return, }; diff --git a/controller/tests/accounts.rs b/controller/tests/accounts.rs index b3eb2f2f6..8d7c5a7e2 100644 --- a/controller/tests/accounts.rs +++ b/controller/tests/accounts.rs @@ -202,7 +202,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> { slate = client1.send_tx_slate_direct("wallet2", &slate)?; api.tx_lock_outputs(m, &slate, 0)?; slate = api.finalize_tx(m, &slate)?; - api.post_tx(m, &slate.tx, false)?; + api.post_tx(m, slate.tx_or_err()?, false)?; Ok(()) })?; diff --git a/controller/tests/file.rs b/controller/tests/file.rs index e7b2ed61d..1f6aa82e5 100644 --- a/controller/tests/file.rs +++ b/controller/tests/file.rs @@ -122,9 +122,9 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro message: Some(message.to_owned()), ..Default::default() }; - let mut slate = api.init_send_tx(m, args)?; + let slate = api.init_send_tx(m, args)?; // output tx file - PathToSlate((&send_file).into()).put_tx(&mut slate)?; + PathToSlate((&send_file).into()).put_tx(&slate)?; api.tx_lock_outputs(m, &slate, 0)?; Ok(()) })?; @@ -160,7 +160,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro let mut slate = PathToSlate(receive_file.into()).get_tx()?; api.verify_slate_messages(m, &slate)?; slate = api.finalize_tx(m, &slate)?; - api.post_tx(m, &slate.tx, false)?; + api.post_tx(m, slate.tx_or_err()?, false)?; bh += 1; Ok(()) })?; diff --git a/controller/tests/invoice.rs b/controller/tests/invoice.rs index 215e69a97..fb90c9bb4 100644 --- a/controller/tests/invoice.rs +++ b/controller/tests/invoice.rs @@ -132,7 +132,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> { // wallet 1 posts so wallet 2 doesn't get the mined amount wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| { - api.post_tx(m, &slate.tx, false)?; + api.post_tx(m, slate.tx_or_err()?, false)?; Ok(()) })?; bh += 1; diff --git a/controller/tests/no_change.rs b/controller/tests/no_change.rs index 245f7d3f1..540135cd9 100644 --- a/controller/tests/no_change.rs +++ b/controller/tests/no_change.rs @@ -91,7 +91,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> { slate = client1.send_tx_slate_direct("wallet2", &slate)?; api.tx_lock_outputs(m, &slate, 0)?; slate = api.finalize_tx(m, &slate)?; - api.post_tx(m, &slate.tx, false)?; + api.post_tx(m, slate.tx_or_err()?, false)?; Ok(()) })?; @@ -139,7 +139,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> { Ok(()) })?; wallet::controller::owner_single_use(Some(wallet2.clone()), mask1, None, |api, m| { - api.post_tx(m, &slate.tx, false)?; + api.post_tx(m, slate.tx_or_err()?, false)?; Ok(()) })?; diff --git a/controller/tests/payment_proofs.rs b/controller/tests/payment_proofs.rs index 66e139944..9f0229de1 100644 --- a/controller/tests/payment_proofs.rs +++ b/controller/tests/payment_proofs.rs @@ -135,7 +135,7 @@ fn payment_proofs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err assert!(pp.is_err()); slate = sender_api.finalize_tx(m, &slate)?; - sender_api.post_tx(m, &slate.tx, true)?; + sender_api.post_tx(m, slate.tx_or_err()?, true)?; Ok(()) })?; diff --git a/controller/tests/repost.rs b/controller/tests/repost.rs index fca444d12..fe8a7b906 100644 --- a/controller/tests/repost.rs +++ b/controller/tests/repost.rs @@ -213,7 +213,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> let slate_i = sender_api.init_send_tx(m, args)?; slate = client1.send_tx_slate_direct("wallet2", &slate_i)?; sender_api.tx_lock_outputs(m, &slate, 0)?; - slate = sender_api.finalize_tx(m, &mut slate)?; + slate = sender_api.finalize_tx(m, &slate)?; Ok(()) })?; diff --git a/controller/tests/revert.rs b/controller/tests/revert.rs index 05e4a608c..7191e617c 100644 --- a/controller/tests/revert.rs +++ b/controller/tests/revert.rs @@ -207,8 +207,13 @@ fn revert( // Build 2 blocks at same height: 1 with the tx, 1 without let head = chain.head_header().unwrap(); - let block_with = - create_block_for_wallet(&chain, head.clone(), vec![&tx], wallet1.clone(), mask1)?; + let block_with = create_block_for_wallet( + &chain, + head.clone(), + vec![&tx.as_ref().unwrap()], + wallet1.clone(), + mask1, + )?; let block_without = create_block_for_wallet(&chain, head, vec![], wallet1.clone(), mask1)?; // Add block with tx to the chain @@ -277,7 +282,15 @@ fn revert( stopper2.store(false, Ordering::Relaxed); Ok(( - chain, stopper, sent, bh, tx, wallet1, mask1_i, wallet2, mask2_i, + chain, + stopper, + sent, + bh, + tx.unwrap(), + wallet1, + mask1_i, + wallet2, + mask2_i, )) } diff --git a/controller/tests/self_send.rs b/controller/tests/self_send.rs index b878d01b6..ce1024cfa 100644 --- a/controller/tests/self_send.rs +++ b/controller/tests/self_send.rs @@ -101,7 +101,7 @@ fn self_send_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> { Ok(()) })?; slate = api.finalize_tx(m, &slate)?; - api.post_tx(m, &slate.tx, false)?; // mines a block + api.post_tx(m, slate.tx_or_err()?, false)?; // mines a block bh += 1; Ok(()) })?; diff --git a/controller/tests/transaction.rs b/controller/tests/transaction.rs index 86c77f671..082878e75 100644 --- a/controller/tests/transaction.rs +++ b/controller/tests/transaction.rs @@ -120,9 +120,14 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error> slate = sender_api.finalize_tx(m, &slate)?; // Check we have a single kernel and that it is a Plain kernel (no lock_height). - assert_eq!(slate.tx.kernels().len(), 1); + assert_eq!(slate.tx_or_err()?.kernels().len(), 1); assert_eq!( - slate.tx.kernels().first().map(|k| k.features).unwrap(), + slate + .tx_or_err()? + .kernels() + .first() + .map(|k| k.features) + .unwrap(), transaction::KernelFeatures::Plain { fee: 2000000 } ); @@ -170,7 +175,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error> // post transaction wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| { - api.post_tx(m, &slate.tx, false)?; + api.post_tx(m, slate.tx_or_err()?, false)?; Ok(()) })?; diff --git a/impls/src/adapters/file.rs b/impls/src/adapters/file.rs index 650fb9ad1..0f49826d6 100644 --- a/impls/src/adapters/file.rs +++ b/impls/src/adapters/file.rs @@ -32,12 +32,12 @@ impl SlatePutter for PathToSlate { if false { warn!("Transaction contains features that require grin-wallet 4.0.0 or later"); warn!("Please ensure the other party is running grin-wallet v4.0.0 or later before sending"); - VersionedSlate::into_version(slate.clone(), SlateVersion::V4) + VersionedSlate::into_version(slate.clone(), SlateVersion::V4)? } else { let mut s = slate.clone(); s.version_info.version = 3; s.version_info.orig_version = 3; - VersionedSlate::into_version(s, SlateVersion::V3) + VersionedSlate::into_version(s, SlateVersion::V3)? } }; pub_tx.write_all( diff --git a/impls/src/adapters/http.rs b/impls/src/adapters/http.rs index 1abd5ddc2..9bb1a42e2 100644 --- a/impls/src/adapters/http.rs +++ b/impls/src/adapters/http.rs @@ -181,7 +181,7 @@ impl SlateSender for HttpSlateSender { } let slate_send = match self.check_other_version(&url_str)? { - SlateVersion::V4 => VersionedSlate::into_version(slate.clone(), SlateVersion::V4), + SlateVersion::V4 => VersionedSlate::into_version(slate.clone(), SlateVersion::V4)?, SlateVersion::V3 => { let mut slate = slate.clone(); let _r: crate::adapters::Reminder; @@ -191,7 +191,7 @@ impl SlateSender for HttpSlateSender { } slate.version_info.version = 3; slate.version_info.orig_version = 3; - VersionedSlate::into_version(slate, SlateVersion::V3) + VersionedSlate::into_version(slate, SlateVersion::V3)? } }; // Note: not using easy-jsonrpc as don't want the dependencies in this crate diff --git a/impls/src/backends/lmdb.rs b/impls/src/backends/lmdb.rs index 961f802c5..8e370c263 100644 --- a/impls/src/backends/lmdb.rs +++ b/impls/src/backends/lmdb.rs @@ -380,7 +380,7 @@ where let mut tx_f = File::open(tx_file)?; let mut content = String::new(); tx_f.read_to_string(&mut content)?; - let tx_bin = util::from_hex(content).unwrap(); + let tx_bin = util::from_hex(&content).unwrap(); Ok(Some( ser::deserialize::(&mut &tx_bin[..], ser::ProtocolVersion(1)).unwrap(), )) diff --git a/impls/src/lifecycle/seed.rs b/impls/src/lifecycle/seed.rs index 01001cc22..f2a67083c 100644 --- a/impls/src/lifecycle/seed.rs +++ b/impls/src/lifecycle/seed.rs @@ -49,8 +49,8 @@ impl WalletSeed { } pub fn _from_hex(hex: &str) -> Result { - let bytes = util::from_hex(hex.to_string()) - .context(ErrorKind::GenericError("Invalid hex".to_owned()))?; + let bytes = util::from_hex(&hex.to_string()) + .map_err(|_| ErrorKind::GenericError("Invalid hex".to_owned()))?; Ok(WalletSeed::from_bytes(&bytes)) } @@ -274,15 +274,15 @@ impl EncryptedWalletSeed { /// Decrypt seed pub fn decrypt(&self, password: &str) -> Result { - let mut encrypted_seed = match util::from_hex(self.encrypted_seed.clone()) { + let mut encrypted_seed = match util::from_hex(&self.encrypted_seed.clone()) { Ok(s) => s, Err(_) => return Err(ErrorKind::Encryption.into()), }; - let salt = match util::from_hex(self.salt.clone()) { + let salt = match util::from_hex(&self.salt.clone()) { Ok(s) => s, Err(_) => return Err(ErrorKind::Encryption.into()), }; - let nonce = match util::from_hex(self.nonce.clone()) { + let nonce = match util::from_hex(&self.nonce.clone()) { Ok(s) => s, Err(_) => return Err(ErrorKind::Encryption.into()), }; diff --git a/impls/src/test_framework/mod.rs b/impls/src/test_framework/mod.rs index 283189a62..89c80e03d 100644 --- a/impls/src/test_framework/mod.rs +++ b/impls/src/test_framework/mod.rs @@ -262,7 +262,7 @@ where let w = w_lock.lc_provider()?.wallet_inst()?; w.w2n_client().clone() }; - owner::post_tx(&client, &slate.tx, false)?; // mines a block + owner::post_tx(&client, slate.tx_or_err()?, false)?; // mines a block Ok(()) } diff --git a/impls/src/test_framework/testclient.rs b/impls/src/test_framework/testclient.rs index 3245fc345..cf3c6e10e 100644 --- a/impls/src/test_framework/testclient.rs +++ b/impls/src/test_framework/testclient.rs @@ -276,7 +276,7 @@ where if o_str.is_empty() { continue; } - let c = util::from_hex(o_str).unwrap(); + let c = util::from_hex(&o_str).unwrap(); let commit = Commitment::from_vec(c); let out = super::get_output_local(&self.chain.clone(), &commit); if let Some(o) = out { @@ -345,7 +345,7 @@ where let excess = split[0].parse::().unwrap(); let min = split[1].parse::().unwrap(); let max = split[2].parse::().unwrap(); - let commit_bytes = util::from_hex(excess).unwrap(); + let commit_bytes = util::from_hex(&excess).unwrap(); let commit = pedersen::Commitment::from_vec(commit_bytes); let min = match min { 0 => None, diff --git a/libwallet/src/api_impl/foreign.rs b/libwallet/src/api_impl/foreign.rs index c26f795f2..ad8e8d2b1 100644 --- a/libwallet/src/api_impl/foreign.rs +++ b/libwallet/src/api_impl/foreign.rs @@ -148,7 +148,7 @@ where check_ttl(w, &sl)?; let context = w.get_private_context(keychain_mask, sl.id.as_bytes(), 1)?; tx::complete_tx(&mut *w, keychain_mask, &mut sl, 1, &context)?; - tx::update_stored_tx(&mut *w, keychain_mask, &context, &sl, true)?; + tx::update_stored_tx(&mut *w, keychain_mask, &context, &mut sl, true)?; tx::update_message(&mut *w, keychain_mask, &sl)?; { let mut batch = w.batch(keychain_mask)?; diff --git a/libwallet/src/error.rs b/libwallet/src/error.rs index 69c027279..df154256f 100644 --- a/libwallet/src/error.rs +++ b/libwallet/src/error.rs @@ -202,6 +202,14 @@ pub enum ErrorKind { #[fail(display = "Unknown Slate Version: {}", _0)] SlateVersion(u16), + /// Attempt to use slate transaction data that doesn't exists + #[fail(display = "Slate transaction required in this context")] + SlateTransactionRequired, + + /// Attempt to downgrade slate that can't be downgraded + #[fail(display = "Can't downgrade slate: {}", _0)] + SlateInvalidDowngrade(String), + /// Compatibility error between incoming slate versions and what's expected #[fail(display = "Compatibility Error: {}", _0)] Compatibility(String), diff --git a/libwallet/src/internal/selection.rs b/libwallet/src/internal/selection.rs index 8aa477e3f..22feabcd7 100644 --- a/libwallet/src/internal/selection.rs +++ b/libwallet/src/internal/selection.rs @@ -211,7 +211,10 @@ where batch.commit()?; t }; - wallet.store_tx(&format!("{}", tx_entry.tx_slate_id.unwrap()), &slate.tx)?; + wallet.store_tx( + &format!("{}", tx_entry.tx_slate_id.unwrap()), + slate.tx_or_err()?, + )?; Ok(()) } diff --git a/libwallet/src/internal/tx.rs b/libwallet/src/internal/tx.rs index 16ae8de11..2a6407c4a 100644 --- a/libwallet/src/internal/tx.rs +++ b/libwallet/src/internal/tx.rs @@ -351,11 +351,11 @@ where Some(t) => t, None => return Err(ErrorKind::TransactionDoesntExist(slate.id.to_string()).into()), }; - wallet.store_tx(&format!("{}", tx.tx_slate_id.unwrap()), &slate.tx)?; + wallet.store_tx(&format!("{}", tx.tx_slate_id.unwrap()), slate.tx_or_err()?)?; let parent_key = tx.parent_key_id.clone(); - tx.kernel_excess = Some(slate.tx.body.kernels[0].excess); + tx.kernel_excess = Some(slate.tx_or_err()?.body.kernels[0].excess); - if let Some(ref p) = slate.payment_proof { + if let Some(ref p) = slate.clone().payment_proof { let derivation_index = match context.payment_proof_derivation_index { Some(i) => i, None => 0, @@ -493,9 +493,9 @@ where .into()); } - if let Some(ref p) = slate.payment_proof { + if let Some(ref p) = slate.clone().payment_proof { let orig_proof_info = match orig_proof_info { - Some(p) => p, + Some(p) => p.clone(), None => { return Err(ErrorKind::PaymentProof( "Original proof info not stored in tx".to_owned(), diff --git a/libwallet/src/internal/updater.rs b/libwallet/src/internal/updater.rs index c9d0b5332..24338d571 100644 --- a/libwallet/src/internal/updater.rs +++ b/libwallet/src/internal/updater.rs @@ -77,7 +77,7 @@ where .into_iter() .map(|output| { let commit = match output.commit.clone() { - Some(c) => pedersen::Commitment::from_vec(util::from_hex(c).unwrap()), + Some(c) => pedersen::Commitment::from_vec(util::from_hex(&c).unwrap()), None => keychain .commit(output.value, &output.key_id, SwitchCommitmentType::Regular) .unwrap(), // TODO: proper support for different switch commitment schemes @@ -187,7 +187,7 @@ where for out in unspents { let commit = match out.commit.clone() { - Some(c) => pedersen::Commitment::from_vec(util::from_hex(c).unwrap()), + Some(c) => pedersen::Commitment::from_vec(util::from_hex(&c).unwrap()), None => keychain .commit(out.value, &out.key_id, SwitchCommitmentType::Regular) .unwrap(), // TODO: proper support for different switch commitment schemes diff --git a/libwallet/src/slate.rs b/libwallet/src/slate.rs index 603138d11..7fe65b97c 100644 --- a/libwallet/src/slate.rs +++ b/libwallet/src/slate.rs @@ -38,6 +38,7 @@ use rand::rngs::mock::StepRng; use rand::thread_rng; use serde::ser::{Serialize, Serializer}; use serde_json; +use std::convert::TryFrom; use std::fmt; use std::sync::Arc; use uuid::Uuid; @@ -172,7 +173,9 @@ pub struct Slate { pub id: Uuid, /// The core transaction data: /// inputs, outputs, kernels, kernel offset - pub tx: Transaction, + /// Optional as of V4 to allow for a compact + /// transaction initiation + pub tx: Option, /// base amount (excluding fee) #[serde(with = "secp_ser::string_or_u64")] pub amount: u64, @@ -221,6 +224,23 @@ pub struct ParticipantMessages { } impl Slate { + /// Return the transaction, throwing an error if it doesn't exist + /// to be used at points in the code where the existence of a transaction + /// is assumed + pub fn tx_or_err(&self) -> Result<&Transaction, Error> { + match &self.tx { + Some(t) => Ok(t), + None => Err(ErrorKind::SlateTransactionRequired.into()), + } + } + + /// As above, but return mutable reference + pub fn tx_or_err_mut(&mut self) -> Result<&mut Transaction, Error> { + match &mut self.tx { + Some(t) => Ok(t), + None => Err(ErrorKind::SlateTransactionRequired.into()), + } + } /// Attempt to find slate version pub fn parse_slate_version(slate_json: &str) -> Result { let probe: SlateVersionProbe = @@ -248,7 +268,7 @@ impl Slate { Slate { num_participants: num_participants, id: Uuid::new_v4(), - tx: Transaction::empty(), + tx: Some(Transaction::empty()), amount: 0, fee: 0, height: 0, @@ -276,20 +296,23 @@ impl Slate { K: Keychain, B: ProofBuild, { - self.update_kernel(); - let (tx, blind) = build::partial_transaction(self.tx.clone(), elems, keychain, builder)?; - self.tx = tx; + self.update_kernel()?; + let (tx, blind) = + build::partial_transaction(self.tx_or_err()?.clone(), elems, keychain, builder)?; + self.tx = Some(tx); Ok(blind) } /// Update the tx kernel based on kernel features derived from the current slate. /// The fee may change as we build a transaction and we need to /// update the tx kernel to reflect this during the tx building process. - pub fn update_kernel(&mut self) { - self.tx = self - .tx - .clone() - .replace_kernel(TxKernel::with_features(self.kernel_features())); + pub fn update_kernel(&mut self) -> Result<(), Error> { + self.tx = Some( + self.tx_or_err()? + .clone() + .replace_kernel(TxKernel::with_features(self.kernel_features())), + ); + Ok(()) } /// Completes callers part of round 1, adding public key info @@ -307,7 +330,7 @@ impl Slate { K: Keychain, { // Whoever does this first generates the offset - if self.tx.offset == BlindingFactor::zero() { + if self.tx_or_err()?.offset == BlindingFactor::zero() { self.generate_offset(keychain, sec_key, use_test_rng)?; } self.add_participant_info( @@ -507,7 +530,7 @@ impl Slate { // Generate a random kernel offset here // and subtract it from the blind_sum so we create // the aggsig context with the "split" key - self.tx.offset = match use_test_rng { + self.tx_or_err_mut()?.offset = match use_test_rng { false => { BlindingFactor::from_secret_key(SecretKey::new(&keychain.secp(), &mut thread_rng())) } @@ -521,7 +544,7 @@ impl Slate { let blind_offset = keychain.blind_sum( &BlindSum::new() .add_blinding_factor(BlindingFactor::from_secret_key(sec_key.clone())) - .sub_blinding_factor(self.tx.offset.clone()), + .sub_blinding_factor(self.tx_or_err()?.offset.clone()), )?; *sec_key = blind_offset.secret_key(&keychain.secp())?; Ok(()) @@ -529,19 +552,20 @@ impl Slate { /// Checks the fees in the transaction in the given slate are valid fn check_fees(&self) -> Result<(), Error> { + let tx = self.tx_or_err()?; // double check the fee amount included in the partial tx // we don't necessarily want to just trust the sender // we could just overwrite the fee here (but we won't) due to the sig let fee = tx_fee( - self.tx.inputs().len(), - self.tx.outputs().len(), - self.tx.kernels().len(), + tx.inputs().len(), + tx.outputs().len(), + tx.kernels().len(), None, ); - if fee > self.tx.fee() { + if fee > tx.fee() { return Err( - ErrorKind::Fee(format!("Fee Dispute Error: {}, {}", self.tx.fee(), fee,)).into(), + ErrorKind::Fee(format!("Fee Dispute Error: {}, {}", tx.fee(), fee,)).into(), ); } @@ -668,8 +692,8 @@ impl Slate { where K: Keychain, { - let kernel_offset = &self.tx.offset; - let tx = self.tx.clone(); + let tx = self.tx_or_err()?.clone(); + let kernel_offset = tx.offset.clone(); let overage = tx.fee() as i64; let tx_excess = tx.sum_commitments(overage)?; @@ -697,7 +721,7 @@ impl Slate { debug!("Final Tx excess: {:?}", final_excess); - let mut final_tx = self.tx.clone(); + let final_tx = self.tx_or_err_mut()?; // update the tx kernel to reflect the offset excess and sig assert_eq!(final_tx.kernels().len(), 1); @@ -713,7 +737,6 @@ impl Slate { let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new())); final_tx.validate(Weighting::AsTransaction, verifier_cache)?; - self.tx = final_tx; Ok(()) } } @@ -730,7 +753,10 @@ impl Serialize for Slate { 4 => v4.serialize(serializer), // left as a reminder 3 => { - let v3 = SlateV3::from(&v4); + let v3 = match SlateV3::try_from(&v4) { + Ok(s) => s, + Err(e) => return Err(S::Error::custom(format!("{}", e))), + }; v3.serialize(serializer) } v => Err(S::Error::custom(format!("Unknown slate version {}", v))), @@ -793,11 +819,14 @@ impl From for SlateV4 { Some(p) => Some(PaymentInfoV4::from(&p)), None => None, }; - let tx = TransactionV4::from(tx); + let tx = match tx { + Some(t) => Some(TransactionV4::from(t)), + None => None, + }; SlateV4 { num_participants, id, - tx, + tx: tx, amount, fee, height, @@ -827,7 +856,6 @@ impl From<&Slate> for SlateV4 { } = slate; let num_participants = *num_participants; let id = *id; - let tx = TransactionV4::from(tx); let amount = *amount; let fee = *fee; let height = *height; @@ -839,6 +867,10 @@ impl From<&Slate> for SlateV4 { Some(p) => Some(PaymentInfoV4::from(p)), None => None, }; + let tx = match tx { + Some(t) => Some(TransactionV4::from(t)), + None => None, + }; SlateV4 { num_participants, id, @@ -1017,7 +1049,10 @@ impl From for Slate { Some(p) => Some(PaymentInfo::from(&p)), None => None, }; - let tx = Transaction::from(tx); + let tx = match tx { + Some(t) => Some(Transaction::from(t)), + None => None, + }; Slate { num_participants, id, diff --git a/libwallet/src/slate_versions/mod.rs b/libwallet/src/slate_versions/mod.rs index 438944a22..3d58e5690 100644 --- a/libwallet/src/slate_versions/mod.rs +++ b/libwallet/src/slate_versions/mod.rs @@ -21,6 +21,8 @@ use crate::slate::Slate; use crate::slate_versions::v3::{CoinbaseV3, SlateV3}; use crate::slate_versions::v4::{CoinbaseV4, SlateV4}; use crate::types::CbData; +use crate::Error; +use std::convert::TryFrom; pub mod ser; @@ -65,13 +67,13 @@ impl VersionedSlate { } /// convert this slate type to a specified older version - pub fn into_version(slate: Slate, version: SlateVersion) -> VersionedSlate { + pub fn into_version(slate: Slate, version: SlateVersion) -> Result { match version { - SlateVersion::V4 => VersionedSlate::V4(slate.into()), + SlateVersion::V4 => Ok(VersionedSlate::V4(slate.into())), SlateVersion::V3 => { let s = SlateV4::from(slate); - let s = SlateV3::from(&s); - VersionedSlate::V3(s) + let s = SlateV3::try_from(&s)?; + Ok(VersionedSlate::V3(s)) } } } diff --git a/libwallet/src/slate_versions/ser.rs b/libwallet/src/slate_versions/ser.rs index 30bbc8fee..edd88a839 100644 --- a/libwallet/src/slate_versions/ser.rs +++ b/libwallet/src/slate_versions/ser.rs @@ -96,7 +96,7 @@ pub mod dalek_pubkey_serde { { use serde::de::Error; String::deserialize(deserializer) - .and_then(|string| from_hex(string).map_err(|err| Error::custom(err.to_string()))) + .and_then(|string| from_hex(&string).map_err(|err| Error::custom(err.to_string()))) .and_then(|bytes: Vec| { DalekPublicKey::from_bytes(&bytes).map_err(|err| Error::custom(err.to_string())) }) @@ -128,7 +128,7 @@ pub mod option_dalek_pubkey_serde { D: Deserializer<'de>, { Option::::deserialize(deserializer).and_then(|res| match res { - Some(string) => from_hex(string) + Some(string) => from_hex(&string) .map_err(|err| Error::custom(err.to_string())) .and_then(|bytes: Vec| { let mut b = [0u8; 32]; @@ -164,7 +164,7 @@ pub mod dalek_sig_serde { D: Deserializer<'de>, { String::deserialize(deserializer) - .and_then(|string| from_hex(string).map_err(|err| Error::custom(err.to_string()))) + .and_then(|string| from_hex(&string).map_err(|err| Error::custom(err.to_string()))) .and_then(|bytes: Vec| { let mut b = [0u8; 64]; b.copy_from_slice(&bytes[0..64]); @@ -198,7 +198,7 @@ pub mod option_dalek_sig_serde { D: Deserializer<'de>, { Option::::deserialize(deserializer).and_then(|res| match res { - Some(string) => from_hex(string) + Some(string) => from_hex(&string) .map_err(|err| Error::custom(err.to_string())) .and_then(|bytes: Vec| { let mut b = [0u8; 64]; diff --git a/libwallet/src/slate_versions/v4.rs b/libwallet/src/slate_versions/v4.rs index 13bf31677..9d2ac0bf5 100644 --- a/libwallet/src/slate_versions/v4.rs +++ b/libwallet/src/slate_versions/v4.rs @@ -26,8 +26,10 @@ use crate::grin_util::secp::pedersen::{Commitment, RangeProof}; use crate::grin_util::secp::Signature; use crate::slate::CompatKernelFeatures; use crate::slate_versions::ser as dalek_ser; +use crate::{Error, ErrorKind}; use ed25519_dalek::PublicKey as DalekPublicKey; use ed25519_dalek::Signature as DalekSignature; +use std::convert::TryFrom; use uuid::Uuid; use crate::slate_versions::v3::{ @@ -45,7 +47,9 @@ pub struct SlateV4 { pub id: Uuid, /// The core transaction data: /// inputs, outputs, kernels, kernel offset - pub tx: TransactionV4, + /// Optional as of V4 to allow for a compact + /// transaction initiation + pub tx: Option, /// base amount (excluding fee) #[serde(with = "secp_ser::string_or_u64")] pub amount: u64, @@ -236,7 +240,7 @@ impl From for SlateV4 { version_info, num_participants, id, - tx, + tx: Some(tx), amount, fee, height, @@ -372,8 +376,9 @@ impl From<&PaymentInfoV3> for PaymentInfoV4 { // V4 to V3 #[allow(unused_variables)] -impl From<&SlateV4> for SlateV3 { - fn from(slate: &SlateV4) -> SlateV3 { +impl TryFrom<&SlateV4> for SlateV3 { + type Error = Error; + fn try_from(slate: &SlateV4) -> Result { let SlateV4 { num_participants, id, @@ -389,7 +394,6 @@ impl From<&SlateV4> for SlateV3 { } = slate; let num_participants = *num_participants; let id = *id; - let tx = TransactionV3::from(tx); let amount = *amount; let fee = *fee; let height = *height; @@ -400,8 +404,18 @@ impl From<&SlateV4> for SlateV3 { Some(p) => Some(PaymentInfoV3::from(p)), None => None, }; + let tx = match tx { + Some(t) => TransactionV3::from(t), + None => { + return Err(ErrorKind::SlateInvalidDowngrade( + "Full transaction info required".to_owned(), + ) + .into()) + } + }; + let ttl_cutoff_height = *ttl_cutoff_height; - SlateV3 { + Ok(SlateV3 { num_participants, id, tx, @@ -413,7 +427,7 @@ impl From<&SlateV4> for SlateV3 { participant_data, version_info, payment_proof, - } + }) } } diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 4a276fabe..579429f9e 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -444,7 +444,7 @@ where #[allow(dead_code)] pub fn derive_ecdh_key(sec_key_str: &str, other_pubkey: &PublicKey) -> SecretKey { - let sec_key_bytes = from_hex(sec_key_str.to_owned()).unwrap(); + let sec_key_bytes = from_hex(sec_key_str).unwrap(); let sec_key = { let secp_inst = static_secp_instance(); let secp = secp_inst.lock(); diff --git a/tests/owner_v3_init_secure.rs b/tests/owner_v3_init_secure.rs index 8cea03355..aa83bf8f7 100644 --- a/tests/owner_v3_init_secure.rs +++ b/tests/owner_v3_init_secure.rs @@ -65,7 +65,7 @@ fn owner_v3_init_secure() -> Result<(), grin_wallet_controller::Error> { let sec_key_str = "e00dcc4a009e3427c6b1e1a550c538179d46f3827a13ed74c759c860761caf1e"; let _pub_key_str = "03b3c18c9a38783d105e238953b1638b021ba7456d87a5c085b3bdb75777b4c490"; - let sec_key_bytes = from_hex(sec_key_str.to_owned()).unwrap(); + let sec_key_bytes = from_hex(sec_key_str).unwrap(); let sec_key = { let secp_inst = static_secp_instance(); let secp = secp_inst.lock(); diff --git a/tests/owner_v3_lifecycle.rs b/tests/owner_v3_lifecycle.rs index 80930977f..15b1773f2 100644 --- a/tests/owner_v3_lifecycle.rs +++ b/tests/owner_v3_lifecycle.rs @@ -409,7 +409,7 @@ fn owner_v3_lifecycle() -> Result<(), grin_wallet_controller::Error> { "id": 1, "method": "finalize_invoice_tx", "params": { - "slate": VersionedSlate::into_version(slate, SlateVersion::V3), + "slate": VersionedSlate::into_version(slate, SlateVersion::V3)?, } }); let res = diff --git a/util/src/ov3.rs b/util/src/ov3.rs index 250a49b52..0edb12777 100644 --- a/util/src/ov3.rs +++ b/util/src/ov3.rs @@ -104,7 +104,7 @@ impl TryFrom<&str> for OnionV3Address { fn try_from(input: &str) -> Result { // First attempt to decode a pubkey from hex - if let Ok(b) = from_hex(input.to_owned()) { + if let Ok(b) = from_hex(input) { if b.len() == 32 { let mut retval = OnionV3Address([0; 32]); retval.0.copy_from_slice(&b[0..32]);