diff --git a/.cargo/config.toml b/.cargo/config.toml
index b707df9d..0c1c209f 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -1,6 +1,2 @@
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
-
-# windows defaults to smaller stack sizes which isn't enough
-[target.'cfg(windows)']
-rustflags = ["-C", "link-args=/STACK:8388608"]
diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml
index 2fdaabdc..29bdde64 100644
--- a/.github/workflows/build-release-binaries.yml
+++ b/.github/workflows/build-release-binaries.yml
@@ -54,12 +54,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout tagged commit
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.1.6
with:
ref: ${{ github.event.release.target_commitish }}
token: ${{ secrets.BOTTY_GITHUB_TOKEN }}
- - uses: Swatinem/rust-cache@v2.7.5
+ - uses: Swatinem/rust-cache@v2.7.3
- uses: dtolnay/rust-toolchain@master
with:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index eda55e3e..cb869ccf 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -11,14 +11,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.1.6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.74"
components: clippy,rustfmt
- - uses: Swatinem/rust-cache@v2.7.5
+ - uses: Swatinem/rust-cache@v2.7.3
- name: Check formatting
uses: dprint/check@v2.2
@@ -35,9 +35,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.1.6
- - uses: Swatinem/rust-cache@v2.7.5
+ - uses: Swatinem/rust-cache@v2.7.3
- name: Build swap
run: cargo build --bin swap
@@ -49,9 +49,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.1.6
- - uses: Swatinem/rust-cache@v2.7.5
+ - uses: Swatinem/rust-cache@v2.7.3
- name: Install sqlx-cli
run: cargo install --locked --version 0.6.3 sqlx-cli
@@ -78,9 +78,9 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.1.6
- - uses: Swatinem/rust-cache@v2.7.5
+ - uses: Swatinem/rust-cache@v2.7.3
- uses: dtolnay/rust-toolchain@master
with:
@@ -131,9 +131,9 @@ jobs:
tool-cache: false
- name: Checkout sources
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.1.6
- - uses: Swatinem/rust-cache@v2.7.5
+ - uses: Swatinem/rust-cache@v2.7.3
- name: Build tests
run: cargo build --tests --workspace --all-features
@@ -157,23 +157,20 @@ jobs:
alice_and_bob_refund_using_cancel_and_refund_command,
alice_and_bob_refund_using_cancel_then_refund_command,
alice_and_bob_refund_using_cancel_and_refund_command_timelock_not_expired,
- alice_manually_punishes_after_bob_dead_and_bob_cancels,
punish,
alice_punishes_after_restart_bob_dead,
alice_manually_punishes_after_bob_dead,
alice_refunds_after_restart_bob_refunded,
ensure_same_swap_id,
concurrent_bobs_before_xmr_lock_proof_sent,
- concurrent_bobs_after_xmr_lock_proof_sent,
alice_manually_redeems_after_enc_sig_learned,
- happy_path_bob_offline_while_alice_redeems_btc,
]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.1.6
- - uses: Swatinem/rust-cache@v2.7.5
+ - uses: Swatinem/rust-cache@v2.7.3
- name: Run test ${{ matrix.test_name }}
run: cargo test --package swap --all-features --test ${{ matrix.test_name }} -- --nocapture
@@ -182,9 +179,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.1.6
- - uses: Swatinem/rust-cache@v2.7.5
+ - uses: Swatinem/rust-cache@v2.7.3
- name: Run RPC server tests
run: cargo test --package swap --all-features --test rpc -- --nocapture
@@ -193,11 +190,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.1.6
- uses: dtolnay/rust-toolchain@stable
- - uses: Swatinem/rust-cache@v2.7.5
+ - uses: Swatinem/rust-cache@v2.7.3
- name: Run cargo check on stable rust
run: cargo check --all-targets
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 3dcd492d..2e52519a 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -11,7 +11,7 @@ jobs:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4.2.1
+ - uses: actions/checkout@v4.1.6
- name: Extract version from branch name
id: extract-version
diff --git a/.github/workflows/draft-new-release.yml b/.github/workflows/draft-new-release.yml
index bd926d53..09df0bd7 100644
--- a/.github/workflows/draft-new-release.yml
+++ b/.github/workflows/draft-new-release.yml
@@ -12,7 +12,7 @@ jobs:
name: "Draft a new release"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4.2.1
+ - uses: actions/checkout@v4.1.6
with:
token: ${{ secrets.BOTTY_GITHUB_TOKEN }}
@@ -20,7 +20,7 @@ jobs:
run: git checkout -b release/${{ github.event.inputs.version }}
- name: Update changelog
- uses: thomaseizinger/keep-a-changelog-new-release@3.1.0
+ uses: thomaseizinger/keep-a-changelog-new-release@3.0.0
with:
version: ${{ github.event.inputs.version }}
changelogPath: CHANGELOG.md
diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml
index b216d283..63ecfe6f 100644
--- a/.github/workflows/preview-release.yml
+++ b/.github/workflows/preview-release.yml
@@ -10,7 +10,7 @@ jobs:
name: Create preview release
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4.2.1
+ - uses: actions/checkout@v4.1.6
- name: Delete 'preview' release
uses: larryjoelane/delete-release-action@v1.0.24
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c22e533e..1fa3bdeb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,28 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
-- ASB + CLI: You can now use the `logs` command to retrieve logs stored in the past, redacting addresses and id's using `logs --redact`.
-- ASB: The `--disable-timestamp` flag has been removed
-
-## [0.13.4] - 2024-07-25
-
-- ASB: The `history` command can now be used while the asb is running.
-- ASB: Retry locking of Monero if it fails on first attempt
-
-## [0.13.3] - 2024-07-15
-
-- Introduced a cooperative Monero redeem feature for Bob to request from Alice if Bob is punished for not refunding in time. Alice can choose to cooperate but is not obligated to do so. This change is backwards compatible. To attempt recovery, resume a swap in the "Bitcoin punished" state. Success depends on Alice being active and still having a record of the swap. Note that Alice's cooperation is voluntary and recovery is not guaranteed
-- CLI: `--change-address` can now be omitted. In that case, any change is refunded to the internal bitcoin wallet.
-
-## [0.13.2] - 2024-07-02
-
-- CLI: Buffer received transfer proofs for later processing if we're currently running a different swap
-- CLI: We now display the reason for a failed cancel-refund operation to the user (#683)
-
-## [0.13.1] - 2024-06-10
-
-- Add retry logic to monero-wallet-rpc wallet refresh
-
## [0.13.0] - 2024-05-29
- Minimum Supported Rust Version (MSRV) bumped to 1.74
@@ -378,11 +356,7 @@ It is possible to migrate critical data from the old db to the sqlite but there
- Fixed an issue where Alice would not verify if Bob's Bitcoin lock transaction is semantically correct, i.e. pays the agreed upon amount to an output owned by both of them.
Fixing this required a **breaking change** on the network layer and hence old versions are not compatible with this version.
-[unreleased]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.4...HEAD
-[0.13.4]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.3...0.13.4
-[0.13.3]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.2...0.13.3
-[0.13.2]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.1...0.13.2
-[0.13.1]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.0...0.13.1
+[unreleased]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.0...HEAD
[0.13.0]: https://github.com/comit-network/xmr-btc-swap/compare/0.12.3...0.13.0
[0.12.3]: https://github.com/comit-network/xmr-btc-swap/compare/0.12.2...0.12.3
[0.12.2]: https://github.com/comit-network/xmr-btc-swap/compare/0.12.1...0.12.2
diff --git a/Cargo.lock b/Cargo.lock
index c31fffba..522c7c75 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -78,15 +78,6 @@ dependencies = [
"memchr",
]
-[[package]]
-name = "aho-corasick"
-version = "1.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
-dependencies = [
- "memchr",
-]
-
[[package]]
name = "ansi_term"
version = "0.11.0"
@@ -107,9 +98,9 @@ dependencies = [
[[package]]
name = "anyhow"
-version = "1.0.91"
+version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8"
+checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]]
name = "arrayref"
@@ -163,13 +154,13 @@ dependencies = [
[[package]]
name = "async-trait"
-version = "0.1.83"
+version = "0.1.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
+checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 2.0.46",
]
[[package]]
@@ -276,6 +267,12 @@ version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
+[[package]]
+name = "base64"
+version = "0.21.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
+
[[package]]
name = "base64"
version = "0.22.1"
@@ -399,21 +396,19 @@ dependencies = [
[[package]]
name = "bitcoin-harness"
-version = "0.2.1"
-source = "git+https://github.com/delta1/bitcoin-harness-rs.git?rev=80cc8d05db2610d8531011be505b7bee2b5cdf9f#80cc8d05db2610d8531011be505b7bee2b5cdf9f"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b6a18713ec8acbc96d1e843f6998f00e8c5d81173e38760023b84926b8db3b8"
dependencies = [
"base64 0.12.3",
"bitcoin",
"bitcoincore-rpc-json",
"futures",
"hex",
- "hmac 0.12.1",
"jsonrpc_client",
- "rand 0.8.3",
"reqwest",
"serde",
"serde_json",
- "sha2 0.10.8",
"testcontainers",
"thiserror",
"tokio",
@@ -501,10 +496,11 @@ dependencies = [
[[package]]
name = "bollard-stubs"
-version = "1.42.0-rc.3"
+version = "1.41.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed59b5c00048f48d7af971b71f800fdf23e858844a6f9e4d32ca72e9399e7864"
+checksum = "ed2f2e73fffe9455141e170fb9c1feb0ac521ec7e7dcd47a7cab72a658490fb8"
dependencies = [
+ "chrono",
"serde",
"serde_with",
]
@@ -660,21 +656,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chacha20"
-version = "0.7.1"
+version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412"
+checksum = "f08493fa7707effc63254c66c6ea908675912493cd67952eda23c09fae2610b1"
dependencies = [
"cfg-if 1.0.0",
"cipher",
- "cpufeatures 0.1.4",
+ "cpufeatures 0.2.1",
"zeroize",
]
[[package]]
name = "chacha20poly1305"
-version = "0.8.0"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5"
+checksum = "b6547abe025f4027edacd9edaa357aded014eecec42a5070d9b885c3c334aba2"
dependencies = [
"aead",
"chacha20",
@@ -692,6 +688,8 @@ dependencies = [
"libc",
"num-integer",
"num-traits",
+ "serde",
+ "time 0.1.43",
"winapi",
]
@@ -752,7 +750,7 @@ dependencies = [
"nom",
"pathdiff",
"serde",
- "toml 0.8.19",
+ "toml 0.8.13",
]
[[package]]
@@ -947,9 +945,9 @@ dependencies = [
[[package]]
name = "crypto-mac"
-version = "0.11.0"
+version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e"
+checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
dependencies = [
"generic-array",
"subtle",
@@ -1026,6 +1024,17 @@ dependencies = [
"syn 1.0.109",
]
+[[package]]
+name = "dashmap"
+version = "5.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c8858831f7781322e539ea39e72449c46b059638250c14344fec8d0aa6e539c"
+dependencies = [
+ "cfg-if 1.0.0",
+ "num_cpus",
+ "parking_lot 0.12.0",
+]
+
[[package]]
name = "data-encoding"
version = "2.6.0"
@@ -1188,6 +1197,15 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
+[[package]]
+name = "encoding_rs"
+version = "0.8.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
[[package]]
name = "enum-as-inner"
version = "0.3.3"
@@ -1224,9 +1242,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]]
name = "fastrand"
-version = "2.1.1"
+version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
+checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]]
name = "filetime"
@@ -1310,9 +1328,9 @@ dependencies = [
[[package]]
name = "futures"
-version = "0.3.31"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
+checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
dependencies = [
"futures-channel",
"futures-core",
@@ -1325,9 +1343,9 @@ dependencies = [
[[package]]
name = "futures-channel"
-version = "0.3.31"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
+checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
dependencies = [
"futures-core",
"futures-sink",
@@ -1335,15 +1353,15 @@ dependencies = [
[[package]]
name = "futures-core"
-version = "0.3.31"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
+checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
[[package]]
name = "futures-executor"
-version = "0.3.31"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f"
+checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
dependencies = [
"futures-core",
"futures-task",
@@ -1364,19 +1382,19 @@ dependencies = [
[[package]]
name = "futures-io"
-version = "0.3.31"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
+checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
[[package]]
name = "futures-macro"
-version = "0.3.31"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
+checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 2.0.46",
]
[[package]]
@@ -1392,15 +1410,15 @@ dependencies = [
[[package]]
name = "futures-sink"
-version = "0.3.31"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
+checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
[[package]]
name = "futures-task"
-version = "0.3.31"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
+checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
[[package]]
name = "futures-timer"
@@ -1410,9 +1428,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
[[package]]
name = "futures-util"
-version = "0.3.31"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
+checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [
"futures-channel",
"futures-core",
@@ -1492,9 +1510,9 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]]
name = "git2"
-version = "0.19.0"
+version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724"
+checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd"
dependencies = [
"bitflags 2.4.0",
"libc",
@@ -1509,7 +1527,7 @@ version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
dependencies = [
- "aho-corasick 0.7.18",
+ "aho-corasick",
"bstr",
"fnv",
"log",
@@ -1535,25 +1553,6 @@ dependencies = [
"tracing",
]
-[[package]]
-name = "h2"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4"
-dependencies = [
- "bytes",
- "fnv",
- "futures-core",
- "futures-sink",
- "futures-util",
- "http 1.0.0",
- "indexmap 2.1.0",
- "slab",
- "tokio",
- "tokio-util",
- "tracing",
-]
-
[[package]]
name = "half"
version = "1.7.1"
@@ -1611,12 +1610,6 @@ dependencies = [
"unicode-segmentation",
]
-[[package]]
-name = "heck"
-version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
-
[[package]]
name = "hermit-abi"
version = "0.1.18"
@@ -1656,7 +1649,7 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
dependencies = [
- "crypto-mac 0.11.0",
+ "crypto-mac 0.11.1",
"digest 0.9.0",
]
@@ -1722,19 +1715,6 @@ dependencies = [
"http 1.0.0",
]
-[[package]]
-name = "http-body-util"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d"
-dependencies = [
- "bytes",
- "futures-core",
- "http 1.0.0",
- "http-body 1.0.0",
- "pin-project-lite 0.2.13",
-]
-
[[package]]
name = "httparse"
version = "1.8.0"
@@ -1757,13 +1737,14 @@ dependencies = [
"futures-channel",
"futures-core",
"futures-util",
- "h2 0.3.18",
+ "h2",
"http 0.2.11",
"http-body 0.4.0",
"httparse",
"httpdate",
"itoa",
"pin-project-lite 0.2.13",
+ "socket2 0.5.5",
"tokio",
"tower-service",
"tracing",
@@ -1772,61 +1753,27 @@ dependencies = [
[[package]]
name = "hyper"
-version = "1.5.0"
+version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a"
+checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d"
dependencies = [
"bytes",
- "futures-channel",
- "futures-util",
- "h2 0.4.3",
"http 1.0.0",
"http-body 1.0.0",
- "httparse",
- "httpdate",
- "itoa",
- "pin-project-lite 0.2.13",
- "smallvec",
"tokio",
- "want",
]
[[package]]
name = "hyper-rustls"
-version = "0.27.2"
+version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155"
+checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7"
dependencies = [
- "futures-util",
- "http 1.0.0",
- "hyper 1.5.0",
- "hyper-util",
- "rustls 0.23.10",
- "rustls-pki-types",
+ "http 0.2.11",
+ "hyper 0.14.28",
+ "rustls 0.21.10",
"tokio",
- "tokio-rustls 0.26.0",
- "tower-service",
- "webpki-roots 0.26.1",
-]
-
-[[package]]
-name = "hyper-util"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
-dependencies = [
- "bytes",
- "futures-channel",
- "futures-util",
- "http 1.0.0",
- "http-body 1.0.0",
- "hyper 1.5.0",
- "pin-project-lite 0.2.13",
- "socket2 0.5.5",
- "tokio",
- "tower",
- "tower-service",
- "tracing",
+ "tokio-rustls 0.24.0",
]
[[package]]
@@ -1915,7 +1862,7 @@ dependencies = [
"socket2 0.3.19",
"widestring",
"winapi",
- "winreg",
+ "winreg 0.6.2",
]
[[package]]
@@ -1980,7 +1927,8 @@ dependencies = [
[[package]]
name = "jsonrpc_client"
version = "0.7.1"
-source = "git+https://github.com/delta1/rust-jsonrpc-client.git?rev=3b6081697cd616c952acb9c2f02d546357d35506#3b6081697cd616c952acb9c2f02d546357d35506"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0c1ec33c537dc1d5a8b597313db6d213fee54320f81ea0d19b0c3869b282e1a"
dependencies = [
"async-trait",
"jsonrpc_client_macro",
@@ -1993,7 +1941,8 @@ dependencies = [
[[package]]
name = "jsonrpc_client_macro"
version = "0.3.0"
-source = "git+https://github.com/delta1/rust-jsonrpc-client.git?rev=3b6081697cd616c952acb9c2f02d546357d35506#3b6081697cd616c952acb9c2f02d546357d35506"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97c11e429f0eaa41fe659013680b459d2368d8f0a3e69dccfb7a35800b0dc27b"
dependencies = [
"quote",
"syn 1.0.109",
@@ -2132,15 +2081,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
-version = "0.2.159"
+version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
+checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "libgit2-sys"
-version = "0.17.0+1.8.1"
+version = "0.16.1+1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224"
+checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c"
dependencies = [
"cc",
"libc",
@@ -2468,9 +2417,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
name = "linux-raw-sys"
-version = "0.4.14"
+version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
+checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
[[package]]
name = "lock_api"
@@ -2517,7 +2466,7 @@ version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
dependencies = [
- "regex-automata 0.1.9",
+ "regex-automata",
]
[[package]]
@@ -2526,7 +2475,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
- "regex-automata 0.1.9",
+ "regex-automata",
]
[[package]]
@@ -2603,19 +2552,14 @@ dependencies = [
[[package]]
name = "mockito"
-version = "1.5.0"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09b34bd91b9e5c5b06338d392463e1318d683cf82ec3d3af4014609be6e2108d"
+checksum = "a8c84fe1f1d8c56dc157f79942056fad4b9efceebba374a01b222428b553facb"
dependencies = [
"assert-json-diff",
- "bytes",
"colored",
- "futures-util",
- "http 1.0.0",
- "http-body 1.0.0",
- "http-body-util",
- "hyper 1.5.0",
- "hyper-util",
+ "futures",
+ "hyper 0.14.28",
"log",
"rand 0.8.3",
"regex",
@@ -2662,7 +2606,7 @@ dependencies = [
"testcontainers",
"tokio",
"tracing",
- "tracing-subscriber 0.3.18",
+ "tracing-subscriber 0.2.25",
]
[[package]]
@@ -2848,9 +2792,9 @@ dependencies = [
[[package]]
name = "once_cell"
-version = "1.20.2"
+version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
+checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]]
name = "opaque-debug"
@@ -3156,18 +3100,18 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "1.0.87"
+version = "1.0.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
+checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db"
dependencies = [
"unicode-ident",
]
[[package]]
name = "proptest"
-version = "1.5.0"
+version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d"
+checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf"
dependencies = [
"bit-set",
"bit-vec",
@@ -3177,7 +3121,7 @@ dependencies = [
"rand 0.8.3",
"rand_chacha 0.3.1",
"rand_xorshift",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.2",
"rusty-fork",
"tempfile",
"unarray",
@@ -3258,9 +3202,9 @@ dependencies = [
[[package]]
name = "qrcode"
-version = "0.14.1"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d68782463e408eb1e668cf6152704bd856c78c5b6417adaee3203d8f4c1fc9ec"
+checksum = "23e719ca51966ff9f5a8436edb00d6115b3c606a0bb27c8f8ca74a38ff2b036d"
dependencies = [
"image",
]
@@ -3282,53 +3226,6 @@ dependencies = [
"pin-project-lite 0.1.12",
]
-[[package]]
-name = "quinn"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad"
-dependencies = [
- "bytes",
- "pin-project-lite 0.2.13",
- "quinn-proto",
- "quinn-udp",
- "rustc-hash",
- "rustls 0.23.10",
- "thiserror",
- "tokio",
- "tracing",
-]
-
-[[package]]
-name = "quinn-proto"
-version = "0.11.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe"
-dependencies = [
- "bytes",
- "rand 0.8.3",
- "ring 0.17.3",
- "rustc-hash",
- "rustls 0.23.10",
- "slab",
- "thiserror",
- "tinyvec",
- "tracing",
-]
-
-[[package]]
-name = "quinn-udp"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46"
-dependencies = [
- "libc",
- "once_cell",
- "socket2 0.5.5",
- "tracing",
- "windows-sys 0.52.0",
-]
-
[[package]]
name = "quote"
version = "1.0.35"
@@ -3458,14 +3355,13 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.11.0"
+version = "1.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8"
+checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d"
dependencies = [
- "aho-corasick 1.1.3",
+ "aho-corasick",
"memchr",
- "regex-automata 0.4.8",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.6.29",
]
[[package]]
@@ -3478,17 +3374,6 @@ dependencies = [
"regex-syntax 0.6.29",
]
-[[package]]
-name = "regex-automata"
-version = "0.4.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
-dependencies = [
- "aho-corasick 1.1.3",
- "memchr",
- "regex-syntax 0.8.5",
-]
-
[[package]]
name = "regex-syntax"
version = "0.6.29"
@@ -3497,9 +3382,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "rend"
@@ -3512,21 +3397,20 @@ dependencies = [
[[package]]
name = "reqwest"
-version = "0.12.8"
+version = "0.11.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b"
+checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62"
dependencies = [
- "base64 0.22.1",
+ "base64 0.21.7",
"bytes",
+ "encoding_rs",
"futures-core",
"futures-util",
- "h2 0.4.3",
- "http 1.0.0",
- "http-body 1.0.0",
- "http-body-util",
- "hyper 1.5.0",
+ "h2",
+ "http 0.2.11",
+ "http-body 0.4.0",
+ "hyper 0.14.28",
"hyper-rustls",
- "hyper-util",
"ipnet",
"js-sys",
"log",
@@ -3534,16 +3418,15 @@ dependencies = [
"once_cell",
"percent-encoding",
"pin-project-lite 0.2.13",
- "quinn",
- "rustls 0.23.10",
- "rustls-pemfile 2.1.2",
- "rustls-pki-types",
+ "rustls 0.21.10",
+ "rustls-pemfile",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
+ "system-configuration",
"tokio",
- "tokio-rustls 0.26.0",
+ "tokio-rustls 0.24.0",
"tokio-socks",
"tokio-util",
"tower-service",
@@ -3552,8 +3435,8 @@ dependencies = [
"wasm-bindgen-futures",
"wasm-streams",
"web-sys",
- "webpki-roots 0.26.1",
- "windows-registry",
+ "webpki-roots 0.25.3",
+ "winreg 0.50.0",
]
[[package]]
@@ -3677,9 +3560,9 @@ dependencies = [
[[package]]
name = "rustix"
-version = "0.38.37"
+version = "0.38.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
+checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
dependencies = [
"bitflags 2.4.0",
"errno",
@@ -3715,16 +3598,14 @@ dependencies = [
[[package]]
name = "rustls"
-version = "0.23.10"
+version = "0.21.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402"
+checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
dependencies = [
- "once_cell",
+ "log",
"ring 0.17.3",
- "rustls-pki-types",
"rustls-webpki",
- "subtle",
- "zeroize",
+ "sct 0.7.0",
]
[[package]]
@@ -3746,7 +3627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
dependencies = [
"openssl-probe",
- "rustls-pemfile 1.0.0",
+ "rustls-pemfile",
"schannel",
"security-framework",
]
@@ -3760,30 +3641,13 @@ dependencies = [
"base64 0.13.1",
]
-[[package]]
-name = "rustls-pemfile"
-version = "2.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d"
-dependencies = [
- "base64 0.22.1",
- "rustls-pki-types",
-]
-
-[[package]]
-name = "rustls-pki-types"
-version = "1.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d"
-
[[package]]
name = "rustls-webpki"
-version = "0.102.4"
+version = "0.101.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e"
+checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
dependencies = [
"ring 0.17.3",
- "rustls-pki-types",
"untrusted 0.9.0",
]
@@ -3822,15 +3686,6 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
-[[package]]
-name = "scc"
-version = "2.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "76ad2bbb0ae5100a07b7a6f2ed7ab5fd0045551a4c507989b7a620046ea3efdc"
-dependencies = [
- "sdd",
-]
-
[[package]]
name = "schannel"
version = "0.1.19"
@@ -3867,12 +3722,6 @@ dependencies = [
"untrusted 0.7.1",
]
-[[package]]
-name = "sdd"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b84345e4c9bd703274a082fb80caaa99b7612be48dfaa1dd9266577ec412309d"
-
[[package]]
name = "seahash"
version = "4.1.0"
@@ -4022,9 +3871,9 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.210"
+version = "1.0.203"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
+checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
dependencies = [
"serde_derive",
]
@@ -4051,32 +3900,31 @@ dependencies = [
[[package]]
name = "serde_derive"
-version = "1.0.210"
+version = "1.0.203"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
+checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 2.0.46",
]
[[package]]
name = "serde_json"
-version = "1.0.132"
+version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
+checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
dependencies = [
"itoa",
- "memchr",
"ryu",
"serde",
]
[[package]]
name = "serde_spanned"
-version = "0.6.7"
+version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d"
+checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0"
dependencies = [
"serde",
]
@@ -4117,27 +3965,27 @@ dependencies = [
[[package]]
name = "serial_test"
-version = "3.1.1"
+version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d"
+checksum = "953ad9342b3aaca7cb43c45c097dd008d4907070394bd0751a0aa8817e5a018d"
dependencies = [
+ "dashmap",
"futures",
+ "lazy_static",
"log",
- "once_cell",
"parking_lot 0.12.0",
- "scc",
"serial_test_derive",
]
[[package]]
name = "serial_test_derive"
-version = "3.1.1"
+version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67"
+checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 2.0.46",
]
[[package]]
@@ -4263,9 +4111,9 @@ dependencies = [
[[package]]
name = "smallvec"
-version = "1.13.2"
+version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
+checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "snow"
@@ -4403,7 +4251,7 @@ dependencies = [
"paste",
"percent-encoding",
"rustls 0.20.2",
- "rustls-pemfile 1.0.0",
+ "rustls-pemfile",
"serde",
"sha2 0.10.8",
"smallvec",
@@ -4509,31 +4357,31 @@ dependencies = [
[[package]]
name = "strum"
-version = "0.26.3"
+version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
+checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
-version = "0.26.4"
+version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
+checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18"
dependencies = [
- "heck 0.5.0",
+ "heck 0.4.1",
"proc-macro2",
"quote",
"rustversion",
- "syn 2.0.79",
+ "syn 2.0.46",
]
[[package]]
name = "subtle"
-version = "2.5.0"
+version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
+checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
[[package]]
name = "subtle-ng"
@@ -4543,7 +4391,7 @@ checksum = "8049cf85f0e715d6af38dde439cb0ccb91f67fb9f5f63c80f8b43e48356e1a3f"
[[package]]
name = "swap"
-version = "0.13.4"
+version = "0.13.0"
dependencies = [
"anyhow",
"async-compression",
@@ -4569,7 +4417,7 @@ dependencies = [
"futures",
"get-port",
"hex",
- "hyper 1.5.0",
+ "hyper 1.3.1",
"itertools 0.13.0",
"jsonrpsee",
"jsonrpsee-core",
@@ -4578,14 +4426,12 @@ dependencies = [
"monero",
"monero-harness",
"monero-rpc",
- "once_cell",
"pem",
"port_check",
"proptest",
"qrcode",
"rand 0.8.3",
"rand_chacha 0.3.1",
- "regex",
"reqwest",
"rust_decimal",
"rust_decimal_macros",
@@ -4609,7 +4455,7 @@ dependencies = [
"tokio-tar",
"tokio-tungstenite",
"tokio-util",
- "toml 0.8.19",
+ "toml 0.8.13",
"torut",
"tracing",
"tracing-appender",
@@ -4635,9 +4481,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.79"
+version = "2.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
+checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e"
dependencies = [
"proc-macro2",
"quote",
@@ -4646,12 +4492,9 @@ dependencies = [
[[package]]
name = "sync_wrapper"
-version = "1.0.1"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
-dependencies = [
- "futures-core",
-]
+checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
name = "synstructure"
@@ -4666,16 +4509,36 @@ dependencies = [
]
[[package]]
-name = "tempfile"
-version = "3.13.0"
+name = "system-configuration"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
+checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation",
+ "system-configuration-sys",
+]
+
+[[package]]
+name = "system-configuration-sys"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
dependencies = [
"cfg-if 1.0.0",
"fastrand",
- "once_cell",
"rustix",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -4690,9 +4553,9 @@ dependencies = [
[[package]]
name = "testcontainers"
-version = "0.15.0"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f83d2931d7f521af5bae989f716c3fa43a6af9af7ec7a5e21b59ae40878cec00"
+checksum = "0e2b1567ca8a2b819ea7b28c92be35d9f76fb9edb214321dcc86eb96023d1f87"
dependencies = [
"bollard-stubs",
"futures",
@@ -4716,22 +4579,22 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.65"
+version = "1.0.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5"
+checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.65"
+version = "1.0.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602"
+checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 2.0.46",
]
[[package]]
@@ -4812,9 +4675,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
-version = "1.38.1"
+version = "1.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df"
+checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787"
dependencies = [
"backtrace",
"bytes",
@@ -4831,13 +4694,13 @@ dependencies = [
[[package]]
name = "tokio-macros"
-version = "2.3.0"
+version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"
+checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 2.0.46",
]
[[package]]
@@ -4864,20 +4727,19 @@ dependencies = [
[[package]]
name = "tokio-rustls"
-version = "0.26.0"
+version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4"
+checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5"
dependencies = [
- "rustls 0.23.10",
- "rustls-pki-types",
+ "rustls 0.21.10",
"tokio",
]
[[package]]
name = "tokio-socks"
-version = "0.5.2"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f"
+checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0"
dependencies = [
"either",
"futures-util",
@@ -4930,9 +4792,9 @@ dependencies = [
[[package]]
name = "tokio-util"
-version = "0.7.12"
+version = "0.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a"
+checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1"
dependencies = [
"bytes",
"futures-core",
@@ -4953,9 +4815,9 @@ dependencies = [
[[package]]
name = "toml"
-version = "0.8.19"
+version = "0.8.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
+checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba"
dependencies = [
"serde",
"serde_spanned",
@@ -4965,18 +4827,18 @@ dependencies = [
[[package]]
name = "toml_datetime"
-version = "0.6.8"
+version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
+checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
-version = "0.22.20"
+version = "0.22.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"
+checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c"
dependencies = [
"indexmap 2.1.0",
"serde",
@@ -5009,11 +4871,6 @@ version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [
- "futures-core",
- "futures-util",
- "pin-project 1.0.5",
- "pin-project-lite 0.2.13",
- "tokio",
"tower-layer",
"tower-service",
"tracing",
@@ -5063,7 +4920,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 2.0.46",
]
[[package]]
@@ -5343,9 +5200,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "url"
-version = "2.5.2"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c"
+checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
dependencies = [
"form_urlencoded",
"idna 0.5.0",
@@ -5361,9 +5218,9 @@ checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7"
[[package]]
name = "uuid"
-version = "1.11.0"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a"
+checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0"
dependencies = [
"getrandom 0.2.11",
"serde",
@@ -5389,9 +5246,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "vergen"
-version = "8.3.2"
+version = "8.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2990d9ea5967266ea0ccf413a4aa5c42a93dbcfda9cb49a97de6931726b12566"
+checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525"
dependencies = [
"anyhow",
"cfg-if 1.0.0",
@@ -5470,7 +5327,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 2.0.46",
"wasm-bindgen-shared",
]
@@ -5504,7 +5361,7 @@ checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 2.0.46",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -5578,12 +5435,9 @@ dependencies = [
[[package]]
name = "webpki-roots"
-version = "0.26.1"
+version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009"
-dependencies = [
- "rustls-pki-types",
-]
+checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10"
[[package]]
name = "which"
@@ -5623,36 +5477,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-[[package]]
-name = "windows-registry"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0"
-dependencies = [
- "windows-result",
- "windows-strings",
- "windows-targets 0.52.6",
-]
-
-[[package]]
-name = "windows-result"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
-dependencies = [
- "windows-targets 0.52.6",
-]
-
-[[package]]
-name = "windows-strings"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
-dependencies = [
- "windows-result",
- "windows-targets 0.52.6",
-]
-
[[package]]
name = "windows-sys"
version = "0.32.0"
@@ -5681,16 +5505,7 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
- "windows-targets 0.52.6",
-]
-
-[[package]]
-name = "windows-sys"
-version = "0.59.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
-dependencies = [
- "windows-targets 0.52.6",
+ "windows-targets 0.52.0",
]
[[package]]
@@ -5710,18 +5525,17 @@ dependencies = [
[[package]]
name = "windows-targets"
-version = "0.52.6"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
- "windows_aarch64_gnullvm 0.52.6",
- "windows_aarch64_msvc 0.52.6",
- "windows_i686_gnu 0.52.6",
- "windows_i686_gnullvm",
- "windows_i686_msvc 0.52.6",
- "windows_x86_64_gnu 0.52.6",
- "windows_x86_64_gnullvm 0.52.6",
- "windows_x86_64_msvc 0.52.6",
+ "windows_aarch64_gnullvm 0.52.0",
+ "windows_aarch64_msvc 0.52.0",
+ "windows_i686_gnu 0.52.0",
+ "windows_i686_msvc 0.52.0",
+ "windows_x86_64_gnu 0.52.0",
+ "windows_x86_64_gnullvm 0.52.0",
+ "windows_x86_64_msvc 0.52.0",
]
[[package]]
@@ -5732,9 +5546,9 @@ checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
[[package]]
name = "windows_aarch64_gnullvm"
-version = "0.52.6"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
@@ -5750,9 +5564,9 @@ checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
[[package]]
name = "windows_aarch64_msvc"
-version = "0.52.6"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
@@ -5768,15 +5582,9 @@ checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
[[package]]
name = "windows_i686_gnu"
-version = "0.52.6"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
-
-[[package]]
-name = "windows_i686_gnullvm"
-version = "0.52.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
@@ -5792,9 +5600,9 @@ checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
[[package]]
name = "windows_i686_msvc"
-version = "0.52.6"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
@@ -5810,9 +5618,9 @@ checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
[[package]]
name = "windows_x86_64_gnu"
-version = "0.52.6"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
@@ -5822,9 +5630,9 @@ checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
[[package]]
name = "windows_x86_64_gnullvm"
-version = "0.52.6"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
@@ -5840,15 +5648,15 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]]
name = "windows_x86_64_msvc"
-version = "0.52.6"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "winnow"
-version = "0.6.18"
+version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f"
+checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8"
dependencies = [
"memchr",
]
@@ -5862,6 +5670,16 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "winreg"
+version = "0.50.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
+dependencies = [
+ "cfg-if 1.0.0",
+ "windows-sys 0.48.0",
+]
+
[[package]]
name = "x25519-dalek"
version = "1.1.0"
@@ -5900,22 +5718,23 @@ dependencies = [
[[package]]
name = "zeroize"
-version = "1.7.0"
+version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
+checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36"
dependencies = [
"zeroize_derive",
]
[[package]]
name = "zeroize_derive"
-version = "1.4.2"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
+checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.79",
+ "syn 1.0.109",
+ "synstructure",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index c3d131a1..ab29e919 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,6 +3,4 @@ resolver = "2"
members = [ "monero-harness", "monero-rpc", "swap", "monero-wallet" ]
[patch.crates-io]
-# patch until new release https://github.com/thomaseizinger/rust-jsonrpc-client/pull/51
-jsonrpc_client = { git = "https://github.com/delta1/rust-jsonrpc-client.git", rev = "3b6081697cd616c952acb9c2f02d546357d35506" }
monero = { git = "https://github.com/comit-network/monero-rs", rev = "818f38b" }
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 05e5d64c..00000000
--- a/Dockerfile
+++ /dev/null
@@ -1,22 +0,0 @@
-# This Dockerfile builds the asb binary
-
-FROM rust:1.79-slim AS builder
-
-WORKDIR /build
-
-RUN apt-get update
-RUN apt-get install -y git clang cmake libsnappy-dev
-
-COPY . .
-
-WORKDIR /build/swap
-
-RUN cargo build --release --bin=asb
-
-FROM debian:bookworm-slim
-
-WORKDIR /data
-
-COPY --from=builder /build/target/release/asb /bin/asb
-
-ENTRYPOINT ["asb"]
diff --git a/README.md b/README.md
index 72130de7..35adc5f0 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,3 @@
-> [!CAUTION]
-> # THIS REPO IS UNMAINTAINED
PLEASE USE [UNSTOPPABLESWAP]([url](https://github.com/UnstoppableSwap/core)) INSTEAD
-
-**This repository is unmaintained**. The original developers (@comit-network) have moved on to other projects. Community volunteers are continuing development at [UnstoppableSwap/core](https://github.com/UnstoppableSwap/core), which includes a graphical user interface. Please note that the fork has introduced network-level breaking changes, making it incompatible with peers running this repository - you will not be able to initiate swaps with them.
-
# XMR to BTC Atomic Swap
This repository hosts an MVP for atomically swapping BTC to XMR.
diff --git a/docs/asb/README.md b/docs/asb/README.md
index 88448b71..b1acc877 100644
--- a/docs/asb/README.md
+++ b/docs/asb/README.md
@@ -110,7 +110,7 @@ The minimum and maximum amount as well as a spread, that is added on top of the
In order to be able to trade, the ASB must define a price to be able to agree on the amounts to be swapped with a CLI.
The `XMR<>BTC` price is currently determined by the price from the central exchange Kraken.
Upon startup the ASB connects to the Kraken price websocket and listens on the stream for price updates.
-You can plug in a different price ticker websocket using the `price_ticker_ws_url` configuration option.
+You can plug in a different price ticker websocket using the the `price_ticker_ws_url` configuration option.
You will have to make sure that the format returned is the same as the format used by Kraken.
Currently, we use a spot-price model, i.e. the ASB dictates the price to the CLI.
diff --git a/docs/cli/README.md b/docs/cli/README.md
index eff9d072..d95d90ef 100644
--- a/docs/cli/README.md
+++ b/docs/cli/README.md
@@ -75,7 +75,7 @@ OPTIONS:
This command has three core options:
-- `--change-address`: A Bitcoin address you control. Will be used for refunds of any kind. You can also omit this flag which will refund any change to the internal wallet.
+- `--change-address`: A Bitcoin address you control. Will be used for refunds of any kind.
- `--receive-address`: A Monero address you control. This is where you will receive the Monero after the swap.
- `--seller`: The multiaddress of the seller you want to swap with.
diff --git a/monero-harness/Cargo.toml b/monero-harness/Cargo.toml
index e15c751d..a4c9ce72 100644
--- a/monero-harness/Cargo.toml
+++ b/monero-harness/Cargo.toml
@@ -10,7 +10,7 @@ anyhow = "1"
futures = "0.3"
monero-rpc = { path = "../monero-rpc" }
rand = "0.7"
-testcontainers = "0.15"
+testcontainers = "0.14"
tokio = { version = "1", default-features = false, features = [ "rt-multi-thread", "time", "macros" ] }
tracing = "0.1"
-tracing-subscriber = { version = "0.3", default-features = false, features = [ "fmt", "ansi", "env-filter", "tracing-log" ] }
+tracing-subscriber = { version = "0.2", default-features = false, features = [ "fmt", "ansi", "env-filter", "tracing-log" ] }
diff --git a/monero-rpc/Cargo.toml b/monero-rpc/Cargo.toml
index 18843745..6da1e88a 100644
--- a/monero-rpc/Cargo.toml
+++ b/monero-rpc/Cargo.toml
@@ -12,7 +12,7 @@ jsonrpc_client = { version = "0.7", features = [ "reqwest" ] }
monero = "0.12"
monero-epee-bin-serde = "1"
rand = "0.7"
-reqwest = { version = "0.12", default-features = false, features = [ "json" ] }
+reqwest = { version = "0.11", default-features = false, features = [ "json" ] }
rust_decimal = { version = "1", features = [ "serde-float" ] }
serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"
diff --git a/monero-rpc/src/wallet.rs b/monero-rpc/src/wallet.rs
index 3e21ad1b..bc78e7a6 100644
--- a/monero-rpc/src/wallet.rs
+++ b/monero-rpc/src/wallet.rs
@@ -162,12 +162,6 @@ pub struct BlockHeight {
pub height: u32,
}
-impl fmt::Display for BlockHeight {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{}", self.height)
- }
-}
-
#[derive(Clone, Copy, Debug, Deserialize)]
#[serde(from = "CheckTxKeyResponse")]
pub struct CheckTxKey {
diff --git a/monero-wallet/Cargo.toml b/monero-wallet/Cargo.toml
index 99bd3f4d..81982c83 100644
--- a/monero-wallet/Cargo.toml
+++ b/monero-wallet/Cargo.toml
@@ -14,6 +14,6 @@ rand = "0.7"
curve25519-dalek = "3"
monero-harness = { path = "../monero-harness" }
rand = "0.7"
-testcontainers = "0.15"
+testcontainers = "0.14"
tokio = { version = "1", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs" ] }
tracing-subscriber = { version = "0.2", default-features = false, features = [ "fmt", "ansi", "env-filter", "chrono", "tracing-log" ] }
diff --git a/swap/Cargo.toml b/swap/Cargo.toml
index 678fdb8d..b37570ba 100644
--- a/swap/Cargo.toml
+++ b/swap/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "swap"
-version = "0.13.4"
+version = "0.13.0"
authors = [ "The COMIT guys " ]
edition = "2021"
description = "XMR/BTC trustless atomic swaps."
@@ -37,14 +37,12 @@ jsonrpsee-core = "0.16.2"
libp2p = { version = "0.42.2", default-features = false, features = [ "tcp-tokio", "yamux", "mplex", "dns-tokio", "noise", "request-response", "websocket", "ping", "rendezvous", "identify" ] }
monero = { version = "0.12", features = [ "serde_support" ] }
monero-rpc = { path = "../monero-rpc" }
-once_cell = "1.20"
pem = "3.0"
proptest = "1"
qrcode = "0.14"
rand = "0.8"
rand_chacha = "0.3"
-regex = "1.11"
-reqwest = { version = "0.12", features = [ "http2", "rustls-tls", "stream", "socks" ], default-features = false }
+reqwest = { version = "0.11", features = [ "rustls-tls", "stream", "socks" ], default-features = false }
rust_decimal = { version = "1", features = [ "serde-float" ] }
rust_decimal_macros = "1"
serde = { version = "1", features = [ "derive" ] }
@@ -69,7 +67,7 @@ tracing-appender = "0.2"
tracing-futures = { version = "0.2", features = [ "std-future", "futures-03" ] }
tracing-subscriber = { version = "0.3", default-features = false, features = [ "fmt", "ansi", "env-filter", "time", "tracing-log", "json" ] }
url = { version = "2", features = [ "serde" ] }
-uuid = { version = "1.11", features = [ "serde", "v4" ] }
+uuid = { version = "1.8", features = [ "serde", "v4" ] }
void = "1"
[target.'cfg(not(windows))'.dependencies]
@@ -79,19 +77,19 @@ tokio-tar = "0.3"
zip = "0.5"
[dev-dependencies]
-bitcoin-harness = { git = "https://github.com/delta1/bitcoin-harness-rs.git", rev = "80cc8d05db2610d8531011be505b7bee2b5cdf9f" }
+bitcoin-harness = "0.2.2"
get-port = "3"
-hyper = "1.5"
+hyper = "1.3"
jsonrpsee = { version = "0.16.2", features = [ "ws-client" ] }
-mockito = "1.5"
+mockito = "1.3.0"
monero-harness = { path = "../monero-harness" }
port_check = "0.2"
proptest = "1"
sequential-test = "0.2.4"
serde_cbor = "0.11"
-serial_test = "3.1"
+serial_test = "3.0"
tempfile = "3"
-testcontainers = "0.15"
+testcontainers = "0.14"
[build-dependencies]
anyhow = "1"
diff --git a/swap/migrations/20240615140942_btcpunished_update.sql b/swap/migrations/20240615140942_btcpunished_update.sql
deleted file mode 100644
index b4c9a8a5..00000000
--- a/swap/migrations/20240615140942_btcpunished_update.sql
+++ /dev/null
@@ -1,135 +0,0 @@
--- This migration script modifies swap states to be compatible with the new state structure introduced in PR #1676.
--- The following changes are made:
--- 1. Bob: BtcPunished state now has a new attribute 'state' (type: State6), 'tx_lock_id' (type: string) remains the same
--- 2. Bob: State6 has two new attributes: 'v' (monero viewkey) and 'monero_wallet_restore_blockheight' (type: BlockHeight)
--- State6 is used in BtcPunished, CancelTimelockExpired, BtcCancelled, BtcRefunded states
--- 3. Alice: BtcPunished state now has a new attribute 'state3' (type: State3)
-
--- Alice: Add new attribute 'state3' (type: State3) to the BtcPunished state by copying it from the BtcLocked state
-UPDATE swap_states SET
- state = json_replace( -- Replaces "{"Alice":{"Done":"BtcPunished"}}" with "{"Alice": {"Done": "BtcPunished": {"state": } }}"
- state,
- '$.Alice.Done',
- json_object(
- 'BtcPunished',
- (
- SELECT json_extract(states.state, '$.Alice.BtcLocked') -- Read state3 object from BtcLocked
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id -- swap_states.swap_id is id of the BtcPunished row
- AND json_extract(states.state, '$.Alice.BtcLocked') IS NOT NULL -- Filters out only the BtcLocked state
- )
- )
- )
-WHERE json_extract(state, '$.Alice.Done') = 'BtcPunished'; -- Apply update only to BtcPunished state rows
-
--- Bob: Add new attribute 'state6' (type: State6) to the BtcPunished state by copying it from the BtcCancelled state
--- and add new State6 attributes 'v' and 'monero_wallet_restore_blockheight' from the BtcLocked state
-UPDATE swap_states SET
- state = json_replace(
- state,
- '$.Bob', -- Replace '{"Bob":{"Done": {"BtcPunished": {"tx_lock_id":"..."} }}}' with {"Bob":{"BtcPunished":{"state":{}, "tx_lock_id": "..."}}}
- json_object(
- 'BtcPunished', -- {"Bob":{"BtcPunished":{}}
- json_object(
- 'state', -- {"Bob":{"BtcPunished":{"state": {}}}
- json_insert(
- ( -- object that we insert properties into (original state6 from BtcCancelled state)
- SELECT json_extract(states.state, '$.Bob.BtcCancelled') -- Get state6 from BtcCancelled state
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id
- AND json_extract(states.state, '$.Bob.BtcCancelled') IS NOT NULL -- Filters out only the BtcCancelled state
- ),
- '$.v', -- {"Bob":{"BtcPunished":{"state": {..., "v": "..."}, "tx_lock_id": "..."}}}
- ( -- Get v property from BtcLocked state
- SELECT json_extract(states.state, '$.Bob.BtcLocked.state3.v')
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id -- swap_states.swap_id is id of the BtcPunished row
- AND json_extract(states.state, '$.Bob.BtcLocked') IS NOT NULL -- Filters out only the BtcLocked state
- ),
- '$.monero_wallet_restore_blockheight', -- { "Bob": { "BtcPunished":{"state": {..., "monero_wallet_restore_blockheight": {"height":...}} }, "tx_lock_id": "..."} } }
- ( -- Get monero_wallet_restore_blockheight property from BtcLocked state
- SELECT json_extract(states.state, '$.Bob.BtcLocked.monero_wallet_restore_blockheight')
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id -- swap_states.swap_id is id of the BtcPunished row, states.swap_id is id of the row that we are looking for
- AND json_extract(states.state, '$.Bob.BtcLocked') IS NOT NULL -- Filters out only the BtcLocked state
- )
- ),
- 'tx_lock_id', -- Insert tx_lock_id BtcPunished -> {"Bob": {"Done": {"BtcPunished": {"state":{}, "tx_lock_id": "..."} } }
- json_extract(state, '$.Bob.Done.BtcPunished.tx_lock_id') -- Gets tx_lock_id from original state row
- )
- )
- )
-WHERE json_extract(state, '$.Bob.Done.BtcPunished') IS NOT NULL; -- Apply update only to BtcPunished state rows
-
--- Bob: Add new State6 attributes 'v' and 'monero_wallet_restore_blockheight' to the BtcRefunded state
-UPDATE swap_states SET
- state = json_insert(
- state, -- Object that we insert properties into (original state from the row)
- '$.Bob.Done.BtcRefunded.v', -- {"Bob":{"BtcRefunded":{..., "v": "..."}}}
- (
- SELECT json_extract(states.state, '$.Bob.BtcLocked.state3.v')
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id -- swap_states.swap_id is id of the BtcRefunded row, states.swap_id is id of the row that we are looking for
- AND json_extract(states.state, '$.Bob.BtcLocked') IS NOT NULL
- ),
- '$.Bob.Done.BtcRefunded.monero_wallet_restore_blockheight', -- {"Bob":{"BtcRefunded":{..., "monero_wallet_restore_blockheight": {"height":...}} }}
- (
- SELECT json_extract(states.state, '$.Bob.BtcLocked.monero_wallet_restore_blockheight')
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id
- AND json_extract(states.state, '$.Bob.BtcLocked') IS NOT NULL
- )
- )
-WHERE json_extract(state, '$.Bob.Done.BtcRefunded') IS NOT NULL; -- Apply update only to BtcRefunded state rows
-
--- Bob: Add new State6 attributes 'v' and 'monero_wallet_restore_blockheight' to the BtcCancelled state
-UPDATE swap_states SET
- state = json_insert(
- state,
- '$.Bob.BtcCancelled.v',
- (
- SELECT json_extract(states.state, '$.Bob.BtcLocked.state3.v')
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id
- AND json_extract(states.state, '$.Bob.BtcLocked') IS NOT NULL
- ),
- '$.Bob.BtcCancelled.monero_wallet_restore_blockheight',
- (
- SELECT json_extract(states.state, '$.Bob.BtcLocked.monero_wallet_restore_blockheight')
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id
- AND json_extract(states.state, '$.Bob.BtcLocked') IS NOT NULL
- )
- )
-WHERE json_extract(state, '$.Bob.BtcCancelled') IS NOT NULL; -- Apply update only to BtcCancelled state rows
-
--- Bob: Add new State6 attributes 'v' and 'monero_wallet_restore_blockheight' to the CancelTimelockExpired state
-UPDATE swap_states SET
- state = json_insert(
- state,
- '$.Bob.CancelTimelockExpired.v',
- (
- SELECT json_extract(states.state, '$.Bob.BtcLocked.state3.v')
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id
- AND json_extract(states.state, '$.Bob.BtcLocked') IS NOT NULL
- ),
- '$.Bob.CancelTimelockExpired.monero_wallet_restore_blockheight',
- (
- SELECT json_extract(states.state, '$.Bob.BtcLocked.monero_wallet_restore_blockheight')
- FROM swap_states AS states
- WHERE
- states.swap_id = swap_states.swap_id
- AND json_extract(states.state, '$.Bob.BtcLocked') IS NOT NULL
- )
- )
-WHERE json_extract(state, '$.Bob.CancelTimelockExpired') IS NOT NULL; -- Apply update only to CancelTimelockExpired state rows
\ No newline at end of file
diff --git a/swap/migrations/20240701231624_create_buffered_transfer_proofs_table.sql b/swap/migrations/20240701231624_create_buffered_transfer_proofs_table.sql
deleted file mode 100644
index 32d2c918..00000000
--- a/swap/migrations/20240701231624_create_buffered_transfer_proofs_table.sql
+++ /dev/null
@@ -1,5 +0,0 @@
-CREATE TABLE if NOT EXISTS buffered_transfer_proofs
-(
- swap_id TEXT PRIMARY KEY NOT NULL,
- proof TEXT NOT NULL
-);
\ No newline at end of file
diff --git a/swap/sqlx-data.json b/swap/sqlx-data.json
index 6ab0f14a..f24a50e6 100644
--- a/swap/sqlx-data.json
+++ b/swap/sqlx-data.json
@@ -195,33 +195,5 @@
}
},
"query": "\n SELECT state\n FROM swap_states\n WHERE swap_id = ?\n "
- },
- "e36c287aa98ae80ad4b6bb6f7e4b59cced041406a9db71da827b09f0d3bacfd6": {
- "describe": {
- "columns": [],
- "nullable": [],
- "parameters": {
- "Right": 2
- }
- },
- "query": "\n INSERT INTO buffered_transfer_proofs (\n swap_id,\n proof\n ) VALUES (?, ?);\n "
- },
- "e9d422daf774d099fcbde6c4cda35821da948bd86cc57798b4d8375baf0b51ae": {
- "describe": {
- "columns": [
- {
- "name": "proof",
- "ordinal": 0,
- "type_info": "Text"
- }
- ],
- "nullable": [
- false
- ],
- "parameters": {
- "Right": 1
- }
- },
- "query": "\n SELECT proof\n FROM buffered_transfer_proofs\n WHERE swap_id = ?\n "
}
}
\ No newline at end of file
diff --git a/swap/src/api.rs b/swap/src/api.rs
index ea87aae3..340c2e39 100644
--- a/swap/src/api.rs
+++ b/swap/src/api.rs
@@ -1,13 +1,12 @@
pub mod request;
use crate::cli::command::{Bitcoin, Monero, Tor};
-use crate::common::tracing_util::Format;
-use crate::database::{open_db, AccessMode};
+use crate::database::open_db;
use crate::env::{Config as EnvConfig, GetConfig, Mainnet, Testnet};
use crate::fs::system_data_dir;
use crate::network::rendezvous::XmrBtcNamespace;
use crate::protocol::Database;
use crate::seed::Seed;
-use crate::{bitcoin, common, monero};
+use crate::{bitcoin, cli, monero};
use anyhow::{bail, Context as AnyContext, Error, Result};
use futures::future::try_join_all;
use std::fmt;
@@ -17,8 +16,6 @@ use std::path::PathBuf;
use std::sync::{Arc, Once};
use tokio::sync::{broadcast, broadcast::Sender, Mutex, RwLock};
use tokio::task::JoinHandle;
-use tracing::level_filters::LevelFilter;
-use tracing::Level;
use url::Url;
static START: Once = Once::new();
@@ -170,7 +167,6 @@ pub struct Context {
pub swap_lock: Arc,
pub config: Config,
pub tasks: Arc,
- pub is_daemon: bool,
}
#[allow(clippy::too_many_arguments)]
@@ -184,20 +180,12 @@ impl Context {
debug: bool,
json: bool,
server_address: Option,
- is_daemon: bool,
) -> Result {
let data_dir = data::data_dir_from(data, is_testnet)?;
let env_config = env_config_from(is_testnet);
- let format = if json { Format::Json } else { Format::Raw };
- let level_filter = if debug {
- LevelFilter::from_level(Level::DEBUG)
- } else {
- LevelFilter::from_level(Level::INFO)
- };
-
START.call_once(|| {
- let _ = common::tracing_util::init(level_filter, format, data_dir.join("logs"));
+ let _ = cli::tracing::init(debug, json, data_dir.join("logs"));
});
let seed = Seed::from_file_or_generate(data_dir.as_path())
@@ -236,7 +224,7 @@ impl Context {
let tor_socks5_port = tor.map_or(9050, |tor| tor.tor_socks5_port);
let context = Context {
- db: open_db(data_dir.join("sqlite"), AccessMode::ReadWrite).await?,
+ db: open_db(data_dir.join("sqlite")).await?,
bitcoin_wallet,
monero_wallet,
monero_rpc_process,
@@ -253,7 +241,6 @@ impl Context {
},
swap_lock: Arc::new(SwapLock::new()),
tasks: Arc::new(PendingTaskList::default()),
- is_daemon,
};
Ok(context)
@@ -272,19 +259,14 @@ impl Context {
bitcoin_wallet: Some(bob_bitcoin_wallet),
monero_wallet: Some(bob_monero_wallet),
config,
- db: open_db(db_path, AccessMode::ReadWrite)
+ db: open_db(db_path)
.await
.expect("Could not open sqlite database"),
monero_rpc_process: None,
swap_lock: Arc::new(SwapLock::new()),
tasks: Arc::new(PendingTaskList::default()),
- is_daemon: true,
}
}
-
- pub fn bitcoin_wallet(&self) -> Option> {
- self.bitcoin_wallet.clone()
- }
}
impl fmt::Debug for Context {
@@ -451,7 +433,7 @@ pub mod api_test {
Request::new(Method::BuyXmr {
seller,
- bitcoin_change_address: Some(bitcoin_change_address),
+ bitcoin_change_address,
monero_receive_address,
swap_id: Uuid::new_v4(),
})
diff --git a/swap/src/api/request.rs b/swap/src/api/request.rs
index 33e261d3..02bf27e1 100644
--- a/swap/src/api/request.rs
+++ b/swap/src/api/request.rs
@@ -1,7 +1,6 @@
use crate::api::Context;
use crate::bitcoin::{Amount, ExpiredTimelocks, TxLock};
use crate::cli::{list_sellers, EventLoop, SellerStatus};
-use crate::common::get_logs;
use crate::libp2p_ext::MultiAddrExt;
use crate::network::quote::{BidQuote, ZeroQuoteReceived};
use crate::network::swarm;
@@ -9,18 +8,14 @@ use crate::protocol::bob::{BobState, Swap};
use crate::protocol::{bob, State};
use crate::{bitcoin, cli, monero, rpc};
use anyhow::{bail, Context as AnyContext, Result};
-use comfy_table::Table;
use libp2p::core::Multiaddr;
use qrcode::render::unicode;
use qrcode::QrCode;
-use rust_decimal::prelude::FromPrimitive;
-use rust_decimal::Decimal;
use serde_json::json;
use std::cmp::min;
use std::convert::TryInto;
use std::future::Future;
use std::net::SocketAddr;
-use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use tracing::{debug_span, field, Instrument, Span};
@@ -36,7 +31,7 @@ pub struct Request {
pub enum Method {
BuyXmr {
seller: Multiaddr,
- bitcoin_change_address: Option,
+ bitcoin_change_address: bitcoin::Address,
monero_receive_address: monero::Address,
swap_id: Uuid,
},
@@ -50,11 +45,6 @@ pub enum Method {
swap_id: Uuid,
},
History,
- Logs {
- logs_dir: Option,
- redact: bool,
- swap_id: Option,
- },
Config,
WithdrawBtc {
amount: Option,
@@ -132,13 +122,6 @@ impl Method {
log_reference_id = field::Empty
)
}
- Method::Logs { .. } => {
- debug_span!(
- "method",
- method_name = "Logs",
- log_reference_id = field::Empty
- )
- }
Method::ListSellers { .. } => {
debug_span!(
"method",
@@ -352,25 +335,6 @@ impl Request {
let env_config = context.config.env_config;
let seed = context.config.seed.clone().context("Could not get seed")?;
- // When no change address was provided we default to the internal wallet
- let bitcoin_change_address = match bitcoin_change_address {
- Some(addr) => addr,
- None => {
- let internal_wallet_address = context
- .bitcoin_wallet()
- .expect("bitcoin wallet should exist")
- .new_address()
- .await?;
-
- tracing::info!(
- internal_wallet_address=%internal_wallet_address,
- "No --change-address supplied. Any change will be received to the internal wallet."
- );
-
- internal_wallet_address
- }
- };
-
let seller_peer_id = seller
.extract_peer_id()
.context("Seller address must contain peer ID")?;
@@ -412,7 +376,7 @@ impl Request {
},
result = async {
let (event_loop, mut event_loop_handle) =
- EventLoop::new(swap_id, swarm, seller_peer_id, context.db.clone())?;
+ EventLoop::new(swap_id, swarm, seller_peer_id)?;
let event_loop = tokio::spawn(event_loop.run().in_current_span());
let bid_quote = event_loop_handle.request_quote().await?;
@@ -558,7 +522,7 @@ impl Request {
}
let (event_loop, event_loop_handle) =
- EventLoop::new(swap_id, swarm, seller_peer_id, context.db.clone())?;
+ EventLoop::new(swap_id, swarm, seller_peer_id)?;
let monero_receive_address = context.db.get_monero_address(swap_id).await?;
let swap = Swap::from_db(
Arc::clone(&context.db),
@@ -655,111 +619,14 @@ impl Request {
})
}
Method::History => {
- let mut table = Table::new();
- table.set_header(vec![
- "Swap ID",
- "Start Date",
- "State",
- "BTC Amount",
- "XMR Amount",
- "Exchange Rate",
- "Trading Partner Peer ID",
- ]);
-
- let all_swaps = context.db.all().await?;
- let mut json_results = Vec::new();
-
- for (swap_id, state) in all_swaps {
- let result: Result<_> = async {
- let latest_state: BobState = state.try_into()?;
- let all_states = context.db.get_states(swap_id).await?;
- let state3 = all_states
- .iter()
- .find_map(|s| {
- if let State::Bob(BobState::BtcLocked { state3, .. }) = s {
- Some(state3)
- } else {
- None
- }
- })
- .context("Failed to get \"BtcLocked\" state")?;
-
- let swap_start_date = context.db.get_swap_start_date(swap_id).await?;
- let peer_id = context.db.get_peer_id(swap_id).await?;
- let btc_amount = state3.tx_lock.lock_amount();
- let xmr_amount = state3.xmr;
- let exchange_rate = Decimal::from_f64(btc_amount.to_btc())
- .ok_or_else(|| {
- anyhow::anyhow!("Failed to convert BTC amount to Decimal")
- })?
- .checked_div(xmr_amount.as_xmr())
- .ok_or_else(|| anyhow::anyhow!("Division by zero or overflow"))?;
- let exchange_rate = format!("{} XMR/BTC", exchange_rate.round_dp(8));
-
- let swap_data = json!({
- "swapId": swap_id.to_string(),
- "startDate": swap_start_date.to_string(),
- "state": latest_state.to_string(),
- "btcAmount": btc_amount.to_string(),
- "xmrAmount": xmr_amount.to_string(),
- "exchangeRate": exchange_rate,
- "tradingPartnerPeerId": peer_id.to_string()
- });
-
- if context.config.json {
- tracing::info!(
- swap_id = %swap_id,
- swap_start_date = %swap_start_date,
- latest_state = %latest_state,
- btc_amount = %btc_amount,
- xmr_amount = %xmr_amount,
- exchange_rate = %exchange_rate,
- trading_partner_peer_id = %peer_id,
- "Found swap in database"
- );
- } else {
- table.add_row(vec![
- swap_id.to_string(),
- swap_start_date.to_string(),
- latest_state.to_string(),
- btc_amount.to_string(),
- xmr_amount.to_string(),
- exchange_rate,
- peer_id.to_string(),
- ]);
- }
-
- Ok(swap_data)
- }
- .await;
-
- match result {
- Ok(swap_data) => json_results.push(swap_data),
- Err(e) => {
- tracing::error!(swap_id = %swap_id, error = %e, "Failed to get swap details")
- }
- }
+ let swaps = context.db.all().await?;
+ let mut vec: Vec<(Uuid, String)> = Vec::new();
+ for (swap_id, state) in swaps {
+ let state: BobState = state.try_into()?;
+ vec.push((swap_id, state.to_string()));
}
- if !context.config.json && !context.is_daemon {
- println!("{}", table);
- }
-
- Ok(json!({"swaps": json_results}))
- }
- Method::Logs {
- logs_dir,
- redact,
- swap_id,
- } => {
- let dir = logs_dir.unwrap_or(context.config.data_dir.join("logs"));
- let logs = get_logs(dir, swap_id, redact).await?;
-
- for msg in &logs {
- println!("{msg}");
- }
-
- Ok(json!({ "logs": logs }))
+ Ok(json!({ "swaps": vec }))
}
Method::GetRawStates => {
let raw_history = context.db.raw_all().await?;
@@ -954,7 +821,6 @@ impl Request {
.await
.map_err(|err| {
method_span.in_scope(|| {
- // The {:?} formatter is used to print the entire error chain
tracing::debug!(err = format!("{:?}", err), "API call resulted in an error");
});
err
@@ -1016,24 +882,19 @@ where
loop {
let min_outstanding = bid_quote.min_quantity - max_giveable;
- let min_bitcoin_lock_tx_fee = estimate_fee(min_outstanding).await?;
- let min_deposit_until_swap_will_start = min_outstanding + min_bitcoin_lock_tx_fee;
- let max_deposit_until_maximum_amount_is_reached =
- maximum_amount - max_giveable + min_bitcoin_lock_tx_fee;
+ let min_fee = estimate_fee(min_outstanding).await?;
+ let min_deposit = min_outstanding + min_fee;
tracing::info!(
"Deposit at least {} to cover the min quantity with fee!",
- min_deposit_until_swap_will_start
+ min_deposit
);
tracing::info!(
%deposit_address,
- %min_deposit_until_swap_will_start,
- %max_deposit_until_maximum_amount_is_reached,
+ %min_deposit,
%max_giveable,
%minimum_amount,
%maximum_amount,
- %min_bitcoin_lock_tx_fee,
- price = %bid_quote.price,
"Waiting for Bitcoin deposit",
);
@@ -1052,7 +913,7 @@ where
tracing::info!(%new_balance, %max_giveable, "Received Bitcoin");
if max_giveable < bid_quote.min_quantity {
- tracing::info!("Deposited amount is not enough to cover `min_quantity` when accounting for network fees");
+ tracing::info!("Deposited amount is less than `min_quantity`");
continue;
}
diff --git a/swap/src/asb.rs b/swap/src/asb.rs
index 404a3b61..b5ed8ac1 100644
--- a/swap/src/asb.rs
+++ b/swap/src/asb.rs
@@ -4,6 +4,7 @@ mod event_loop;
mod network;
mod rate;
mod recovery;
+pub mod tracing;
pub use event_loop::{EventLoop, EventLoopHandle, FixedRate, KrakenRate, LatestRate};
pub use network::behaviour::{Behaviour, OutEvent};
diff --git a/swap/src/asb/command.rs b/swap/src/asb/command.rs
index 67565065..f22e1500 100644
--- a/swap/src/asb/command.rs
+++ b/swap/src/asb/command.rs
@@ -19,6 +19,7 @@ where
let args = RawArguments::from_clap(&matches);
let json = args.json;
+ let disable_timestamp = args.disable_timestamp;
let testnet = args.testnet;
let config = args.config;
let command: RawCommand = args.cmd;
@@ -27,35 +28,23 @@ where
RawCommand::Start { resume_only } => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Start { resume_only },
},
- RawCommand::History { only_unfinished } => Arguments {
+ RawCommand::History => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
- cmd: Command::History { only_unfinished },
- },
- RawCommand::Logs {
- logs_dir: dir_path,
- swap_id,
- redact,
- } => Arguments {
- testnet,
- json,
- config_path: config_path(config, testnet)?,
- env_config: env_config(testnet),
- cmd: Command::Logs {
- logs_dir: dir_path,
- swap_id,
- redact,
- },
+ cmd: Command::History,
},
RawCommand::WithdrawBtc { amount, address } => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::WithdrawBtc {
@@ -66,6 +55,7 @@ where
RawCommand::Balance => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Balance,
@@ -73,6 +63,7 @@ where
RawCommand::Config => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Config,
@@ -80,6 +71,7 @@ where
RawCommand::ExportBitcoinWallet => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::ExportBitcoinWallet,
@@ -90,6 +82,7 @@ where
}) => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Redeem {
@@ -103,6 +96,7 @@ where
}) => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Cancel { swap_id },
@@ -112,6 +106,7 @@ where
}) => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Refund { swap_id },
@@ -121,6 +116,7 @@ where
}) => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Punish { swap_id },
@@ -128,6 +124,7 @@ where
RawCommand::ManualRecovery(ManualRecovery::SafelyAbort { swap_id }) => Arguments {
testnet,
json,
+ disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::SafelyAbort { swap_id },
@@ -187,6 +184,7 @@ pub struct BitcoinAddressNetworkMismatch {
pub struct Arguments {
pub testnet: bool,
pub json: bool,
+ pub disable_timestamp: bool,
pub config_path: PathBuf,
pub env_config: env::Config,
pub cmd: Command,
@@ -197,15 +195,8 @@ pub enum Command {
Start {
resume_only: bool,
},
- History {
- only_unfinished: bool,
- },
+ History,
Config,
- Logs {
- logs_dir: Option,
- swap_id: Option,
- redact: bool,
- },
WithdrawBtc {
amount: Option,
address: Address,
@@ -277,33 +268,8 @@ pub enum RawCommand {
)]
resume_only: bool,
},
- #[structopt(about = "Prints all logging messages issued in the past.")]
- Logs {
- #[structopt(
- short = "d",
- help = "Print the logs from this directory instead of the default one."
- )]
- logs_dir: Option,
- #[structopt(
- help = "Redact swap-ids, Bitcoin and Monero addresses.",
- long = "redact"
- )]
- redact: bool,
- #[structopt(
- long = "swap-id",
- help = "Filter for logs concerning this swap.",
- long_help = "This checks whether each logging message contains the swap id. Some messages might be skipped when they don't contain the swap id even though they're relevant."
- )]
- swap_id: Option,
- },
#[structopt(about = "Prints swap-id and the state of each swap ever made.")]
- History {
- #[structopt(
- long = "only-unfinished",
- help = "If set, only unfinished swaps will be printed."
- )]
- only_unfinished: bool,
- },
+ History,
#[structopt(about = "Prints the current config")]
Config,
#[structopt(about = "Allows withdrawing BTC from the internal Bitcoin wallet.")]
@@ -400,6 +366,7 @@ mod tests {
let expected_args = Arguments {
testnet: false,
json: false,
+ disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Start { resume_only: false },
@@ -417,11 +384,10 @@ mod tests {
let expected_args = Arguments {
testnet: false,
json: false,
+ disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
- cmd: Command::History {
- only_unfinished: false,
- },
+ cmd: Command::History,
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
@@ -436,6 +402,7 @@ mod tests {
let expected_args = Arguments {
testnet: false,
json: false,
+ disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Balance,
@@ -457,6 +424,7 @@ mod tests {
let expected_args = Arguments {
testnet: false,
json: false,
+ disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::WithdrawBtc {
@@ -483,6 +451,7 @@ mod tests {
let expected_args = Arguments {
testnet: false,
json: false,
+ disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Cancel {
@@ -508,6 +477,7 @@ mod tests {
let expected_args = Arguments {
testnet: false,
json: false,
+ disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Refund {
@@ -533,6 +503,7 @@ mod tests {
let expected_args = Arguments {
testnet: false,
json: false,
+ disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Punish {
@@ -558,6 +529,7 @@ mod tests {
let expected_args = Arguments {
testnet: false,
json: false,
+ disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::SafelyAbort {
@@ -577,6 +549,7 @@ mod tests {
let expected_args = Arguments {
testnet: true,
json: false,
+ disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Start { resume_only: false },
@@ -594,11 +567,10 @@ mod tests {
let expected_args = Arguments {
testnet: true,
json: false,
+ disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
- cmd: Command::History {
- only_unfinished: false,
- },
+ cmd: Command::History,
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
@@ -613,6 +585,7 @@ mod tests {
let expected_args = Arguments {
testnet: true,
json: false,
+ disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Balance,
@@ -636,6 +609,7 @@ mod tests {
let expected_args = Arguments {
testnet: true,
json: false,
+ disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::WithdrawBtc {
@@ -662,6 +636,7 @@ mod tests {
let expected_args = Arguments {
testnet: true,
json: false,
+ disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Cancel {
@@ -688,6 +663,7 @@ mod tests {
let expected_args = Arguments {
testnet: true,
json: false,
+ disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Refund {
@@ -714,6 +690,7 @@ mod tests {
let expected_args = Arguments {
testnet: true,
json: false,
+ disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Punish {
@@ -740,6 +717,7 @@ mod tests {
let expected_args = Arguments {
testnet: true,
json: false,
+ disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::SafelyAbort {
@@ -759,6 +737,7 @@ mod tests {
let expected_args = Arguments {
testnet: false,
json: false,
+ disable_timestamp: true,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Start { resume_only: false },
diff --git a/swap/src/asb/event_loop.rs b/swap/src/asb/event_loop.rs
index 8e3ac4c3..0d6de9a7 100644
--- a/swap/src/asb/event_loop.rs
+++ b/swap/src/asb/event_loop.rs
@@ -1,7 +1,5 @@
use crate::asb::{Behaviour, OutEvent, Rate};
use crate::monero::Amount;
-use crate::network::cooperative_xmr_redeem_after_punish::CooperativeXmrRedeemRejectReason;
-use crate::network::cooperative_xmr_redeem_after_punish::Response::{Fullfilled, Rejected};
use crate::network::quote::BidQuote;
use crate::network::swap_setup::alice::WalletSnapshot;
use crate::network::transfer_proof;
@@ -255,59 +253,6 @@ where
channel
}.boxed());
}
- SwarmEvent::Behaviour(OutEvent::CooperativeXmrRedeemRequested { swap_id, channel, peer }) => {
- let swap_peer = self.db.get_peer_id(swap_id).await;
- let swap_state = self.db.get_state(swap_id).await;
-
- let (swap_peer, swap_state) = match (swap_peer, swap_state) {
- (Ok(peer), Ok(state)) => (peer, state),
- _ => {
- tracing::warn!(
- swap_id = %swap_id,
- received_from = %peer,
- reason = "swap not found",
- "Rejecting cooperative XMR redeem request"
- );
- if self.swarm.behaviour_mut().cooperative_xmr_redeem.send_response(channel, Rejected { swap_id, reason: CooperativeXmrRedeemRejectReason::UnknownSwap }).is_err() {
- tracing::error!(swap_id = %swap_id, "Failed to reject cooperative XMR redeem request");
- }
- continue;
- }
- };
-
- if swap_peer != peer {
- tracing::warn!(
- swap_id = %swap_id,
- received_from = %peer,
- expected_from = %swap_peer,
- reason = "unexpected peer",
- "Rejecting cooperative XMR redeem request"
- );
- if self.swarm.behaviour_mut().cooperative_xmr_redeem.send_response(channel, Rejected { swap_id, reason: CooperativeXmrRedeemRejectReason::MaliciousRequest }).is_err() {
- tracing::error!(swap_id = %swap_id, "Failed to reject cooperative XMR redeem request");
- }
- continue;
- }
-
- let State::Alice (AliceState::BtcPunished { state3 }) = swap_state else {
- tracing::warn!(
- swap_id = %swap_id,
- reason = "swap is in invalid state",
- "Rejecting cooperative XMR redeem request"
- );
- if self.swarm.behaviour_mut().cooperative_xmr_redeem.send_response(channel, Rejected { swap_id, reason: CooperativeXmrRedeemRejectReason::SwapInvalidState }).is_err() {
- tracing::error!(swap_id = %swap_id, "Failed to reject cooperative XMR redeem request");
- }
- continue;
- };
-
- if self.swarm.behaviour_mut().cooperative_xmr_redeem.send_response(channel, Fullfilled { swap_id, s_a: state3.s_a }).is_err() {
- tracing::error!(peer = %peer, "Failed to respond to cooperative XMR redeem request");
- continue;
- }
-
- tracing::info!(swap_id = %swap_id, peer = %peer, "Fullfilled cooperative XMR redeem request");
- }
SwarmEvent::Behaviour(OutEvent::Rendezvous(libp2p::rendezvous::client::Event::Registered { rendezvous_node, ttl, namespace })) => {
tracing::info!("Successfully registered with rendezvous node: {} with namespace: {} and TTL: {:?}", rendezvous_node, namespace, ttl);
}
diff --git a/swap/src/asb/network.rs b/swap/src/asb/network.rs
index 268a3cba..7b85f8fb 100644
--- a/swap/src/asb/network.rs
+++ b/swap/src/asb/network.rs
@@ -5,9 +5,7 @@ use crate::network::rendezvous::XmrBtcNamespace;
use crate::network::swap_setup::alice;
use crate::network::swap_setup::alice::WalletSnapshot;
use crate::network::transport::authenticate_and_multiplex;
-use crate::network::{
- cooperative_xmr_redeem_after_punish, encrypted_signature, quote, transfer_proof,
-};
+use crate::network::{encrypted_signature, quote, transfer_proof};
use crate::protocol::alice::State3;
use anyhow::{anyhow, Error, Result};
use futures::FutureExt;
@@ -78,11 +76,6 @@ pub mod behaviour {
channel: ResponseChannel<()>,
peer: PeerId,
},
- CooperativeXmrRedeemRequested {
- channel: ResponseChannel,
- swap_id: Uuid,
- peer: PeerId,
- },
Rendezvous(libp2p::rendezvous::client::Event),
Failure {
peer: PeerId,
@@ -121,7 +114,6 @@ pub mod behaviour {
pub quote: quote::Behaviour,
pub swap_setup: alice::Behaviour,
pub transfer_proof: transfer_proof::Behaviour,
- pub cooperative_xmr_redeem: cooperative_xmr_redeem_after_punish::Behaviour,
pub encrypted_signature: encrypted_signature::Behaviour,
pub identify: Identify,
@@ -168,7 +160,6 @@ pub mod behaviour {
),
transfer_proof: transfer_proof::alice(),
encrypted_signature: encrypted_signature::alice(),
- cooperative_xmr_redeem: cooperative_xmr_redeem_after_punish::alice(),
ping: Ping::new(PingConfig::new().with_keep_alive(true)),
identify: Identify::new(identifyConfig),
}
diff --git a/swap/src/asb/recovery/cancel.rs b/swap/src/asb/recovery/cancel.rs
index f71b3e38..ec70a8df 100644
--- a/swap/src/asb/recovery/cancel.rs
+++ b/swap/src/asb/recovery/cancel.rs
@@ -38,8 +38,8 @@ pub async fn cancel(
// Alice already in final state
| AliceState::BtcRedeemed
| AliceState::XmrRefunded
- | AliceState::BtcPunished { .. }
- | AliceState::SafelyAborted => bail!("Swap is in state {} which is not cancelable", state),
+ | AliceState::BtcPunished
+ | AliceState::SafelyAborted => bail!("Swap is is in state {} which is not cancelable", state),
};
let txid = match state3.submit_tx_cancel(bitcoin_wallet.as_ref()).await {
diff --git a/swap/src/asb/recovery/punish.rs b/swap/src/asb/recovery/punish.rs
index e1d1ad28..e94abac8 100644
--- a/swap/src/asb/recovery/punish.rs
+++ b/swap/src/asb/recovery/punish.rs
@@ -38,7 +38,7 @@ pub async fn punish(
// Alice already in final state
| AliceState::BtcRedeemed
| AliceState::XmrRefunded
- | AliceState::BtcPunished { .. }
+ | AliceState::BtcPunished
| AliceState::SafelyAborted => bail!(Error::SwapNotPunishable(state)),
};
@@ -46,9 +46,7 @@ pub async fn punish(
let txid = state3.punish_btc(&bitcoin_wallet).await?;
- let state = AliceState::BtcPunished {
- state3: state3.clone(),
- };
+ let state = AliceState::BtcPunished;
db.insert_latest_state(swap_id, state.clone().into())
.await?;
diff --git a/swap/src/asb/recovery/redeem.rs b/swap/src/asb/recovery/redeem.rs
index 47f4a048..e4642feb 100644
--- a/swap/src/asb/recovery/redeem.rs
+++ b/swap/src/asb/recovery/redeem.rs
@@ -81,7 +81,7 @@ pub async fn redeem(
| AliceState::BtcPunishable { .. }
| AliceState::BtcRedeemed
| AliceState::XmrRefunded
- | AliceState::BtcPunished { .. }
+ | AliceState::BtcPunished
| AliceState::SafelyAborted => bail!(
"Cannot redeem swap {} because it is in state {} which cannot be manually redeemed",
swap_id,
diff --git a/swap/src/asb/recovery/refund.rs b/swap/src/asb/recovery/refund.rs
index 3067a8f6..64e5c3f3 100644
--- a/swap/src/asb/recovery/refund.rs
+++ b/swap/src/asb/recovery/refund.rs
@@ -55,7 +55,7 @@ pub async fn refund(
AliceState::BtcRedeemTransactionPublished { .. }
| AliceState::BtcRedeemed
| AliceState::XmrRefunded
- | AliceState::BtcPunished { .. }
+ | AliceState::BtcPunished
| AliceState::SafelyAborted => bail!(Error::SwapNotRefundable(state)),
};
diff --git a/swap/src/asb/recovery/safely_abort.rs b/swap/src/asb/recovery/safely_abort.rs
index 8a9e1d95..ad162f8d 100644
--- a/swap/src/asb/recovery/safely_abort.rs
+++ b/swap/src/asb/recovery/safely_abort.rs
@@ -31,7 +31,7 @@ pub async fn safely_abort(swap_id: Uuid, db: Arc) -> Result bail!(
"Cannot safely abort swap {} because it is in state {} which cannot be safely aborted",
swap_id,
diff --git a/swap/src/asb/tracing.rs b/swap/src/asb/tracing.rs
new file mode 100644
index 00000000..c21c1e70
--- /dev/null
+++ b/swap/src/asb/tracing.rs
@@ -0,0 +1,30 @@
+use anyhow::Result;
+use tracing_subscriber::filter::LevelFilter;
+use tracing_subscriber::fmt::time::UtcTime;
+use tracing_subscriber::FmtSubscriber;
+
+pub fn init(level: LevelFilter, json_format: bool, timestamp: bool) -> Result<()> {
+ if level == LevelFilter::OFF {
+ return Ok(());
+ }
+
+ let is_terminal = atty::is(atty::Stream::Stderr);
+
+ let builder = FmtSubscriber::builder()
+ .with_env_filter(format!("asb={},swap={}", level, level))
+ .with_writer(std::io::stderr)
+ .with_ansi(is_terminal)
+ .with_timer(UtcTime::rfc_3339())
+ .with_target(false);
+
+ match (json_format, timestamp) {
+ (true, true) => builder.json().init(),
+ (true, false) => builder.json().without_time().init(),
+ (false, true) => builder.init(),
+ (false, false) => builder.without_time().init(),
+ }
+
+ tracing::info!(%level, "Initialized tracing");
+
+ Ok(())
+}
diff --git a/swap/src/bin/asb.rs b/swap/src/bin/asb.rs
index 3a0d2dd4..ff3b0e4c 100644
--- a/swap/src/bin/asb.rs
+++ b/swap/src/bin/asb.rs
@@ -18,8 +18,6 @@ use libp2p::core::multiaddr::Protocol;
use libp2p::core::Multiaddr;
use libp2p::swarm::AddressScore;
use libp2p::Swarm;
-use rust_decimal::prelude::FromPrimitive;
-use rust_decimal::Decimal;
use std::convert::TryInto;
use std::env;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
@@ -31,50 +29,51 @@ use swap::asb::config::{
initial_setup, query_user_for_initial_config, read_config, Config, ConfigNotInitialized,
};
use swap::asb::{cancel, punish, redeem, refund, safely_abort, EventLoop, Finality, KrakenRate};
-use swap::common::tracing_util::Format;
-use swap::common::{self, check_latest_version, get_logs};
-use swap::database::{open_db, AccessMode};
+use swap::common::check_latest_version;
+use swap::database::open_db;
use swap::network::rendezvous::XmrBtcNamespace;
use swap::network::swarm;
-use swap::protocol::alice::swap::is_complete;
use swap::protocol::alice::{run, AliceState};
-use swap::protocol::State;
use swap::seed::Seed;
use swap::tor::AuthenticatedClient;
-use swap::{bitcoin, kraken, monero, tor};
+use swap::{asb, bitcoin, kraken, monero, tor};
use tracing_subscriber::filter::LevelFilter;
const DEFAULT_WALLET_NAME: &str = "asb-wallet";
#[tokio::main]
async fn main() -> Result<()> {
- // parse cli arguments
let Arguments {
testnet,
json,
+ disable_timestamp,
config_path,
env_config,
cmd,
} = match parse_args(env::args_os()) {
Ok(args) => args,
Err(e) => {
- // make sure to display the clap error message it exists
if let Some(clap_err) = e.downcast_ref::() {
- if let ErrorKind::HelpDisplayed | ErrorKind::VersionDisplayed = clap_err.kind {
- println!("{}", clap_err.message);
- std::process::exit(0);
+ match clap_err.kind {
+ ErrorKind::HelpDisplayed | ErrorKind::VersionDisplayed => {
+ println!("{}", clap_err.message);
+ std::process::exit(0);
+ }
+ _ => {
+ bail!(e);
+ }
}
}
bail!(e);
}
};
- // warn if we're not on the latest version
if let Err(e) = check_latest_version(env!("CARGO_PKG_VERSION")).await {
eprintln!("{}", e);
}
- // read config from the specified path
+ asb::tracing::init(LevelFilter::DEBUG, json, !disable_timestamp).expect("initialize tracing");
+
let config = match read_config(config_path.clone())? {
Ok(config) => config,
Err(ConfigNotInitialized {}) => {
@@ -83,12 +82,6 @@ async fn main() -> Result<()> {
}
};
- // initialize tracing
- let format = if json { Format::Json } else { Format::Raw };
- let log_dir = config.data.dir.join("logs");
- common::tracing_util::init(LevelFilter::DEBUG, format, log_dir).expect("initialize tracing");
-
- // check for conflicting env / config values
if config.monero.network != env_config.monero_network {
bail!(format!(
"Expected monero network in config file to be {:?} but was {:?}",
@@ -102,20 +95,19 @@ async fn main() -> Result<()> {
));
}
+ let db = open_db(config.data.dir.join("sqlite")).await?;
+
let seed =
Seed::from_file_or_generate(&config.data.dir).expect("Could not retrieve/initialize seed");
match cmd {
Command::Start { resume_only } => {
- let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite).await?;
-
// check and warn for duplicate rendezvous points
let mut rendezvous_addrs = config.network.rendezvous_point.clone();
let prev_len = rendezvous_addrs.len();
rendezvous_addrs.sort();
rendezvous_addrs.dedup();
let new_len = rendezvous_addrs.len();
-
if new_len < prev_len {
tracing::warn!(
"`rendezvous_point` config has {} duplicate entries, they are being ignored.",
@@ -123,12 +115,9 @@ async fn main() -> Result<()> {
);
}
- // initialize monero wallet
let monero_wallet = init_monero_wallet(&config, env_config).await?;
let monero_address = monero_wallet.get_main_address();
tracing::info!(%monero_address, "Monero wallet address");
-
- // check monero balance
let monero = monero_wallet.get_balance().await?;
match (monero.balance, monero.unlocked_balance) {
(0, _) => {
@@ -151,7 +140,6 @@ async fn main() -> Result<()> {
}
}
- // init bitcoin wallet
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
let bitcoin_balance = bitcoin_wallet.balance().await?;
tracing::info!(%bitcoin_balance, "Bitcoin wallet balance");
@@ -236,105 +224,22 @@ async fn main() -> Result<()> {
event_loop.run().await;
}
- Command::History { only_unfinished } => {
- let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadOnly).await?;
- let mut table: Table = Table::new();
+ Command::History => {
+ let mut table = Table::new();
- table.set_header(vec![
- "Swap ID",
- "Start Date",
- "State",
- "BTC Amount",
- "XMR Amount",
- "Exchange Rate",
- "Trading Partner Peer ID",
- "Completed",
- ]);
+ table.set_header(vec!["SWAP ID", "STATE"]);
- let all_swaps = db.all().await?;
- for (swap_id, state) in all_swaps {
- if let Err(e) = async {
- let latest_state: AliceState = state.try_into()?;
- let is_completed = is_complete(&latest_state);
-
- if only_unfinished && is_completed {
- return Ok::<_, anyhow::Error>(());
- }
-
- let all_states = db.get_states(swap_id).await?;
- let state3 = all_states
- .iter()
- .find_map(|s| match s {
- State::Alice(AliceState::BtcLockTransactionSeen { state3 }) => {
- Some(state3)
- }
- _ => None,
- })
- .context("Failed to get \"BtcLockTransactionSeen\" state")?;
-
- let swap_start_date = db.get_swap_start_date(swap_id).await?;
- let peer_id = db.get_peer_id(swap_id).await?;
-
- let exchange_rate = Decimal::from_f64(state3.btc.to_btc())
- .ok_or_else(|| anyhow::anyhow!("Failed to convert BTC amount to Decimal"))?
- .checked_div(state3.xmr.as_xmr())
- .ok_or_else(|| anyhow::anyhow!("Division by zero or overflow"))?;
- let exchange_rate = format!("{} XMR/BTC", exchange_rate.round_dp(8));
-
- if json {
- tracing::info!(
- swap_id = %swap_id,
- swap_start_date = %swap_start_date,
- latest_state = %latest_state,
- btc_amount = %state3.btc,
- xmr_amount = %state3.xmr,
- exchange_rate = %exchange_rate,
- trading_partner_peer_id = %peer_id,
- completed = is_completed,
- "Found swap in database"
- );
- } else {
- table.add_row(vec![
- swap_id.to_string(),
- swap_start_date.to_string(),
- latest_state.to_string(),
- state3.btc.to_string(),
- state3.xmr.to_string(),
- exchange_rate,
- peer_id.to_string(),
- is_completed.to_string(),
- ]);
- }
-
- Ok::<_, anyhow::Error>(())
- }
- .await
- {
- tracing::error!(swap_id = %swap_id, error = %e, "Failed to get swap details");
- }
+ for (swap_id, state) in db.all().await? {
+ let state: AliceState = state.try_into()?;
+ table.add_row(vec![swap_id.to_string(), state.to_string()]);
}
- if !json {
- println!("{}", table);
- }
+ println!("{}", table);
}
Command::Config => {
let config_json = serde_json::to_string_pretty(&config)?;
println!("{}", config_json);
}
- Command::Logs {
- logs_dir,
- swap_id,
- redact,
- } => {
- let dir = logs_dir.unwrap_or(config.data.dir.join("logs"));
-
- let log_messages = get_logs(dir, swap_id, redact).await?;
-
- for msg in log_messages {
- println!("{msg}");
- }
- }
Command::WithdrawBtc { amount, address } => {
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
@@ -365,8 +270,6 @@ async fn main() -> Result<()> {
tracing::info!(%bitcoin_balance, %monero_balance, "Current balance");
}
Command::Cancel { swap_id } => {
- let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite).await?;
-
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
let (txid, _) = cancel(swap_id, Arc::new(bitcoin_wallet), db).await?;
@@ -374,8 +277,6 @@ async fn main() -> Result<()> {
tracing::info!("Cancel transaction successfully published with id {}", txid);
}
Command::Refund { swap_id } => {
- let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite).await?;
-
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
let monero_wallet = init_monero_wallet(&config, env_config).await?;
@@ -390,8 +291,6 @@ async fn main() -> Result<()> {
tracing::info!("Monero successfully refunded");
}
Command::Punish { swap_id } => {
- let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite).await?;
-
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
let (txid, _) = punish(swap_id, Arc::new(bitcoin_wallet), db).await?;
@@ -399,8 +298,6 @@ async fn main() -> Result<()> {
tracing::info!("Punish transaction successfully published with id {}", txid);
}
Command::SafelyAbort { swap_id } => {
- let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite).await?;
-
safely_abort(swap_id, db).await?;
tracing::info!("Swap safely aborted");
@@ -409,8 +306,6 @@ async fn main() -> Result<()> {
swap_id,
do_not_await_finality,
} => {
- let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite).await?;
-
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
let (txid, _) = redeem(
diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs
index 55a05b73..9748d740 100644
--- a/swap/src/bitcoin/wallet.rs
+++ b/swap/src/bitcoin/wallet.rs
@@ -468,7 +468,6 @@ where
) -> Result {
let client = self.client.lock().await;
let fee_rate = client.estimate_feerate(self.target_block)?;
-
let min_relay_fee = client.min_relay_fee()?;
estimate_fee(weight, transfer_amount, fee_rate, min_relay_fee)
@@ -872,11 +871,6 @@ impl EstimateFeeRate for Client {
// https://github.com/romanz/electrs/blob/f9cf5386d1b5de6769ee271df5eef324aa9491bc/src/rpc.rs#L213
// Returned estimated fees are per BTC/kb.
let fee_per_byte = self.electrum.estimate_fee(target_block)?;
-
- if fee_per_byte < 0.0 {
- bail!("Fee per byte returned by electrum server is negative: {}. This may indicate that fee estimation is not supported by this server", fee_per_byte);
- }
-
// we do not expect fees being that high.
#[allow(clippy::cast_possible_truncation)]
Ok(FeeRate::from_btc_per_kvb(fee_per_byte as f32))
diff --git a/swap/src/cli.rs b/swap/src/cli.rs
index 6085eca0..f0faf146 100644
--- a/swap/src/cli.rs
+++ b/swap/src/cli.rs
@@ -3,6 +3,7 @@ pub mod cancel_and_refund;
pub mod command;
mod event_loop;
mod list_sellers;
+pub mod tracing;
pub mod transport;
pub use behaviour::{Behaviour, OutEvent};
diff --git a/swap/src/cli/behaviour.rs b/swap/src/cli/behaviour.rs
index 72dc5891..2ca8448f 100644
--- a/swap/src/cli/behaviour.rs
+++ b/swap/src/cli/behaviour.rs
@@ -1,11 +1,7 @@
-use crate::monero::Scalar;
-use crate::network::cooperative_xmr_redeem_after_punish::CooperativeXmrRedeemRejectReason;
use crate::network::quote::BidQuote;
use crate::network::rendezvous::XmrBtcNamespace;
use crate::network::swap_setup::bob;
-use crate::network::{
- cooperative_xmr_redeem_after_punish, encrypted_signature, quote, redial, transfer_proof,
-};
+use crate::network::{encrypted_signature, quote, redial, transfer_proof};
use crate::protocol::bob::State2;
use crate::{bitcoin, env};
use anyhow::{anyhow, Error, Result};
@@ -32,16 +28,6 @@ pub enum OutEvent {
EncryptedSignatureAcknowledged {
id: RequestId,
},
- CooperativeXmrRedeemFulfilled {
- id: RequestId,
- s_a: Scalar,
- swap_id: uuid::Uuid,
- },
- CooperativeXmrRedeemRejected {
- id: RequestId,
- reason: CooperativeXmrRedeemRejectReason,
- swap_id: uuid::Uuid,
- },
AllRedialAttemptsExhausted {
peer: PeerId,
},
@@ -78,7 +64,6 @@ pub struct Behaviour {
pub quote: quote::Behaviour,
pub swap_setup: bob::Behaviour,
pub transfer_proof: transfer_proof::Behaviour,
- pub cooperative_xmr_redeem: cooperative_xmr_redeem_after_punish::Behaviour,
pub encrypted_signature: encrypted_signature::Behaviour,
pub redial: redial::Behaviour,
pub identify: Identify,
@@ -106,7 +91,6 @@ impl Behaviour {
swap_setup: bob::Behaviour::new(env_config, bitcoin_wallet),
transfer_proof: transfer_proof::bob(),
encrypted_signature: encrypted_signature::bob(),
- cooperative_xmr_redeem: cooperative_xmr_redeem_after_punish::bob(),
redial: redial::Behaviour::new(alice, Duration::from_secs(2)),
ping: Ping::new(PingConfig::new().with_keep_alive(true)),
identify: Identify::new(identifyConfig),
diff --git a/swap/src/cli/cancel_and_refund.rs b/swap/src/cli/cancel_and_refund.rs
index 7ab4e4b0..d542b7ed 100644
--- a/swap/src/cli/cancel_and_refund.rs
+++ b/swap/src/cli/cancel_and_refund.rs
@@ -1,4 +1,5 @@
-use crate::bitcoin::{ExpiredTimelocks, Wallet};
+use crate::bitcoin::wallet::Subscription;
+use crate::bitcoin::{parse_rpc_error_code, RpcErrorCode, Wallet};
use crate::protocol::bob::BobState;
use crate::protocol::Database;
use anyhow::{bail, Result};
@@ -12,7 +13,7 @@ pub async fn cancel_and_refund(
db: Arc,
) -> Result {
if let Err(err) = cancel(swap_id, bitcoin_wallet.clone(), db.clone()).await {
- tracing::warn!(%err, "Could not cancel swap. Attempting to refund anyway");
+ tracing::info!(%err, "Could not submit cancel transaction");
};
let state = match refund(swap_id, bitcoin_wallet, db).await {
@@ -20,6 +21,7 @@ pub async fn cancel_and_refund(
Err(e) => bail!(e),
};
+ tracing::info!("Refund transaction submitted");
Ok(state)
}
@@ -27,20 +29,12 @@ pub async fn cancel(
swap_id: Uuid,
bitcoin_wallet: Arc,
db: Arc,
-) -> Result<(Txid, BobState)> {
+) -> Result<(Txid, Subscription, BobState)> {
let state = db.get_state(swap_id).await?.try_into()?;
let state6 = match state {
- BobState::BtcLocked {
- state3,
- monero_wallet_restore_blockheight,
- ..
- } => state3.cancel(monero_wallet_restore_blockheight),
- BobState::XmrLockProofReceived {
- state,
- monero_wallet_restore_blockheight,
- ..
- } => state.cancel(monero_wallet_restore_blockheight),
+ BobState::BtcLocked { state3, .. } => state3.cancel(),
+ BobState::XmrLockProofReceived { state, .. } => state.cancel(),
BobState::XmrLocked(state4) => state4.cancel(),
BobState::EncSigSent(state4) => state4.cancel(),
BobState::CancelTimelockExpired(state6) => state6,
@@ -53,70 +47,34 @@ pub async fn cancel(
| BobState::XmrRedeemed { .. }
| BobState::BtcPunished { .. }
| BobState::SafelyAborted => bail!(
- "Cannot cancel swap {} because it is in state {} which is not cancellable.",
+ "Cannot cancel swap {} because it is in state {} which is not refundable.",
swap_id,
state
),
};
- tracing::info!(%swap_id, "Attempting to manually cancel swap");
+ tracing::info!(%swap_id, "Manually cancelling swap");
- // Attempt to just publish the cancel transaction
- match state6.submit_tx_cancel(bitcoin_wallet.as_ref()).await {
- Ok((txid, _)) => {
- let state = BobState::BtcCancelled(state6);
- db.insert_latest_state(swap_id, state.clone().into())
- .await?;
- Ok((txid, state))
- }
-
- // If we fail to submit the cancel transaction it can have one of two reasons:
- // 1. The cancel timelock hasn't expired yet
- // 2. The cancel transaction has already been published by Alice
+ let (txid, subscription) = match state6.submit_tx_cancel(bitcoin_wallet.as_ref()).await {
+ Ok(txid) => txid,
Err(err) => {
- // Check if Alice has already published the cancel transaction while we were absent
- if let Ok(tx) = state6.check_for_tx_cancel(bitcoin_wallet.as_ref()).await {
- let state = BobState::BtcCancelled(state6);
- db.insert_latest_state(swap_id, state.clone().into())
- .await?;
- tracing::info!("Alice has already cancelled the swap");
- return Ok((tx.txid(), state));
- }
-
- // The cancel transaction has not been published yet and we failed to publish it ourselves
- // Here we try to figure out why
- match state6.expired_timelock(bitcoin_wallet.as_ref()).await {
- // We cannot cancel because Alice has already cancelled and punished afterwards
- Ok(ExpiredTimelocks::Punish { .. }) => {
- let state = BobState::BtcPunished {
- state: state6.clone(),
- tx_lock_id: state6.tx_lock_id(),
- };
- db.insert_latest_state(swap_id, state.clone().into())
- .await?;
- tracing::info!("You have been punished for not refunding in time");
- bail!(err.context("Cannot cancel swap because we have already been punished"));
- }
- // We cannot cancel because the cancel timelock has not expired yet
- Ok(ExpiredTimelocks::None { blocks_left }) => {
- bail!(err.context(
- format!(
- "Cannot cancel swap because the cancel timelock has not expired yet. Blocks left: {}",
- blocks_left
- )
- ));
- }
- Ok(ExpiredTimelocks::Cancel { .. }) => {
- bail!(err.context("Failed to cancel swap even though cancel timelock has expired. This is unexpected."));
- }
- Err(timelock_err) => {
- bail!(err
- .context(timelock_err)
- .context("Failed to cancel swap and could not check timelock status"));
+ if let Ok(error_code) = parse_rpc_error_code(&err) {
+ tracing::debug!(%error_code, "parse rpc error");
+ if error_code == i64::from(RpcErrorCode::RpcVerifyAlreadyInChain) {
+ tracing::info!("Cancel transaction has already been confirmed on chain");
+ } else if error_code == i64::from(RpcErrorCode::RpcVerifyError) {
+ tracing::info!("General error trying to submit cancel transaction");
}
}
+ bail!(err);
}
- }
+ };
+
+ let state = BobState::BtcCancelled(state6);
+ db.insert_latest_state(swap_id, state.clone().into())
+ .await?;
+
+ Ok((txid, subscription, state))
}
pub async fn refund(
@@ -127,15 +85,8 @@ pub async fn refund(
let state = db.get_state(swap_id).await?.try_into()?;
let state6 = match state {
- BobState::BtcLocked {
- state3,
- monero_wallet_restore_blockheight,
- } => state3.cancel(monero_wallet_restore_blockheight),
- BobState::XmrLockProofReceived {
- state,
- monero_wallet_restore_blockheight,
- ..
- } => state.cancel(monero_wallet_restore_blockheight),
+ BobState::BtcLocked { state3, .. } => state3.cancel(),
+ BobState::XmrLockProofReceived { state, .. } => state.cancel(),
BobState::XmrLocked(state4) => state4.cancel(),
BobState::EncSigSent(state4) => state4.cancel(),
BobState::CancelTimelockExpired(state6) => state6,
@@ -153,52 +104,12 @@ pub async fn refund(
),
};
- tracing::info!(%swap_id, "Attempting to manually refund swap");
+ tracing::info!(%swap_id, "Manually refunding swap");
+ state6.publish_refund_btc(bitcoin_wallet.as_ref()).await?;
- // Attempt to just publish the refund transaction
- match state6.publish_refund_btc(bitcoin_wallet.as_ref()).await {
- Ok(_) => {
- let state = BobState::BtcRefunded(state6);
- db.insert_latest_state(swap_id, state.clone().into())
- .await?;
+ let state = BobState::BtcRefunded(state6);
+ db.insert_latest_state(swap_id, state.clone().into())
+ .await?;
- Ok(state)
- }
-
- // If we fail to submit the refund transaction it can have one of two reasons:
- // 1. The cancel transaction has not been published yet
- // 2. The refund timelock has already expired and we have been punished
- Err(bitcoin_publication_err) => {
- match state6.expired_timelock(bitcoin_wallet.as_ref()).await {
- // We have been punished
- Ok(ExpiredTimelocks::Punish { .. }) => {
- let state = BobState::BtcPunished {
- state: state6.clone(),
- tx_lock_id: state6.tx_lock_id(),
- };
- db.insert_latest_state(swap_id, state.clone().into())
- .await?;
- tracing::info!("You have been punished for not refunding in time");
- bail!(bitcoin_publication_err
- .context("Cannot refund swap because we have already been punished"));
- }
- Ok(ExpiredTimelocks::None { blocks_left }) => {
- bail!(
- bitcoin_publication_err.context(format!(
- "Cannot refund swap because the cancel timelock has not expired yet. Blocks left: {}",
- blocks_left
- ))
- );
- }
- Ok(ExpiredTimelocks::Cancel { .. }) => {
- bail!(bitcoin_publication_err.context("Failed to refund swap even though cancel timelock has expired. This is unexpected."));
- }
- Err(e) => {
- bail!(bitcoin_publication_err
- .context(e)
- .context("Failed to refund swap and could not check timelock status"));
- }
- }
- }
- }
+ Ok(state)
}
diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs
index acce7a50..af72df1b 100644
--- a/swap/src/cli/command.rs
+++ b/swap/src/cli/command.rs
@@ -69,6 +69,18 @@ where
monero_receive_address,
tor,
} => {
+ let monero_receive_address =
+ monero_address::validate_is_testnet(monero_receive_address, is_testnet)?;
+ let bitcoin_change_address =
+ bitcoin_address::validate_is_testnet(bitcoin_change_address, is_testnet)?;
+
+ let request = Request::new(Method::BuyXmr {
+ seller,
+ bitcoin_change_address,
+ monero_receive_address,
+ swap_id: Uuid::new_v4(),
+ });
+
let context = Context::build(
Some(bitcoin),
Some(monero),
@@ -78,55 +90,22 @@ where
debug,
json,
None,
- false,
)
.await?;
-
- let monero_receive_address =
- monero_address::validate_is_testnet(monero_receive_address, is_testnet)?;
- let bitcoin_change_address = bitcoin_change_address
- .map(|address| bitcoin_address::validate_is_testnet(address, is_testnet))
- .transpose()?;
-
- let request = Request::new(Method::BuyXmr {
- seller,
- bitcoin_change_address,
- monero_receive_address,
- swap_id: Uuid::new_v4(),
- });
-
(context, request)
}
CliCommand::History => {
let request = Request::new(Method::History);
let context =
- Context::build(None, None, None, data, is_testnet, debug, json, None, false)
- .await?;
- (context, request)
- }
- CliCommand::Logs {
- logs_dir,
- redact,
- swap_id,
- } => {
- let request = Request::new(Method::Logs {
- logs_dir,
- redact,
- swap_id,
- });
- let context =
- Context::build(None, None, None, data, is_testnet, debug, json, None, false)
- .await?;
-
+ Context::build(None, None, None, data, is_testnet, debug, json, None).await?;
(context, request)
}
CliCommand::Config => {
let request = Request::new(Method::Config);
let context =
- Context::build(None, None, None, data, is_testnet, debug, json, None, false)
- .await?;
+ Context::build(None, None, None, data, is_testnet, debug, json, None).await?;
(context, request)
}
CliCommand::Balance { bitcoin } => {
@@ -143,7 +122,6 @@ where
debug,
json,
None,
- false,
)
.await?;
(context, request)
@@ -165,7 +143,6 @@ where
debug,
json,
server_address,
- true,
)
.await?;
(context, request)
@@ -187,7 +164,6 @@ where
debug,
json,
None,
- false,
)
.await?;
(context, request)
@@ -209,7 +185,6 @@ where
debug,
json,
None,
- false,
)
.await?;
(context, request)
@@ -230,7 +205,6 @@ where
debug,
json,
None,
- false,
)
.await?;
(context, request)
@@ -241,18 +215,8 @@ where
} => {
let request = Request::new(Method::ListSellers { rendezvous_point });
- let context = Context::build(
- None,
- None,
- Some(tor),
- data,
- is_testnet,
- debug,
- json,
- None,
- false,
- )
- .await?;
+ let context =
+ Context::build(None, None, Some(tor), data, is_testnet, debug, json, None).await?;
(context, request)
}
@@ -268,7 +232,6 @@ where
debug,
json,
None,
- false,
)
.await?;
(context, request)
@@ -279,8 +242,7 @@ where
let request = Request::new(Method::MoneroRecovery { swap_id });
let context =
- Context::build(None, None, None, data, is_testnet, debug, json, None, false)
- .await?;
+ Context::build(None, None, None, data, is_testnet, debug, json, None).await?;
(context, request)
}
@@ -338,10 +300,10 @@ enum CliCommand {
#[structopt(
long = "change-address",
- help = "The bitcoin address where any form of change or excess funds should be sent to. If omitted they will be sent to the internal wallet.",
+ help = "The bitcoin address where any form of change or excess funds should be sent to",
parse(try_from_str = bitcoin_address::parse)
)]
- bitcoin_change_address: Option,
+ bitcoin_change_address: bitcoin::Address,
#[structopt(flatten)]
monero: Monero,
@@ -357,25 +319,6 @@ enum CliCommand {
},
/// Show a list of past, ongoing and completed swaps
History,
- /// Output all logging messages that have been issued.
- Logs {
- #[structopt(
- short = "d",
- help = "Print the logs from this directory instead of the default one."
- )]
- logs_dir: Option,
- #[structopt(
- help = "Redact swap-ids, Bitcoin and Monero addresses.",
- long = "redact"
- )]
- redact: bool,
- #[structopt(
- long = "swap-id",
- help = "Filter for logs concerning this swap.",
- long_help = "This checks whether each logging message contains the swap id. Some messages might be skipped when they don't contain the swap id even though they're relevant."
- )]
- swap_id: Option,
- },
#[structopt(about = "Prints the current config")]
Config,
#[structopt(about = "Allows withdrawing BTC from the internal Bitcoin wallet.")]
diff --git a/swap/src/cli/event_loop.rs b/swap/src/cli/event_loop.rs
index 53ee65b8..befe1dc5 100644
--- a/swap/src/cli/event_loop.rs
+++ b/swap/src/cli/event_loop.rs
@@ -1,12 +1,10 @@
use crate::bitcoin::EncryptedSignature;
use crate::cli::behaviour::{Behaviour, OutEvent};
use crate::monero;
-use crate::network::cooperative_xmr_redeem_after_punish::{Request, Response};
use crate::network::encrypted_signature;
use crate::network::quote::BidQuote;
use crate::network::swap_setup::bob::NewSwap;
use crate::protocol::bob::State2;
-use crate::protocol::Database;
use anyhow::{Context, Result};
use futures::future::{BoxFuture, OptionFuture};
use futures::{FutureExt, StreamExt};
@@ -15,7 +13,6 @@ use libp2p::swarm::dial_opts::DialOpts;
use libp2p::swarm::SwarmEvent;
use libp2p::{PeerId, Swarm};
use std::collections::HashMap;
-use std::sync::Arc;
use std::time::Duration;
use uuid::Uuid;
@@ -24,11 +21,9 @@ pub struct EventLoop {
swap_id: Uuid,
swarm: libp2p::Swarm,
alice_peer_id: PeerId,
- db: Arc,
// these streams represents outgoing requests that we have to make
quote_requests: bmrng::RequestReceiverStream<(), BidQuote>,
- cooperative_xmr_redeem_requests: bmrng::RequestReceiverStream,
encrypted_signatures: bmrng::RequestReceiverStream,
swap_setup_requests: bmrng::RequestReceiverStream>,
@@ -38,7 +33,7 @@ pub struct EventLoop {
inflight_quote_requests: HashMap>,
inflight_encrypted_signature_requests: HashMap>,
inflight_swap_setup: Option>>,
- inflight_cooperative_xmr_redeem_requests: HashMap>,
+
/// The sender we will use to relay incoming transfer proofs.
transfer_proof: bmrng::RequestSender,
/// The future representing the successful handling of an incoming transfer
@@ -56,13 +51,12 @@ impl EventLoop {
swap_id: Uuid,
swarm: Swarm,
alice_peer_id: PeerId,
- db: Arc,
) -> Result<(Self, EventLoopHandle)> {
let execution_setup = bmrng::channel_with_timeout(1, Duration::from_secs(60));
let transfer_proof = bmrng::channel_with_timeout(1, Duration::from_secs(60));
let encrypted_signature = bmrng::channel(1);
let quote = bmrng::channel_with_timeout(1, Duration::from_secs(60));
- let cooperative_xmr_redeem = bmrng::channel_with_timeout(1, Duration::from_secs(60));
+
let event_loop = EventLoop {
swap_id,
swarm,
@@ -70,21 +64,17 @@ impl EventLoop {
swap_setup_requests: execution_setup.1.into(),
transfer_proof: transfer_proof.0,
encrypted_signatures: encrypted_signature.1.into(),
- cooperative_xmr_redeem_requests: cooperative_xmr_redeem.1.into(),
quote_requests: quote.1.into(),
inflight_quote_requests: HashMap::default(),
inflight_swap_setup: None,
inflight_encrypted_signature_requests: HashMap::default(),
- inflight_cooperative_xmr_redeem_requests: HashMap::default(),
pending_transfer_proof: OptionFuture::from(None),
- db,
};
let handle = EventLoopHandle {
swap_setup: execution_setup.0,
transfer_proof: transfer_proof.1,
encrypted_signature: encrypted_signature.0,
- cooperative_xmr_redeem: cooperative_xmr_redeem.0,
quote: quote.0,
};
@@ -118,79 +108,44 @@ impl EventLoop {
SwarmEvent::Behaviour(OutEvent::TransferProofReceived { msg, channel, peer }) => {
let swap_id = msg.swap_id;
- if swap_id == self.swap_id {
- if peer != self.alice_peer_id {
- tracing::warn!(
- %swap_id,
- "Ignoring malicious transfer proof from {}, expected to receive it from {}",
- peer,
- self.alice_peer_id);
- continue;
- }
-
- let mut responder = match self.transfer_proof.send(msg.tx_lock_proof).await {
- Ok(responder) => responder,
- Err(e) => {
- tracing::warn!("Failed to pass on transfer proof: {:#}", e);
+ if peer != self.alice_peer_id {
+ tracing::warn!(
+ %swap_id,
+ "Ignoring malicious transfer proof from {}, expected to receive it from {}",
+ peer,
+ self.alice_peer_id);
continue;
- }
- };
-
- self.pending_transfer_proof = OptionFuture::from(Some(async move {
- let _ = responder.recv().await;
-
- channel
- }.boxed()));
- }else {
- // Check if the transfer proof is sent from the correct peer and if we have a record of the swap
- match self.db.get_peer_id(swap_id).await {
- // We have a record of the swap
- Ok(buffer_swap_alice_peer_id) => {
- if buffer_swap_alice_peer_id == self.alice_peer_id {
- // Save transfer proof in the database such that we can process it later when we resume the swap
- match self.db.insert_buffered_transfer_proof(swap_id, msg.tx_lock_proof).await {
- Ok(_) => {
- tracing::info!("Received transfer proof for swap {} while running swap {}. Buffering this transfer proof in the database for later retrieval", swap_id, self.swap_id);
- let _ = self.swarm.behaviour_mut().transfer_proof.send_response(channel, ());
- }
- Err(e) => {
- tracing::error!("Failed to buffer transfer proof for swap {}: {:#}", swap_id, e);
- }
- };
- }else {
- tracing::warn!(
- %swap_id,
- "Ignoring malicious transfer proof from {}, expected to receive it from {}",
- self.swap_id,
- buffer_swap_alice_peer_id);
- }
- },
- // We do not have a record of the swap or an error occurred while retrieving the peer id of Alice
- Err(e) => {
- if let Some(sqlx::Error::RowNotFound) = e.downcast_ref::() {
- tracing::warn!("Ignoring transfer proof for swap {} while running swap {}. We do not have a record of this swap", swap_id, self.swap_id);
- } else {
- tracing::error!("Ignoring transfer proof for swap {} while running swap {}. Failed to retrieve the peer id of Alice for the corresponding swap: {:#}", swap_id, self.swap_id, e);
- }
- }
- }
}
+
+ if swap_id != self.swap_id {
+
+ // TODO: Save unexpected transfer proofs in the database and check for messages in the database when handling swaps
+ tracing::warn!("Received unexpected transfer proof for swap {} while running swap {}. This transfer proof will be ignored", swap_id, self.swap_id);
+
+ // When receiving a transfer proof that is unexpected we still have to acknowledge that it was received
+ let _ = self.swarm.behaviour_mut().transfer_proof.send_response(channel, ());
+ continue;
+ }
+
+ let mut responder = match self.transfer_proof.send(msg.tx_lock_proof).await {
+ Ok(responder) => responder,
+ Err(e) => {
+ tracing::warn!("Failed to pass on transfer proof: {:#}", e);
+ continue;
+ }
+ };
+
+ self.pending_transfer_proof = OptionFuture::from(Some(async move {
+ let _ = responder.recv().await;
+
+ channel
+ }.boxed()));
}
SwarmEvent::Behaviour(OutEvent::EncryptedSignatureAcknowledged { id }) => {
if let Some(responder) = self.inflight_encrypted_signature_requests.remove(&id) {
let _ = responder.respond(());
}
}
- SwarmEvent::Behaviour(OutEvent::CooperativeXmrRedeemFulfilled { id, swap_id, s_a }) => {
- if let Some(responder) = self.inflight_cooperative_xmr_redeem_requests.remove(&id) {
- let _ = responder.respond(Response::Fullfilled { s_a, swap_id });
- }
- }
- SwarmEvent::Behaviour(OutEvent::CooperativeXmrRedeemRejected { id, swap_id, reason }) => {
- if let Some(responder) = self.inflight_cooperative_xmr_redeem_requests.remove(&id) {
- let _ = responder.respond(Response::Rejected { reason, swap_id });
- }
- }
SwarmEvent::Behaviour(OutEvent::AllRedialAttemptsExhausted { peer }) if peer == self.alice_peer_id => {
tracing::error!("Exhausted all re-dial attempts to Alice");
return;
@@ -249,14 +204,7 @@ impl EventLoop {
let _ = self.swarm.behaviour_mut().transfer_proof.send_response(response_channel, ());
self.pending_transfer_proof = OptionFuture::from(None);
- },
-
- Some((swap_id, responder)) = self.cooperative_xmr_redeem_requests.next().fuse(), if self.is_connected_to_alice() => {
- let id = self.swarm.behaviour_mut().cooperative_xmr_redeem.send_request(&self.alice_peer_id, Request {
- swap_id
- });
- self.inflight_cooperative_xmr_redeem_requests.insert(id, responder);
- },
+ }
}
}
}
@@ -272,7 +220,6 @@ pub struct EventLoopHandle {
transfer_proof: bmrng::RequestReceiver,
encrypted_signature: bmrng::RequestSender,
quote: bmrng::RequestSender<(), BidQuote>,
- cooperative_xmr_redeem: bmrng::RequestSender,
}
impl EventLoopHandle {
@@ -297,9 +244,6 @@ impl EventLoopHandle {
tracing::debug!("Requesting quote");
Ok(self.quote.send_receive(()).await?)
}
- pub async fn request_cooperative_xmr_redeem(&mut self, swap_id: Uuid) -> Result {
- Ok(self.cooperative_xmr_redeem.send_receive(swap_id).await?)
- }
pub async fn send_encrypted_signature(
&mut self,
diff --git a/swap/src/cli/tracing.rs b/swap/src/cli/tracing.rs
new file mode 100644
index 00000000..6b6de60f
--- /dev/null
+++ b/swap/src/cli/tracing.rs
@@ -0,0 +1,112 @@
+use anyhow::Result;
+use std::path::Path;
+use time::format_description::well_known::Rfc3339;
+use tracing::subscriber::set_global_default;
+use tracing::{Event, Level, Subscriber};
+use tracing_subscriber::fmt::format::{DefaultFields, Format, JsonFields};
+use tracing_subscriber::fmt::time::UtcTime;
+use tracing_subscriber::layer::{Context, SubscriberExt};
+use tracing_subscriber::{fmt, EnvFilter, Layer, Registry};
+
+pub fn init(debug: bool, json: bool, dir: impl AsRef) -> Result<()> {
+ let level_filter = EnvFilter::try_new("swap=debug")?;
+ let registry = Registry::default().with(level_filter);
+
+ let appender = tracing_appender::rolling::never(dir.as_ref(), "swap-all.log");
+
+ let file_logger = registry.with(
+ fmt::layer()
+ .with_ansi(false)
+ .with_target(false)
+ .json()
+ .with_writer(appender),
+ );
+
+ if json && debug {
+ set_global_default(file_logger.with(debug_json_terminal_printer()))?;
+ } else if json && !debug {
+ set_global_default(file_logger.with(info_json_terminal_printer()))?;
+ } else if !json && debug {
+ set_global_default(file_logger.with(debug_terminal_printer()))?;
+ } else {
+ set_global_default(file_logger.with(info_terminal_printer()))?;
+ }
+
+ tracing::info!("Logging initialized to {}", dir.as_ref().display());
+ Ok(())
+}
+
+pub struct StdErrPrinter {
+ inner: L,
+ level: Level,
+}
+
+type StdErrLayer =
+ fmt::Layer, fn() -> std::io::Stderr>;
+
+type StdErrJsonLayer =
+ fmt::Layer, fn() -> std::io::Stderr>;
+
+fn debug_terminal_printer() -> StdErrPrinter>> {
+ let is_terminal = atty::is(atty::Stream::Stderr);
+ StdErrPrinter {
+ inner: fmt::layer()
+ .with_ansi(is_terminal)
+ .with_target(false)
+ .with_timer(UtcTime::rfc_3339())
+ .with_writer(std::io::stderr),
+ level: Level::DEBUG,
+ }
+}
+
+fn debug_json_terminal_printer() -> StdErrPrinter>> {
+ let is_terminal = atty::is(atty::Stream::Stderr);
+ StdErrPrinter {
+ inner: fmt::layer()
+ .with_ansi(is_terminal)
+ .with_target(false)
+ .with_timer(UtcTime::rfc_3339())
+ .json()
+ .with_writer(std::io::stderr),
+ level: Level::DEBUG,
+ }
+}
+
+fn info_terminal_printer() -> StdErrPrinter> {
+ let is_terminal = atty::is(atty::Stream::Stderr);
+ StdErrPrinter {
+ inner: fmt::layer()
+ .with_ansi(is_terminal)
+ .with_target(false)
+ .with_level(false)
+ .without_time()
+ .with_writer(std::io::stderr),
+ level: Level::INFO,
+ }
+}
+
+fn info_json_terminal_printer() -> StdErrPrinter> {
+ let is_terminal = atty::is(atty::Stream::Stderr);
+ StdErrPrinter {
+ inner: fmt::layer()
+ .with_ansi(is_terminal)
+ .with_target(false)
+ .with_level(false)
+ .without_time()
+ .json()
+ .with_writer(std::io::stderr),
+ level: Level::INFO,
+ }
+}
+
+impl Layer for StdErrPrinter
+where
+ L: 'static + Layer,
+ S: Subscriber + for<'a> tracing_subscriber::registry::LookupSpan<'a>,
+{
+ fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) {
+ if self.level.ge(event.metadata().level()) {
+ self.inner.on_event(event, ctx);
+ }
+ }
+}
diff --git a/swap/src/common.rs b/swap/src/common.rs
new file mode 100644
index 00000000..98b9b99d
--- /dev/null
+++ b/swap/src/common.rs
@@ -0,0 +1,56 @@
+use anyhow::anyhow;
+
+const LATEST_RELEASE_URL: &str = "https://github.com/comit-network/xmr-btc-swap/releases/latest";
+
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub enum Version {
+ Current,
+ Available,
+}
+
+/// Check the latest release from GitHub API.
+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 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_version, latest_version) {
+ Version::Current
+ } else {
+ tracing::warn!(%current_version, %latest_version, %download_url,
+ "You are not on the latest version",
+ );
+ Version::Available
+ };
+
+ Ok(result)
+}
+
+// todo: naive implementation can be improved using semver
+fn is_latest_version(current: &str, latest: &str) -> bool {
+ current == latest
+}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+
+ #[test]
+ fn it_compares_versions() {
+ assert!(is_latest_version("0.10.2", "0.10.2"));
+ assert!(!is_latest_version("0.10.2", "0.10.3"));
+ assert!(!is_latest_version("0.10.2", "0.11.0"));
+ }
+
+ #[tokio::test]
+ #[ignore = "For local testing, makes http requests to github."]
+ async fn it_compares_with_github() {
+ let result = check_latest_version("0.11.0").await.unwrap();
+ assert_eq!(result, Version::Available);
+
+ let result = check_latest_version("0.11.1").await.unwrap();
+ assert_eq!(result, Version::Current);
+ }
+}
diff --git a/swap/src/common/mod.rs b/swap/src/common/mod.rs
deleted file mode 100644
index bae1c0f4..00000000
--- a/swap/src/common/mod.rs
+++ /dev/null
@@ -1,221 +0,0 @@
-pub mod tracing_util;
-
-use std::{collections::HashMap, path::PathBuf};
-
-use anyhow::anyhow;
-use tokio::{
- fs::{read_dir, File},
- io::{AsyncBufReadExt, BufReader},
-};
-use uuid::Uuid;
-
-const LATEST_RELEASE_URL: &str = "https://github.com/comit-network/xmr-btc-swap/releases/latest";
-
-#[derive(Clone, Debug, PartialEq, Eq)]
-pub enum Version {
- Current,
- Available,
-}
-
-/// Check the latest release from GitHub API.
-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 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_version, latest_version) {
- Version::Current
- } else {
- tracing::warn!(%current_version, %latest_version, %download_url,
- "You are not on the latest version",
- );
- Version::Available
- };
-
- Ok(result)
-}
-
-// todo: naive implementation can be improved using semver
-fn is_latest_version(current: &str, latest: &str) -> bool {
- current == latest
-}
-
-/// helper macro for [`redact`]... eldrich sorcery
-/// the macro does in essence the following:
-/// 1. create a static regex automaton for the pattern
-/// 2. find all matching patterns using regex
-/// 3. create a placeholder for each distinct matching pattern
-/// 4. add the placeholder to the hashmap
-macro_rules! regex_find_placeholders {
- ($pattern:expr, $create_placeholder:expr, $replacements:expr, $input:expr) => {{
- // compile the regex pattern
- static REGEX: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| {
- tracing::debug!("initializing regex");
- regex::Regex::new($pattern).expect("invalid regex pattern")
- });
-
- // keep count of count patterns to generate distinct placeholders
- let mut counter: usize = 0;
-
- // for every matched address check whether we already found it
- // and if we didn't, generate a placeholder for it
- for address in REGEX.find_iter($input) {
- if !$replacements.contains_key(address.as_str()) {
- #[allow(clippy::redundant_closure_call)]
- $replacements.insert(address.as_str().to_owned(), $create_placeholder(counter));
- counter += 1;
- }
- }
- }};
-}
-
-/// Print the logs from the specified logs or from the default location
-/// to the specified path or the terminal.
-///
-/// If specified, filter by swap id or redact addresses.
-pub async fn get_logs(
- logs_dir: PathBuf,
- swap_id: Option,
- redact_addresses: bool,
-) -> anyhow::Result> {
- tracing::debug!("reading logfiles from {}", logs_dir.display());
-
- // get all files in the directory
- let mut log_files = read_dir(&logs_dir).await?;
-
- let mut log_messages = Vec::new();
- // when we redact we need to store the placeholder
- let mut placeholders = HashMap::new();
-
- // print all lines from every log file. TODO: sort files by date?
- while let Some(entry) = log_files.next_entry().await? {
- // get the file path
- let file_path = entry.path();
-
- // filter for .log files
- let file_name = file_path
- .file_name()
- .and_then(|name| name.to_str())
- .unwrap_or("");
-
- if !file_name.ends_with(".log") {
- continue;
- }
-
- // use BufReader to stay easy on memory and then read line by line
- let buf_reader = BufReader::new(File::open(&file_path).await?);
- let mut lines = buf_reader.lines();
-
- // print each line, redacted if the flag is set
- while let Some(line) = lines.next_line().await? {
- // if we should filter by swap id, check if the line contains it
- if let Some(swap_id) = swap_id {
- // we only want lines which contain the swap id
- if !line.contains(&swap_id.to_string()) {
- continue;
- }
- }
-
- // redact if necessary
- let line = if redact_addresses {
- redact_with(&line, &mut placeholders)
- } else {
- line
- };
- // save redacted message
- log_messages.push(line);
- }
- }
-
- Ok(log_messages)
-}
-
-/// Redact logs, etc. by replacing Bitcoin and Monero addresses
-/// with generic placeholders.
-///
-/// # Example
-/// ```rust
-/// use swap::common::redact;
-///
-/// let redacted = redact("a9165a1e-d26d-4b56-bf6d-ca9658825c44");
-/// assert_eq!(redacted, "");
-/// ```
-pub fn redact(input: &str) -> String {
- let mut replacements = HashMap::new();
- redact_with(input, &mut replacements)
-}
-
-/// Same as [`redact`] but retrieves palceholders from and stores them
-/// in a specified hashmap.
-pub fn redact_with(input: &str, replacements: &mut HashMap) -> String {
- // TODO: verify regex patterns
- const MONERO_ADDR_REGEX: &str = r#"[48][1-9A-HJ-NP-Za-km-z]{94}"#;
- const BITCOIN_ADDR_REGEX: &str = r#"\b[13][a-km-zA-HJ-NP-Z1-9]{25,34}\b"#;
- // Both XMR and BTC transactions have
- // a 64 bit hex id so they aren't distinguishible
- const TX_ID_REGEX: &str = r#"\b[a-fA-F0-9]{64}\b"#;
- const SWAP_ID_REGEX: &str =
- r#"\b[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}\b"#;
-
- // use the macro to find all addresses and generate placeholders
- // has to be a macro in order to create the regex automata only once.
- regex_find_placeholders!(
- MONERO_ADDR_REGEX,
- |count| format!(""),
- replacements,
- input
- );
- regex_find_placeholders!(
- BITCOIN_ADDR_REGEX,
- |count| format!(""),
- replacements,
- input
- );
- regex_find_placeholders!(
- TX_ID_REGEX,
- |count| format!(""),
- replacements,
- input
- );
- regex_find_placeholders!(
- SWAP_ID_REGEX,
- |count| format!(""),
- replacements,
- input
- );
-
- // allocate string variable to operate on
- let mut redacted = input.to_owned();
-
- // Finally we go through the input string and replace each occurance of an
- // address we want to redact with the corresponding placeholder
- for (address, placeholder) in replacements.iter() {
- redacted = redacted.replace(address, placeholder);
- }
-
- redacted
-}
-
-#[cfg(test)]
-mod test {
- use super::*;
-
- #[test]
- fn it_compares_versions() {
- assert!(is_latest_version("0.10.2", "0.10.2"));
- assert!(!is_latest_version("0.10.2", "0.10.3"));
- assert!(!is_latest_version("0.10.2", "0.11.0"));
- }
-
- #[tokio::test]
- #[ignore = "For local testing, makes http requests to github."]
- async fn it_compares_with_github() {
- let result = check_latest_version("0.11.0").await.unwrap();
- assert_eq!(result, Version::Available);
-
- let result = check_latest_version("0.11.1").await.unwrap();
- assert_eq!(result, Version::Current);
- }
-}
diff --git a/swap/src/common/tracing_util.rs b/swap/src/common/tracing_util.rs
deleted file mode 100644
index 191c43bf..00000000
--- a/swap/src/common/tracing_util.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-use std::path::Path;
-use std::str::FromStr;
-
-use anyhow::Result;
-use tracing_subscriber::filter::{Directive, LevelFilter};
-use tracing_subscriber::fmt::time::UtcTime;
-use tracing_subscriber::layer::SubscriberExt;
-use tracing_subscriber::util::SubscriberInitExt;
-use tracing_subscriber::{fmt, EnvFilter, Layer};
-
-/// Output formats for logging messages.
-pub enum Format {
- /// Standard, human readable format.
- Raw,
- /// JSON, machine readable format.
- Json,
-}
-
-/// Initialize tracing and enable logging messages according to these options.
-/// Besides printing to `stdout`, this will append to a log file.
-/// Said file will contain JSON-formatted logs of all levels,
-/// disregarding the arguments to this function.
-pub fn init(level_filter: LevelFilter, format: Format, dir: impl AsRef) -> Result<()> {
- let env_filter = EnvFilter::from_default_env()
- .add_directive(Directive::from_str(&format!("asb={}", &level_filter))?)
- .add_directive(Directive::from_str(&format!("swap={}", &level_filter))?);
-
- // file logger will always write in JSON format and with timestamps
- let file_appender = tracing_appender::rolling::never(&dir, "swap-all.log");
-
- let file_layer = fmt::layer()
- .with_writer(file_appender)
- .with_ansi(false)
- .with_timer(UtcTime::rfc_3339())
- .with_target(false)
- .json()
- .with_filter(env_filter);
-
- // terminal logger
- let is_terminal = atty::is(atty::Stream::Stderr);
- let terminal_layer = fmt::layer()
- .with_writer(std::io::stdout)
- .with_ansi(is_terminal)
- .with_timer(UtcTime::rfc_3339())
- .with_target(false);
-
- // combine the layers and start logging, format with json if specified
- if let Format::Json = format {
- tracing_subscriber::registry()
- .with(file_layer)
- .with(terminal_layer.json().with_filter(level_filter))
- .init();
- } else {
- tracing_subscriber::registry()
- .with(file_layer)
- .with(terminal_layer.with_filter(level_filter))
- .init();
- }
-
- // now we can use the tracing macros to log messages
- tracing::info!(%level_filter, logs_dir=%dir.as_ref().display(), "Initialized tracing");
-
- Ok(())
-}
diff --git a/swap/src/database.rs b/swap/src/database.rs
index 7c6185f7..7af16196 100644
--- a/swap/src/database.rs
+++ b/swap/src/database.rs
@@ -83,25 +83,16 @@ impl Swap {
}
}
-#[derive(Debug, Clone, Copy, Serialize, Deserialize, Hash, PartialEq)]
-pub enum AccessMode {
- ReadWrite,
- ReadOnly,
-}
-
-pub async fn open_db(
- sqlite_path: impl AsRef,
- access_mode: AccessMode,
-) -> Result> {
+pub async fn open_db(sqlite_path: impl AsRef) -> Result> {
if sqlite_path.as_ref().exists() {
tracing::debug!("Using existing sqlite database.");
- let sqlite = SqliteDatabase::open(sqlite_path, access_mode).await?;
+ let sqlite = SqliteDatabase::open(sqlite_path).await?;
Ok(Arc::new(sqlite))
} else {
tracing::debug!("Creating and using new sqlite database.");
ensure_directory_exists(sqlite_path.as_ref())?;
tokio::fs::File::create(&sqlite_path).await?;
- let sqlite = SqliteDatabase::open(sqlite_path, access_mode).await?;
+ let sqlite = SqliteDatabase::open(sqlite_path).await?;
Ok(Arc::new(sqlite))
}
}
diff --git a/swap/src/database/alice.rs b/swap/src/database/alice.rs
index fcf3ead3..4ed61790 100644
--- a/swap/src/database/alice.rs
+++ b/swap/src/database/alice.rs
@@ -70,12 +70,12 @@ pub enum Alice {
Done(AliceEndState),
}
-#[derive(Clone, strum::Display, Debug, Deserialize, Serialize, PartialEq)]
+#[derive(Copy, Clone, strum::Display, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub enum AliceEndState {
SafelyAborted,
BtcRedeemed,
XmrRefunded,
- BtcPunished { state3: alice::State3 },
+ BtcPunished,
}
impl From for Alice {
@@ -173,9 +173,7 @@ impl From for Alice {
transfer_proof,
state3: state3.as_ref().clone(),
},
- AliceState::BtcPunished { state3 } => Alice::Done(AliceEndState::BtcPunished {
- state3: state3.as_ref().clone(),
- }),
+ AliceState::BtcPunished => Alice::Done(AliceEndState::BtcPunished),
AliceState::SafelyAborted => Alice::Done(AliceEndState::SafelyAborted),
}
}
@@ -279,9 +277,7 @@ impl From for AliceState {
AliceEndState::SafelyAborted => AliceState::SafelyAborted,
AliceEndState::BtcRedeemed => AliceState::BtcRedeemed,
AliceEndState::XmrRefunded => AliceState::XmrRefunded,
- AliceEndState::BtcPunished { state3 } => AliceState::BtcPunished {
- state3: Box::new(state3),
- },
+ AliceEndState::BtcPunished => AliceState::BtcPunished,
},
}
}
diff --git a/swap/src/database/bob.rs b/swap/src/database/bob.rs
index 735f45a2..25117763 100644
--- a/swap/src/database/bob.rs
+++ b/swap/src/database/bob.rs
@@ -33,10 +33,6 @@ pub enum Bob {
EncSigSent {
state4: bob::State4,
},
- BtcPunished {
- state: bob::State6,
- tx_lock_id: bitcoin::Txid,
- },
BtcRedeemed(bob::State5),
CancelTimelockExpired(bob::State6),
BtcCancelled(bob::State6),
@@ -48,6 +44,7 @@ pub enum BobEndState {
SafelyAborted,
XmrRedeemed { tx_lock_id: bitcoin::Txid },
BtcRefunded(Box),
+ BtcPunished { tx_lock_id: bitcoin::Txid },
}
impl From for Bob {
@@ -82,11 +79,13 @@ impl From for Bob {
BobState::BtcRedeemed(state5) => Bob::BtcRedeemed(state5),
BobState::CancelTimelockExpired(state6) => Bob::CancelTimelockExpired(state6),
BobState::BtcCancelled(state6) => Bob::BtcCancelled(state6),
- BobState::BtcPunished { state, tx_lock_id } => Bob::BtcPunished { state, tx_lock_id },
BobState::BtcRefunded(state6) => Bob::Done(BobEndState::BtcRefunded(Box::new(state6))),
BobState::XmrRedeemed { tx_lock_id } => {
Bob::Done(BobEndState::XmrRedeemed { tx_lock_id })
}
+ BobState::BtcPunished { tx_lock_id } => {
+ Bob::Done(BobEndState::BtcPunished { tx_lock_id })
+ }
BobState::SafelyAborted => Bob::Done(BobEndState::SafelyAborted),
}
}
@@ -124,11 +123,11 @@ impl From for BobState {
Bob::BtcRedeemed(state5) => BobState::BtcRedeemed(state5),
Bob::CancelTimelockExpired(state6) => BobState::CancelTimelockExpired(state6),
Bob::BtcCancelled(state6) => BobState::BtcCancelled(state6),
- Bob::BtcPunished { state, tx_lock_id } => BobState::BtcPunished { state, tx_lock_id },
Bob::Done(end_state) => match end_state {
BobEndState::SafelyAborted => BobState::SafelyAborted,
BobEndState::XmrRedeemed { tx_lock_id } => BobState::XmrRedeemed { tx_lock_id },
BobEndState::BtcRefunded(state6) => BobState::BtcRefunded(*state6),
+ BobEndState::BtcPunished { tx_lock_id } => BobState::BtcPunished { tx_lock_id },
},
}
}
@@ -149,7 +148,6 @@ impl fmt::Display for Bob {
Bob::BtcRedeemed(_) => f.write_str("Monero redeemable"),
Bob::Done(end_state) => write!(f, "Done: {}", end_state),
Bob::EncSigSent { .. } => f.write_str("Encrypted signature sent"),
- Bob::BtcPunished { .. } => f.write_str("Bitcoin punished"),
}
}
}
diff --git a/swap/src/database/sqlite.rs b/swap/src/database/sqlite.rs
index ce455b6c..751f76aa 100644
--- a/swap/src/database/sqlite.rs
+++ b/swap/src/database/sqlite.rs
@@ -1,41 +1,30 @@
use crate::database::Swap;
-use crate::monero::{Address, TransferProof};
+use crate::monero::Address;
use crate::protocol::{Database, State};
use anyhow::{anyhow, Context, Result};
use async_trait::async_trait;
use libp2p::{Multiaddr, PeerId};
-use sqlx::sqlite::{Sqlite, SqliteConnectOptions};
-use sqlx::{ConnectOptions, Pool, SqlitePool};
+use sqlx::sqlite::Sqlite;
+use sqlx::{Pool, SqlitePool};
use std::collections::HashMap;
use std::path::Path;
use std::str::FromStr;
use time::OffsetDateTime;
use uuid::Uuid;
-use super::AccessMode;
-
pub struct SqliteDatabase {
pool: Pool,
}
impl SqliteDatabase {
- pub async fn open(path: impl AsRef, access_mode: AccessMode) -> Result
+ pub async fn open(path: impl AsRef) -> Result
where
Self: std::marker::Sized,
{
- let read_only = matches!(access_mode, AccessMode::ReadOnly);
-
let path_str = format!("sqlite:{}", path.as_ref().display());
- let mut options = SqliteConnectOptions::from_str(&path_str)?.read_only(read_only);
- options.disable_statement_logging();
-
- let pool = SqlitePool::connect_with(options).await?;
+ let pool = SqlitePool::connect(&path_str).await?;
let mut sqlite = Self { pool };
-
- if !read_only {
- sqlite.run_migrations().await?;
- }
-
+ sqlite.run_migrations().await?;
Ok(sqlite)
}
@@ -314,56 +303,6 @@ impl Database for SqliteDatabase {
result
}
- async fn insert_buffered_transfer_proof(
- &self,
- swap_id: Uuid,
- proof: TransferProof,
- ) -> Result<()> {
- let mut conn = self.pool.acquire().await?;
- let swap_id = swap_id.to_string();
- let proof = serde_json::to_string(&proof)?;
-
- sqlx::query!(
- r#"
- INSERT INTO buffered_transfer_proofs (
- swap_id,
- proof
- ) VALUES (?, ?);
- "#,
- swap_id,
- proof
- )
- .execute(&mut conn)
- .await?;
-
- Ok(())
- }
-
- async fn get_buffered_transfer_proof(&self, swap_id: Uuid) -> Result