diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index f8191be6..267b3173 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -50,17 +50,21 @@ jobs: ref: ${{ github.event.release.target_commitish }} token: ${{ secrets.BOTTY_GITHUB_TOKEN }} - - uses: Swatinem/rust-cache@v2.0.2 + - uses: Swatinem/rust-cache@v2.2.0 - - name: Install compiler for armhf arch - if: matrix.target == 'armv7-unknown-linux-gnueabihf' - run: | - sudo apt-get update - sudo apt-get install gcc-arm-linux-gnueabihf + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + target: armv7-unknown-linux-gnueabihf + override: true - name: Build ${{ matrix.target }} ${{ matrix.bin }} release binary - - run: cargo build --target=${{ matrix.target }} --release --package swap --bin ${{ matrix.bin }} + uses: actions-rs/cargo@v1 + with: + command: build + args: --target=${{ matrix.target }} --release --package swap --bin ${{ matrix.bin }} + use-cross: true - name: Smoke test the binary if: matrix.target != 'armv7-unknown-linux-gnueabihf' # armv7-unknown-linux-gnueabihf is only cross-compiled, no smoke test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e16167ec..9d606e81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v3.1.0 - - uses: Swatinem/rust-cache@v2.0.2 + - uses: Swatinem/rust-cache@v2.2.0 - name: Check formatting uses: dprint/check@v2.1 @@ -26,6 +26,36 @@ jobs: - name: Run clippy with all features enabled run: cargo clippy --workspace --all-targets --all-features -- -D warnings + bdk_test: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v3.1.0 + + - uses: Swatinem/rust-cache@v2.0.2 + + - name: Build swap + run: cargo build --bin swap + + - name: Run BDK regression script + run: ./swap/tests/bdk.sh + + sqlx_test: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v3.1.0 + + - uses: Swatinem/rust-cache@v2.0.2 + + - name: Install sqlx-cli + run: cargo install sqlx-cli + + - name: Run sqlite_dev_setup.sh script + run: | + cd swap + ./sqlite_dev_setup.sh + build: strategy: matrix: @@ -43,26 +73,38 @@ jobs: - name: Checkout sources uses: actions/checkout@v3.1.0 - - uses: Swatinem/rust-cache@v2.0.2 + - uses: Swatinem/rust-cache@v2.2.0 - - name: Install compiler for armhf arch - if: matrix.target == 'armv7-unknown-linux-gnueabihf' - run: | - sudo apt-get update - sudo apt-get install gcc-arm-linux-gnueabihf + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + target: armv7-unknown-linux-gnueabihf + override: true - name: Build binary - run: | - cargo build -p swap --target ${{ matrix.target }} + if: matrix.target != 'armv7-unknown-linux-gnueabihf' + uses: actions-rs/cargo@v1 + with: + command: build + args: -p swap --target ${{ matrix.target }} + + - name: Build binary (armv7) + if: matrix.target == 'armv7-unknown-linux-gnueabihf' + uses: actions-rs/cargo@v1 + with: + command: build + args: -p swap --target ${{ matrix.target }} + use-cross: true - name: Upload swap binary - uses: actions/upload-artifact@v2-preview + uses: actions/upload-artifact@v3 with: name: swap-${{ matrix.target }} path: target/${{ matrix.target }}/debug/swap - name: Upload asb binary - uses: actions/upload-artifact@v2-preview + uses: actions/upload-artifact@v3 with: name: asb-${{ matrix.target }} path: target/${{ matrix.target }}/debug/asb @@ -76,7 +118,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v3.1.0 - - uses: Swatinem/rust-cache@v2.0.2 + - uses: Swatinem/rust-cache@v2.2.0 - name: Build tests run: cargo build --tests --workspace --all-features @@ -112,7 +154,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v3.1.0 - - uses: Swatinem/rust-cache@v2.0.2 + - uses: Swatinem/rust-cache@v2.2.0 - name: Run test ${{ matrix.test_name }} run: cargo test --package swap --all-features --test ${{ matrix.test_name }} -- --nocapture diff --git a/.gitignore b/.gitignore index 905e678b..9b4798c4 100644 --- a/.gitignore +++ b/.gitignore @@ -159,4 +159,5 @@ flycheck_*.el # End of https://www.toptal.com/developers/gitignore/api/rust,clion+all,emacs *.log -.vscode \ No newline at end of file +.vscode +swap/tempdb diff --git a/Cargo.lock b/Cargo.lock index e650676b..3232e4e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,9 +45,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ "getrandom 0.2.6", "once_cell", @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" dependencies = [ "proc-macro2", "quote", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "atoi" -version = "0.4.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616896e05fc0e2649463a93a15183c6a16bf03413a7af88ef1285ddedfa9cda5" +checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" dependencies = [ "num-traits", ] @@ -163,7 +163,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3410529e8288c463bedb5930f82833bc0c90e5d2fe639a56582a4d09220b281" dependencies = [ - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -177,12 +177,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - [[package]] name = "autocfg" version = "1.0.1" @@ -230,29 +224,21 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "base64-compat" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a8d4d2746f89841e49230dd26917df1876050f95abafafbe34f47cb534b88d7" -dependencies = [ - "byteorder", -] - [[package]] name = "bdk" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a03818e03fb03c159053bf474a23c474c92796cc0ebc5f677512e989ee449c04" +checksum = "c50e3f08fbcd7eb34f11e066a1353986d583f1f87af70f7cd50bff9fce97c817" dependencies = [ "async-trait", "bdk-macros", "bitcoin", "electrum-client", + "getrandom 0.2.6", "js-sys", "log", "miniscript", - "rand 0.7.3", + "rand 0.8.3", "serde", "serde_json", "sled", @@ -272,9 +258,9 @@ dependencies = [ [[package]] name = "bech32" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9ff0bbfd639f15c74af777d81383cf53efb7c93613f6cab67c6c11e05bbf8b" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" [[package]] name = "big-bytes" @@ -314,11 +300,11 @@ checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitcoin" -version = "0.28.1" +version = "0.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05bba324e6baf655b882df672453dbbc527bc938cadd27750ae510aaccc3a66a" +checksum = "0694ea59225b0c5f3cb405ff3f670e4828358ed26aec49dc352f730f0cb1a8a3" dependencies = [ - "base64-compat", + "base64 0.13.1", "bech32", "bitcoin_hashes", "secp256k1", @@ -327,8 +313,9 @@ dependencies = [ [[package]] name = "bitcoin-harness" -version = "0.2.0" -source = "git+https://github.com/coblox/bitcoin-harness-rs?rev=bff9a64b5cd75dec2ce807cbfade7b98c2e1e0d4#bff9a64b5cd75dec2ce807cbfade7b98c2e1e0d4" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b6a18713ec8acbc96d1e843f6998f00e8c5d81173e38760023b84926b8db3b8" dependencies = [ "base64 0.12.3", "bitcoin", @@ -348,18 +335,18 @@ dependencies = [ [[package]] name = "bitcoin_hashes" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006cc91e1a1d99819bc5b8214be3555c1f0611b169f527a1fdc54ed1f2b745b0" +checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" dependencies = [ "serde", ] [[package]] name = "bitcoincore-rpc-json" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e2ae16202721ba8c3409045681fac790a5ddc791f05731a2df22c0c6bffc0f1" +checksum = "c231bea28e314879c5aef240f6052e8a72a369e3c9f9b20d9bfbb33ad18029b2" dependencies = [ "bitcoin", "serde", @@ -429,6 +416,51 @@ dependencies = [ "serde_with", ] +[[package]] +name = "borsh" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" +dependencies = [ + "borsh-derive", + "hashbrown 0.11.2", +] + +[[package]] +name = "borsh-derive" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "bs58" version = "0.4.0" @@ -441,6 +473,27 @@ version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" +[[package]] +name = "bytecheck" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d11cac2c12b5adc6570dad2ee1b87eff4955dac476fe12d81e5fdd352e52406f" +dependencies = [ + "bytecheck_derive", + "ptr_meta", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "bytemuck" version = "1.5.1" @@ -455,9 +508,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.0.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] name = "bzip2" @@ -570,15 +623,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "color_quant" version = "1.1.0" @@ -587,9 +631,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "comfy-table" -version = "6.1.2" +version = "6.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1090f39f45786ec6dc6286f8ea9c75d0a7ef0a0d3cda674cef0c3af7b307fbc2" +checksum = "e621e7e86c46fd8a14c32c6ae3cb95656621b4743a27d0cffedb831d46e7ad21" dependencies = [ "crossterm", "strum", @@ -687,18 +731,18 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "crc" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10c2722795460108a7872e1cd933a85d6ec38abc4baecad51028f702da28889f" +checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3" dependencies = [ "crc-catalog", ] [[package]] name = "crc-catalog" -version = "1.1.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" +checksum = "2d0165d2900ae6778e36e80bbc4da3b5eefccee9ba939761f9c2882a5d9af3ff" [[package]] name = "crc32fast" @@ -734,9 +778,9 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.1" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6cb3c7f5b8e51bc3ebb73a2327ad4abdbd119dc13223f14f961d2f38486756" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -761,7 +805,7 @@ dependencies = [ "bitflags", "crossterm_winapi", "libc", - "mio 0.8.4", + "mio", "parking_lot 0.12.0", "signal-hook", "signal-hook-mio", @@ -966,10 +1010,10 @@ dependencies = [ ] [[package]] -name = "dotenv" -version = "0.15.0" +name = "dotenvy" +version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" [[package]] name = "dtoa" @@ -980,12 +1024,11 @@ checksum = "5caaa75cbd2b960ff1e5392d2cfb1f44717fffe12fc1f32b7b5d1267f99732a6" [[package]] name = "ecdsa_fun" version = "0.7.1" -source = "git+https://github.com/LLFourn/secp256kfun#7f1ae3db3933e215ae59f115f20c2a4eea23fb29" +source = "git+https://github.com/LLFourn/secp256kfun#da6ffd2ef4d58c84d508428356c92d92d5f11ac4" dependencies = [ "bincode", "rand_chacha 0.3.1", "secp256kfun", - "serde", "sigma_fun", ] @@ -1023,9 +1066,9 @@ dependencies = [ [[package]] name = "electrum-client" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af53c415260dcb220fa02182669727c730535bfed4edbfde42e1291342af95cd" +checksum = "82a232d46710f8064b7bb2029d82819fc1f5fba053687e0e3bb47cc762af24f6" dependencies = [ "bitcoin", "byteorder", @@ -1068,24 +1111,30 @@ dependencies = [ [[package]] name = "enum-iterator" -version = "0.6.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79a6321a1197d7730510c7e3f6cb80432dfefecb32426de8cea0aa19b4bb8d7" +checksum = "45a0ac4aeb3a18f92eaf09c6bb9b3ac30ff61ca95514fc58cbead1c9a6bf5401" dependencies = [ "enum-iterator-derive", ] [[package]] name = "enum-iterator-derive" -version = "0.6.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e94aa31f7c0dc764f57896dc615ddd76fc13b0d5dca7eb6cc5e018a5a09ec06" +checksum = "828de45d0ca18782232dfb8f3ea9cc428e8ced380eb26a520baaacfc70de39ce" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "fastrand" version = "1.7.0" @@ -1138,6 +1187,18 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "flume" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +dependencies = [ + "futures-core", + "futures-sink", + "pin-project 1.0.5", + "spin 0.9.4", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1320,10 +1381,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -1339,9 +1398,9 @@ dependencies = [ [[package]] name = "getset" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b328c01a4d71d2d8173daa93562a73ab0fe85616876f02500f53d82948c504" +checksum = "e45727250e75cc04ff2846a66397da8ef2b3db8e40e0cef4df67950a07621eb9" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1361,9 +1420,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.13.20" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9831e983241f8c5591ed53f17d874833e2fa82cac2625f3888c50cbfe136cba" +checksum = "d0155506aab710a86160ddb504a480d2964d7ab5b9e62419be69e0032bc5931c" dependencies = [ "bitflags", "libc", @@ -1407,12 +1466,21 @@ dependencies = [ ] [[package]] -name = "hashlink" -version = "0.7.0" +name = "hashbrown" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "hashbrown", + "ahash", +] + +[[package]] +name = "hashlink" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" +dependencies = [ + "hashbrown 0.12.3", ] [[package]] @@ -1429,6 +1497,9 @@ name = "heck" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +dependencies = [ + "unicode-segmentation", +] [[package]] name = "hermit-abi" @@ -1526,9 +1597,9 @@ checksum = "05842d0d43232b23ccb7060ecb0f0626922c21f30012e97b767b30afd4a5d4b9" [[package]] name = "hyper" -version = "0.14.22" +version = "0.14.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abfba89e19b959ca163c7752ba59d737c1ceea53a5d31a149c805446fc958064" +checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" dependencies = [ "bytes", "futures-channel", @@ -1541,7 +1612,7 @@ dependencies = [ "httpdate", "itoa 1.0.1", "pin-project-lite 0.2.9", - "socket2 0.4.0", + "socket2 0.4.7", "tokio", "tower-service", "tracing", @@ -1618,8 +1689,8 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" dependencies = [ - "autocfg 1.0.1", - "hashbrown", + "autocfg", + "hashbrown 0.11.2", ] [[package]] @@ -1749,15 +1820,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.121" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "libgit2-sys" -version = "0.12.21+1.1.0" +version = "0.13.4+1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86271bacd72b2b9e854c3dcfb82efd538f15f870e4c11af66900effb462f6825" +checksum = "d0fa6563431ede25f5cc7f6d803c6afbc1c5d3ad3d4925d12c882bf2b526f5d1" dependencies = [ "cc", "libc", @@ -2013,7 +2084,7 @@ dependencies = [ "libc", "libp2p-core", "log", - "socket2 0.4.0", + "socket2 0.4.7", "tokio", ] @@ -2050,9 +2121,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.22.2" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290b64917f8b0cb885d9de0f9959fe1f775d7fa12f1da2db9001c1c8ab60f89d" +checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" dependencies = [ "cc", "pkg-config", @@ -2101,7 +2172,7 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32613e41de4c47ab04970c348ca7ae7382cf116625755af070b008a15516a889" dependencies = [ - "hashbrown", + "hashbrown 0.11.2", ] [[package]] @@ -2155,7 +2226,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" dependencies = [ - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -2172,9 +2243,9 @@ checksum = "0c835948974f68e0bd58636fc6c5b1fbff7b297e3046f11b3b3c18bbac012c6d" [[package]] name = "miniscript" -version = "7.0.0" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da39fc7a8adea97a677337b0091779dd86349226b869053af496584a9b9e5847" +checksum = "7f4975078076f0b7b914a3044ad7432d2a7fcec38edb855afdc672e24ca35b69" dependencies = [ "bitcoin", "serde", @@ -2189,19 +2260,6 @@ dependencies = [ "adler32", ] -[[package]] -name = "mio" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2182a122f3b7f3f5329cb1972cee089ba2459a0a80a56935e6e674f096f8d839" -dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "winapi", -] - [[package]] name = "mio" version = "0.8.4" @@ -2214,16 +2272,6 @@ dependencies = [ "windows-sys 0.36.1", ] -[[package]] -name = "miow" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" -dependencies = [ - "socket2 0.3.19", - "winapi", -] - [[package]] name = "monero" version = "0.12.0" @@ -2337,7 +2385,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.0", "proc-macro-error", "proc-macro2", "quote", @@ -2393,15 +2441,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "ntapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi", -] - [[package]] name = "num" version = "0.1.42" @@ -2444,7 +2483,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg 1.0.1", + "autocfg", "num-traits", ] @@ -2454,7 +2493,7 @@ version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" dependencies = [ - "autocfg 1.0.1", + "autocfg", "num-integer", "num-traits", ] @@ -2477,7 +2516,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" dependencies = [ - "autocfg 1.0.1", + "autocfg", "num-integer", "num-traits", ] @@ -2488,7 +2527,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -2501,15 +2540,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_threads" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ba99ba6393e2c3734791401b66902d981cb03bf190af674ca69949b6d5fb15" -dependencies = [ - "libc", -] - [[package]] name = "once_cell" version = "1.13.0" @@ -2608,6 +2638,12 @@ dependencies = [ "windows-sys 0.32.0", ] +[[package]] +name = "paste" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" + [[package]] name = "pem" version = "1.1.0" @@ -2750,6 +2786,15 @@ dependencies = [ "uint", ] +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + [[package]] name = "proc-macro-crate" version = "1.1.0" @@ -2786,9 +2831,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ "unicode-ident", ] @@ -2807,7 +2852,7 @@ dependencies = [ "quick-error 2.0.0", "rand 0.8.3", "rand_chacha 0.3.1", - "rand_xorshift 0.3.0", + "rand_xorshift", "regex-syntax", "rusty-fork", "tempfile", @@ -2866,6 +2911,26 @@ dependencies = [ "prost", ] +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "qrcode" version = "0.12.0" @@ -2901,9 +2966,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.9" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -2921,25 +2986,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift 0.1.1", - "winapi", -] - [[package]] name = "rand" version = "0.7.3" @@ -2965,16 +3011,6 @@ dependencies = [ "rand_hc 0.3.0", ] -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", -] - [[package]] name = "rand_chacha" version = "0.2.2" @@ -3028,15 +3064,6 @@ dependencies = [ "getrandom 0.2.6", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -3055,59 +3082,6 @@ dependencies = [ "rand_core 0.6.2", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_xorshift" version = "0.3.0" @@ -3182,10 +3156,19 @@ dependencies = [ ] [[package]] -name = "reqwest" -version = "0.11.12" +name = "rend" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" +checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "reqwest" +version = "0.11.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" dependencies = [ "base64 0.13.1", "bytes", @@ -3212,7 +3195,7 @@ dependencies = [ "tokio", "tokio-rustls 0.23.1", "tokio-socks", - "tokio-util 0.7.2", + "tokio-util 0.7.3", "tower-service", "url", "wasm-bindgen", @@ -3241,28 +3224,60 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", + "spin 0.5.2", "untrusted", "web-sys", "winapi", ] [[package]] -name = "rust_decimal" -version = "1.26.1" +name = "rkyv" +version = "0.7.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee9164faf726e4f3ece4978b25ca877ddc6802fa77f38cdccb32c7f805ecd70c" +checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15" +dependencies = [ + "bytecheck", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eaedadc88b53e36dd32d940ed21ae4d850d5916f2581526921f553a72ac34c4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "rust_decimal" +version = "1.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c321ee4e17d2b7abe12b5d20c1231db708dd36185c8a21e9de5fed6da4dbe9" dependencies = [ "arrayvec 0.7.2", + "borsh", + "bytecheck", + "byteorder", + "bytes", "num-traits", + "rand 0.8.3", + "rkyv", "serde", + "serde_json", ] [[package]] name = "rust_decimal_macros" -version = "1.26.1" +version = "1.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4903d8db81d2321699ca8318035d6ff805c548868df435813968795a802171b2" +checksum = "5a7e2dba1342e9f1166786a4329ba0d6d6b8d9db7e81d702ec9ba3b39591ddff" dependencies = [ "quote", "rust_decimal", @@ -3337,9 +3352,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.4" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" [[package]] name = "rusty-fork" @@ -3407,21 +3422,28 @@ dependencies = [ ] [[package]] -name = "secp256k1" -version = "0.22.1" +name = "seahash" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "secp256k1" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff55dc09d460954e9ef2fa8a7ced735a964be9981fd50e870b2b3b0705e14964" dependencies = [ - "rand 0.6.5", + "bitcoin_hashes", + "rand 0.8.3", "secp256k1-sys", "serde", ] [[package]] name = "secp256k1-sys" -version = "0.5.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "152e20a0fd0519390fc43ab404663af8a0b794273d2a91d60ad4a39f13ffe110" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" dependencies = [ "cc", ] @@ -3429,7 +3451,7 @@ dependencies = [ [[package]] name = "secp256kfun" version = "0.7.1" -source = "git+https://github.com/LLFourn/secp256kfun#7f1ae3db3933e215ae59f115f20c2a4eea23fb29" +source = "git+https://github.com/LLFourn/secp256kfun#da6ffd2ef4d58c84d508428356c92d92d5f11ac4" dependencies = [ "digest 0.10.5", "rand_core 0.6.2", @@ -3481,9 +3503,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" dependencies = [ "serde_derive", ] @@ -3510,9 +3532,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", @@ -3521,11 +3543,10 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" dependencies = [ - "indexmap", "itoa 1.0.1", "ryu", "serde", @@ -3626,7 +3647,7 @@ dependencies = [ [[package]] name = "sigma_fun" version = "0.4.1" -source = "git+https://github.com/LLFourn/secp256kfun#7f1ae3db3933e215ae59f115f20c2a4eea23fb29" +source = "git+https://github.com/LLFourn/secp256kfun#da6ffd2ef4d58c84d508428356c92d92d5f11ac4" dependencies = [ "curve25519-dalek-ng", "digest 0.10.5", @@ -3653,7 +3674,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", - "mio 0.8.4", + "mio", "signal-hook", ] @@ -3696,9 +3717,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.6.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "snow" @@ -3731,9 +3752,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.0" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", "winapi", @@ -3771,10 +3792,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] -name = "sqlformat" -version = "0.1.8" +name = "spin" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b7922be017ee70900be125523f38bdd644f4f06a1b16e8fa5a8ee8c34bffd4" +checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +dependencies = [ + "lock_api", +] + +[[package]] +name = "sqlformat" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87e292b4291f154971a43c3774364e2cbcaec599d3f5bf6fa9d122885dbc38a" dependencies = [ "itertools", "nom 7.0.0", @@ -3783,9 +3813,9 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.5.9" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7911b0031a0247af40095838002999c7a52fba29d9739e93326e71a5a1bc9d43" +checksum = "9249290c05928352f71c077cc44a464d880c63f26f7534728cca008e135c0428" dependencies = [ "sqlx-core", "sqlx-macros", @@ -3793,9 +3823,9 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.5.9" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aec89bfaca8f7737439bad16d52b07f1ccd0730520d3bf6ae9d069fe4b641fb1" +checksum = "dcbc16ddba161afc99e14d1713a453747a2b07fc097d2009f4c300ec99286105" dependencies = [ "ahash", "atoi", @@ -3803,28 +3833,31 @@ dependencies = [ "byteorder", "bytes", "crc", - "crossbeam-channel", "crossbeam-queue", - "crossbeam-utils", + "dotenvy", "either", + "event-listener", + "flume", "futures-channel", "futures-core", + "futures-executor", "futures-intrusive", "futures-util", "hashlink", "hex", "indexmap", - "itoa 0.4.7", + "itoa 1.0.1", "libc", "libsqlite3-sys", "log", "memchr", "once_cell", - "parking_lot 0.11.2", + "paste", "percent-encoding", - "rustls 0.19.0", + "rustls 0.20.2", + "rustls-pemfile", "serde", - "sha2 0.9.8", + "sha2 0.10.6", "smallvec", "sqlformat", "sqlx-rt", @@ -3832,27 +3865,25 @@ dependencies = [ "thiserror", "tokio-stream", "url", - "webpki 0.21.4", - "webpki-roots 0.21.0", - "whoami", + "webpki-roots 0.22.2", ] [[package]] name = "sqlx-macros" -version = "0.5.9" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "584866c833511b1a152e87a7ee20dee2739746f60c858b3c5209150bc4b466f5" +checksum = "b850fa514dc11f2ee85be9d055c512aa866746adfacd1cb42d867d68e6a5b0d9" dependencies = [ - "dotenv", + "dotenvy", "either", - "heck 0.3.2", + "heck 0.4.0", "hex", "once_cell", "proc-macro2", "quote", "serde", "serde_json", - "sha2 0.9.8", + "sha2 0.10.6", "sqlx-core", "sqlx-rt", "syn", @@ -3861,13 +3892,13 @@ dependencies = [ [[package]] name = "sqlx-rt" -version = "0.5.9" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d1bd069de53442e7a320f525a6d4deb8bb0621ac7a55f7eccbc2b58b57f43d0" +checksum = "24c5b2d25fa654cc5f841750b8e1cdedbe21189bf9a9382ee90bfa9dd3562396" dependencies = [ "once_cell", "tokio", - "tokio-rustls 0.22.0", + "tokio-rustls 0.23.1", ] [[package]] @@ -4017,12 +4048,12 @@ dependencies = [ "tempfile", "testcontainers 0.12.0", "thiserror", - "time 0.3.16", + "time 0.3.17", "tokio", "tokio-socks", "tokio-tar", "tokio-tungstenite", - "tokio-util 0.7.2", + "tokio-util 0.7.3", "toml", "torut", "tracing", @@ -4038,9 +4069,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.98" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce" dependencies = [ "proc-macro2", "quote", @@ -4165,13 +4196,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca" +checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" dependencies = [ "itoa 1.0.1", - "libc", - "num_threads", "serde", "time-core", "time-macros", @@ -4185,9 +4214,9 @@ checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" [[package]] name = "time-macros" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" dependencies = [ "time-core", ] @@ -4218,19 +4247,20 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.16.1" +version = "1.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c27a64b625de6d309e8c57716ba93021dccf1b3b5c97edd6d3dd2d2135afc0a" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" dependencies = [ "bytes", "libc", "memchr", - "mio 0.7.10", + "mio", "num_cpus", "once_cell", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "pin-project-lite 0.2.9", "signal-hook-registry", + "socket2 0.4.7", "tokio-macros", "winapi", ] @@ -4282,9 +4312,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.4" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c535f53c0cfa1acace62995a8994fc9cc1f12d202420da96ff306ee24d576469" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" dependencies = [ "futures-core", "pin-project-lite 0.2.9", @@ -4339,9 +4369,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f988a1a1adc2fb21f9c12aa96441da33a1728193ae0b95d2be22dbd17fcb4e5c" +checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" dependencies = [ "bytes", "futures-core", @@ -4403,7 +4433,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" dependencies = [ "crossbeam-channel", - "time 0.3.16", + "time 0.3.17", "tracing-subscriber 0.3.15", ] @@ -4493,7 +4523,7 @@ dependencies = [ "serde_json", "sharded-slab", "thread_local", - "time 0.3.16", + "time 0.3.17", "tracing", "tracing-core", "tracing-log", @@ -4693,9 +4723,9 @@ checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" [[package]] name = "uuid" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" dependencies = [ "getrandom 0.2.6", "serde", @@ -4721,9 +4751,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "vergen" -version = "7.0.0" +version = "7.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4db743914c971db162f35bf46601c5a63ec4452e61461937b4c1ab817a60c12e" +checksum = "447f9238a4553957277b3ee09d80babeae0811f1b3baefb093de1c0448437a37" dependencies = [ "anyhow", "cfg-if 1.0.0", @@ -4732,7 +4762,7 @@ dependencies = [ "git2", "rustversion", "thiserror", - "time 0.3.16", + "time 0.3.17", ] [[package]] @@ -4908,16 +4938,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "whoami" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7741161a40200a867c96dfa5574544efa4178cf4c8f770b62dd1cc0362d7ae1" -dependencies = [ - "wasm-bindgen", - "web-sys", -] - [[package]] name = "widestring" version = "0.4.3" diff --git a/bors.toml b/bors.toml index b736980f..e02a79db 100644 --- a/bors.toml +++ b/bors.toml @@ -1,5 +1,7 @@ status = [ "static_analysis", + "bdk_test", + "sqlx_test", "build (x86_64-unknown-linux-gnu, ubuntu-latest)", "build (armv7-unknown-linux-gnueabihf, ubuntu-latest)", "build (x86_64-apple-darwin, macos-latest)", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 31b7ee14..7e23ef24 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -15,9 +15,9 @@ async-trait = "0.1" atty = "0.2" backoff = { version = "0.4", features = [ "tokio" ] } base64 = "0.13" -bdk = "0.23" +bdk = "0.24" big-bytes = "1" -bitcoin = { version = "0.28", features = [ "rand", "use-serde" ] } +bitcoin = { version = "0.29", features = [ "rand", "serde" ] } bmrng = "0.5" comfy-table = "6.1" config = { version = "0.11", default-features = false, features = [ "toml" ] } @@ -48,7 +48,7 @@ serde_json = "1" serde_with = { version = "1", features = [ "macros" ] } sha2 = "0.10" sigma_fun = { git = "https://github.com/LLFourn/secp256kfun", default-features = false, features = [ "ed25519", "serde", "secp256k1", "alloc" ] } -sqlx = { version = "0.5", features = [ "sqlite", "runtime-tokio-rustls", "offline" ] } +sqlx = { version = "0.6", features = [ "sqlite", "runtime-tokio-rustls", "offline" ] } structopt = "0.3" strum = { version = "0.24", features = [ "derive" ] } thiserror = "1" @@ -74,7 +74,7 @@ tokio-tar = "0.3" zip = "0.5" [dev-dependencies] -bitcoin-harness = { git = "https://github.com/coblox/bitcoin-harness-rs", rev = "bff9a64b5cd75dec2ce807cbfade7b98c2e1e0d4" } # waiting on crates.io release +bitcoin-harness = "0.2.2" get-port = "3" hyper = "0.14" monero-harness = { path = "../monero-harness" } diff --git a/swap/sqlite_dev_setup.sh b/swap/sqlite_dev_setup.sh old mode 100644 new mode 100755 index d07a763a..67d2c9da --- a/swap/sqlite_dev_setup.sh +++ b/swap/sqlite_dev_setup.sh @@ -1,6 +1,14 @@ -# crated temporary DB -# run the migration scripts to create the tables -# prepare the sqlx-data.json rust mappings +#!/bin/bash + +# run this script from the swap dir +# make sure you have sqlx-cli installed: cargo install sqlx-cli + +# this script creates a temporary sqlite database +# then runs the migration scripts to create the tables (migrations folder) +# then it prepares the offline sqlx-data.json rust mappings DATABASE_URL=sqlite:tempdb cargo sqlx database create DATABASE_URL=sqlite:tempdb cargo sqlx migrate run -DATABASE_URL=sqlite:./swap/tempdb cargo sqlx prepare -- --bin swap \ No newline at end of file +# needs the absolute path here +# https://github.com/launchbadge/sqlx/issues/1399 +DB_PATH=$(readlink -f tempdb) +DATABASE_URL="sqlite:$DB_PATH" cargo sqlx prepare -- --bin swap diff --git a/swap/sqlx-data.json b/swap/sqlx-data.json index 61254fc2..fd50cd87 100644 --- a/swap/sqlx-data.json +++ b/swap/sqlx-data.json @@ -1,7 +1,6 @@ { "db": "SQLite", "081c729a0f1ad6e4ff3e13d6702c946bc4d37d50f40670b4f51d2efcce595aa6": { - "query": "\n SELECT peer_id\n FROM peers\n WHERE swap_id = ?\n ", "describe": { "columns": [ { @@ -10,26 +9,26 @@ "type_info": "Text" } ], - "parameters": { - "Right": 1 - }, "nullable": [ false - ] - } + ], + "parameters": { + "Right": 1 + } + }, + "query": "\n SELECT peer_id\n FROM peers\n WHERE swap_id = ?\n " }, "0ab84c094964968e96a3f2bf590d9ae92227d057386921e0e57165b887de3c75": { - "query": "\n insert into peer_addresses (\n peer_id,\n address\n ) values (?, ?);\n ", "describe": { "columns": [], + "nullable": [], "parameters": { "Right": 2 - }, - "nullable": [] - } + } + }, + "query": "\n insert into peer_addresses (\n peer_id,\n address\n ) values (?, ?);\n " }, "1ec38c85e7679b2eb42b3df75d9098772ce44fdb8db3012d3c2410d828b74157": { - "query": "\n SELECT swap_id, state\n FROM (\n SELECT max(id), swap_id, state\n FROM swap_states\n GROUP BY swap_id\n )\n ", "describe": { "columns": [ { @@ -43,37 +42,37 @@ "type_info": "Text" } ], - "parameters": { - "Right": 0 - }, "nullable": [ false, false - ] - } + ], + "parameters": { + "Right": 0 + } + }, + "query": "\n SELECT swap_id, state\n FROM (\n SELECT max(id), swap_id, state\n FROM swap_states\n GROUP BY swap_id\n )\n " }, "2a356078a41b321234adf2aa385b501749f907f7c422945a8bdda2b6274f5225": { - "query": "\n insert into peers (\n swap_id,\n peer_id\n ) values (?, ?);\n ", "describe": { "columns": [], + "nullable": [], "parameters": { "Right": 2 - }, - "nullable": [] - } + } + }, + "query": "\n insert into peers (\n swap_id,\n peer_id\n ) values (?, ?);\n " }, "50a5764546f69c118fa0b64120da50f51073d36257d49768de99ff863e3511e0": { - "query": "\n insert into monero_addresses (\n swap_id,\n address\n ) values (?, ?);\n ", "describe": { "columns": [], + "nullable": [], "parameters": { "Right": 2 - }, - "nullable": [] - } + } + }, + "query": "\n insert into monero_addresses (\n swap_id,\n address\n ) values (?, ?);\n " }, "88f761a4f7a0429cad1df0b1bebb1c0a27b2a45656549b23076d7542cfa21ecf": { - "query": "\n SELECT state\n FROM swap_states\n WHERE swap_id = ?\n ORDER BY id desc\n LIMIT 1;\n\n ", "describe": { "columns": [ { @@ -82,16 +81,16 @@ "type_info": "Text" } ], - "parameters": { - "Right": 1 - }, "nullable": [ false - ] - } + ], + "parameters": { + "Right": 1 + } + }, + "query": "\n SELECT state\n FROM swap_states\n WHERE swap_id = ?\n ORDER BY id desc\n LIMIT 1;\n\n " }, "a0eb85d04ee3842c52291dad4d225941d1141af735922fcbc665868997fce304": { - "query": "\n SELECT address\n FROM peer_addresses\n WHERE peer_id = ?\n ", "describe": { "columns": [ { @@ -100,26 +99,26 @@ "type_info": "Text" } ], - "parameters": { - "Right": 1 - }, "nullable": [ false - ] - } + ], + "parameters": { + "Right": 1 + } + }, + "query": "\n SELECT address\n FROM peer_addresses\n WHERE peer_id = ?\n " }, "b703032b4ddc627a1124817477e7a8e5014bdc694c36a14053ef3bb2fc0c69b0": { - "query": "\n insert into swap_states (\n swap_id,\n entered_at,\n state\n ) values (?, ?, ?);\n ", "describe": { "columns": [], + "nullable": [], "parameters": { "Right": 3 - }, - "nullable": [] - } + } + }, + "query": "\n insert into swap_states (\n swap_id,\n entered_at,\n state\n ) values (?, ?, ?);\n " }, "ce270dd4a4b9615695a79864240c5401e2122077365e5e5a19408c068c7f9454": { - "query": "\n SELECT address\n FROM monero_addresses\n WHERE swap_id = ?\n ", "describe": { "columns": [ { @@ -128,12 +127,13 @@ "type_info": "Text" } ], - "parameters": { - "Right": 1 - }, "nullable": [ false - ] - } + ], + "parameters": { + "Right": 1 + } + }, + "query": "\n SELECT address\n FROM monero_addresses\n WHERE swap_id = ?\n " } } \ No newline at end of file diff --git a/swap/src/asb/rate.rs b/swap/src/asb/rate.rs index ffcdcf7c..c394e91f 100644 --- a/swap/src/asb/rate.rs +++ b/swap/src/asb/rate.rs @@ -29,7 +29,7 @@ impl Rate { /// /// This applies the spread to the market asking price. pub fn ask(&self) -> Result { - let sats = self.ask.as_sat(); + let sats = self.ask.to_sat(); let sats = Decimal::from(sats); let additional_sats = sats * self.ask_spread; @@ -51,13 +51,13 @@ impl Rate { // quote (btc) = rate * base (xmr) // base = quote / rate - let quote_in_sats = quote.as_sat(); + let quote_in_sats = quote.to_sat(); let quote_in_btc = Decimal::from(quote_in_sats) - .checked_div(Decimal::from(bitcoin::Amount::ONE_BTC.as_sat())) + .checked_div(Decimal::from(bitcoin::Amount::ONE_BTC.to_sat())) .context("Division overflow")?; - let rate_in_btc = Decimal::from(rate.as_sat()) - .checked_div(Decimal::from(bitcoin::Amount::ONE_BTC.as_sat())) + let rate_in_btc = Decimal::from(rate.to_sat()) + .checked_div(Decimal::from(bitcoin::Amount::ONE_BTC.to_sat())) .context("Division overflow")?; let base_in_xmr = quote_in_btc @@ -105,7 +105,7 @@ mod tests { let amount = rate.ask().unwrap(); - assert_eq!(amount.as_sat(), 102); + assert_eq!(amount.to_sat(), 102); } #[test] diff --git a/swap/src/bin/asb.rs b/swap/src/bin/asb.rs index 17ddc224..43381399 100644 --- a/swap/src/bin/asb.rs +++ b/swap/src/bin/asb.rs @@ -320,11 +320,10 @@ async fn init_bitcoin_wallet( env_config: swap::env::Config, ) -> Result { tracing::debug!("Opening Bitcoin wallet"); - let wallet_dir = config.data.dir.join("wallet"); - + let data_dir = &config.data.dir; let wallet = bitcoin::Wallet::new( config.bitcoin.electrum_rpc_url.clone(), - &wallet_dir, + data_dir, seed.derive_extended_private_key(env_config.bitcoin_network)?, env_config, config.bitcoin.target_block, diff --git a/swap/src/bin/swap.rs b/swap/src/bin/swap.rs index be5a92cc..67209785 100644 --- a/swap/src/bin/swap.rs +++ b/swap/src/bin/swap.rs @@ -523,12 +523,12 @@ async fn init_bitcoin_wallet( env_config: Config, bitcoin_target_block: usize, ) -> Result { - let wallet_dir = data_dir.join("wallet"); + let xprivkey = seed.derive_extended_private_key(env_config.bitcoin_network)?; let wallet = bitcoin::Wallet::new( electrum_rpc_url.clone(), - &wallet_dir, - seed.derive_extended_private_key(env_config.bitcoin_network)?, + data_dir, + xprivkey, env_config, bitcoin_target_block, ) diff --git a/swap/src/bitcoin.rs b/swap/src/bitcoin.rs index 4215fe44..a375aaf9 100644 --- a/swap/src/bitcoin.rs +++ b/swap/src/bitcoin.rs @@ -373,8 +373,8 @@ mod tests { #[tokio::test] async fn calculate_transaction_weights() { - let alice_wallet = WalletBuilder::new(Amount::ONE_BTC.as_sat()).build(); - let bob_wallet = WalletBuilder::new(Amount::ONE_BTC.as_sat()).build(); + let alice_wallet = WalletBuilder::new(Amount::ONE_BTC.to_sat()).build(); + let bob_wallet = WalletBuilder::new(Amount::ONE_BTC.to_sat()).build(); let spending_fee = Amount::from_sat(1_000); let btc_amount = Amount::from_sat(500_000); let xmr_amount = crate::monero::Amount::from_piconero(10000); diff --git a/swap/src/bitcoin/cancel.rs b/swap/src/bitcoin/cancel.rs index eed2c590..354b0c00 100644 --- a/swap/src/bitcoin/cancel.rs +++ b/swap/src/bitcoin/cancel.rs @@ -4,9 +4,11 @@ use crate::bitcoin::{ build_shared_output_descriptor, Address, Amount, BlockHeight, PublicKey, Transaction, TxLock, }; use ::bitcoin::util::sighash::SighashCache; -use ::bitcoin::{EcdsaSighashType, OutPoint, Script, Sighash, TxIn, TxOut, Txid}; +use ::bitcoin::{ + EcdsaSighashType, OutPoint, PackedLockTime, Script, Sequence, Sighash, TxIn, TxOut, Txid, +}; use anyhow::Result; -use bdk::miniscript::{Descriptor, DescriptorTrait}; +use bdk::miniscript::Descriptor; use ecdsa_fun::Signature; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; @@ -109,18 +111,18 @@ impl TxCancel { let tx_in = TxIn { previous_output: tx_lock.as_outpoint(), script_sig: Default::default(), - sequence: cancel_timelock.0, + sequence: Sequence(cancel_timelock.0), witness: Default::default(), }; let tx_out = TxOut { - value: tx_lock.lock_amount().as_sat() - spending_fee.as_sat(), + value: tx_lock.lock_amount().to_sat() - spending_fee.to_sat(), script_pubkey: cancel_output_descriptor.script_pubkey(), }; let transaction = Transaction { version: 2, - lock_time: 0, + lock_time: PackedLockTime(0), input: vec![tx_in], output: vec![tx_out], }; @@ -129,7 +131,7 @@ impl TxCancel { .segwit_signature_hash( 0, // Only one input: lock_input (lock transaction) &tx_lock.output_descriptor.script_code().expect("scriptcode"), - tx_lock.lock_amount().as_sat(), + tx_lock.lock_amount().to_sat(), EcdsaSighashType::All, ) .expect("sighash"); @@ -235,21 +237,22 @@ impl TxCancel { ) -> Transaction { let previous_output = self.as_outpoint(); + let sequence = Sequence(sequence.map(|seq| seq.0).unwrap_or(0xFFFF_FFFF)); let tx_in = TxIn { previous_output, script_sig: Default::default(), - sequence: sequence.map(|seq| seq.0).unwrap_or(0xFFFF_FFFF), + sequence, witness: Default::default(), }; let tx_out = TxOut { - value: self.amount().as_sat() - spending_fee.as_sat(), + value: self.amount().to_sat() - spending_fee.to_sat(), script_pubkey: spend_address.script_pubkey(), }; Transaction { version: 2, - lock_time: 0, + lock_time: PackedLockTime(0), input: vec![tx_in], output: vec![tx_out], } diff --git a/swap/src/bitcoin/lock.rs b/swap/src/bitcoin/lock.rs index 1840997c..9e2b8795 100644 --- a/swap/src/bitcoin/lock.rs +++ b/swap/src/bitcoin/lock.rs @@ -6,8 +6,8 @@ use ::bitcoin::util::psbt::PartiallySignedTransaction; use ::bitcoin::{OutPoint, TxIn, TxOut, Txid}; use anyhow::{bail, Result}; use bdk::database::BatchDatabase; -use bdk::miniscript::{Descriptor, DescriptorTrait}; -use bitcoin::Script; +use bdk::miniscript::Descriptor; +use bitcoin::{PackedLockTime, Script, Sequence}; use serde::{Deserialize, Serialize}; const SCRIPT_SIZE: usize = 34; @@ -58,14 +58,14 @@ impl TxLock { btc: Amount, ) -> Result { let shared_output_candidate = match psbt.unsigned_tx.output.as_slice() { - [shared_output_candidate, _] if shared_output_candidate.value == btc.as_sat() => { + [shared_output_candidate, _] if shared_output_candidate.value == btc.to_sat() => { shared_output_candidate } - [_, shared_output_candidate] if shared_output_candidate.value == btc.as_sat() => { + [_, shared_output_candidate] if shared_output_candidate.value == btc.to_sat() => { shared_output_candidate } // A single output is possible if Bob funds without any change necessary - [shared_output_candidate] if shared_output_candidate.value == btc.as_sat() => { + [shared_output_candidate] if shared_output_candidate.value == btc.to_sat() => { shared_output_candidate } [_, _] => { @@ -140,14 +140,15 @@ impl TxLock { ) -> Transaction { let previous_output = self.as_outpoint(); + let sequence = Sequence(sequence.unwrap_or(0xFFFF_FFFF)); let tx_in = TxIn { previous_output, script_sig: Default::default(), - sequence: sequence.unwrap_or(0xFFFF_FFFF), + sequence, witness: Default::default(), }; - let fee = spending_fee.as_sat(); + let fee = spending_fee.to_sat(); let tx_out = TxOut { value: self.inner.clone().extract_tx().output[self.lock_output_vout()].value - fee, script_pubkey: spend_address.script_pubkey(), @@ -157,7 +158,7 @@ impl TxLock { Transaction { version: 2, - lock_time: 0, + lock_time: PackedLockTime(0), input: vec![tx_in], output: vec![tx_out], } @@ -207,7 +208,7 @@ mod tests { let (A, B) = alice_and_bob(); let fees = 300; let agreed_amount = Amount::from_sat(10000); - let amount = agreed_amount.as_sat() + fees; + let amount = agreed_amount.to_sat() + fees; let wallet = WalletBuilder::new(amount).build(); let psbt = bob_make_psbt(A, B, &wallet, agreed_amount).await; diff --git a/swap/src/bitcoin/punish.rs b/swap/src/bitcoin/punish.rs index 0d21c3af..df7a1367 100644 --- a/swap/src/bitcoin/punish.rs +++ b/swap/src/bitcoin/punish.rs @@ -4,7 +4,7 @@ use ::bitcoin::util::sighash::SighashCache; use ::bitcoin::{EcdsaSighashType, Sighash}; use anyhow::{Context, Result}; use bdk::bitcoin::Script; -use bdk::miniscript::{Descriptor, DescriptorTrait}; +use bdk::miniscript::Descriptor; use std::collections::HashMap; #[derive(Debug)] @@ -32,7 +32,7 @@ impl TxPunish { .output_descriptor .script_code() .expect("scriptcode"), - tx_cancel.amount().as_sat(), + tx_cancel.amount().to_sat(), EcdsaSighashType::All, ) .expect("sighash"); diff --git a/swap/src/bitcoin/redeem.rs b/swap/src/bitcoin/redeem.rs index 39e38ad6..d94f03d9 100644 --- a/swap/src/bitcoin/redeem.rs +++ b/swap/src/bitcoin/redeem.rs @@ -5,7 +5,7 @@ use crate::bitcoin::{ }; use ::bitcoin::{Sighash, Txid}; use anyhow::{bail, Context, Result}; -use bdk::miniscript::{Descriptor, DescriptorTrait}; +use bdk::miniscript::Descriptor; use bitcoin::secp256k1::ecdsa; use bitcoin::util::sighash::SighashCache; use bitcoin::{EcdsaSighashType, Script}; @@ -34,7 +34,7 @@ impl TxRedeem { .segwit_signature_hash( 0, // Only one input: lock_input (lock transaction) &tx_lock.output_descriptor.script_code().expect("scriptcode"), - tx_lock.lock_amount().as_sat(), + tx_lock.lock_amount().to_sat(), EcdsaSighashType::All, ) .expect("sighash"); diff --git a/swap/src/bitcoin/refund.rs b/swap/src/bitcoin/refund.rs index ba7ac9ef..55aa6c25 100644 --- a/swap/src/bitcoin/refund.rs +++ b/swap/src/bitcoin/refund.rs @@ -8,7 +8,7 @@ use ::bitcoin::secp256k1::ecdsa; use ::bitcoin::util::sighash::SighashCache; use ::bitcoin::{EcdsaSighashType, Script, Sighash, Txid}; use anyhow::{bail, Context, Result}; -use bdk::miniscript::{Descriptor, DescriptorTrait}; +use bdk::miniscript::Descriptor; use ecdsa_fun::Signature; use std::collections::HashMap; @@ -31,7 +31,7 @@ impl TxRefund { .output_descriptor .script_code() .expect("scriptcode"), - tx_cancel.amount().as_sat(), + tx_cancel.amount().to_sat(), EcdsaSighashType::All, ) .expect("sighash"); diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index 98bbe2ef..61bff14d 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -6,12 +6,12 @@ use ::bitcoin::Txid; use anyhow::{bail, Context, Result}; use bdk::blockchain::{Blockchain, ElectrumBlockchain, GetTx}; use bdk::database::BatchDatabase; -use bdk::descriptor::Segwitv0; use bdk::electrum_client::{ElectrumApi, GetHistoryRes}; -use bdk::keys::DerivableKey; +use bdk::sled::Tree; use bdk::wallet::export::FullyNodedExport; use bdk::wallet::AddressIndex; use bdk::{FeeRate, KeychainKind, SignOptions, SyncOptions}; +use bitcoin::util::bip32::ExtendedPrivKey; use bitcoin::{Network, Script}; use reqwest::Url; use rust_decimal::prelude::*; @@ -33,7 +33,10 @@ const MAX_RELATIVE_TX_FEE: Decimal = dec!(0.03); const MAX_ABSOLUTE_TX_FEE: Decimal = dec!(100_000); const DUST_AMOUNT: u64 = 546; -pub struct Wallet { +const WALLET: &str = "wallet"; +const WALLET_OLD: &str = "wallet-old"; + +pub struct Wallet { client: Arc>, wallet: Arc>>, finality_confirmations: u32, @@ -44,19 +47,28 @@ pub struct Wallet { impl Wallet { pub async fn new( electrum_rpc_url: Url, - wallet_dir: &Path, - key: impl DerivableKey + Clone, + data_dir: impl AsRef, + xprivkey: ExtendedPrivKey, env_config: env::Config, target_block: usize, ) -> Result { - let db = bdk::sled::open(wallet_dir)?.open_tree(SLED_TREE_NAME)?; + let data_dir = data_dir.as_ref(); + let wallet_dir = data_dir.join(WALLET); + let database = bdk::sled::open(&wallet_dir)?.open_tree(SLED_TREE_NAME)?; + let network = env_config.bitcoin_network; - let wallet = bdk::Wallet::new( - bdk::template::Bip84(key.clone(), KeychainKind::External), - Some(bdk::template::Bip84(key, KeychainKind::Internal)), - env_config.bitcoin_network, - db, - )?; + let wallet = match bdk::Wallet::new( + bdk::template::Bip84(xprivkey, KeychainKind::External), + Some(bdk::template::Bip84(xprivkey, KeychainKind::Internal)), + network, + database, + ) { + Ok(w) => w, + Err(e) if matches!(e, bdk::Error::ChecksumMismatch) => { + Self::migrate(data_dir, xprivkey, network)? + } + err => err?, + }; let client = Client::new(electrum_rpc_url, env_config.bitcoin_sync_interval())?; @@ -71,6 +83,32 @@ impl Wallet { }) } + /// Create a new database for the wallet and rename the old one. + /// This is necessary when getting a ChecksumMismatch from a wallet + /// created with an older version of BDK. Only affected Testnet wallets. + // https://github.com/comit-network/xmr-btc-swap/issues/1182 + fn migrate( + data_dir: &Path, + xprivkey: ExtendedPrivKey, + network: bitcoin::Network, + ) -> Result> { + let from = data_dir.join(WALLET); + let to = data_dir.join(WALLET_OLD); + std::fs::rename(from, to)?; + + let wallet_dir = data_dir.join(WALLET); + let database = bdk::sled::open(&wallet_dir)?.open_tree(SLED_TREE_NAME)?; + + let wallet = bdk::Wallet::new( + bdk::template::Bip84(xprivkey, KeychainKind::External), + Some(bdk::template::Bip84(xprivkey, KeychainKind::Internal)), + network, + database, + )?; + + Ok(wallet) + } + /// Broadcast the given transaction to the network and emit a log statement /// if done so successfully. /// @@ -346,7 +384,7 @@ where let script = address.script_pubkey(); let mut tx_builder = wallet.build_tx(); - tx_builder.add_recipient(script.clone(), amount.as_sat()); + tx_builder.add_recipient(script.clone(), amount.to_sat()); tx_builder.fee_rate(fee_rate); let (psbt, _details) = tx_builder.finish()?; let mut psbt: PartiallySignedTransaction = psbt; @@ -392,7 +430,7 @@ where return Ok(Amount::ZERO); } let client = self.client.lock().await; - let min_relay_fee = client.min_relay_fee()?.as_sat(); + let min_relay_fee = client.min_relay_fee()?.to_sat(); if balance.get_total() < min_relay_fee { return Ok(Amount::ZERO); @@ -443,18 +481,18 @@ fn estimate_fee( fee_rate: FeeRate, min_relay_fee: Amount, ) -> Result { - if transfer_amount.as_sat() <= 546 { + if transfer_amount.to_sat() <= 546 { bail!("Amounts needs to be greater than Bitcoin dust amount.") } let fee_rate_svb = fee_rate.as_sat_per_vb(); if fee_rate_svb <= 0.0 { bail!("Fee rate needs to be > 0") } - if fee_rate_svb > 100_000_000.0 || min_relay_fee.as_sat() > 100_000_000 { + if fee_rate_svb > 100_000_000.0 || min_relay_fee.to_sat() > 100_000_000 { bail!("A fee_rate or min_relay_fee of > 1BTC does not make sense") } - let min_relay_fee = if min_relay_fee.as_sat() == 0 { + let min_relay_fee = if min_relay_fee.to_sat() == 0 { // if min_relay_fee is 0 we don't fail, we just set it to 1 satoshi; Amount::ONE_SAT } else { @@ -474,9 +512,9 @@ fn estimate_fee( "Estimated fee for transaction", ); - let transfer_amount = Decimal::from(transfer_amount.as_sat()); + let transfer_amount = Decimal::from(transfer_amount.to_sat()); let max_allowed_fee = transfer_amount * MAX_RELATIVE_TX_FEE; - let min_relay_fee = Decimal::from(min_relay_fee.as_sat()); + let min_relay_fee = Decimal::from(min_relay_fee.to_sat()); let recommended_fee = if sats_per_vbyte < min_relay_fee { tracing::warn!( @@ -932,6 +970,7 @@ mod tests { use super::*; use crate::bitcoin::{PublicKey, TxLock}; use crate::tracing_ext::capture_logs; + use bitcoin::hashes::Hash; use proptest::prelude::*; use tracing::level_filters::LevelFilter; @@ -1031,7 +1070,7 @@ mod tests { // weight / 4.0 * sat_per_vb would be greater than 3% hence we take total // max allowed fee. - assert_eq!(is_fee.as_sat(), MAX_ABSOLUTE_TX_FEE.to_u64().unwrap()); + assert_eq!(is_fee.to_sat(), MAX_ABSOLUTE_TX_FEE.to_u64().unwrap()); } proptest! { @@ -1067,7 +1106,7 @@ mod tests { let is_fee = estimate_fee(weight, amount, fee_rate, relay_fee).unwrap(); // weight / 4 * 1_000 is always lower than MAX_ABSOLUTE_TX_FEE - assert!(is_fee.as_sat() < MAX_ABSOLUTE_TX_FEE.to_u64().unwrap()); + assert!(is_fee.to_sat() < MAX_ABSOLUTE_TX_FEE.to_u64().unwrap()); } } @@ -1086,7 +1125,7 @@ mod tests { let is_fee = estimate_fee(weight, amount, fee_rate, relay_fee).unwrap(); // weight / 4 * 1_000 is always higher than MAX_ABSOLUTE_TX_FEE - assert!(is_fee.as_sat() >= MAX_ABSOLUTE_TX_FEE.to_u64().unwrap()); + assert!(is_fee.to_sat() >= MAX_ABSOLUTE_TX_FEE.to_u64().unwrap()); } } @@ -1142,7 +1181,7 @@ mod tests { let wallet = WalletBuilder::new(10_000).build(); let amount = wallet.max_giveable(TxLock::script_size()).await.unwrap(); - assert!(amount.as_sat() > 0); + assert!(amount.to_sat() > 0); } /// This test ensures that the relevant script output of the transaction @@ -1212,7 +1251,8 @@ mod tests { fn printing_status_change_doesnt_spam_on_same_status() { let writer = capture_logs(LevelFilter::DEBUG); - let tx = Txid::default(); + let inner = bitcoin::hashes::sha256d::Hash::all_zeros(); + let tx = Txid::from_hash(inner); let mut old = None; old = Some(print_status_change(tx, old, ScriptStatus::Unseen)); old = Some(print_status_change(tx, old, ScriptStatus::InMempool)); diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs index 631cc00e..4e131ed5 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -338,6 +338,7 @@ struct RawArguments { testnet: bool, #[structopt( + short, long = "--data-base-dir", help = "The base data directory to be used for mainnet / testnet specific data like database, wallets etc" )] diff --git a/swap/src/common.rs b/swap/src/common.rs index 291997e6..959d0a3b 100644 --- a/swap/src/common.rs +++ b/swap/src/common.rs @@ -9,19 +9,18 @@ pub enum Version { } /// Check the latest release from GitHub API. -pub async fn check_latest_version(current: &str) -> anyhow::Result { +pub async fn check_latest_version(current_version: &str) -> anyhow::Result { let response = reqwest::get(LATEST_RELEASE_URL).await?; let e = "Failed to get latest release."; - let url = response.url(); - let segments = url.path_segments().ok_or_else(|| anyhow!(e))?; - let latest = segments.last().ok_or_else(|| anyhow!(e))?; + let download_url = response.url(); + let segments = download_url.path_segments().ok_or_else(|| anyhow!(e))?; + let latest_version = segments.last().ok_or_else(|| anyhow!(e))?; - let result = if is_latest_version(current, latest) { + let result = if is_latest_version(current_version, latest_version) { Version::Current } else { - println!( - "You are not on the latest version: {} is available. \n{}", - latest, url + tracing::warn!(%current_version, %latest_version, %download_url, + "You are not on the latest version", ); Version::Available }; diff --git a/swap/src/monero.rs b/swap/src/monero.rs index 94555c8a..e5163f77 100644 --- a/swap/src/monero.rs +++ b/swap/src/monero.rs @@ -110,7 +110,7 @@ impl Amount { } // safely convert the BTC/XMR rate to sat/pico - let ask_sats = Decimal::from(ask_price.as_sat()); + let ask_sats = Decimal::from(ask_price.to_sat()); let pico_per_xmr = Decimal::from(PICONERO_OFFSET); let ask_sats_per_pico = ask_sats / pico_per_xmr; diff --git a/swap/src/monero/wallet_rpc.rs b/swap/src/monero/wallet_rpc.rs index 9cda2fe3..819eeccb 100644 --- a/swap/src/monero/wallet_rpc.rs +++ b/swap/src/monero/wallet_rpc.rs @@ -20,8 +20,8 @@ compile_error!("unsupported operating system"); #[cfg(all(target_os = "macos", target_arch = "x86_64"))] const DOWNLOAD_URL: &str = "https://downloads.getmonero.org/cli/monero-mac-x64-v0.18.1.2.tar.bz2"; -#[cfg(all(target_os = "macos", target_arch = "arm"))] -const DOWNLOAD_URL: &str = "https://downloads.getmonero.org/cli/monero-mac-armv8-v0.18.1.2.tar.bz2"; +#[cfg(all(target_os = "macos", target_arch = "aarch64"))] +const DOWNLOAD_URL: &str = "https://downloads.getmonero.org/cli/monero-mac-armv8-v0.18.0.0.tar.bz2"; #[cfg(all(target_os = "linux", target_arch = "x86_64"))] const DOWNLOAD_URL: &str = "https://downloads.getmonero.org/cli/monero-linux-x64-v0.18.1.2.tar.bz2"; diff --git a/swap/tests/bdk.sh b/swap/tests/bdk.sh new file mode 100755 index 00000000..b4be9dd1 --- /dev/null +++ b/swap/tests/bdk.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -euxo pipefail + +VERSION=0.11.1 + +mkdir bdk +stat ./target/debug/swap || exit 1 +cp ./target/debug/swap bdk/swap-current +pushd bdk + +echo "download swap $VERSION" +curl -L "https://github.com/comit-network/xmr-btc-swap/releases/download/${VERSION}/swap_${VERSION}_Linux_x86_64.tar" | tar xv + +echo "create testnet wallet with $VERSION" +./swap --testnet --data-base-dir . --debug balance || exit 1 +echo "check testnet wallet with this version" +./swap-current --testnet --data-base-dir . --debug balance || exit 1 + +echo "create mainnet wallet with $VERSION" +./swap --version || exit 1 +./swap --data-base-dir . --debug balance || exit 1 +echo "check mainnet wallet with this version" +./swap-current --version || exit 1 +./swap-current --data-base-dir . --debug balance || exit 1 + +exit 0 diff --git a/swap/tests/harness/mod.rs b/swap/tests/harness/mod.rs index 29319c21..29fcce5c 100644 --- a/swap/tests/harness/mod.rs +++ b/swap/tests/harness/mod.rs @@ -56,7 +56,7 @@ where monero.init_miner().await.unwrap(); let btc_amount = bitcoin::Amount::from_sat(1_000_000); - let xmr_amount = monero::Amount::from_monero(btc_amount.as_btc() / FixedRate::RATE).unwrap(); + let xmr_amount = monero::Amount::from_monero(btc_amount.to_btc() / FixedRate::RATE).unwrap(); let alice_starting_balances = StartingBalances::new(bitcoin::Amount::ZERO, xmr_amount, Some(10));