diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml new file mode 100644 index 0000000..c9f630f --- /dev/null +++ b/.github/workflows/clippy.yml @@ -0,0 +1,16 @@ +on: push +name: Clippy check +jobs: + clippy_check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + components: clippy + override: true + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features diff --git a/CHANGELOG.md b/CHANGELOG.md index 45f5970..fa3f4be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## v0.5.0 + +- Upgrade to new bdk commit +- Switch over to using ureq as http backend exclusively + ## v0.4.0 - Upgrade to base2048 v2 which removes right-to-left characters which made copy pasting very difficult. diff --git a/Cargo.lock b/Cargo.lock index cfc1575..bfa569f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,9 +28,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.44" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" +checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7" [[package]] name = "async-trait" @@ -93,7 +93,7 @@ dependencies = [ [[package]] name = "bdk" version = "0.9.1-dev" -source = "git+https://github.com/llfourn/bdk?rev=7cf457ac31a7b40efb31662c6470597b1340fb43#7cf457ac31a7b40efb31662c6470597b1340fb43" +source = "git+https://github.com/llfourn/bdk?rev=5108b75b44032f0461bf737cdc78b76023d7433e#5108b75b44032f0461bf737cdc78b76023d7433e" dependencies = [ "async-trait", "bdk-macros", @@ -101,18 +101,17 @@ dependencies = [ "core-rpc", "electrsd", "electrum-client", - "futures", "js-sys", "log", "miniscript", "rand 0.7.3", - "reqwest", "serde", "serde_json", "sled", "thiserror", "tiny-bip39", "tokio", + "ureq", ] [[package]] @@ -196,9 +195,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.7.1" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" +checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" [[package]] name = "byteorder" @@ -235,9 +234,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" +checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" [[package]] name = "cfg-if" @@ -300,22 +299,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "core-foundation" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" - [[package]] name = "core-rpc" version = "0.14.0" @@ -462,19 +445,10 @@ dependencies = [ "serde", "serde_json", "socks", - "webpki", + "webpki 0.21.4", "webpki-roots 0.19.0", ] -[[package]] -name = "encoding_rs" -version = "0.8.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" -dependencies = [ - "cfg-if", -] - [[package]] name = "filetime" version = "0.2.15" @@ -499,27 +473,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.0.1" @@ -540,100 +493,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "futures" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" - -[[package]] -name = "futures-executor" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" - -[[package]] -name = "futures-macro" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" -dependencies = [ - "autocfg", - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" - -[[package]] -name = "futures-task" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" - -[[package]] -name = "futures-util" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" -dependencies = [ - "autocfg", - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - [[package]] name = "fxhash" version = "0.2.1" @@ -679,7 +538,7 @@ dependencies = [ [[package]] name = "gun_wallet" -version = "0.4.0" +version = "0.5.0" dependencies = [ "anyhow", "base2048", @@ -692,40 +551,16 @@ dependencies = [ "olivia_describe", "olivia_secp256k1", "rand 0.8.4", - "reqwest", "serde", "serde_json", "sha2", "structopt", "term-table", "thiserror", + "ureq", + "url", ] -[[package]] -name = "h2" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f3675cfef6a30c8031cf9e6493ebdc3bb3272a3fea3923c4210d1830e6a472" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" - [[package]] name = "heck" version = "0.3.3" @@ -763,77 +598,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "http" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "399c583b2979440c60be0821a6199eca73bc3c8dcd9d070d75ac726e2c6186e5" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" - -[[package]] -name = "httpdate" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" - -[[package]] -name = "hyper" -version = "0.14.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d1cfb9e4f68655fa04c01f59edb405b6074a0f7118ea881e5026e4a1cd8593" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "idna" version = "0.2.3" @@ -845,34 +609,15 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "indexmap" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" -dependencies = [ - "autocfg", - "hashbrown", -] - [[package]] name = "instant" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "716d3d89f35ac6a34fd0eed635395f4c3b76fa889338a4632e5231a8684216bd" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", ] -[[package]] -name = "ipnet" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" - [[package]] name = "itoa" version = "0.4.8" @@ -908,9 +653,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.103" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" +checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673" [[package]] name = "lock_api" @@ -951,12 +696,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - [[package]] name = "miniscript" version = "6.0.1" @@ -977,46 +716,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mio" -version = "0.7.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" -dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "winapi 0.3.9", -] - -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "native-tls" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nix" version = "0.22.2" @@ -1030,15 +729,6 @@ dependencies = [ "memoffset", ] -[[package]] -name = "ntapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "num-integer" version = "0.1.44" @@ -1058,16 +748,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "olivia_core" version = "0.1.0" @@ -1106,9 +786,6 @@ name = "once_cell" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" -dependencies = [ - "parking_lot", -] [[package]] name = "opaque-debug" @@ -1116,39 +793,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "openssl" -version = "0.10.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-sys", -] - -[[package]] -name = "openssl-probe" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" - -[[package]] -name = "openssl-sys" -version = "0.9.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69df2d8dfc6ce3aaf44b40dec6f487d5a886516cf6879c49e98e0710f310a058" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "parking_lot" version = "0.11.2" @@ -1195,23 +839,17 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - [[package]] name = "pkg-config" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb" +checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "proc-macro-error" @@ -1237,32 +875,20 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" -version = "1.0.29" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" dependencies = [ "proc-macro2", ] @@ -1393,41 +1019,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "reqwest" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22" -dependencies = [ - "base64 0.13.0", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "http", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "lazy_static", - "log", - "mime", - "native-tls", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-native-tls", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - [[package]] name = "ring" version = "0.16.20" @@ -1458,21 +1049,20 @@ dependencies = [ "base64 0.10.1", "log", "ring", - "sct", - "webpki", + "sct 0.6.1", + "webpki 0.21.4", ] [[package]] name = "rustls" -version = "0.19.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +checksum = "9b5ac6078ca424dc1d3ae2328526a76787fecc7f8011f520e3276730e711fc95" dependencies = [ - "base64 0.13.0", "log", "ring", - "sct", - "webpki", + "sct 0.7.0", + "webpki 0.22.0", ] [[package]] @@ -1481,16 +1071,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "schannel" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" -dependencies = [ - "lazy_static", - "winapi 0.3.9", -] - [[package]] name = "schnorr_fun" version = "0.6.3-alpha.0" @@ -1516,6 +1096,16 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "secp256k1" version = "0.20.3" @@ -1557,29 +1147,6 @@ dependencies = [ "subtle-ng", ] -[[package]] -name = "security-framework" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "serde" version = "1.0.130" @@ -1611,18 +1178,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_urlencoded" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - [[package]] name = "sha2" version = "0.9.8" @@ -1636,12 +1191,6 @@ dependencies = [ "opaque-debug", ] -[[package]] -name = "slab" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" - [[package]] name = "sled" version = "0.34.7" @@ -1664,16 +1213,6 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "socket2" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" -dependencies = [ - "libc", - "winapi 0.3.9", -] - [[package]] name = "socks" version = "0.3.3" @@ -1700,9 +1239,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.23" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf9d950ef167e25e0bdb073cf1d68e9ad2795ac826f2f3f59647817cf23c0bfa" +checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" dependencies = [ "clap", "lazy_static", @@ -1711,9 +1250,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.16" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ "heck", "proc-macro-error", @@ -1736,9 +1275,9 @@ checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" [[package]] name = "syn" -version = "1.0.77" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0" +checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" dependencies = [ "proc-macro2", "quote", @@ -1747,9 +1286,9 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "474aaa926faa1603c40b7885a9eaea29b444d1cb2850cb7c0e37bb1a4182f4fa" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", @@ -1804,18 +1343,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", @@ -1834,20 +1373,20 @@ dependencies = [ [[package]] name = "tiny-bip39" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524daa5624d9d4ffb5a0625971d35205b882111daa6b6338a7a6c578a3c36928" +checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" dependencies = [ "anyhow", "hmac", "once_cell", - "parking_lot", "pbkdf2", "rand 0.7.3", "rustc-hash", "sha2", "thiserror", "unicode-normalization", + "wasm-bindgen", "zeroize", ] @@ -1868,76 +1407,14 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc" +checksum = "588b2d10a336da58d877567cd8fb8a14b463e2104910f8132cd054b4b96e29ee" dependencies = [ "autocfg", - "bytes", - "libc", - "memchr", - "mio", - "num_cpus", "pin-project-lite", - "winapi 0.3.9", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tower-service" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" - -[[package]] -name = "tracing" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf" -dependencies = [ - "lazy_static", ] -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - [[package]] name = "typenum" version = "1.14.0" @@ -1946,9 +1423,9 @@ checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" [[package]] name = "unicode-bidi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246f4c42e67e7a4e3c6106ff716a5d067d4132a642840b242e357e468a2a0085" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" [[package]] name = "unicode-normalization" @@ -1985,18 +1462,20 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "ureq" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3131cd6cb18488da91da1d10ed31e966f453c06b65bf010d35638456976a3fd7" +checksum = "1dd912a3d096959150c4d71ac752e13f1683085922658c205b89b40fe8ebe07f" dependencies = [ "base64 0.13.0", "chunked_transfer", "log", "once_cell", - "rustls 0.19.1", + "rustls 0.20.0", + "serde", + "serde_json", "url", - "webpki", - "webpki-roots 0.21.1", + "webpki 0.22.0", + "webpki-roots 0.22.1", ] [[package]] @@ -2011,12 +1490,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "vec_map" version = "0.8.2" @@ -2029,16 +1502,6 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -2058,8 +1521,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if", - "serde", - "serde_json", "wasm-bindgen-macro", ] @@ -2078,18 +1539,6 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" version = "0.2.78" @@ -2139,22 +1588,32 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "webpki-roots" version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8eff4b7516a57307f9349c64bf34caa34b940b66fed4b2fb3136cb7386e5739" dependencies = [ - "webpki", + "webpki 0.21.4", ] [[package]] name = "webpki-roots" -version = "0.21.1" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" +checksum = "c475786c6f47219345717a043a37ec04cb4bc185e28853adcc4fa0a947eba630" dependencies = [ - "webpki", + "webpki 0.22.0", ] [[package]] @@ -2191,15 +1650,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "winreg" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "ws2_32-sys" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index f734b00..087093f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gun_wallet" -version = "0.4.0" +version = "0.5.0" authors = ["LLFourn "] edition = "2018" license = "0BSD" @@ -9,8 +9,8 @@ license = "0BSD" [dependencies] dirs = "3.0" -bdk = { git = "https://github.com/llfourn/bdk", rev = "7cf457ac31a7b40efb31662c6470597b1340fb43", features = ["key-value-db", "esplora", "compiler", "keys-bip39"], default-features = false } -# bdk = { path = "../bdk", features = ["key-value-db", "esplora", "compiler", "keys-bip39"], default-features = false } +bdk = { git = "https://github.com/llfourn/bdk", rev = "5108b75b44032f0461bf737cdc78b76023d7433e", features = ["key-value-db", "esplora", "compiler", "keys-bip39"], default-features = false } +#bdk = { path = "../bdk", features = ["key-value-db", "esplora", "compiler", "keys-bip39"], default-features = false } serde_json = "1.0" olivia_core = { git = "https://github.com/llfourn/olivia", rev = "025cb6ad31b85d3150571b902e3502a16cab88ad" } olivia_secp256k1 = { git = "https://github.com/llfourn/olivia", features = ["libsecp_compat"], rev = "025cb6ad31b85d3150571b902e3502a16cab88ad" } @@ -25,8 +25,8 @@ thiserror = "1.0" structopt = "0.3" miniscript = { version = "6", features = ["serde"] } term-table = { version = "1", default-features = false } -reqwest = { version = "0.11", features = ["blocking"] } - +ureq = { version = "2", features = ["json"] } +url = "2" [features] nightly = ["olivia_secp256k1/nightly"] @@ -34,5 +34,5 @@ nightly = ["olivia_secp256k1/nightly"] [dev-dependencies] rand = "0.8" -bdk = { git = "https://github.com/llfourn/bdk", rev = "7cf457ac31a7b40efb31662c6470597b1340fb43", features = ["key-value-db", "esplora", "compiler", "keys-bip39", "test-esplora", "test-blockchains"], default-features = false } -# bdk = { path = "../bdk", features = ["key-value-db", "esplora", "compiler", "keys-bip39", "test-esplora", "test-blockchains"], default-features = false } +bdk = { git = "https://github.com/llfourn/bdk", rev = "5108b75b44032f0461bf737cdc78b76023d7433e", features = ["key-value-db", "esplora", "compiler", "keys-bip39", "test-esplora", "test-blockchains"], default-features = false } +#bdk = { path = "../bdk", features = ["key-value-db", "esplora", "compiler", "keys-bip39", "test-esplora", "test-blockchains"], default-features = false } diff --git a/src/betting/bet.rs b/src/betting/bet.rs index 1488b25..459dc95 100644 --- a/src/betting/bet.rs +++ b/src/betting/bet.rs @@ -32,7 +32,7 @@ impl Bet { pub fn my_inputs(&self) -> Vec { self.my_input_indexes .iter() - .map(|i| self.tx().input[*i as usize].previous_output.clone()) + .map(|i| self.tx().input[*i as usize].previous_output) .collect() } diff --git a/src/betting/database.rs b/src/betting/database.rs index 2fe999a..6964d79 100644 --- a/src/betting/database.rs +++ b/src/betting/database.rs @@ -187,12 +187,12 @@ impl BetDatabase { for bet_id in bet_ids { let key = VersionedKey::from(MapKey::Bet(*bet_id)); let key = key.to_bytes(); - let old_state = - db.remove(key.clone())? - .ok_or(ConflictableTransactionError::Abort(anyhow!( - "bet {} does not exist", - bet_id - )))?; + let old_state = db.remove(key.clone())?.ok_or_else(|| { + ConflictableTransactionError::Abort(anyhow!( + "bet {} does not exist", + bet_id + )) + })?; let old_state = serde_json::from_slice(&old_state[..]) .expect("it's in the DB so it should be deserializable"); let new_state = f(old_state, *bet_id, TxDb(db)) diff --git a/src/betting/joint_output.rs b/src/betting/joint_output.rs index c5d627c..a387c50 100644 --- a/src/betting/joint_output.rs +++ b/src/betting/joint_output.rs @@ -152,8 +152,7 @@ impl JointOutput { .unwrap() .compile() .unwrap(); - let descriptor = Descriptor::Wsh(Wsh::new(compiled_policy).unwrap()); - descriptor + Descriptor::Wsh(Wsh::new(compiled_policy).unwrap()) } pub fn descriptor(&self) -> Descriptor { diff --git a/src/betting/offer.rs b/src/betting/offer.rs index 4733482..f1afff4 100644 --- a/src/betting/offer.rs +++ b/src/betting/offer.rs @@ -47,7 +47,7 @@ impl Ciphertext { } } - pub fn to_string(&self) -> String { + pub fn to_base2048_string(&self) -> String { crate::encode::serialize_base2048(self) } @@ -55,17 +55,17 @@ impl Ciphertext { &self, pad_to: usize, pad_cipher: &mut impl StreamCipher, - ) -> (String, Option) { + ) -> (String, usize) { let mut bytes = crate::encode::serialize(self); - let mut overflow = None; - if bytes.len() < pad_to { - let mut padding = vec![0u8; pad_to - bytes.len()]; - pad_cipher.apply_keystream(&mut padding); - bytes.append(&mut padding); - } else if bytes.len() > pad_to { - overflow = Some(bytes.len() - pad_to); + let mut overflow = 0; + match bytes.len() { + len if len < pad_to => { + let mut padding = vec![0u8; pad_to - len]; + pad_cipher.apply_keystream(&mut padding); + bytes.append(&mut padding); + } + len => overflow = len - pad_to, } - (base2048::encode(&bytes), overflow) } diff --git a/src/betting/party/bet_args.rs b/src/betting/party/bet_args.rs index df118ec..f9bf619 100644 --- a/src/betting/party/bet_args.rs +++ b/src/betting/party/bet_args.rs @@ -29,23 +29,16 @@ impl Default for BetArgs<'_, '_> { } impl BetArgs<'_, '_> { - pub fn apply_args< - 'a, - B, - D: BatchDatabase, - Cs: CoinSelectionAlgorithm, - Ctx: TxBuilderContext, - >( + pub fn apply_args, Ctx: TxBuilderContext>( &self, bet_db: &BetDatabase, builder: &mut TxBuilder, ) -> anyhow::Result<()> { builder.unspendable(bet_db.currently_used_utxos(self.may_overlap)?); for bet_id in self.must_overlap { - let bet = bet_db.get_entity::(*bet_id)?.ok_or(anyhow!( - "bet {} that we must overlap with does not exist", - bet_id - ))?; + let bet = bet_db.get_entity::(*bet_id)?.ok_or_else(|| { + anyhow!("bet {} that we must overlap with does not exist", bet_id) + })?; for input in bet.reserved_utxos() { builder.add_utxo(input).with_context(|| { format!("adding utxo {} for 'must_overlap' with {}", input, bet_id) diff --git a/src/betting/party/mod.rs b/src/betting/party/mod.rs index 8e8a435..9c294f3 100644 --- a/src/betting/party/mod.rs +++ b/src/betting/party/mod.rs @@ -32,7 +32,7 @@ use olivia_secp256k1::{ pub struct Party { wallet: Wallet, pub(crate) keychain: Keychain, - client: crate::reqwest::blocking::Client, + client: ureq::Agent, bet_db: BetDatabase, blockchain_config: AnyBlockchainConfig, } @@ -51,7 +51,7 @@ where wallet, keychain, bet_db, - client: crate::reqwest::blocking::Client::new(), + client: ureq::Agent::new(), blockchain_config, } } @@ -152,10 +152,9 @@ where match bet_state { BetState::Proposed { local_proposal } => { let inputs = &local_proposal.proposal.inputs; - if inputs + if !inputs .iter() - .find(|input| utxos_that_need_canceling.contains(input)) - .is_none() + .any(|input| utxos_that_need_canceling.contains(input)) { utxos_that_need_canceling.push(inputs[0]); } @@ -187,10 +186,9 @@ where .iter() .map(|i| tx.input[*i as usize].previous_output) .collect::>(); - if inputs + if !inputs .iter() - .find(|input| utxos_that_need_canceling.contains(input)) - .is_none() + .any(|input| utxos_that_need_canceling.contains(input)) { utxos_that_need_canceling.push(inputs[0]); } @@ -311,43 +309,6 @@ where Ok(psbt_input) } - pub fn get_spending_tx( - &self, - outpoint: OutPoint, - descriptor: ExtendedDescriptor, - ) -> anyhow::Result> { - let blockchain = self.new_blockchain()?; - let wallet = Wallet::new( - descriptor, - None, - self.wallet.network(), - MemoryDatabase::default(), - blockchain, - )?; - wallet.sync(bdk::blockchain::noop_progress(), None)?; - let res = Ok(wallet - .list_transactions(true)? - .iter() - .find(|tx| { - tx.confirmation_time.is_some() - && tx - .transaction - .as_ref() - .unwrap() - .input - .iter() - .find(|x| x.previous_output == outpoint) - .is_some() - }) - .map(|tx| tx.txid)); - debug_assert!(wallet - .list_unspent()? - .iter() - .find(|utxo| utxo.outpoint == outpoint) - .is_none()); - res - } - // convenience methods pub fn sync(&self) -> anyhow::Result<()> { eprintln!("syncing wallet with {:?}", self.blockchain_config); diff --git a/src/betting/party/offer.rs b/src/betting/party/offer.rs index e82c941..35ff9ba 100644 --- a/src/betting/party/offer.rs +++ b/src/betting/party/offer.rs @@ -132,7 +132,7 @@ impl Party { .output .iter() .enumerate() - .find(|(_i, txout)| &txout.script_pubkey == &output_script) + .find(|(_i, txout)| txout.script_pubkey == output_script) .expect("The bet output must be in there"); let joint_output_value = Amount::from_sat(txout.value); @@ -175,7 +175,7 @@ impl Party { psbt, my_input_indexes, vout: vout as u32, - joint_output: joint_output.clone(), + joint_output, oracle_id: oracle_info.id, oracle_event, local_value, @@ -198,10 +198,7 @@ impl Party { let encrypted_offer = Ciphertext::create( local_public_key, cipher, - Plaintext::Offerv1 { - offer: offer.clone(), - message, - }, + Plaintext::Offerv1 { offer, message }, ); let bet_id = self.bet_db.insert_bet(BetState::Offered { bet: OfferedBet(bet), diff --git a/src/betting/party/proposal.rs b/src/betting/party/proposal.rs index 97dea36..86b0781 100644 --- a/src/betting/party/proposal.rs +++ b/src/betting/party/proposal.rs @@ -55,7 +55,7 @@ impl Party { .unsigned_tx .input .iter() - .map(|txin| txin.previous_output.clone()) + .map(|txin| txin.previous_output) .collect(); let value = Amount::from_sat( @@ -85,7 +85,7 @@ impl Party { }; let mut proposal = Proposal { - oracle: oracle_id.clone(), + oracle: oracle_id, event_id: event_id.clone(), value, inputs: tx_inputs, @@ -97,7 +97,7 @@ impl Party { proposal.public_key = keypair.public_key; let local_proposal = LocalProposal { - proposal: proposal.clone(), + proposal, oracle_event, change, tags: args.tags, diff --git a/src/betting/party/state_machine.rs b/src/betting/party/state_machine.rs index ae437f2..5ef16ab 100644 --- a/src/betting/party/state_machine.rs +++ b/src/betting/party/state_machine.rs @@ -140,7 +140,7 @@ where update_bet! { self, bet_id, BetState::Offered { bet, .. } => { let bet = bet.add_counterparty_sigs(tx.clone()); - BetState::Included { bet: bet.clone(), height } + BetState::Included { bet, height } } } } @@ -159,7 +159,7 @@ where bet_spent_vin: vin_target, cancel_txid: txid, cancel_vin: vin, - height: height, + height, i_intend_cancel, } } @@ -235,13 +235,13 @@ where fn try_get_outcome(&self, bet_id: BetId, bet: Bet) -> anyhow::Result<()> { let event_id = bet.oracle_event.event.id; - let event_url = reqwest::Url::parse(&format!("https://{}{}", bet.oracle_id, event_id))?; + let event_url = format!("https://{}{}", bet.oracle_id, event_id); let event_response = self .client - .get(event_url) - .send()? - .error_for_status()? - .json::()?; + .get(&event_url) + .call() + .with_context(|| format!("trying to outcome for bet {} from {}", bet_id, event_url))? + .into_json::()?; if let Some(attestation) = event_response.attestation { self.learn_outcome(bet_id, attestation)?; diff --git a/src/betting/party/take_offer.rs b/src/betting/party/take_offer.rs index 34cc7b0..9b51cd3 100644 --- a/src/betting/party/take_offer.rs +++ b/src/betting/party/take_offer.rs @@ -103,7 +103,7 @@ impl Party { Either::Left(keypair.secret_key), anticipated_attestations, offer.choose_right, - randomize.clone(), + randomize, ); let joint_output_value = offer .value @@ -193,9 +193,9 @@ impl Party { psbt, my_input_indexes, vout, - oracle_id: oracle_info.id.clone(), - oracle_event: oracle_event.clone(), - joint_output: joint_output.clone(), + oracle_id: oracle_info.id, + oracle_event, + joint_output, local_value: proposal.value, joint_output_value, i_chose_right: !offer.choose_right, diff --git a/src/betting/proposal.rs b/src/betting/proposal.rs index 95d2134..97580b0 100644 --- a/src/betting/proposal.rs +++ b/src/betting/proposal.rs @@ -93,7 +93,7 @@ impl FromStr for VersionedProposal { type Err = anyhow::Error; fn from_str(string: &str) -> Result { - let mut segments = string.split("#"); + let mut segments = string.split('#'); let value = Amount::from_str_in( segments.next().ok_or(anyhow!("missing amount"))?, bitcoin::Denomination::Bitcoin, diff --git a/src/bin/gun.rs b/src/bin/gun.rs index 3b689ea..4ed14a6 100644 --- a/src/bin/gun.rs +++ b/src/bin/gun.rs @@ -90,10 +90,8 @@ fn main() -> anyhow::Result<()> { ) } else if opt.tabs { println!("{}", output.render_simple()) - } else { - if let Some(output) = output.render() { - println!("{}", output) - } + } else if let Some(output) = output.render() { + println!("{}", output) } } Err(e) => { diff --git a/src/change.rs b/src/change.rs index 6ec642f..a34af4f 100644 --- a/src/change.rs +++ b/src/change.rs @@ -71,7 +71,7 @@ impl<'de> serde::Deserialize<'de> for BinScript { impl<'de> serde::Serialize for BinScript { fn serialize(&self, serializer: S) -> Result { if serializer.is_human_readable() { - serializer.serialize_str(&hex::encode(&self.0.as_bytes())) + serializer.serialize_str(&hex::encode(self.0.as_bytes())) } else { serializer.serialize_bytes(self.0.as_bytes()) } diff --git a/src/cmd/bet.rs b/src/cmd/bet.rs index 88caf78..1d452d8 100644 --- a/src/cmd/bet.rs +++ b/src/cmd/bet.rs @@ -11,7 +11,7 @@ use anyhow::*; use bdk::bitcoin::{Address, Amount, Script}; use chacha20::cipher::StreamCipher; use olivia_core::{chrono::Utc, Outcome, OutcomeError}; -use std::{path::PathBuf, str::FromStr}; +use std::{path::Path, str::FromStr}; use structopt::StructOpt; #[derive(Clone, Debug, structopt::StructOpt)] @@ -53,6 +53,7 @@ impl BetArgs { #[derive(StructOpt, Debug, Clone)] #[structopt(about = "Make or take a bet", rename_all = "kebab")] +#[allow(clippy::large_enum_variant)] pub enum BetOpt { /// Propose an event to bet on Propose { @@ -202,11 +203,7 @@ pub enum TagOpt { }, } -pub fn run_bet_cmd( - wallet_dir: &PathBuf, - cmd: BetOpt, - sync: bool, -) -> anyhow::Result { +pub fn run_bet_cmd(wallet_dir: &Path, cmd: BetOpt, sync: bool) -> anyhow::Result { // For now just always do this but we may want to do something more fine grained later. if sync { let party = cmd::load_party(wallet_dir)?; @@ -321,8 +318,8 @@ pub fn run_bet_cmd( .collect::>(); let outcome = match choice { - Some(choice) => Outcome::try_from_id_and_outcome(event_id.clone(), &choice) - .map_err(|e| match e { + Some(choice) => { + Outcome::try_from_id_and_outcome(event_id, &choice).map_err(|e| match e { OutcomeError::Invalid { outcome } => anyhow!( "{} is not a valid outcome. Valid outcomes are {}", outcome, @@ -332,7 +329,8 @@ pub fn run_bet_cmd( .collect::>() .join(", ") ), - })?, + })? + } None => read_input( &format!( "The outcomes for this bet are\n{}\nWhat outcome do you want to bet on", @@ -351,7 +349,7 @@ pub fn run_bet_cmd( .map(Outcome::outcome_string) .collect::>() .join(", "), - |input| Ok(Outcome::try_from_id_and_outcome(event_id.clone(), &input)?), + |input| Ok(Outcome::try_from_id_and_outcome(event_id.clone(), input)?), ), }; @@ -379,13 +377,11 @@ pub fn run_bet_cmd( eprintln!("Post this offer in reponse to the proposal"); let (padded_encrypted_offer, overflow) = encrypted_offer.to_string_padded(pad, &mut cipher); - if let Some(overflow) = overflow { - if pad != 0 { - eprintln!( - "WARNING: this offer is longer than the pad value {} by {} bytes", - pad, overflow - ); - } + if overflow > 0 && pad != 0 { + eprintln!( + "WARNING: ciphertext is longer than {} by {} bytes so it will look unusually big", + pad, overflow + ); } Ok(CmdOutput::EmphasisedItem { main: ("offer", Cell::string(padded_encrypted_offer)), @@ -419,7 +415,7 @@ pub fn run_bet_cmd( yes, print_tx, )?; - if let Some(_) = txid { + if txid.is_some() { party.set_offer_taken(validated_offer)?; } Ok(output) @@ -527,7 +523,7 @@ pub fn run_bet_cmd( } Ok(CmdOutput::List( - to_remove.into_iter().map(|x| Cell::string(x)).collect(), + to_remove.into_iter().map(Cell::string).collect(), )) } BetOpt::Show { id, raw } => { @@ -550,11 +546,11 @@ pub fn run_bet_cmd( "event-id" => Cell::string(&local_proposal.proposal.event_id), "oracle" => Cell::string(&local_proposal.proposal.oracle), "outcome-time" => local_proposal.oracle_event.event.expected_outcome_time.map(Cell::datetime).unwrap_or(Cell::Empty), - "inputs" => Cell::List(local_proposal.proposal.inputs.clone().into_iter().map(|x| Box::new(Cell::string(x))).collect()), + "inputs" => Cell::List(local_proposal.proposal.inputs.clone().into_iter().map(Cell::string).collect()), "change-addr" => local_proposal.change.as_ref().and_then(|change| Address::from_script(change.script(), party.wallet().network())).map(Cell::string).unwrap_or(Cell::Empty), "change-value" => local_proposal.change.as_ref().map(|change| Cell::Amount(change.value())).unwrap_or(Cell::Empty), - "tags" => Cell::List(local_proposal.tags.iter().map(Cell::string).map(Box::new).collect()), - "string" => Cell::string(local_proposal.proposal.clone().into_versioned()), + "tags" => Cell::List(local_proposal.tags.iter().map(Cell::string).collect()), + "string" => Cell::string(local_proposal.proposal.into_versioned()), }, BetOrProp::Bet(bet) | BetOrProp::OfferedBet { @@ -568,7 +564,7 @@ pub fn run_bet_cmd( "event-id" => Cell::string(&bet.oracle_event.event.id), "oracle" => Cell::string(&bet.oracle_id), "outcome-time" => bet.oracle_event.event.expected_outcome_time.map(Cell::datetime).unwrap_or(Cell::Empty), - "my-inputs" => Cell::List(bet.my_inputs().into_iter().map(|x| Box::new(Cell::string(x))).collect()), + "my-inputs" => Cell::List(bet.my_inputs().into_iter().map(Cell::string).collect()), "bet-outpoint" => Cell::string(bet.outpoint()), "bet-value" => Cell::Amount(bet.joint_output_value), "bet-descriptor" => Cell::string(bet.joint_output.descriptor()), @@ -576,7 +572,7 @@ pub fn run_bet_cmd( BetState::Claimed { txid, .. } => Cell::string(txid), _ => Cell::Empty }, - "tags" => Cell::List(bet.tags.iter().map(Cell::string).map(Box::new).collect()) + "tags" => Cell::List(bet.tags.iter().map(Cell::string).collect()) }, }) } @@ -603,7 +599,7 @@ pub fn run_bet_cmd( "oracle" => Cell::string(oracle), "event-id" => Cell::string(event_id), "value" => Cell::Amount(value), - "inputs" => Cell::List(inputs.into_iter().map(|x| Box::new(Cell::string(x))).collect()), + "inputs" => Cell::List(inputs.into_iter().map(Cell::string).collect()), "public-key" => Cell::string(public_key), "change-script" => change_script.map(|x| Cell::string(Script::from(x))).unwrap_or(Cell::Empty) }, @@ -654,7 +650,7 @@ pub fn run_bet_cmd( "their-choice" => Cell::string(chosen_outcome.outcome_string()), "public-key" => Cell::string(&offer_public_key), "change-script" => change.map(|x| Cell::string(x.script())).unwrap_or(Cell::Empty), - "inputs" => Cell::List(inputs.into_iter().map(|x| Cell::string(x.outpoint)).map(Box::new).collect()), + "inputs" => Cell::List(inputs.into_iter().map(|x| Cell::string(x.outpoint)).collect()), "valid" => Cell::string(valid), "fee" => fee.map(Cell::Amount).unwrap_or(Cell::Empty), "feerate" => feerate.map(|x| Cell::string(x.as_sat_vb())).unwrap_or(Cell::Empty), @@ -711,9 +707,9 @@ pub fn run_bet_cmd( let party = cmd::load_party(wallet_dir)?; let (ciphertext, mut cipher) = reply(&party.keychain, proposal, message); let (ciphertext_str, overflow) = ciphertext.to_string_padded(pad, &mut cipher); - if let Some(overflow) = overflow { + if overflow > 0 && pad != 0 { eprintln!( - "WARNING: ciphertext is longer than {} -- it needs to be cut down by {} to fit", + "WARNING: ciphertext is longer than {} by {} bytes so it will look unusually big", pad, overflow ); } @@ -767,14 +763,7 @@ fn list_bets(bet_db: &BetDatabase) -> CmdOutput { ), Cell::Amount(local_proposal.proposal.value), Cell::Empty, - Cell::List( - local_proposal - .tags - .iter() - .map(Cell::string) - .map(Box::new) - .collect(), - ), + Cell::List(local_proposal.tags.iter().map(Cell::string).collect()), Cell::string(local_proposal.proposal.oracle), Cell::Empty, Cell::string(local_proposal.proposal.event_id.short_id()), @@ -800,7 +789,7 @@ fn list_bets(bet_db: &BetDatabase) -> CmdOutput { ), Cell::Amount(bet.local_value), Cell::Amount(bet.joint_output_value.checked_sub(bet.local_value).unwrap()), - Cell::List(bet.tags.iter().map(Cell::string).map(Box::new).collect()), + Cell::List(bet.tags.iter().map(Cell::string).collect()), Cell::string(&bet.oracle_id), Cell::String(bet.my_outcome().outcome_string()), Cell::string(bet.oracle_event.event.id.short_id()), @@ -831,10 +820,10 @@ fn get_oracle_event_from_url( ) -> anyhow::Result<(OracleEvent, OracleInfo, bool)> { let oracle_id = url.host_str().ok_or(anyhow!("url {} missing host", url))?; - let event_response = reqwest::blocking::get(url.clone())? - .error_for_status() + let event_response = ureq::get(url.as_str()) + .call() .with_context(|| format!("while getting {}", url))? - .json::() + .into_json::() .with_context(|| { format!( "while decoding the response from {}. Are you sure this is a valid event url?", @@ -903,21 +892,19 @@ fn bet_prompt(bet: &Bet, bet_verb: &str, you_paying_fee: bool) -> String { ])); } - write!(&mut res, "{}", table.render()).unwrap(); - write!(&mut res, "\n").unwrap(); - write!( + writeln!(&mut res, "{}", table.render()).unwrap(); + writeln!( &mut res, - "You are betting that {}", + "You are betting that {}.", olivia_describe::outcome(&outcome).positive ) .unwrap(); - write!(&mut res, "\n").unwrap(); if you_paying_fee { - write!(&mut res, "You are paying the fee.\n").unwrap(); + writeln!(&mut res, "You are paying the fee.").unwrap(); } else { - write!(&mut res, "you are NOT paying the fee.\n").unwrap(); + writeln!(&mut res, "you are NOT paying the fee.").unwrap(); } - write!(&mut res, "Do you want to {} this bet", bet_verb).unwrap(); + writeln!(&mut res, "Do you want to {} this bet", bet_verb).unwrap(); res } @@ -954,7 +941,7 @@ mod test { let (ciphertext, mut pad_cipher) = reply(&keychain, fixed, "a test message".into()); let (ciphertext_str, overflow) = &ciphertext.to_string_padded(385, &mut pad_cipher); - assert!(!overflow.is_some()); + assert_eq!(*overflow, 0); let ciphertext = Ciphertext::from_str(ciphertext_str).unwrap(); let (mut cipher, _) = ecdh(&proposal_keypair, &ciphertext.public_key); match ciphertext.decrypt(&mut cipher).unwrap() { diff --git a/src/cmd/init.rs b/src/cmd/init.rs index c767415..674ac75 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -29,7 +29,7 @@ pub struct InitOpt { } pub fn run_init( - wallet_dir: &PathBuf, + wallet_dir: &std::path::Path, InitOpt { network, n_words, @@ -69,14 +69,14 @@ pub fn run_init( if wallet_dir.exists() { return Err(anyhow!( "wallet directory {} already exists -- delete it to create a new wallet", - wallet_dir.as_path().display() + wallet_dir.display() )); } std::fs::create_dir(&wallet_dir)?; { - let mut config_file = wallet_dir.clone(); + let mut config_file = wallet_dir.to_path_buf(); config_file.push("config.json"); let config = Config::default_config(network); diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index d6bd733..e0cd3d7 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -29,7 +29,11 @@ use crate::{ FeeSpec, ValueChoice, }; use anyhow::anyhow; -use std::{collections::HashMap, fs, path::PathBuf}; +use std::{ + collections::HashMap, + fs, + path::{Path, PathBuf}, +}; #[derive(Clone, Debug, structopt::StructOpt)] pub struct FeeArgs { @@ -48,8 +52,8 @@ pub enum FeeChoice { Speed(u32), } -pub fn load_config(wallet_dir: &PathBuf) -> anyhow::Result { - let mut config_file = wallet_dir.clone(); +pub fn load_config(wallet_dir: &std::path::Path) -> anyhow::Result { + let mut config_file = wallet_dir.to_path_buf(); config_file.push("config.json"); match config_file.exists() { @@ -104,14 +108,14 @@ pub fn read_input( std::process::exit(2) } -pub fn get_seed_words_file(wallet_dir: &PathBuf) -> PathBuf { - let mut seed_words_file = wallet_dir.clone(); +pub fn get_seed_words_file(wallet_dir: &Path) -> PathBuf { + let mut seed_words_file = wallet_dir.to_path_buf(); seed_words_file.push("seed.txt"); seed_words_file } -pub fn load_bet_db(wallet_dir: &PathBuf) -> anyhow::Result { - let mut db_file = wallet_dir.clone(); +pub fn load_bet_db(wallet_dir: &Path) -> anyhow::Result { + let mut db_file = wallet_dir.to_path_buf(); db_file.push("database.sled"); let database = sled::open(db_file.to_str().unwrap())?; let bet_db = BetDatabase::new(database.open_tree("bets")?); @@ -119,7 +123,7 @@ pub fn load_bet_db(wallet_dir: &PathBuf) -> anyhow::Result { } pub fn load_party( - wallet_dir: &PathBuf, + wallet_dir: &Path, ) -> anyhow::Result> { let (wallet, bet_db, keychain, config) = load_wallet(wallet_dir).context("loading wallet")?; let party = Party::new(wallet, bet_db, keychain, config.blockchain); @@ -127,7 +131,7 @@ pub fn load_party( } pub fn load_wallet( - wallet_dir: &PathBuf, + wallet_dir: &std::path::Path, ) -> anyhow::Result<( Wallet, BetDatabase, @@ -139,14 +143,14 @@ pub fn load_wallet( if !wallet_dir.exists() { return Err(anyhow!( "No wallet found at {}. Run `gun init` to set a new one up or set --gun-dir.", - wallet_dir.as_path().display() + wallet_dir.display() )); } - let config = load_config(&wallet_dir).context("loading configuration")?; + let config = load_config(wallet_dir).context("loading configuration")?; let keychain = match config.keys { crate::config::WalletKeys::SeedWordsFile => { - let sw_file = get_seed_words_file(&wallet_dir); + let sw_file = get_seed_words_file(wallet_dir); let seed_words = fs::read_to_string(sw_file.clone()).context("loading seed words")?; let mnemonic = Mnemonic::from_phrase(&seed_words, Language::English).map_err(|e| { anyhow!( @@ -162,7 +166,7 @@ pub fn load_wallet( } }; let database = { - let mut db_file = wallet_dir.clone(); + let mut db_file = wallet_dir.to_path_buf(); db_file.push("database.sled"); sled::open(db_file.to_str().unwrap()).context("opening database.sled")? }; @@ -206,16 +210,14 @@ pub fn load_wallet( Ok((wallet, bet_db, keychain, config)) } -pub fn load_wallet_db(wallet_dir: &PathBuf) -> anyhow::Result { +pub fn load_wallet_db(wallet_dir: &std::path::Path) -> anyhow::Result { let database = { - let mut db_file = wallet_dir.clone(); + let mut db_file = wallet_dir.to_path_buf(); db_file.push("database.sled"); sled::open(db_file.to_str().unwrap()).context("opening database.sled")? }; - Ok(database - .open_tree("wallet") - .context("opening wallet tree")?) + database.open_tree("wallet").context("opening wallet tree") } pub struct TableData { @@ -231,7 +233,7 @@ pub enum Cell { Int(u64), Empty, DateTime(u64), - List(Vec>), + List(Vec), } impl From for Cell { @@ -279,7 +281,7 @@ impl Cell { .to_string(), List(list) => list .into_iter() - .map(|x| Cell::render(*x)) + .map(Cell::render) .collect::>() .join("\n"), } @@ -297,7 +299,7 @@ impl Cell { .to_string(), List(list) => list .into_iter() - .map(|x| Cell::render_tabs(*x)) + .map(Cell::render_tabs) .collect::>() .join(" "), } @@ -313,7 +315,7 @@ impl Cell { Empty => serde_json::Value::Null, List(list) => serde_json::Value::Array( list.into_iter() - .map(|x| serde_json::to_value(&*x).unwrap()) + .map(|x| serde_json::to_value(&x).unwrap()) .collect(), ), } @@ -366,13 +368,11 @@ impl CmdOutput { } table.render() } - List(list) => format!( - "{}", - list.into_iter() - .map(Cell::render) - .collect::>() - .join("\n") - ), + List(list) => list + .into_iter() + .map(Cell::render) + .collect::>() + .join("\n"), EmphasisedItem { main, .. } => main.1.render(), None => return Option::None, }) @@ -403,15 +403,11 @@ impl CmdOutput { .map(|(k, v)| format!("{}\t{}", k, v.render_tabs())) .collect::>() .join("\n"), - List(list) => { - format!( - "{}", - list.into_iter() - .map(Cell::render_tabs) - .collect::>() - .join("\t") - ) - } + List(list) => list + .into_iter() + .map(Cell::render_tabs) + .collect::>() + .join("\t"), None => String::new(), } } diff --git a/src/cmd/oracle.rs b/src/cmd/oracle.rs index 6de2413..f8eebfe 100644 --- a/src/cmd/oracle.rs +++ b/src/cmd/oracle.rs @@ -1,6 +1,6 @@ use crate::{ betting::{BetDatabase, OracleInfo}, - cmd, item, reqwest, Url, + cmd, item, Url, }; use anyhow::anyhow; use olivia_core::{http::RootResponse, OracleId}; @@ -46,9 +46,9 @@ pub fn run_oralce_cmd(bet_db: BetDatabase, cmd: OracleOpt) -> anyhow::Result(oracle_id.clone())? { Some(_) => eprintln!("oracle {} is already trusted", oracle_id), None => { - let root_response = reqwest::blocking::get(url)? - .error_for_status()? - .json::>()?; + let root_response = ureq::get(url.as_str()) + .call()? + .into_json::>()?; let oracle_info = OracleInfo { id: oracle_id, oracle_keys: root_response.public_keys, @@ -56,8 +56,8 @@ pub fn run_oralce_cmd(bet_db: BetDatabase, cmd: OracleOpt) -> anyhow::Result anyhow::Result { if currently_used .iter() - .find(|outpoint| local_utxo.outpoint == **outpoint) - .is_some() + .any(|outpoint| local_utxo.outpoint == *outpoint) { (confirmed, unconfirmed, in_use + value) } else if is_confirmed { @@ -91,7 +90,10 @@ pub enum AddressOpt { Show { address: Address }, } -pub fn get_address(wallet_dir: &PathBuf, addr_opt: AddressOpt) -> anyhow::Result { +pub fn get_address( + wallet_dir: &std::path::Path, + addr_opt: AddressOpt, +) -> anyhow::Result { match addr_opt { AddressOpt::New => { let (wallet, _, _, _) = load_wallet(wallet_dir)?; @@ -120,7 +122,7 @@ pub fn get_address(wallet_dir: &PathBuf, addr_opt: AddressOpt) -> anyhow::Result .iter() .take(index as usize + 1) .map(|script| { - let address = Address::from_script(&script, config.network).unwrap(); + let address = Address::from_script(script, config.network).unwrap(); let value = map .get(script) .map(|utxos| { @@ -243,7 +245,7 @@ impl SpendOpt { let in_use = party.bet_db().currently_used_utxos(&[])?; - if !spend_in_use && in_use.len() > 0 { + if !spend_in_use && !in_use.is_empty() { eprintln!( "note that {} utxos are not availble becuase they are in use", in_use.len() @@ -296,7 +298,7 @@ impl SpendOpt { Ok(output) } } -pub fn run_send(wallet_dir: &PathBuf, send_opt: SendOpt) -> anyhow::Result { +pub fn run_send(wallet_dir: &std::path::Path, send_opt: SendOpt) -> anyhow::Result { let SendOpt { to, value, @@ -319,7 +321,10 @@ pub enum TransactionOpt { Show { txid: Txid }, } -pub fn run_transaction_cmd(wallet_dir: &PathBuf, opt: TransactionOpt) -> anyhow::Result { +pub fn run_transaction_cmd( + wallet_dir: &std::path::Path, + opt: TransactionOpt, +) -> anyhow::Result { use TransactionOpt::*; let (wallet, _, _, _) = load_wallet(wallet_dir)?; @@ -393,10 +398,10 @@ pub enum UtxoOpt { Show { outpoint: OutPoint }, } -pub fn run_utxo_cmd(wallet_dir: &PathBuf, opt: UtxoOpt) -> anyhow::Result { +pub fn run_utxo_cmd(wallet_dir: &std::path::Path, opt: UtxoOpt) -> anyhow::Result { match opt { UtxoOpt::List => { - let party = load_party(&wallet_dir)?; + let party = load_party(wallet_dir)?; let in_use_utxos = party.bet_db().currently_used_utxos(&[])?; let wallet = party.wallet(); let rows = wallet @@ -501,7 +506,7 @@ pub struct SplitOpt { spend_opt: SpendOpt, } -pub fn run_split_cmd(wallet_dir: &PathBuf, opt: SplitOpt) -> anyhow::Result { +pub fn run_split_cmd(wallet_dir: &std::path::Path, opt: SplitOpt) -> anyhow::Result { let SplitOpt { output_size, n, diff --git a/src/config.rs b/src/config.rs index e52eb75..6ddaf67 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,26 +28,19 @@ pub struct Config { impl Config { pub fn default_config(network: Network) -> Config { use Network::*; - let concurrency = Some(4); - let blockchain = match network { - Bitcoin => AnyBlockchainConfig::Esplora(EsploraBlockchainConfig { - base_url: "https://mempool.space/api".to_string(), - concurrency, - stop_gap: 10, - }), - Testnet => AnyBlockchainConfig::Esplora(EsploraBlockchainConfig { - base_url: "https://blockstream.info/testnet/api".to_string(), - concurrency, - stop_gap: 10, - }), - Regtest => AnyBlockchainConfig::Esplora(EsploraBlockchainConfig { - base_url: "http://localhost:3000".to_string(), - concurrency, - stop_gap: 10, - }), + let url = match network { + Bitcoin => "https://mempool.space/api", + Testnet => "https://blockstream.info/testnet/api", + Regtest => "http://localhost:3000", Signet => unimplemented!("signet not supported yet!"), }; + let blockchain = AnyBlockchainConfig::Esplora(EsploraBlockchainConfig { + concurrency: Some(10), + stop_gap: 10, + ..EsploraBlockchainConfig::new(url.into()) + }); + Config { network, blockchain, diff --git a/src/fee_spec.rs b/src/fee_spec.rs index b6e28f8..263c9a2 100644 --- a/src/fee_spec.rs +++ b/src/fee_spec.rs @@ -74,7 +74,7 @@ impl FromStr for FeeSpec { return Ok(FeeSpec::Height(in_blocks)); } - return Err(anyhow!("{} is not a valid fee specification")); + Err(anyhow!("{} is not a valid fee specification")) } } diff --git a/src/lib.rs b/src/lib.rs index 8df54e7..376ef1a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![allow(non_snake_case)] +#![allow(non_snake_case, clippy::or_fun_call, clippy::vec_init_then_push)] use std::str::FromStr; @@ -14,12 +14,11 @@ mod fee_spec; pub mod keychain; pub mod psbt_ext; pub use fee_spec::*; -pub use reqwest; pub use chacha20::cipher; pub use olivia_core::chrono; pub use olivia_secp256k1::schnorr_fun::fun::{hex, rand_core}; -pub use reqwest::Url; +pub use url::Url; #[derive(Clone, Debug)] pub enum ValueChoice { @@ -44,8 +43,7 @@ impl FromStr for ValueChoice { pub(crate) fn placeholder_point( ) -> olivia_secp256k1::fun::Point { use olivia_secp256k1::fun::marker::*; - olivia_secp256k1::fun::G - .clone() + (*olivia_secp256k1::fun::G) .mark::() .into_point_with_even_y() .0 diff --git a/tests/end_to_end.rs b/tests/end_to_end.rs index f9e94a1..50aaa44 100644 --- a/tests/end_to_end.rs +++ b/tests/end_to_end.rs @@ -35,7 +35,7 @@ fn create_party( "http://{}", test_client.electrsd.esplora_url.as_ref().unwrap() ); - let esplora = EsploraBlockchain::new(&esplora_url, None, 5); + let esplora = EsploraBlockchain::new(&esplora_url, 5); let wallet = Wallet::new(descriptor, None, Network::Regtest, db, esplora) .context("Initializing wallet failed")?; @@ -60,11 +60,7 @@ fn create_party( wallet, bet_db, keychain, - AnyBlockchainConfig::Esplora(EsploraBlockchainConfig { - base_url: esplora_url, - concurrency: None, - stop_gap: 5, - }), + AnyBlockchainConfig::Esplora(EsploraBlockchainConfig::new(esplora_url)), ); Ok(party) } @@ -517,7 +513,6 @@ fn create_proposal_with_dust_change() { setup_test!(); let balance = party_1.wallet().get_balance().unwrap(); - dbg!(&balance); let bet_value = balance - 250; let local_proposal = party_1