From 802dc61e7e0791ca44f70f47c62abf5e5b45022e Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Wed, 27 Jan 2021 13:33:32 +1100 Subject: [PATCH] Configuration for RPC urls and Bitcoin wallet name --- Cargo.lock | 541 ++++++++++++++------- swap/Cargo.toml | 6 +- swap/src/bitcoin.rs | 8 +- swap/src/bitcoin/wallet.rs | 12 +- swap/src/cli.rs | 79 ++- swap/src/config.rs | 40 +- swap/src/configuration.rs | 145 ++++++ swap/src/{config => configuration}/seed.rs | 0 swap/src/fs.rs | 24 +- swap/src/lib.rs | 1 - swap/src/main.rs | 125 ++--- swap/src/protocol/alice.rs | 18 +- swap/src/protocol/alice/steps.rs | 45 +- swap/src/protocol/alice/swap.rs | 48 +- swap/src/protocol/bob.rs | 28 +- swap/src/protocol/bob/state.rs | 10 +- swap/src/protocol/bob/swap.rs | 28 +- swap/tests/testutils/mod.rs | 55 +-- 18 files changed, 775 insertions(+), 438 deletions(-) create mode 100644 swap/src/configuration.rs rename swap/src/{config => configuration}/seed.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 8e9949b8..3853cca9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.38" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +checksum = "2c0df63cb2955042487fad3aefd2c6e3ae7389ac5dc1beb28921de0b69f779d4" [[package]] name = "arrayref" @@ -146,6 +146,27 @@ dependencies = [ "syn", ] +[[package]] +name = "async-stream" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3670df70cbc01729f901f94c887814b3c68db038aad1329a418bae178bc5295c" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3548b8efc9f8e8a5a0a2808c5bd8451a9031b9e5b879a79590304ae928b0a70" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-trait" version = "0.1.42" @@ -163,7 +184,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb4401f0a3622dad2e0763fa79e0eb328bc70fb7dccfdd645341f00d671247d6" dependencies = [ - "bytes", + "bytes 1.0.1", "futures-sink", "futures-util", "memchr", @@ -208,10 +229,10 @@ version = "0.2.2-alpha.0" source = "git+https://github.com/ihrwein/backoff?rev=9d03992a83dfdc596be26276d4e5c5254a4b11a2#9d03992a83dfdc596be26276d4e5c5254a4b11a2" dependencies = [ "futures-core", - "getrandom 0.2.1", + "getrandom 0.2.2", "instant", - "pin-project 1.0.4", - "rand 0.8.2", + "pin-project 1.0.2", + "rand 0.8.3", "tokio", ] @@ -424,9 +445,15 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "bytes" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" [[package]] name = "bytes" @@ -465,7 +492,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "244fbce0d47e97e8ef2f63b81d5e05882cb518c68531eb33194990d7b7e85845" dependencies = [ "stream-cipher", - "zeroize", + "zeroize 1.2.0", ] [[package]] @@ -478,7 +505,7 @@ dependencies = [ "chacha20", "poly1305", "stream-cipher", - "zeroize", + "zeroize 1.2.0", ] [[package]] @@ -514,11 +541,23 @@ dependencies = [ "cache-padded", ] +[[package]] +name = "config" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b076e143e1d9538dde65da30f8481c2a6c44040edb8e02b9bf1351edb92ce3" +dependencies = [ + "lazy_static", + "nom", + "serde", + "toml", +] + [[package]] name = "conquer-once" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c6d3a9775a69f6d1fe2cc888999b67ed30257d3da4d2af91984e722f2ec918a" +checksum = "5cb45322099323eefa1b48850ce6c148f5b510894c531e038539f6370c887214" dependencies = [ "conquer-util", ] @@ -529,11 +568,27 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582" +[[package]] +name = "console" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a50aab2529019abfabfa93f1e6c41ef392f91fbf179b347a7e96abb524884a08" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "regex", + "terminal_size", + "unicode-width", + "winapi", + "winapi-util", +] + [[package]] name = "const_fn" -version = "0.4.5" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" +checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826" [[package]] name = "constant_time_eq" @@ -584,7 +639,7 @@ version = "0.1.0" source = "git+https://github.com/comit-network/cross-curve-dleq?rev=eddcdea1d1f16fa33ef581d1744014ece535c920#eddcdea1d1f16fa33ef581d1744014ece535c920" dependencies = [ "bit-vec", - "curve25519-dalek 2.1.2", + "curve25519-dalek 2.1.0", "ecdsa_fun", "generic-array 0.14.4", "hex-literal", @@ -676,29 +731,29 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "2.1.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "434e1720189a637d44fe464f4df1e6eb900b4835255b14354497c78af37d9bb8" +checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5" dependencies = [ "byteorder", "digest 0.8.1", "rand_core 0.5.1", "serde", "subtle 2.4.0", - "zeroize", + "zeroize 1.2.0", ] [[package]] name = "curve25519-dalek" -version = "3.0.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f627126b946c25a4638eec0ea634fc52506dea98db118aae985118ce7c3d723f" +checksum = "c8492de420e9e60bc9a1d66e2dbb91825390b738a388606600663fc529b4b307" dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", "subtle 2.4.0", - "zeroize", + "zeroize 1.2.0", ] [[package]] @@ -709,15 +764,27 @@ checksum = "993a608597367c6377b258c25d7120740f00ed23a2252b729b1932dd7866f908" [[package]] name = "derivative" -version = "2.1.3" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaed5874effa6cde088c644ddcdcb4ffd1511391c5be4fdd7a5ccd02c7e4a183" +checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "dialoguer" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f807b2943dc90f9747497d9d65d7e92472149be0b88bf4ce1201b4ac979c26" +dependencies = [ + "console", + "lazy_static", + "tempfile", + "zeroize 0.9.3", +] + [[package]] name = "digest" version = "0.8.1" @@ -749,6 +816,16 @@ dependencies = [ "sha2 0.8.2", ] +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + [[package]] name = "dirs" version = "1.0.5" @@ -760,6 +837,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "dirs-sys-next" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99de365f605554ae33f115102a02057d4fc18b01f3284d6870be0938743cfe7d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "discard" version = "1.0.4" @@ -791,13 +879,13 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek 3.0.2", + "curve25519-dalek 3.0.0", "ed25519", "rand 0.7.3", "serde", "serde_bytes", "sha2 0.9.2", - "zeroize", + "zeroize 1.2.0", ] [[package]] @@ -963,9 +1051,9 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "futures" -version = "0.3.11" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fa4cc29d25b0687b8570b0da86eac698dcb525110ad8b938fe6712baa711ec" +checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0" dependencies = [ "futures-channel", "futures-core", @@ -978,9 +1066,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.11" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ebc390c6913de330e418add60e1a7e5af4cb5ec600d19111b339cafcdcc027" +checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" dependencies = [ "futures-core", "futures-sink", @@ -988,15 +1076,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.11" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "089bd0baf024d3216916546338fffe4fc8dfffdd901e33c278abb091e0d52111" +checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" [[package]] name = "futures-executor" -version = "0.3.11" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0cb59f15119671c94cd9cc543dc9a50b8d5edc468b4ff5f0bb8567f66c6b48a" +checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65" dependencies = [ "futures-core", "futures-task", @@ -1006,9 +1094,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.11" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3868967e4e5ab86614e2176c99949eeef6cbcacaee737765f6ae693988273997" +checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb" [[package]] name = "futures-lite" @@ -1027,9 +1115,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.11" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95778720c3ee3c179cd0d8fd5a0f9b40aa7d745c080f86a8f8bed33c4fd89758" +checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -1039,15 +1127,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.11" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4e0f6be0ec0357772fd58fb751958dd600bd0b3edfd429e77793e4282831360" +checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" [[package]] name = "futures-task" -version = "0.3.11" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "868090f28a925db6cb7462938c51d807546e298fb314088239f0e52fb4338b96" +checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" dependencies = [ "once_cell", ] @@ -1060,9 +1148,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.11" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad5e82786df758d407932aded1235e24d8e2eb438b6adafd37930c2462fb5d1" +checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" dependencies = [ "futures-channel", "futures-core", @@ -1071,7 +1159,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite", + "pin-project 1.0.2", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -1087,6 +1175,19 @@ dependencies = [ "byteorder", ] +[[package]] +name = "generator" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cdc09201b2e8ca1b19290cf7e65de2246b8e91fb6874279722189c4de7b94dc" +dependencies = [ + "cc", + "libc", + "log", + "rustc_version", + "winapi", +] + [[package]] name = "generic-array" version = "0.12.3" @@ -1114,33 +1215,32 @@ checksum = "ac6c41a39c60ae1fc5bf0e220347ce90fa1e4bb0fcdac65b09bb5f4576bebc84" [[package]] name = "getrandom" -version = "0.1.16" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] name = "getrandom" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.10.1+wasi-snapshot-preview1", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "ghash" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" +checksum = "d6e27f0689a6e15944bdce7e45425efb87eaa8ab0c6e87f11d0987a9133e2531" dependencies = [ - "opaque-debug 0.3.0", "polyval", ] @@ -1150,7 +1250,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" dependencies = [ - "bytes", + "bytes 1.0.1", "fnv", "futures-core", "futures-sink", @@ -1190,9 +1290,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" dependencies = [ "unicode-segmentation", ] @@ -1270,11 +1370,11 @@ dependencies = [ [[package]] name = "http" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" +checksum = "84129d298a6d57d246960ff8eb831ca4af3f96d29e2e28848dae275408658e26" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "itoa", ] @@ -1285,7 +1385,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" dependencies = [ - "bytes", + "bytes 1.0.1", "http", ] @@ -1307,7 +1407,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe" dependencies = [ - "bytes", + "bytes 1.0.1", "futures-channel", "futures-core", "futures-util", @@ -1317,7 +1417,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project 1.0.4", + "pin-project 1.0.2", "socket2", "tokio", "tower-service", @@ -1331,7 +1431,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes", + "bytes 1.0.1", "hyper", "native-tls", "tokio", @@ -1372,9 +1472,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d7c5e361e6b05c882b4847dd98992534cebc6fcde7f4bc98225bcf10fd6d0d" +checksum = "97b8538953a3f0d0d3868f0a706eb4273535e10d72acb5c82c1c23ae48835c85" dependencies = [ "async-io", "futures", @@ -1431,9 +1531,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" [[package]] name = "js-sys" @@ -1492,11 +1592,24 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lexical-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db65c6da02e61f55dae90a0ae427b2a5f6b3e8db09f58d10efab23af92592616" +dependencies = [ + "arrayvec", + "bitflags", + "cfg-if 0.1.10", + "ryu", + "static_assertions 1.1.0", +] + [[package]] name = "libc" -version = "0.2.82" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" +checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" [[package]] name = "libp2p" @@ -1505,7 +1618,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5133112ce42be9482f6a87be92a605dd6bbc9e93c297aee77d172ff06908f3a" dependencies = [ "atomic", - "bytes", + "bytes 1.0.1", "futures", "lazy_static", "libp2p-core", @@ -1519,7 +1632,7 @@ dependencies = [ "libp2p-yamux", "parity-multiaddr", "parking_lot", - "pin-project 1.0.4", + "pin-project 1.0.2", "smallvec", "wasm-timer", ] @@ -1544,7 +1657,7 @@ dependencies = [ "multistream-select", "parity-multiaddr", "parking_lot", - "pin-project 1.0.4", + "pin-project 1.0.2", "prost", "prost-build", "rand 0.7.3", @@ -1555,7 +1668,7 @@ dependencies = [ "thiserror", "unsigned-varint 0.6.0", "void", - "zeroize", + "zeroize 1.2.0", ] [[package]] @@ -1586,7 +1699,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2705dc94b01ab9e3779b42a09bbf3712e637ed213e875c30face247291a85af0" dependencies = [ "asynchronous-codec", - "bytes", + "bytes 1.0.1", "futures", "libp2p-core", "log", @@ -1603,8 +1716,8 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4aca322b52a0c5136142a7c3971446fb1e9964923a526c9cc6ef3b7c94e57778" dependencies = [ - "bytes", - "curve25519-dalek 3.0.2", + "bytes 1.0.1", + "curve25519-dalek 3.0.0", "futures", "lazy_static", "libp2p-core", @@ -1616,7 +1729,7 @@ dependencies = [ "snow", "static_assertions 1.1.0", "x25519-dalek", - "zeroize", + "zeroize 1.2.0", ] [[package]] @@ -1626,7 +1739,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d37637a4b33b5390322ccc068a33897d0aa541daf4fec99f6a7efbf37295346e" dependencies = [ "async-trait", - "bytes", + "bytes 1.0.1", "futures", "libp2p-core", "libp2p-swarm", @@ -1641,9 +1754,9 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.27.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ea8c69839a0e593c8c6a24282cb234d48ac37be4153183f4914e00f5303e75" +checksum = "d4f89ebb4d8953bda12623e9871959fe728dea3bf6eae0421dc9c42dc821e488" dependencies = [ "either", "futures", @@ -1714,19 +1827,32 @@ dependencies = [ [[package]] name = "log" -version = "0.4.13" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf3805d4480bb5b86070dcfeb9e2cb2ebc148adb753c5cca5f884d1d65a42b2" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ "cfg-if 0.1.10", "serde", ] +[[package]] +name = "loom" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0e8460f2f2121162705187214720353c517b97bdfb3494c0b1e33d83ebe4bed" +dependencies = [ + "cfg-if 0.1.10", + "generator", + "scoped-tls", + "serde", + "serde_json", +] + [[package]] name = "lru" -version = "0.6.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3aae342b73d57ad0b8b364bd12584819f2c1fe9114285dfcf8b0722607671635" +checksum = "3abe07af102235a56ac9a6dd904aab1e05483e2e8afdfffec3598be55b1b7606" dependencies = [ "hashbrown", ] @@ -1780,18 +1906,18 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "minicbor" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0164190d1771b1458c3742075b057ed55d25cd9dfb930aade99315a1eb1fe12d" +checksum = "3265a9f5210bb726f81ef9c456ae0aff5321cd95748c0e71889b0e19d8f0332b" dependencies = [ "minicbor-derive", ] [[package]] name = "minicbor-derive" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e071b3159835ee91df62dbdbfdd7ec366b7ea77c838f43aff4acda6b61bcfb9" +checksum = "130b9455e28a3f308f6579671816a6f2621e2e0cbf55dc2f886345bef699481e" dependencies = [ "proc-macro2", "quote", @@ -1839,7 +1965,7 @@ checksum = "d53d4207d0bd4d1eb3323e33a64f9ea99e5e3d257d5cd7a659fad5be48c8b9af" dependencies = [ "base58-monero", "byteorder", - "curve25519-dalek 2.1.2", + "curve25519-dalek 2.1.0", "fixed-hash 0.3.2", "hex 0.4.2", "keccak-hash 0.3.0", @@ -1908,19 +2034,19 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10ddc0eb0117736f19d556355464fc87efc8ad98b29e3fd84f02531eb6e90840" dependencies = [ - "bytes", + "bytes 1.0.1", "futures", "log", - "pin-project 1.0.4", + "pin-project 1.0.2", "smallvec", "unsigned-varint 0.6.0", ] [[package]] name = "native-tls" -version = "0.2.7" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" +checksum = "6fcc7939b5edc4e4f86b1b4a04bb1498afaaf871b1a6691838ed06fcb48d3a3f" dependencies = [ "lazy_static", "libc", @@ -1950,6 +2076,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +[[package]] +name = "nom" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +dependencies = [ + "lexical-core", + "memchr", + "version_check", +] + [[package]] name = "ntapi" version = "0.3.6" @@ -2067,9 +2204,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.32" +version = "0.10.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70" +checksum = "8d008f51b1acffa0d3450a68606e6a51c123012edaacb0f4e1426bd978869187" dependencies = [ "bitflags", "cfg-if 1.0.0", @@ -2087,9 +2224,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-sys" -version = "0.9.60" +version = "0.9.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6" +checksum = "de52d8eabd217311538a39bba130d7dea1f1e118010fee7a033d966845e7d5fe" dependencies = [ "autocfg 1.0.1", "cc", @@ -2118,9 +2255,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "1.3.6" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79602888a81ace83e3d1d4b2873286c1f5f906c84db667594e8db8da3506c383" +checksum = "7c740e5fbcb6847058b40ac7e5574766c6388f585e184d769910fe0d3a2ca861" dependencies = [ "arrayvec", "bitvec", @@ -2147,14 +2284,14 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" +checksum = "d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0" dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall 0.1.57", + "redox_syscall", "smallvec", "winapi", ] @@ -2197,11 +2334,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.4" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b70b68509f17aa2857863b6fa00bf21fc93674c7a8893de2f469f6aa7ca2f2" +checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" dependencies = [ - "pin-project-internal 1.0.4", + "pin-project-internal 1.0.2", ] [[package]] @@ -2217,9 +2354,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.0.4" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caa25a6393f22ce819b0f50e0be89287292fda8d425be38ee0ca14c4931d9e71" +checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" dependencies = [ "proc-macro2", "quote", @@ -2228,9 +2365,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" [[package]] name = "pin-utils" @@ -2269,12 +2406,11 @@ dependencies = [ [[package]] name = "polyval" -version = "0.4.5" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" +checksum = "b4fd92d8e0c06d08525d2e2643cc2b5c80c69ae8eb12c18272d501cd7079ccc0" dependencies = [ "cpuid-bool 0.2.0", - "opaque-debug 0.3.0", "universal-hash", ] @@ -2356,9 +2492,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" +checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" [[package]] name = "proc-macro2" @@ -2375,7 +2511,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2" dependencies = [ - "bytes", + "bytes 1.0.1", "prost-derive", ] @@ -2385,7 +2521,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32d3ebd75ac2679c2af3a92246639f9fcc8a442ee420719cc4fe195b98dd5fa3" dependencies = [ - "bytes", + "bytes 1.0.1", "heck", "itertools", "log", @@ -2416,15 +2552,15 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb" dependencies = [ - "bytes", + "bytes 1.0.1", "prost", ] [[package]] name = "quote" -version = "1.0.8" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ "proc-macro2", ] @@ -2486,7 +2622,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom 0.1.16", + "getrandom 0.1.15", "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", @@ -2495,9 +2631,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18519b42a40024d661e1714153e9ad0c3de27cd495760ceb09710920f1098b1e" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", "rand_chacha 0.3.0", @@ -2556,7 +2692,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.16", + "getrandom 0.1.15", ] [[package]] @@ -2565,7 +2701,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" dependencies = [ - "getrandom 0.2.1", + "getrandom 0.2.2", ] [[package]] @@ -2663,31 +2799,22 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" -[[package]] -name = "redox_syscall" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" -dependencies = [ - "bitflags", -] - [[package]] name = "redox_users" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom 0.1.16", - "redox_syscall 0.1.57", + "getrandom 0.1.15", + "redox_syscall", "rust-argon2", ] [[package]] name = "regex" -version = "1.4.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" dependencies = [ "regex-syntax", ] @@ -2704,9 +2831,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" [[package]] name = "remove_dir_all" @@ -2724,7 +2851,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd281b1030aa675fb90aa994d07187645bb3c8fc756ca766e7c3070b439de9de" dependencies = [ "base64 0.13.0", - "bytes", + "bytes 1.0.1", "encoding_rs", "futures-core", "futures-util", @@ -2781,9 +2908,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.9.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5c739ba050709eae138f053356d27ff818d71fe54ce5a8d9f4c7a660bfb6684" +checksum = "c9e81662973c7a8d9663e64a0de4cd642b89a21d64966e3d99606efdc5fb0cc6" dependencies = [ "num-traits", "serde", @@ -2837,6 +2964,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + [[package]] name = "scopeguard" version = "1.1.0" @@ -2925,9 +3058,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.119" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bdd36f49e35b61d49efd8aa7fc068fd295961fd2286d0b2ee9a4c7a14e99cc3" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" dependencies = [ "serde_derive", ] @@ -2963,9 +3096,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.119" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552954ce79a059ddd5fd68c271592374bd15cab2274970380c000118aeffe1cd" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ "proc-macro2", "quote", @@ -2974,9 +3107,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.61" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" +checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" dependencies = [ "itoa", "ryu", @@ -3028,18 +3161,19 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" +checksum = "7b4921be914e16899a80adefb821f8ddb7974e3f1250223575a44ed994882127" dependencies = [ "lazy_static", + "loom", ] [[package]] name = "signature" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0242b8e50dd9accdd56170e94ca1ebd223b098eb9c83539a6e367d0f36ae68" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" [[package]] name = "slab" @@ -3065,9 +3199,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.6.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" [[package]] name = "snow" @@ -3089,9 +3223,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.3.19" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +checksum = "97e0e9fd577458a4f61fb91fcb559ea2afecc54c934119421f9f5d3d5b1a1057" dependencies = [ "cfg-if 1.0.0", "libc", @@ -3115,9 +3249,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "standback" -version = "0.2.14" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c66a8cff4fa24853fdf6b51f75c6d7f8206d7c75cab4e467bcd7f25c2b1febe0" +checksum = "cf906c8b8fc3f6ecd1046e01da1d8ddec83e48c8b08b84dcc02b585a6bedf5a8" dependencies = [ "version_check", ] @@ -3268,10 +3402,13 @@ dependencies = [ "base64 0.12.3", "bitcoin", "bitcoin-harness", + "config", "conquer-once", "cross-curve-dleq", - "curve25519-dalek 2.1.2", + "curve25519-dalek 2.1.0", "derivative", + "dialoguer", + "directories-next", "ecdsa_fun", "ed25519-dalek", "futures", @@ -3302,6 +3439,7 @@ dependencies = [ "thiserror", "time", "tokio", + "toml", "tracing", "tracing-core", "tracing-futures", @@ -3314,9 +3452,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.58" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" +checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" dependencies = [ "proc-macro2", "quote", @@ -3337,14 +3475,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.2.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "libc", - "rand 0.8.2", - "redox_syscall 0.2.4", + "rand 0.7.3", + "redox_syscall", "remove_dir_all", "winapi", ] @@ -3360,6 +3498,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "terminal_size" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "testcontainers" version = "0.11.0" @@ -3387,18 +3535,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.23" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" +checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.23" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" +checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" dependencies = [ "proc-macro2", "quote", @@ -3407,18 +3555,18 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" dependencies = [ "lazy_static", ] [[package]] name = "time" -version = "0.2.24" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "273d3ed44dca264b0d6b3665e8d48fb515042d42466fad93d2a45b90ec4058f7" +checksum = "bcdaeea317915d59b2b4cd3b5efcd156c309108664277793f5351700c02ce98b" dependencies = [ "const_fn", "libc", @@ -3478,12 +3626,12 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca04cec6ff2474c638057b65798f60ac183e5e79d3448bb7163d36a39cff6ec" +checksum = "8efab2086f17abcddb8f756117665c958feee6b2e39974c2f1600592ab3a4195" dependencies = [ "autocfg 1.0.1", - "bytes", + "bytes 1.0.1", "libc", "memchr", "mio", @@ -3526,11 +3674,12 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ae4751faa60b9f96dd8344d74592e5a17c0c9a220413dbc6942d14139bbfcc" +checksum = "feb971a26599ffd28066d387f109746df178eff14d5ea1e235015c5601967a4b" dependencies = [ - "bytes", + "async-stream", + "bytes 1.0.1", "futures-core", "futures-sink", "log", @@ -3720,7 +3869,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35581ff83d4101e58b582e607120c7f5ffb17e632a980b1f38334d76b36908b2" dependencies = [ "asynchronous-codec", - "bytes", + "bytes 1.0.1", "futures-io", "futures-util", ] @@ -3741,15 +3890,16 @@ dependencies = [ "idna", "matches", "percent-encoding", + "serde", ] [[package]] name = "uuid" -version = "0.8.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" dependencies = [ - "getrandom 0.2.1", + "rand 0.7.3", "serde", ] @@ -3807,9 +3957,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.1+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" @@ -3939,6 +4089,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -3960,9 +4119,9 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc614d95359fd7afc321b66d2107ede58b246b844cf5d8a0adcca413e439f088" dependencies = [ - "curve25519-dalek 3.0.2", + "curve25519-dalek 3.0.0", "rand_core 0.5.1", - "zeroize", + "zeroize 1.2.0", ] [[package]] @@ -3979,6 +4138,12 @@ dependencies = [ "static_assertions 1.1.0", ] +[[package]] +name = "zeroize" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" + [[package]] name = "zeroize" version = "1.2.0" diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 2d7b7bff..94eda471 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -14,10 +14,13 @@ backoff = { git = "https://github.com/ihrwein/backoff", rev = "9d03992a83dfdc596 base64 = "0.12" bitcoin = { version = "0.25", features = ["rand", "use-serde"] } bitcoin-harness = { git = "https://github.com/coblox/bitcoin-harness-rs", rev = "ae2f6cd547496e680941c0910018bbe884128799" } +config = { version = "0.10", default-features = false, features = ["toml"] } conquer-once = "0.3" cross-curve-dleq = { git = "https://github.com/comit-network/cross-curve-dleq", rev = "eddcdea1d1f16fa33ef581d1744014ece535c920", features = ["serde"] } curve25519-dalek = "2" derivative = "2" +dialoguer = "0.7" +directories-next = "2" ecdsa_fun = { git = "https://github.com/LLFourn/secp256kfun", rev = "cdfbc766045ea678a41780919d6228dd5acee3be", features = ["libsecp_compat", "serde"] } ed25519-dalek = { version = "1.0.0-pre.4", features = ["serde"] }# Cannot be 1 because they depend on curve25519-dalek version 3 futures = { version = "0.3", default-features = false } @@ -43,12 +46,13 @@ tempfile = "3" thiserror = "1" time = "0.2" tokio = { version = "1.0", features = ["rt-multi-thread", "time", "macros", "sync"] } +toml = "0.5" tracing = { version = "0.1", features = ["attributes"] } tracing-core = "0.1" tracing-futures = { version = "0.2", features = ["std-future", "futures-03"] } tracing-log = "0.1" tracing-subscriber = { version = "0.2", default-features = false, features = ["fmt", "ansi", "env-filter"] } -url = "2.1" +url = { version = "2.1", features = ["serde"] } uuid = { version = "0.8", features = ["serde", "v4"] } void = "1" diff --git a/swap/src/bitcoin.rs b/swap/src/bitcoin.rs index c4efba5b..95bcf036 100644 --- a/swap/src/bitcoin.rs +++ b/swap/src/bitcoin.rs @@ -10,7 +10,7 @@ pub use ::bitcoin::{util::amount::Amount, Address, Network, Transaction, Txid}; pub use ecdsa_fun::{adaptor::EncryptedSignature, fun::Scalar, Signature}; pub use wallet::Wallet; -use crate::{bitcoin::timelocks::BlockHeight, config::Config}; +use crate::{bitcoin::timelocks::BlockHeight, config::ExecutionParams}; use ::bitcoin::{ hashes::{hex::ToHex, Hash}, secp256k1, @@ -208,7 +208,11 @@ pub trait WatchForRawTransaction { #[async_trait] pub trait WaitForTransactionFinality { - async fn wait_for_transaction_finality(&self, txid: Txid, config: Config) -> Result<()>; + async fn wait_for_transaction_finality( + &self, + txid: Txid, + execution_params: ExecutionParams, + ) -> Result<()>; } #[async_trait] diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index 44a1e24e..38271436 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -4,7 +4,7 @@ use crate::{ GetBlockHeight, GetNetwork, GetRawTransaction, SignTxLock, Transaction, TransactionBlockHeight, TxLock, WaitForTransactionFinality, WatchForRawTransaction, }, - config::Config, + config::ExecutionParams, }; use ::bitcoin::{util::psbt::PartiallySignedTransaction, Txid}; use anyhow::{Context, Result}; @@ -171,17 +171,21 @@ impl TransactionBlockHeight for Wallet { #[async_trait] impl WaitForTransactionFinality for Wallet { - async fn wait_for_transaction_finality(&self, txid: Txid, config: Config) -> Result<()> { + async fn wait_for_transaction_finality( + &self, + txid: Txid, + execution_params: ExecutionParams, + ) -> Result<()> { // TODO(Franck): This assumes that bitcoind runs with txindex=1 // Divide by 4 to not check too often yet still be aware of the new block early // on. - let mut interval = interval(config.bitcoin_avg_block_time / 4); + let mut interval = interval(execution_params.bitcoin_avg_block_time / 4); loop { let tx = self.inner.client.get_raw_transaction_verbose(txid).await?; if let Some(confirmations) = tx.confirmations { - if confirmations >= config.bitcoin_finality_confirmations { + if confirmations >= execution_params.bitcoin_finality_confirmations { break; } } diff --git a/swap/src/cli.rs b/swap/src/cli.rs index a2a48a48..4a04359b 100644 --- a/swap/src/cli.rs +++ b/swap/src/cli.rs @@ -1,13 +1,16 @@ use crate::{bitcoin, monero}; use libp2p::{core::Multiaddr, PeerId}; -use url::Url; +use std::path::PathBuf; use uuid::Uuid; #[derive(structopt::StructOpt, Debug)] pub struct Options { - // TODO: Default value should points to proper configuration folder in home folder - #[structopt(long = "data-dir", default_value = "./.swap-data/")] - pub data_dir: String, + #[structopt( + long = "data-dir", + help = "Provide a custom path to the data directory.", + parse(from_os_str) + )] + pub data_dir: Option, #[structopt(subcommand)] pub cmd: Command, @@ -17,18 +20,6 @@ pub struct Options { #[structopt(name = "xmr_btc-swap", about = "XMR BTC atomic swap")] pub enum Command { SellXmr { - #[structopt(long = "bitcoind-rpc", default_value = "http://127.0.0.1:8332")] - bitcoind_url: Url, - - #[structopt(long = "bitcoin-wallet-name")] - bitcoin_wallet_name: String, - - #[structopt( - long = "monero-wallet-rpc", - default_value = "http://127.0.0.1:18083/json_rpc" - )] - monero_wallet_rpc_url: Url, - #[structopt(long = "p2p-address", default_value = "/ip4/0.0.0.0/tcp/9876")] listen_addr: Multiaddr, @@ -37,6 +28,9 @@ pub enum Command { #[structopt(long = "receive-btc", help = "Bitcoin amount as floating point nr without denomination (e.g. 1.25)", parse(try_from_str = parse_btc))] receive_bitcoin: bitcoin::Amount, + + #[structopt(flatten)] + config: Config, }, BuyXmr { #[structopt(long = "connect-peer-id")] @@ -45,23 +39,14 @@ pub enum Command { #[structopt(long = "connect-addr")] alice_addr: Multiaddr, - #[structopt(long = "bitcoind-rpc", default_value = "http://127.0.0.1:8332")] - bitcoind_url: Url, - - #[structopt(long = "bitcoin-wallet-name")] - bitcoin_wallet_name: String, - - #[structopt( - long = "monero-wallet-rpc", - default_value = "http://127.0.0.1:18083/json_rpc" - )] - monero_wallet_rpc_url: Url, - #[structopt(long = "send-btc", help = "Bitcoin amount as floating point nr without denomination (e.g. 1.25)", parse(try_from_str = parse_btc))] send_bitcoin: bitcoin::Amount, #[structopt(long = "receive-xmr", help = "Monero amount as floating point nr without denomination (e.g. 125.1)", parse(try_from_str = parse_xmr))] receive_monero: monero::Amount, + + #[structopt(flatten)] + config: Config, }, History, Resume(Resume), @@ -73,20 +58,11 @@ pub enum Resume { #[structopt(long = "swap-id")] swap_id: Uuid, - #[structopt(long = "bitcoind-rpc", default_value = "http://127.0.0.1:8332")] - bitcoind_url: Url, - - #[structopt(long = "bitcoin-wallet-name")] - bitcoin_wallet_name: String, - - #[structopt( - long = "monero-wallet-rpc", - default_value = "http://127.0.0.1:18083/json_rpc" - )] - monero_wallet_rpc_url: Url, - #[structopt(long = "listen-address", default_value = "/ip4/127.0.0.1/tcp/9876")] listen_addr: Multiaddr, + + #[structopt(flatten)] + config: Config, }, BuyXmr { #[structopt(long = "swap-id")] @@ -98,20 +74,21 @@ pub enum Resume { #[structopt(long = "counterpart-addr")] alice_addr: Multiaddr, - #[structopt(long = "bitcoind-rpc", default_value = "http://127.0.0.1:8332")] - bitcoind_url: Url, - - #[structopt(long = "bitcoin-wallet-name")] - bitcoin_wallet_name: String, - - #[structopt( - long = "monero-wallet-rpc", - default_value = "http://127.0.0.1:18083/json_rpc" - )] - monero_wallet_rpc_url: Url, + #[structopt(flatten)] + config: Config, }, } +#[derive(structopt::StructOpt, Debug)] +pub struct Config { + #[structopt( + long = "config", + help = "Provide a custom path to the configuration file. The configuration file must be a toml file.", + parse(from_os_str) + )] + pub path: Option, +} + fn parse_btc(str: &str) -> anyhow::Result { let amount = bitcoin::Amount::from_str_in(str, ::bitcoin::Denomination::Bitcoin)?; Ok(amount) diff --git a/swap/src/config.rs b/swap/src/config.rs index 286f0309..d73f8683 100644 --- a/swap/src/config.rs +++ b/swap/src/config.rs @@ -1,23 +1,19 @@ -pub mod seed; - use crate::bitcoin::Timelock; use conquer_once::Lazy; use std::time::Duration; #[derive(Debug, Copy, Clone)] -pub struct Config { +pub struct ExecutionParams { pub bob_time_to_act: Duration, pub bitcoin_finality_confirmations: u32, pub bitcoin_avg_block_time: Duration, pub monero_finality_confirmations: u32, pub bitcoin_cancel_timelock: Timelock, pub bitcoin_punish_timelock: Timelock, - pub bitcoin_network: bitcoin::Network, - pub monero_network: monero::Network, } -pub trait GetConfig { - fn get_config() -> Config; +pub trait GetExecutionParams { + fn get_execution_params() -> ExecutionParams; } #[derive(Clone, Copy)] @@ -29,53 +25,47 @@ pub struct Testnet; #[derive(Clone, Copy)] pub struct Regtest; -impl GetConfig for Mainnet { - fn get_config() -> Config { - Config { +impl GetExecutionParams for Mainnet { + fn get_execution_params() -> ExecutionParams { + ExecutionParams { bob_time_to_act: *mainnet::BOB_TIME_TO_ACT, bitcoin_finality_confirmations: mainnet::BITCOIN_FINALITY_CONFIRMATIONS, bitcoin_avg_block_time: *mainnet::BITCOIN_AVG_BLOCK_TIME, monero_finality_confirmations: mainnet::MONERO_FINALITY_CONFIRMATIONS, bitcoin_cancel_timelock: mainnet::BITCOIN_CANCEL_TIMELOCK, bitcoin_punish_timelock: mainnet::BITCOIN_PUNISH_TIMELOCK, - bitcoin_network: bitcoin::Network::Bitcoin, - monero_network: monero::Network::Mainnet, } } } -impl GetConfig for Testnet { - fn get_config() -> Config { - Config { +impl GetExecutionParams for Testnet { + fn get_execution_params() -> ExecutionParams { + ExecutionParams { bob_time_to_act: *testnet::BOB_TIME_TO_ACT, bitcoin_finality_confirmations: testnet::BITCOIN_FINALITY_CONFIRMATIONS, bitcoin_avg_block_time: *testnet::BITCOIN_AVG_BLOCK_TIME, monero_finality_confirmations: testnet::MONERO_FINALITY_CONFIRMATIONS, bitcoin_cancel_timelock: testnet::BITCOIN_CANCEL_TIMELOCK, bitcoin_punish_timelock: testnet::BITCOIN_PUNISH_TIMELOCK, - bitcoin_network: bitcoin::Network::Testnet, - monero_network: monero::Network::Stagenet, } } } -impl GetConfig for Regtest { - fn get_config() -> Config { - Config { +impl GetExecutionParams for Regtest { + fn get_execution_params() -> ExecutionParams { + ExecutionParams { bob_time_to_act: *regtest::BOB_TIME_TO_ACT, bitcoin_finality_confirmations: regtest::BITCOIN_FINALITY_CONFIRMATIONS, bitcoin_avg_block_time: *regtest::BITCOIN_AVG_BLOCK_TIME, monero_finality_confirmations: regtest::MONERO_FINALITY_CONFIRMATIONS, bitcoin_cancel_timelock: regtest::BITCOIN_CANCEL_TIMELOCK, bitcoin_punish_timelock: regtest::BITCOIN_PUNISH_TIMELOCK, - bitcoin_network: bitcoin::Network::Regtest, - monero_network: monero::Network::default(), } } } mod mainnet { - use super::*; + use crate::config::*; // For each step, we are giving Bob 10 minutes to act. pub static BOB_TIME_TO_ACT: Lazy = Lazy::new(|| Duration::from_secs(10 * 60)); @@ -92,7 +82,7 @@ mod mainnet { } mod testnet { - use super::*; + use crate::config::*; pub static BOB_TIME_TO_ACT: Lazy = Lazy::new(|| Duration::from_secs(60 * 60)); @@ -110,7 +100,7 @@ mod testnet { } mod regtest { - use super::*; + use crate::config::*; // In test, we set a shorter time to fail fast pub static BOB_TIME_TO_ACT: Lazy = Lazy::new(|| Duration::from_secs(30)); diff --git a/swap/src/configuration.rs b/swap/src/configuration.rs new file mode 100644 index 00000000..11049581 --- /dev/null +++ b/swap/src/configuration.rs @@ -0,0 +1,145 @@ +use crate::fs::ensure_directory_exists; +use anyhow::{Context, Result}; +use config::{Config, ConfigError}; +use dialoguer::{theme::ColorfulTheme, Input}; +use serde::{Deserialize, Serialize}; +use std::{ + ffi::OsStr, + fs, + path::{Path, PathBuf}, +}; +use tracing::info; +use url::Url; + +pub mod seed; + +const DEFAULT_BITCOIND_TESTNET_URL: &str = "http://127.0.0.1:18332"; +const DEFAULT_MONERO_WALLET_RPC_TESTNET_URL: &str = "http://127.0.0.1:38083/json_rpc"; + +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq)] +pub struct File { + pub bitcoin: Bitcoin, + pub monero: Monero, +} + +impl File { + pub fn read(config_file: D) -> Result + where + D: AsRef, + { + let config_file = Path::new(&config_file); + + let mut config = Config::new(); + config.merge(config::File::from(config_file))?; + config.try_into() + } +} + +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Bitcoin { + pub bitcoind_url: Url, + pub wallet_name: String, +} + +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Monero { + pub wallet_rpc_url: Url, +} + +#[derive(thiserror::Error, Debug, Clone, Copy)] +#[error("config not initialized")] +pub struct ConfigNotInitialized {} + +pub fn read_config(config_path: PathBuf) -> Result> { + if config_path.exists() { + info!( + "Using config file at default path: {}", + config_path.display() + ); + } else { + return Ok(Err(ConfigNotInitialized {})); + } + + let file = File::read(&config_path) + .with_context(|| format!("failed to read config file {}", config_path.display()))?; + + Ok(Ok(file)) +} + +pub fn initial_setup(config_path: PathBuf, config_file: F) -> Result<()> +where + F: Fn() -> Result, +{ + info!("Config file not found, running initial setup..."); + ensure_directory_exists(config_path.as_path())?; + let initial_config = config_file()?; + + let toml = toml::to_string(&initial_config)?; + fs::write(&config_path, toml)?; + + info!( + "Initial setup complete, config file created at {} ", + config_path.as_path().display() + ); + Ok(()) +} + +pub fn query_user_for_initial_testnet_config() -> Result { + println!(); + let bitcoind_url: String = Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Enter Bitcoind URL (including username and password if applicable) or hit return to use default") + .default(DEFAULT_BITCOIND_TESTNET_URL.to_owned()) + .interact_text()?; + let bitcoind_url = Url::parse(bitcoind_url.as_str())?; + + let bitcoin_wallet_name: String = Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Enter Bitcoind wallet name") + .interact_text()?; + + let monero_wallet_rpc_url: String = Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Enter Monero Wallet RPC URL or hit enter to use default") + .default(DEFAULT_MONERO_WALLET_RPC_TESTNET_URL.to_owned()) + .interact_text()?; + let monero_wallet_rpc_url = Url::parse(monero_wallet_rpc_url.as_str())?; + println!(); + + Ok(File { + bitcoin: Bitcoin { + bitcoind_url, + wallet_name: bitcoin_wallet_name, + }, + monero: Monero { + wallet_rpc_url: monero_wallet_rpc_url, + }, + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::str::FromStr; + use tempfile::tempdir; + + #[test] + fn config_roundtrip() { + let temp_dir = tempdir().unwrap().path().to_path_buf(); + let config_path = Path::join(&temp_dir, "config.toml"); + + let expected = File { + bitcoin: Bitcoin { + bitcoind_url: Url::from_str("http://127.0.0.1:18332").unwrap(), + wallet_name: "alice".to_string(), + }, + monero: Monero { + wallet_rpc_url: Url::from_str("http://127.0.0.1:38083/json_rpc").unwrap(), + }, + }; + + initial_setup(config_path.clone(), || Ok(expected.clone())).unwrap(); + let actual = read_config(config_path).unwrap().unwrap(); + + assert_eq!(expected, actual); + } +} diff --git a/swap/src/config/seed.rs b/swap/src/configuration/seed.rs similarity index 100% rename from swap/src/config/seed.rs rename to swap/src/configuration/seed.rs diff --git a/swap/src/fs.rs b/swap/src/fs.rs index f3dc889b..c0de4ec0 100644 --- a/swap/src/fs.rs +++ b/swap/src/fs.rs @@ -1,4 +1,26 @@ -use std::path::Path; +use anyhow::Context; +use directories_next::ProjectDirs; +use std::path::{Path, PathBuf}; + +/// This is to store the configuration and seed files +// Linux: /home//.config/xmr-btc-swap/ +// OSX: /Users//Library/Preferences/xmr-btc-swap/ +fn default_config_dir() -> Option { + ProjectDirs::from("", "", "xmr-btc-swap").map(|proj_dirs| proj_dirs.config_dir().to_path_buf()) +} + +pub fn default_config_path() -> anyhow::Result { + default_config_dir() + .map(|dir| Path::join(&dir, "config.toml")) + .context("Could not generate default configuration path") +} + +/// This is to store the DB +// Linux: /home//.local/share/nectar/ +// OSX: /Users//Library/Application Support/nectar/ +pub fn default_data_dir() -> Option { + ProjectDirs::from("", "", "nectar").map(|proj_dirs| proj_dirs.data_dir().to_path_buf()) +} pub fn ensure_directory_exists(file: &Path) -> Result<(), std::io::Error> { if let Some(path) = file.parent() { diff --git a/swap/src/lib.rs b/swap/src/lib.rs index 5e51f8d5..ce734445 100644 --- a/swap/src/lib.rs +++ b/swap/src/lib.rs @@ -25,5 +25,4 @@ pub mod protocol; pub mod seed; pub mod trace; -mod fs; mod serde_peer_id; diff --git a/swap/src/main.rs b/swap/src/main.rs index 1e22d901..2d62d1e9 100644 --- a/swap/src/main.rs +++ b/swap/src/main.rs @@ -12,14 +12,20 @@ #![forbid(unsafe_code)] #![allow(non_snake_case)] -use crate::cli::{Command, Options, Resume}; +use crate::{ + cli::{Command, Options, Resume}, + config::GetExecutionParams, + configuration::{ + initial_setup, query_user_for_initial_testnet_config, read_config, ConfigNotInitialized, + }, +}; use anyhow::{Context, Result}; -use config::{Config, GetConfig}; use database::Database; +use fs::{default_config_path, default_data_dir}; use log::LevelFilter; use prettytable::{row, Table}; use protocol::{alice, bob, bob::Builder, SwapAmounts}; -use std::sync::Arc; +use std::{path::PathBuf, sync::Arc}; use structopt::StructOpt; use trace::init_tracing; use tracing::info; @@ -27,6 +33,7 @@ use uuid::Uuid; pub mod bitcoin; pub mod config; +pub mod configuration; pub mod database; pub mod monero; pub mod network; @@ -46,40 +53,42 @@ async fn main() -> Result<()> { init_tracing(LevelFilter::Info).expect("initialize tracing"); let opt = Options::from_args(); - let config = config::Testnet::get_config(); + + let data_dir = if let Some(data_dir) = opt.data_dir { + data_dir + } else { + default_data_dir().context("unable to determine default data path")? + }; info!( "Database and Seed will be stored in directory: {}", - opt.data_dir + data_dir.display() ); - let data_dir = std::path::Path::new(opt.data_dir.as_str()).to_path_buf(); - let db_path = data_dir.join("database"); - let seed = config::seed::Seed::from_file_or_generate(&data_dir) + let db_path = data_dir.join("database"); + let seed = configuration::seed::Seed::from_file_or_generate(&data_dir) .expect("Could not retrieve/initialize seed") .into(); + // hardcode to testnet/stagenet + let bitcoin_network = bitcoin::Network::Testnet; + let monero_network = monero::Network::Stagenet; + let execution_params = config::Testnet::get_execution_params(); + match opt.cmd { Command::SellXmr { - bitcoind_url, - bitcoin_wallet_name, - monero_wallet_rpc_url, listen_addr, send_monero, receive_bitcoin, + config, } => { let swap_amounts = SwapAmounts { xmr: send_monero, btc: receive_bitcoin, }; - let (bitcoin_wallet, monero_wallet) = setup_wallets( - bitcoind_url, - bitcoin_wallet_name.as_str(), - monero_wallet_rpc_url, - config, - ) - .await?; + let (bitcoin_wallet, monero_wallet) = + init_wallets(config.path, bitcoin_network, monero_network).await?; let swap_id = Uuid::new_v4(); @@ -90,7 +99,7 @@ async fn main() -> Result<()> { let alice_factory = alice::Builder::new( seed, - config, + execution_params, swap_id, Arc::new(bitcoin_wallet), Arc::new(monero_wallet), @@ -106,24 +115,17 @@ async fn main() -> Result<()> { Command::BuyXmr { alice_peer_id, alice_addr, - bitcoind_url, - bitcoin_wallet_name, - monero_wallet_rpc_url, send_bitcoin, receive_monero, + config, } => { let swap_amounts = SwapAmounts { btc: send_bitcoin, xmr: receive_monero, }; - let (bitcoin_wallet, monero_wallet) = setup_wallets( - bitcoind_url, - bitcoin_wallet_name.as_str(), - monero_wallet_rpc_url, - config, - ) - .await?; + let (bitcoin_wallet, monero_wallet) = + init_wallets(config.path, bitcoin_network, monero_network).await?; let swap_id = Uuid::new_v4(); @@ -140,7 +142,7 @@ async fn main() -> Result<()> { Arc::new(monero_wallet), alice_addr, alice_peer_id, - config, + execution_params, ); let (swap, event_loop) = bob_factory.with_init_params(swap_amounts).build().await?; @@ -163,22 +165,15 @@ async fn main() -> Result<()> { } Command::Resume(Resume::SellXmr { swap_id, - bitcoind_url, - bitcoin_wallet_name, - monero_wallet_rpc_url, listen_addr, + config, }) => { - let (bitcoin_wallet, monero_wallet) = setup_wallets( - bitcoind_url, - bitcoin_wallet_name.as_str(), - monero_wallet_rpc_url, - config, - ) - .await?; + let (bitcoin_wallet, monero_wallet) = + init_wallets(config.path, bitcoin_network, monero_network).await?; let alice_factory = alice::Builder::new( seed, - config, + execution_params, swap_id, Arc::new(bitcoin_wallet), Arc::new(monero_wallet), @@ -192,19 +187,12 @@ async fn main() -> Result<()> { } Command::Resume(Resume::BuyXmr { swap_id, - bitcoind_url, - bitcoin_wallet_name, - monero_wallet_rpc_url, alice_peer_id, alice_addr, + config, }) => { - let (bitcoin_wallet, monero_wallet) = setup_wallets( - bitcoind_url, - bitcoin_wallet_name.as_str(), - monero_wallet_rpc_url, - config, - ) - .await?; + let (bitcoin_wallet, monero_wallet) = + init_wallets(config.path, bitcoin_network, monero_network).await?; let bob_factory = Builder::new( seed, @@ -214,7 +202,7 @@ async fn main() -> Result<()> { Arc::new(monero_wallet), alice_addr, alice_peer_id, - config, + execution_params, ); let (swap, event_loop) = bob_factory.build().await?; @@ -226,21 +214,38 @@ async fn main() -> Result<()> { Ok(()) } -async fn setup_wallets( - bitcoind_url: url::Url, - bitcoin_wallet_name: &str, - monero_wallet_rpc_url: url::Url, - config: Config, +async fn init_wallets( + config_path: Option, + bitcoin_network: bitcoin::Network, + monero_network: monero::Network, ) -> Result<(bitcoin::Wallet, monero::Wallet)> { - let bitcoin_wallet = - bitcoin::Wallet::new(bitcoin_wallet_name, bitcoind_url, config.bitcoin_network).await?; + let config_path = if let Some(config_path) = config_path { + config_path + } else { + default_config_path()? + }; + + let config = match read_config(config_path.clone())? { + Ok(config) => config, + Err(ConfigNotInitialized {}) => { + initial_setup(config_path.clone(), query_user_for_initial_testnet_config)?; + read_config(config_path)?.expect("after initial setup config can be read") + } + }; + + let bitcoin_wallet = bitcoin::Wallet::new( + config.bitcoin.wallet_name.as_str(), + config.bitcoin.bitcoind_url, + bitcoin_network, + ) + .await?; let bitcoin_balance = bitcoin_wallet.balance().await?; info!( "Connection to Bitcoin wallet succeeded, balance: {}", bitcoin_balance ); - let monero_wallet = monero::Wallet::new(monero_wallet_rpc_url, config.monero_network); + let monero_wallet = monero::Wallet::new(config.monero.wallet_rpc_url, monero_network); let monero_balance = monero_wallet.get_balance().await?; info!( "Connection to Monero wallet succeeded, balance: {}", diff --git a/swap/src/protocol/alice.rs b/swap/src/protocol/alice.rs index b2ea0a16..c1bbdfdd 100644 --- a/swap/src/protocol/alice.rs +++ b/swap/src/protocol/alice.rs @@ -11,7 +11,7 @@ pub use self::{ }; use crate::{ bitcoin, - config::Config, + config::ExecutionParams, database, database::Database, monero, @@ -49,7 +49,7 @@ pub struct Swap { pub event_loop_handle: EventLoopHandle, pub bitcoin_wallet: Arc, pub monero_wallet: Arc, - pub config: Config, + pub execution_params: ExecutionParams, pub swap_id: Uuid, pub db: Database, } @@ -59,7 +59,7 @@ pub struct Builder { identity: Keypair, peer_id: PeerId, db_path: PathBuf, - config: Config, + execution_params: ExecutionParams, listen_address: Multiaddr, @@ -77,7 +77,7 @@ enum InitParams { impl Builder { pub fn new( seed: Seed, - config: Config, + execution_params: ExecutionParams, swap_id: Uuid, bitcoin_wallet: Arc, monero_wallet: Arc, @@ -93,7 +93,7 @@ impl Builder { identity, peer_id, db_path, - config, + execution_params, listen_address, bitcoin_wallet, monero_wallet, @@ -124,7 +124,7 @@ impl Builder { event_loop_handle, bitcoin_wallet: self.bitcoin_wallet, monero_wallet: self.monero_wallet, - config: self.config, + execution_params: self.execution_params, db, state: initial_state, swap_id: self.swap_id, @@ -154,7 +154,7 @@ impl Builder { event_loop_handle, bitcoin_wallet: self.bitcoin_wallet, monero_wallet: self.monero_wallet, - config: self.config, + execution_params: self.execution_params, swap_id: self.swap_id, db, }, @@ -195,8 +195,8 @@ impl Builder { v_a, amounts.btc, amounts.xmr, - self.config.bitcoin_cancel_timelock, - self.config.bitcoin_punish_timelock, + self.execution_params.bitcoin_cancel_timelock, + self.execution_params.bitcoin_punish_timelock, redeem_address, punish_address, ); diff --git a/swap/src/protocol/alice/steps.rs b/swap/src/protocol/alice/steps.rs index 37de2b34..b3850ca3 100644 --- a/swap/src/protocol/alice/steps.rs +++ b/swap/src/protocol/alice/steps.rs @@ -7,7 +7,7 @@ use crate::{ TransactionBlockHeight, TxCancel, TxLock, TxRefund, WaitForTransactionFinality, WatchForRawTransaction, }, - config::Config, + config::ExecutionParams, monero, monero::Transfer, protocol::{ @@ -33,28 +33,34 @@ pub async fn negotiate( state0: alice::State0, xmr_amount: monero::Amount, event_loop_handle: &mut EventLoopHandle, - config: Config, + execution_params: ExecutionParams, ) -> Result<(PeerId, alice::State3)> { trace!("Starting negotiate"); // todo: we can move this out, we dont need to timeout here let bob_peer_id = timeout( - config.bob_time_to_act, + execution_params.bob_time_to_act, event_loop_handle.recv_conn_established(), ) .await .context("Failed to receive dial connection from Bob")??; - let event = timeout(config.bob_time_to_act, event_loop_handle.recv_request()) - .await - .context("Failed to receive swap request from Bob")??; + let event = timeout( + execution_params.bob_time_to_act, + event_loop_handle.recv_request(), + ) + .await + .context("Failed to receive swap request from Bob")??; event_loop_handle .send_swap_response(event.channel, SwapResponse { xmr_amount }) .await?; - let (bob_message0, channel) = - timeout(config.bob_time_to_act, event_loop_handle.recv_message0()).await??; + let (bob_message0, channel) = timeout( + execution_params.bob_time_to_act, + event_loop_handle.recv_message0(), + ) + .await??; let alice_message0 = state0.next_message(&mut OsRng); event_loop_handle @@ -63,8 +69,11 @@ pub async fn negotiate( let state1 = state0.receive(bob_message0)?; - let (bob_message1, channel) = - timeout(config.bob_time_to_act, event_loop_handle.recv_message1()).await??; + let (bob_message1, channel) = timeout( + execution_params.bob_time_to_act, + event_loop_handle.recv_message1(), + ) + .await??; let state2 = state1.receive(bob_message1); @@ -72,7 +81,11 @@ pub async fn negotiate( .send_message1(channel, state2.next_message()) .await?; - let bob_message2 = timeout(config.bob_time_to_act, event_loop_handle.recv_message2()).await??; + let bob_message2 = timeout( + execution_params.bob_time_to_act, + event_loop_handle.recv_message2(), + ) + .await??; let state3 = state2.receive(bob_message2)?; @@ -84,14 +97,14 @@ pub async fn negotiate( pub async fn wait_for_locked_bitcoin( lock_bitcoin_txid: bitcoin::Txid, bitcoin_wallet: Arc, - config: Config, + execution_params: ExecutionParams, ) -> Result<()> where W: WatchForRawTransaction + WaitForTransactionFinality, { // We assume we will see Bob's transaction in the mempool first. timeout( - config.bob_time_to_act, + execution_params.bob_time_to_act, bitcoin_wallet.watch_for_raw_transaction(lock_bitcoin_txid), ) .await @@ -99,7 +112,7 @@ where // // We saw the transaction in the mempool, waiting for it to be confirmed. bitcoin_wallet - .wait_for_transaction_finality(lock_bitcoin_txid, config) + .wait_for_transaction_finality(lock_bitcoin_txid, execution_params) .await?; Ok(()) @@ -324,7 +337,7 @@ pub fn build_bitcoin_punish_transaction( pub async fn publish_bitcoin_punish_transaction( punish_tx: bitcoin::Transaction, bitcoin_wallet: Arc, - config: Config, + execution_params: ExecutionParams, ) -> Result where W: BroadcastSignedTransaction + WaitForTransactionFinality, @@ -334,7 +347,7 @@ where .await?; bitcoin_wallet - .wait_for_transaction_finality(txid, config) + .wait_for_transaction_finality(txid, execution_params) .await?; Ok(txid) diff --git a/swap/src/protocol/alice/swap.rs b/swap/src/protocol/alice/swap.rs index 198ee389..641aac72 100644 --- a/swap/src/protocol/alice/swap.rs +++ b/swap/src/protocol/alice/swap.rs @@ -6,7 +6,7 @@ use crate::{ timelocks::ExpiredTimelocks, TransactionBlockHeight, WaitForTransactionFinality, WatchForRawTransaction, }, - config::Config, + config::ExecutionParams, database, database::Database, monero, @@ -66,7 +66,7 @@ pub async fn run_until( swap.event_loop_handle, swap.bitcoin_wallet, swap.monero_wallet, - swap.config, + swap.execution_params, swap.swap_id, swap.db, ) @@ -82,7 +82,7 @@ async fn run_until_internal( mut event_loop_handle: EventLoopHandle, bitcoin_wallet: Arc, monero_wallet: Arc, - config: Config, + execution_params: ExecutionParams, swap_id: Uuid, db: Database, ) -> Result { @@ -92,8 +92,13 @@ async fn run_until_internal( } else { match state { AliceState::Started { amounts, state0 } => { - let (bob_peer_id, state3) = - negotiate(state0, amounts.xmr, &mut event_loop_handle, config).await?; + let (bob_peer_id, state3) = negotiate( + state0, + amounts.xmr, + &mut event_loop_handle, + execution_params, + ) + .await?; let state = AliceState::Negotiated { bob_peer_id, @@ -110,7 +115,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet, monero_wallet, - config, + execution_params, swap_id, db, ) @@ -121,9 +126,12 @@ async fn run_until_internal( bob_peer_id, amounts, } => { - let _ = - wait_for_locked_bitcoin(state3.tx_lock.txid(), bitcoin_wallet.clone(), config) - .await?; + let _ = wait_for_locked_bitcoin( + state3.tx_lock.txid(), + bitcoin_wallet.clone(), + execution_params, + ) + .await?; let state = AliceState::BtcLocked { bob_peer_id, @@ -140,7 +148,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet, monero_wallet, - config, + execution_params, swap_id, db, ) @@ -171,7 +179,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet, monero_wallet, - config, + execution_params, swap_id, db, ) @@ -209,7 +217,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet.clone(), monero_wallet, - config, + execution_params, swap_id, db, ) @@ -235,7 +243,7 @@ async fn run_until_internal( { Ok(txid) => { let publishded_redeem_tx = bitcoin_wallet - .wait_for_transaction_finality(txid, config) + .wait_for_transaction_finality(txid, execution_params) .await; match publishded_redeem_tx { @@ -281,7 +289,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet, monero_wallet, - config, + execution_params, swap_id, db, ) @@ -308,7 +316,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet, monero_wallet, - config, + execution_params, swap_id, db, ) @@ -342,7 +350,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet.clone(), monero_wallet, - config, + execution_params, swap_id, db, ) @@ -367,7 +375,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet.clone(), monero_wallet, - config, + execution_params, swap_id, db, ) @@ -402,7 +410,7 @@ async fn run_until_internal( let punish_tx_finalised = publish_bitcoin_punish_transaction( signed_tx_punish, bitcoin_wallet.clone(), - config, + execution_params, ); let refund_tx_seen = bitcoin_wallet.watch_for_raw_transaction(tx_refund.txid()); @@ -422,7 +430,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet.clone(), monero_wallet, - config, + execution_params, swap_id, db, ) @@ -446,7 +454,7 @@ async fn run_until_internal( event_loop_handle, bitcoin_wallet.clone(), monero_wallet, - config, + execution_params, swap_id, db, ) diff --git a/swap/src/protocol/bob.rs b/swap/src/protocol/bob.rs index dc9f560e..16d31568 100644 --- a/swap/src/protocol/bob.rs +++ b/swap/src/protocol/bob.rs @@ -1,9 +1,7 @@ //! Run an XMR/BTC swap in the role of Bob. //! Bob holds BTC and wishes receive XMR. use crate::{ - bitcoin, - config::Config, - database, + bitcoin, database, database::Database, monero, network, network::{ @@ -30,7 +28,7 @@ pub use self::{ swap::{run, run_until}, swap_request::*, }; -use crate::protocol::alice::TransferProof; +use crate::{config::ExecutionParams, protocol::alice::TransferProof}; mod encrypted_signature; pub mod event_loop; @@ -48,7 +46,7 @@ pub struct Swap { pub db: Database, pub bitcoin_wallet: Arc, pub monero_wallet: Arc, - pub config: Config, + pub execution_params: ExecutionParams, pub swap_id: Uuid, } @@ -65,7 +63,7 @@ pub struct Builder { monero_wallet: Arc, init_params: InitParams, - config: Config, + execution_params: ExecutionParams, } enum InitParams { @@ -83,7 +81,7 @@ impl Builder { monero_wallet: Arc, alice_address: Multiaddr, alice_peer_id: PeerId, - config: Config, + execution_params: ExecutionParams, ) -> Self { let identity = network::Seed::new(seed).derive_libp2p_identity(); let peer_id = identity.public().into_peer_id(); @@ -98,7 +96,7 @@ impl Builder { bitcoin_wallet, monero_wallet, init_params: InitParams::None, - config, + execution_params, } } @@ -113,7 +111,7 @@ impl Builder { match self.init_params { InitParams::New { swap_amounts } => { let initial_state = self - .make_initial_state(swap_amounts.btc, swap_amounts.xmr, self.config) + .make_initial_state(swap_amounts.btc, swap_amounts.xmr, self.execution_params) .await?; let (event_loop, event_loop_handle) = self.init_event_loop()?; @@ -128,7 +126,7 @@ impl Builder { bitcoin_wallet: self.bitcoin_wallet.clone(), monero_wallet: self.monero_wallet.clone(), swap_id: self.swap_id, - config: self.config, + execution_params: self.execution_params, }, event_loop, )) @@ -157,7 +155,7 @@ impl Builder { bitcoin_wallet: self.bitcoin_wallet.clone(), monero_wallet: self.monero_wallet.clone(), swap_id: self.swap_id, - config: self.config, + execution_params: self.execution_params, }, event_loop, )) @@ -183,7 +181,7 @@ impl Builder { &self, btc_to_swap: bitcoin::Amount, xmr_to_swap: monero::Amount, - config: Config, + execution_params: ExecutionParams, ) -> Result { let amounts = SwapAmounts { btc: btc_to_swap, @@ -195,10 +193,10 @@ impl Builder { &mut OsRng, btc_to_swap, xmr_to_swap, - config.bitcoin_cancel_timelock, - config.bitcoin_punish_timelock, + execution_params.bitcoin_cancel_timelock, + execution_params.bitcoin_punish_timelock, refund_address, - config.monero_finality_confirmations, + execution_params.monero_finality_confirmations, ); Ok(BobState::Started { state0, amounts }) diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index 74f09ca2..9b453f6e 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -6,7 +6,7 @@ use crate::{ GetBlockHeight, GetNetwork, GetRawTransaction, Transaction, TransactionBlockHeight, TxCancel, Txid, WatchForRawTransaction, }, - config::Config, + config::ExecutionParams, monero, monero::{monero_private_key, TransferProof}, protocol::{alice, bob, bob::EncryptedSignature, SwapAmounts}, @@ -556,7 +556,11 @@ impl State4 { .await } - pub async fn refund_btc(&self, bitcoin_wallet: &W, config: Config) -> Result<()> + pub async fn refund_btc( + &self, + bitcoin_wallet: &W, + execution_params: ExecutionParams, + ) -> Result<()> where W: bitcoin::BroadcastSignedTransaction + bitcoin::WaitForTransactionFinality, { @@ -581,7 +585,7 @@ impl State4 { .await?; bitcoin_wallet - .wait_for_transaction_finality(txid, config) + .wait_for_transaction_finality(txid, execution_params) .await?; Ok(()) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 808f551a..8bbabe6d 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -1,7 +1,7 @@ use crate::{ bitcoin, bitcoin::timelocks::ExpiredTimelocks, - config::Config, + config::ExecutionParams, database::{Database, Swap}, monero, protocol::{ @@ -46,7 +46,7 @@ pub async fn run_until( swap.monero_wallet, OsRng, swap.swap_id, - swap.config, + swap.execution_params, ) .await } @@ -63,7 +63,7 @@ async fn run_until_internal( monero_wallet: Arc, mut rng: R, swap_id: Uuid, - config: Config, + execution_params: ExecutionParams, ) -> Result where R: RngCore + CryptoRng + Send, @@ -97,7 +97,7 @@ where monero_wallet, rng, swap_id, - config, + execution_params, ) .await } @@ -119,7 +119,7 @@ where monero_wallet, rng, swap_id, - config, + execution_params, ) .await } @@ -172,7 +172,7 @@ where monero_wallet, rng, swap_id, - config, + execution_params, ) .await } @@ -219,7 +219,7 @@ where monero_wallet, rng, swap_id, - config, + execution_params, ) .await } @@ -262,7 +262,7 @@ where monero_wallet, rng, swap_id, - config, + execution_params, ) .await } @@ -298,7 +298,7 @@ where monero_wallet, rng, swap_id, - config, + execution_params, ) .await } @@ -320,7 +320,7 @@ where monero_wallet, rng, swap_id, - config, + execution_params, ) .await } @@ -346,7 +346,7 @@ where monero_wallet, rng, swap_id, - config, + execution_params, ) .await } @@ -357,7 +357,9 @@ where bail!("Internal error: canceled state reached before cancel timelock was expired"); } ExpiredTimelocks::Cancel => { - state.refund_btc(bitcoin_wallet.as_ref(), config).await?; + state + .refund_btc(bitcoin_wallet.as_ref(), execution_params) + .await?; BobState::BtcRefunded(state) } ExpiredTimelocks::Punish => BobState::BtcPunished { @@ -376,7 +378,7 @@ where monero_wallet, rng, swap_id, - config, + execution_params, ) .await } diff --git a/swap/tests/testutils/mod.rs b/swap/tests/testutils/mod.rs index 5d8f364f..9ddccbe1 100644 --- a/swap/tests/testutils/mod.rs +++ b/swap/tests/testutils/mod.rs @@ -9,7 +9,7 @@ use swap::{ bitcoin, bitcoin::Timelock, config, - config::{Config, GetConfig}, + config::{ExecutionParams, GetExecutionParams}, monero, protocol::{alice, alice::AliceState, bob, bob::BobState, SwapAmounts}, seed::Seed, @@ -29,7 +29,7 @@ pub struct StartingBalances { struct AliceParams { seed: Seed, - config: Config, + execution_params: ExecutionParams, swap_id: Uuid, bitcoin_wallet: Arc, monero_wallet: Arc, @@ -41,7 +41,7 @@ impl AliceParams { pub fn builder(&self) -> alice::Builder { alice::Builder::new( self.seed, - self.config, + self.execution_params, self.swap_id, self.bitcoin_wallet.clone(), self.monero_wallet.clone(), @@ -64,7 +64,7 @@ struct BobParams { monero_wallet: Arc, alice_address: Multiaddr, alice_peer_id: PeerId, - config: Config, + execution_params: ExecutionParams, } impl BobParams { @@ -77,7 +77,7 @@ impl BobParams { self.monero_wallet.clone(), self.alice_address.clone(), self.alice_peer_id, - self.config, + self.execution_params, ) } } @@ -308,13 +308,13 @@ pub async fn setup_test(_config: C, testfn: T) where T: Fn(TestContext) -> F, F: Future, - C: GetConfig, + C: GetExecutionParams, { let cli = Cli::default(); let _guard = init_tracing(); - let config = C::get_config(); + let execution_params = C::get_execution_params(); let (monero, containers) = testutils::init_containers(&cli).await; @@ -334,18 +334,17 @@ where .parse() .expect("failed to parse Alice's address"); - let (alice_bitcoin_wallet, alice_monero_wallet) = init_wallets( + let (alice_bitcoin_wallet, alice_monero_wallet) = init_test_wallets( "alice", &containers.bitcoind, &monero, alice_starting_balances.clone(), - config, ) .await; let alice_params = AliceParams { seed: Seed::random().unwrap(), - config, + execution_params, swap_id: Uuid::new_v4(), bitcoin_wallet: alice_bitcoin_wallet.clone(), monero_wallet: alice_monero_wallet.clone(), @@ -358,12 +357,11 @@ where btc: swap_amounts.btc * 10, }; - let (bob_bitcoin_wallet, bob_monero_wallet) = init_wallets( + let (bob_bitcoin_wallet, bob_monero_wallet) = init_test_wallets( "bob", &containers.bitcoind, &monero, bob_starting_balances.clone(), - config, ) .await; @@ -375,7 +373,7 @@ where monero_wallet: bob_monero_wallet.clone(), alice_address: alice_params.listen_address.clone(), alice_peer_id: alice_params.peer_id(), - config, + execution_params, }; let test = TestContext { @@ -403,12 +401,11 @@ async fn init_containers(cli: &Cli) -> (Monero, Containers<'_>) { (monero, Containers { bitcoind, monerods }) } -async fn init_wallets( +async fn init_test_wallets( name: &str, bitcoind: &Bitcoind<'_>, monero: &Monero, starting_balances: StartingBalances, - config: Config, ) -> (Arc, Arc) { monero .init(vec![(name, starting_balances.xmr.as_piconero())]) @@ -417,11 +414,11 @@ async fn init_wallets( let xmr_wallet = Arc::new(swap::monero::Wallet { inner: monero.wallet(name).unwrap().client(), - network: config.monero_network, + network: monero::Network::default(), }); let btc_wallet = Arc::new( - swap::bitcoin::Wallet::new(name, bitcoind.node_url.clone(), config.bitcoin_network) + swap::bitcoin::Wallet::new(name, bitcoind.node_url.clone(), bitcoin::Network::Regtest) .await .unwrap(), ); @@ -517,34 +514,34 @@ pub mod bob_run_until { pub struct SlowCancelConfig; -impl GetConfig for SlowCancelConfig { - fn get_config() -> Config { - Config { +impl GetExecutionParams for SlowCancelConfig { + fn get_execution_params() -> ExecutionParams { + ExecutionParams { bitcoin_cancel_timelock: Timelock::new(180), - ..config::Regtest::get_config() + ..config::Regtest::get_execution_params() } } } pub struct FastCancelConfig; -impl GetConfig for FastCancelConfig { - fn get_config() -> Config { - Config { +impl GetExecutionParams for FastCancelConfig { + fn get_execution_params() -> ExecutionParams { + ExecutionParams { bitcoin_cancel_timelock: Timelock::new(1), - ..config::Regtest::get_config() + ..config::Regtest::get_execution_params() } } } pub struct FastPunishConfig; -impl GetConfig for FastPunishConfig { - fn get_config() -> Config { - Config { +impl GetExecutionParams for FastPunishConfig { + fn get_execution_params() -> ExecutionParams { + ExecutionParams { bitcoin_cancel_timelock: Timelock::new(1), bitcoin_punish_timelock: Timelock::new(1), - ..config::Regtest::get_config() + ..config::Regtest::get_execution_params() } } }