From 122aee022a8cd7e1db6d052a1b749d7bdc6f562e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:53:20 +0000 Subject: [PATCH 001/108] build(deps): bump actions/checkout from 4.1.6 to 4.1.7 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.1.7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4.1.6...v4.1.7) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/build-release-binaries.yml | 2 +- .github/workflows/ci.yml | 16 ++++++++-------- .github/workflows/create-release.yml | 2 +- .github/workflows/draft-new-release.yml | 2 +- .github/workflows/preview-release.yml | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index 29bdde64..662e3a5e 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -54,7 +54,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout tagged commit - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 with: ref: ${{ github.event.release.target_commitish }} token: ${{ secrets.BOTTY_GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 629e4e37..6b3fdbf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - uses: dtolnay/rust-toolchain@master with: @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - uses: Swatinem/rust-cache@v2.7.3 @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - uses: Swatinem/rust-cache@v2.7.3 @@ -78,7 +78,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout sources - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - uses: Swatinem/rust-cache@v2.7.3 @@ -131,7 +131,7 @@ jobs: tool-cache: false - name: Checkout sources - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - uses: Swatinem/rust-cache@v2.7.3 @@ -169,7 +169,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - uses: Swatinem/rust-cache@v2.7.3 @@ -180,7 +180,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - uses: Swatinem/rust-cache@v2.7.3 @@ -191,7 +191,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - uses: dtolnay/rust-toolchain@stable diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 2e52519a..443c4418 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.1.6 + - uses: actions/checkout@v4.1.7 - 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 09df0bd7..74ff34ba 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.1.6 + - uses: actions/checkout@v4.1.7 with: token: ${{ secrets.BOTTY_GITHUB_TOKEN }} diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml index 63ecfe6f..ccd7e641 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.1.6 + - uses: actions/checkout@v4.1.7 - name: Delete 'preview' release uses: larryjoelane/delete-release-action@v1.0.24 From f4792174da1c34022a06b0ceee6b543d951d2e4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:45:28 +0000 Subject: [PATCH 002/108] build(deps): bump reqwest from 0.12.4 to 0.12.5 Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.12.4 to 0.12.5. - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/reqwest/compare/v0.12.4...v0.12.5) --- updated-dependencies: - dependency-name: reqwest dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 93 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 955142f1..9a248e5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1788,19 +1788,20 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.0.0", "hyper 1.3.1", "hyper-util", - "rustls 0.22.2", + "rustls 0.23.10", "rustls-pki-types", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tower-service", + "webpki-roots 0.26.1", ] [[package]] @@ -2837,9 +2838,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.13.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -3271,6 +3272,53 @@ 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" @@ -3442,9 +3490,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64 0.22.1", "bytes", @@ -3464,7 +3512,8 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite 0.2.13", - "rustls 0.22.2", + "quinn", + "rustls 0.23.10", "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", @@ -3472,7 +3521,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tokio-socks", "tokio-util", "tower-service", @@ -3644,11 +3693,11 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.2" +version = "0.23.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" dependencies = [ - "log", + "once_cell", "ring 0.17.3", "rustls-pki-types", "rustls-webpki", @@ -3701,15 +3750,15 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.3.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" -version = "0.102.2" +version = "0.102.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" dependencies = [ "ring 0.17.3", "rustls-pki-types", @@ -4557,9 +4606,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "synstructure" @@ -4771,11 +4820,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.22.2", + "rustls 0.23.10", "rustls-pki-types", "tokio", ] From 7da996ab7be4136f5d53c8758557c7367ba4796c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 11:34:57 +0000 Subject: [PATCH 003/108] build(deps): bump url from 2.5.0 to 2.5.2 Bumps [url](https://github.com/servo/rust-url) from 2.5.0 to 2.5.2. - [Release notes](https://github.com/servo/rust-url/releases) - [Commits](https://github.com/servo/rust-url/compare/v2.5.0...v2.5.2) --- updated-dependencies: - dependency-name: url dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a248e5b..2c673099 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5299,9 +5299,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna 0.5.0", From 543f2748b5942cc7f83c3da7ec7cb5aa54074dd6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 11:35:30 +0000 Subject: [PATCH 004/108] build(deps): bump serial_test from 3.0.0 to 3.1.1 Bumps [serial_test](https://github.com/palfrey/serial_test) from 3.0.0 to 3.1.1. - [Release notes](https://github.com/palfrey/serial_test/releases) - [Commits](https://github.com/palfrey/serial_test/compare/v3.0.0...v3.1.1) --- updated-dependencies: - dependency-name: serial_test dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 38 +++++++++++++++++++++----------------- swap/Cargo.toml | 2 +- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a248e5b..a9ed4569 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1017,17 +1017,6 @@ 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" @@ -3800,6 +3789,15 @@ 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" @@ -3836,6 +3834,12 @@ 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" @@ -4079,23 +4083,23 @@ dependencies = [ [[package]] name = "serial_test" -version = "3.0.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ad9342b3aaca7cb43c45c097dd008d4907070394bd0751a0aa8817e5a018d" +checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" dependencies = [ - "dashmap", "futures", - "lazy_static", "log", + "once_cell", "parking_lot 0.12.0", + "scc", "serial_test_derive", ] [[package]] name = "serial_test_derive" -version = "3.0.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" +checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 0d2f70c9..2e70742b 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -87,7 +87,7 @@ port_check = "0.2" proptest = "1" sequential-test = "0.2.4" serde_cbor = "0.11" -serial_test = "3.0" +serial_test = "3.1" tempfile = "3" testcontainers = "0.15" From 4d557d1ef9c33bf6b3a92a7067acc0166b6a6330 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:35:05 +0200 Subject: [PATCH 005/108] build(deps): bump mockito from 1.3.0 to 1.4.0 (#1567) * build(deps): bump mockito from 1.3.0 to 1.3.1 Bumps [mockito](https://github.com/lipanski/mockito) from 1.3.0 to 1.3.1. - [Release notes](https://github.com/lipanski/mockito/releases) - [Commits](https://github.com/lipanski/mockito/compare/1.3.0...1.3.1) --- updated-dependencies: - dependency-name: mockito dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * fix: breaking change in mockito async * bump mockito to 1.4 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Byron Hambly --- Cargo.lock | 6 +++--- swap/Cargo.toml | 2 +- swap/src/monero/wallet_rpc.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51a7fa08..203c718d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2587,13 +2587,13 @@ dependencies = [ [[package]] name = "mockito" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8c84fe1f1d8c56dc157f79942056fad4b9efceebba374a01b222428b553facb" +checksum = "d2f6e023aa5bdf392aa06c78e4a4e6d498baab5138d0c993503350ebbc37bf1e" dependencies = [ "assert-json-diff", "colored", - "futures", + "futures-core", "hyper 0.14.28", "log", "rand 0.8.3", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 2e70742b..fd2b0b39 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -81,7 +81,7 @@ bitcoin-harness = { git = "https://github.com/delta1/bitcoin-harness-rs.git", re get-port = "3" hyper = "1.3" jsonrpsee = { version = "0.16.2", features = [ "ws-client" ] } -mockito = "1.3.0" +mockito = "1.4" monero-harness = { path = "../monero-harness" } port_check = "0.2" proptest = "1" diff --git a/swap/src/monero/wallet_rpc.rs b/swap/src/monero/wallet_rpc.rs index c7009993..609c3eab 100644 --- a/swap/src/monero/wallet_rpc.rs +++ b/swap/src/monero/wallet_rpc.rs @@ -480,7 +480,7 @@ mod tests { #[tokio::test] async fn test_is_daemon_available_success() { - let mut server = mockito::Server::new(); + let mut server = mockito::Server::new_async().await; let _ = server .mock("GET", "/get_info") @@ -511,7 +511,7 @@ mod tests { #[tokio::test] async fn test_is_daemon_available_wrong_network_failure() { - let mut server = mockito::Server::new(); + let mut server = mockito::Server::new_async().await; let _ = server .mock("GET", "/get_info") @@ -542,7 +542,7 @@ mod tests { #[tokio::test] async fn test_is_daemon_available_not_synced_failure() { - let mut server = mockito::Server::new(); + let mut server = mockito::Server::new_async().await; let _ = server .mock("GET", "/get_info") From cca0d0027e982af00f64aee1835f07f8243a777b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:09:33 +0000 Subject: [PATCH 006/108] build(deps): bump proptest from 1.4.0 to 1.5.0 Bumps [proptest](https://github.com/proptest-rs/proptest) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/proptest-rs/proptest/releases) - [Changelog](https://github.com/proptest-rs/proptest/blob/master/CHANGELOG.md) - [Commits](https://github.com/proptest-rs/proptest/compare/v1.4.0...v1.5.0) --- updated-dependencies: - dependency-name: proptest dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 203c718d..b96308c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3144,9 +3144,9 @@ dependencies = [ [[package]] name = "proptest" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", From dabe1abb216378b1644457fa10d4e38c09734421 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:10:02 +0000 Subject: [PATCH 007/108] build(deps): bump uuid from 1.8.0 to 1.9.0 Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.8.0 to 1.9.0. - [Release notes](https://github.com/uuid-rs/uuid/releases) - [Commits](https://github.com/uuid-rs/uuid/compare/1.8.0...1.9.0) --- updated-dependencies: - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- swap/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 203c718d..18870f31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5321,9 +5321,9 @@ checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" [[package]] name = "uuid" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "3ea73390fe27785838dcbf75b91b1d84799e28f1ce71e6f372a5dc2200c80de5" dependencies = [ "getrandom 0.2.11", "serde", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index fd2b0b39..cbb7a802 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -67,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.8", features = [ "serde", "v4" ] } +uuid = { version = "1.9", features = [ "serde", "v4" ] } void = "1" [target.'cfg(not(windows))'.dependencies] From 2068a4cf787e6b2277d7469bad90804191779f4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:12:44 +0000 Subject: [PATCH 008/108] build(deps): bump strum from 0.26.2 to 0.26.3 Bumps [strum](https://github.com/Peternator7/strum) from 0.26.2 to 0.26.3. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/compare/v0.26.2...v0.26.3) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 203c718d..1b9d0b5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1602,6 +1602,12 @@ 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" @@ -4475,20 +4481,20 @@ dependencies = [ [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.26.1" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", From 3fc934a189baa8a2dede7bf7f57a2bfc4ee7780a Mon Sep 17 00:00:00 2001 From: Ian McKenzie Date: Mon, 24 Jun 2024 21:27:13 -0700 Subject: [PATCH 009/108] Add concurrent_bobs_after_xmr_lock_proof_sent test to ci --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b3fdbf3..2b0a0ce6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -163,6 +163,7 @@ jobs: 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, ] From fbf1c3dabfb4105d33accdbff74da00708e9738d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:48:33 +0000 Subject: [PATCH 010/108] build(deps): bump serde_json from 1.0.117 to 1.0.118 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.117 to 1.0.118. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.117...v1.0.118) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2277173..ed0db29d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4035,9 +4035,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" dependencies = [ "itoa", "ryu", From 5551f513d562ae09431b05224a13b184e2738542 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:49:47 +0000 Subject: [PATCH 011/108] build(deps): bump uuid from 1.9.0 to 1.9.1 Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.9.0 to 1.9.1. - [Release notes](https://github.com/uuid-rs/uuid/releases) - [Commits](https://github.com/uuid-rs/uuid/compare/1.9.0...1.9.1) --- updated-dependencies: - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2277173..677345d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5327,9 +5327,9 @@ checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" [[package]] name = "uuid" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea73390fe27785838dcbf75b91b1d84799e28f1ce71e6f372a5dc2200c80de5" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" dependencies = [ "getrandom 0.2.11", "serde", From 4c9d1e8d8d1ac6444ae0ab01b8a46cdceef08978 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:24:27 +0200 Subject: [PATCH 012/108] Reduce check interval for Monero `watch_for_transfer` (#1670) Oftentimes we fail to check the status of the Monero transaction on the first try (because it hasn't been registered on our Monero daemon yet, it takes a few seconds). By decreasing the check interval from the default of 2 minutes to a 10th of that, we ensure that Bob get's his transfer proof faster. --- swap/src/monero/wallet.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/swap/src/monero/wallet.rs b/swap/src/monero/wallet.rs index 99fa206a..e3db3416 100644 --- a/swap/src/monero/wallet.rs +++ b/swap/src/monero/wallet.rs @@ -6,6 +6,7 @@ use ::monero::{Address, Network, PrivateKey, PublicKey}; use anyhow::{Context, Result}; use monero_rpc::wallet::{BlockHeight, MoneroWalletRpc as _, Refreshed}; use monero_rpc::{jsonrpc, wallet}; +use std::ops::Div; use std::str::FromStr; use std::time::Duration; use tokio::sync::Mutex; @@ -233,7 +234,7 @@ impl Wallet { let address = Address::standard(self.network, public_spend_key, public_view_key.into()); - let check_interval = tokio::time::interval(self.sync_interval); + let check_interval = tokio::time::interval(self.sync_interval.div(10)); wait_for_confirmations( &self.inner, From 23a27680a48535ee9a92b613e322e7eff398bc29 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Fri, 28 Jun 2024 21:39:30 +0200 Subject: [PATCH 013/108] feat (Bob): Buffer transfer proof to database when we are running a different swap (#1669) --- CHANGELOG.md | 2 + .../20210903050345_create_swaps_table.sql | 6 ++ swap/sqlx-data.json | 28 ++++++ swap/src/api/request.rs | 4 +- swap/src/cli/event_loop.rs | 88 +++++++++++++------ swap/src/database/sqlite.rs | 52 ++++++++++- swap/src/network/test.rs | 6 +- swap/src/protocol.rs | 9 ++ swap/src/protocol/bob/swap.rs | 25 +++++- ...current_bobs_before_xmr_lock_proof_sent.rs | 11 +-- swap/tests/harness/mod.rs | 13 +-- 11 files changed, 193 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2c930c9..0c48cb79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- CLI: Buffer received transfer proofs for later processing if we're currently running a different swap + ## [0.13.1] - 2024-06-10 - Add retry logic to monero-wallet-rpc wallet refresh diff --git a/swap/migrations/20210903050345_create_swaps_table.sql b/swap/migrations/20210903050345_create_swaps_table.sql index 741a45e6..84a97d0f 100644 --- a/swap/migrations/20210903050345_create_swaps_table.sql +++ b/swap/migrations/20210903050345_create_swaps_table.sql @@ -22,4 +22,10 @@ CREATE TABLE if NOT EXISTS peer_addresses ( peer_id TEXT NOT NULL, address TEXT NOT NULL +); + +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 f24a50e6..6ab0f14a 100644 --- a/swap/sqlx-data.json +++ b/swap/sqlx-data.json @@ -195,5 +195,33 @@ } }, "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/request.rs b/swap/src/api/request.rs index 338432c3..800e1c06 100644 --- a/swap/src/api/request.rs +++ b/swap/src/api/request.rs @@ -376,7 +376,7 @@ impl Request { }, result = async { let (event_loop, mut event_loop_handle) = - EventLoop::new(swap_id, swarm, seller_peer_id)?; + EventLoop::new(swap_id, swarm, seller_peer_id, context.db.clone())?; let event_loop = tokio::spawn(event_loop.run().in_current_span()); let bid_quote = event_loop_handle.request_quote().await?; @@ -522,7 +522,7 @@ impl Request { } let (event_loop, event_loop_handle) = - EventLoop::new(swap_id, swarm, seller_peer_id)?; + EventLoop::new(swap_id, swarm, seller_peer_id, context.db.clone())?; let monero_receive_address = context.db.get_monero_address(swap_id).await?; let swap = Swap::from_db( Arc::clone(&context.db), diff --git a/swap/src/cli/event_loop.rs b/swap/src/cli/event_loop.rs index befe1dc5..fd7b4308 100644 --- a/swap/src/cli/event_loop.rs +++ b/swap/src/cli/event_loop.rs @@ -5,6 +5,7 @@ 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}; @@ -13,6 +14,7 @@ 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; @@ -21,6 +23,7 @@ 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>, @@ -51,6 +54,7 @@ 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)); @@ -69,6 +73,7 @@ impl EventLoop { inflight_swap_setup: None, inflight_encrypted_signature_requests: HashMap::default(), pending_transfer_proof: OptionFuture::from(None), + db, }; let handle = EventLoopHandle { @@ -108,38 +113,63 @@ impl EventLoop { SwarmEvent::Behaviour(OutEvent::TransferProofReceived { msg, channel, peer }) => { let swap_id = msg.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; - } - - 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; + 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; } - }; - self.pending_transfer_proof = OptionFuture::from(Some(async move { - let _ = responder.recv().await; + 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; + } + }; - channel - }.boxed())); + 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); + } + } + } + } } SwarmEvent::Behaviour(OutEvent::EncryptedSignatureAcknowledged { id }) => { if let Some(responder) = self.inflight_encrypted_signature_requests.remove(&id) { diff --git a/swap/src/database/sqlite.rs b/swap/src/database/sqlite.rs index 751f76aa..6cddd50e 100644 --- a/swap/src/database/sqlite.rs +++ b/swap/src/database/sqlite.rs @@ -1,5 +1,5 @@ use crate::database::Swap; -use crate::monero::Address; +use crate::monero::{Address, TransferProof}; use crate::protocol::{Database, State}; use anyhow::{anyhow, Context, Result}; use async_trait::async_trait; @@ -303,6 +303,56 @@ 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> { + let mut conn = self.pool.acquire().await?; + let swap_id = swap_id.to_string(); + + let row = sqlx::query!( + r#" + SELECT proof + FROM buffered_transfer_proofs + WHERE swap_id = ? + "#, + swap_id + ) + .fetch_all(&mut conn) + .await?; + + if row.is_empty() { + return Ok(None); + } + + let proof_str = &row[0].proof; + let proof = serde_json::from_str(proof_str)?; + + Ok(Some(proof)) + } + async fn raw_all(&self) -> Result>> { let mut conn = self.pool.acquire().await?; let rows = sqlx::query!( diff --git a/swap/src/network/test.rs b/swap/src/network/test.rs index 5a324385..f27c3824 100644 --- a/swap/src/network/test.rs +++ b/swap/src/network/test.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use futures::stream::FusedStream; -use futures::{future, Future, Stream, StreamExt}; +use futures::{future, Future, StreamExt}; use libp2p::core::muxing::StreamMuxerBox; use libp2p::core::transport::upgrade::Version; use libp2p::core::transport::MemoryTransport; @@ -75,8 +75,8 @@ async fn get_local_tcp_address() -> Multiaddr { } pub async fn await_events_or_timeout( - swarm_1: &mut (impl Stream> + FusedStream + Unpin), - swarm_2: &mut (impl Stream> + FusedStream + Unpin), + swarm_1: &mut (impl FusedStream> + FusedStream + Unpin), + swarm_2: &mut (impl FusedStream> + FusedStream + Unpin), ) -> (SwarmEvent, SwarmEvent) where SwarmEvent: Debug, diff --git a/swap/src/protocol.rs b/swap/src/protocol.rs index 0e15f89a..676a03f4 100644 --- a/swap/src/protocol.rs +++ b/swap/src/protocol.rs @@ -146,4 +146,13 @@ pub trait Database { async fn get_states(&self, swap_id: Uuid) -> Result>; async fn all(&self) -> Result>; async fn raw_all(&self) -> Result>>; + async fn insert_buffered_transfer_proof( + &self, + swap_id: Uuid, + proof: monero::TransferProof, + ) -> Result<()>; + async fn get_buffered_transfer_proof( + &self, + swap_id: Uuid, + ) -> Result>; } diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 3900a17b..7a702d77 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -1,10 +1,11 @@ use crate::bitcoin::{ExpiredTimelocks, TxCancel, TxRefund}; use crate::cli::EventLoopHandle; use crate::network::swap_setup::bob::NewSwap; -use crate::protocol::bob; use crate::protocol::bob::state::*; +use crate::protocol::{bob, Database}; use crate::{bitcoin, monero}; use anyhow::{bail, Context, Result}; +use std::sync::Arc; use tokio::select; use uuid::Uuid; @@ -34,6 +35,7 @@ pub async fn run_until( swap.id, current_state.clone(), &mut swap.event_loop_handle, + swap.db.clone(), swap.bitcoin_wallet.as_ref(), swap.monero_wallet.as_ref(), swap.monero_receive_address, @@ -52,6 +54,7 @@ async fn next_state( swap_id: Uuid, state: BobState, event_loop_handle: &mut EventLoopHandle, + db: Arc, bitcoin_wallet: &bitcoin::Wallet, monero_wallet: &monero::Wallet, monero_receive_address: monero::Address, @@ -118,12 +121,28 @@ async fn next_state( let tx_lock_status = bitcoin_wallet.subscribe_to(state3.tx_lock.clone()).await; if let ExpiredTimelocks::None { .. } = state3.expired_timelock(bitcoin_wallet).await? { + tracing::info!("Waiting for Alice to lock Monero"); + + let buffered_transfer_proof = db + .get_buffered_transfer_proof(swap_id) + .await + .context("Failed to get buffered transfer proof")?; + + if let Some(transfer_proof) = buffered_transfer_proof { + tracing::debug!(txid = %transfer_proof.tx_hash(), "Found buffered transfer proof"); + tracing::info!(txid = %transfer_proof.tx_hash(), "Alice locked Monero"); + + return Ok(BobState::XmrLockProofReceived { + state: state3, + lock_transfer_proof: transfer_proof, + monero_wallet_restore_blockheight, + }); + } + let transfer_proof_watcher = event_loop_handle.recv_transfer_proof(); let cancel_timelock_expires = tx_lock_status.wait_until_confirmed_with(state3.cancel_timelock); - tracing::info!("Waiting for Alice to lock Monero"); - select! { transfer_proof = transfer_proof_watcher => { let transfer_proof = transfer_proof?; diff --git a/swap/tests/concurrent_bobs_before_xmr_lock_proof_sent.rs b/swap/tests/concurrent_bobs_before_xmr_lock_proof_sent.rs index d76b3b5f..bf8adb06 100644 --- a/swap/tests/concurrent_bobs_before_xmr_lock_proof_sent.rs +++ b/swap/tests/concurrent_bobs_before_xmr_lock_proof_sent.rs @@ -32,8 +32,7 @@ async fn concurrent_bobs_before_xmr_lock_proof_sent() { let alice_swap_2 = tokio::spawn(alice::run(alice_swap_2, FixedRate::default())); // The 2nd swap ALWAYS finish successfully in this - // scenario, but will receive an "unwanted" transfer proof that is ignored in - // the event loop. + // scenario, but will receive an "unwanted" transfer proof that is buffered until the 1st swap is resumed let bob_state_2 = bob_swap_2.await??; assert!(matches!(bob_state_2, BobState::XmrRedeemed { .. })); @@ -46,15 +45,13 @@ async fn concurrent_bobs_before_xmr_lock_proof_sent() { .await; assert!(matches!(bob_state_1, BobState::BtcLocked { .. })); - // The 1st (paused) swap is expected to refund, because the transfer - // proof is delivered to the wrong swap, and we currently don't store it in the - // database for the other swap. + // The 1st (paused) swap is expected to finish successfully because the transfer proof is buffered when it is receives while another swap is running. let bob_state_1 = bob::run(bob_swap_1).await?; - assert!(matches!(bob_state_1, BobState::BtcRefunded { .. })); + assert!(matches!(bob_state_1, BobState::XmrRedeemed { .. })); let alice_state_1 = alice_swap_1.await??; - assert!(matches!(alice_state_1, AliceState::XmrRefunded { .. })); + assert!(matches!(alice_state_1, AliceState::BtcRedeemed { .. })); Ok(()) }) diff --git a/swap/tests/harness/mod.rs b/swap/tests/harness/mod.rs index 24083a71..028b0935 100644 --- a/swap/tests/harness/mod.rs +++ b/swap/tests/harness/mod.rs @@ -427,8 +427,6 @@ impl BobParams { } pub async fn new_swap_from_db(&self, swap_id: Uuid) -> Result<(bob::Swap, cli::EventLoop)> { - let (event_loop, handle) = self.new_eventloop(swap_id).await?; - if let Some(parent_dir) = self.db_path.parent() { ensure_directory_exists(parent_dir)?; } @@ -437,8 +435,10 @@ impl BobParams { } let db = Arc::new(SqliteDatabase::open(&self.db_path).await?); + let (event_loop, handle) = self.new_eventloop(swap_id, db.clone()).await?; + let swap = bob::Swap::from_db( - db, + db.clone(), swap_id, self.bitcoin_wallet.clone(), self.monero_wallet.clone(), @@ -457,8 +457,6 @@ impl BobParams { ) -> Result<(bob::Swap, cli::EventLoop)> { let swap_id = Uuid::new_v4(); - let (event_loop, handle) = self.new_eventloop(swap_id).await?; - if let Some(parent_dir) = self.db_path.parent() { ensure_directory_exists(parent_dir)?; } @@ -467,6 +465,8 @@ impl BobParams { } let db = Arc::new(SqliteDatabase::open(&self.db_path).await?); + let (event_loop, handle) = self.new_eventloop(swap_id, db.clone()).await?; + db.insert_peer_id(swap_id, self.alice_peer_id).await?; let swap = bob::Swap::new( @@ -487,6 +487,7 @@ impl BobParams { pub async fn new_eventloop( &self, swap_id: Uuid, + db: Arc, ) -> Result<(cli::EventLoop, cli::EventLoopHandle)> { let tor_socks5_port = get_port() .expect("We don't care about Tor in the tests so we get a free port to disable it."); @@ -503,7 +504,7 @@ impl BobParams { .behaviour_mut() .add_address(self.alice_peer_id, self.alice_address.clone()); - cli::EventLoop::new(swap_id, swarm, self.alice_peer_id) + cli::EventLoop::new(swap_id, swarm, self.alice_peer_id, db.clone()) } } From 173d077751bce0522d5542f05c5ac04709f716e5 Mon Sep 17 00:00:00 2001 From: patrini32 Date: Mon, 1 Jul 2024 21:14:44 +0000 Subject: [PATCH 014/108] feat (Cli): Display reason for failed cancel-refund operation to the user (#1668) We now display the reason for a failed cancel-refund operation to the user. Fixes #683 --- .github/workflows/ci.yml | 1 + CHANGELOG.md | 1 + swap/src/api/request.rs | 1 + swap/src/cli/cancel_and_refund.rs | 130 ++++++++++++++---- swap/src/protocol/bob/state.rs | 37 ++--- ..._refund_using_cancel_and_refund_command.rs | 2 +- ...and_refund_command_timelock_not_expired.rs | 15 +- ...punishes_after_bob_dead_and_bob_cancels.rs | 98 +++++++++++++ 8 files changed, 224 insertions(+), 61 deletions(-) create mode 100644 swap/tests/alice_manually_punishes_after_bob_dead_and_bob_cancels.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b0a0ce6..b3f742fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -157,6 +157,7 @@ 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, diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c48cb79..098db809 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - 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 diff --git a/swap/src/api/request.rs b/swap/src/api/request.rs index 800e1c06..50274ab1 100644 --- a/swap/src/api/request.rs +++ b/swap/src/api/request.rs @@ -821,6 +821,7 @@ 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 diff --git a/swap/src/cli/cancel_and_refund.rs b/swap/src/cli/cancel_and_refund.rs index d542b7ed..e92283ea 100644 --- a/swap/src/cli/cancel_and_refund.rs +++ b/swap/src/cli/cancel_and_refund.rs @@ -1,5 +1,4 @@ -use crate::bitcoin::wallet::Subscription; -use crate::bitcoin::{parse_rpc_error_code, RpcErrorCode, Wallet}; +use crate::bitcoin::{ExpiredTimelocks, Wallet}; use crate::protocol::bob::BobState; use crate::protocol::Database; use anyhow::{bail, Result}; @@ -13,7 +12,7 @@ pub async fn cancel_and_refund( db: Arc, ) -> Result { if let Err(err) = cancel(swap_id, bitcoin_wallet.clone(), db.clone()).await { - tracing::info!(%err, "Could not submit cancel transaction"); + tracing::warn!(%err, "Could not cancel swap. Attempting to refund anyway"); }; let state = match refund(swap_id, bitcoin_wallet, db).await { @@ -21,7 +20,6 @@ pub async fn cancel_and_refund( Err(e) => bail!(e), }; - tracing::info!("Refund transaction submitted"); Ok(state) } @@ -29,7 +27,7 @@ pub async fn cancel( swap_id: Uuid, bitcoin_wallet: Arc, db: Arc, -) -> Result<(Txid, Subscription, BobState)> { +) -> Result<(Txid, BobState)> { let state = db.get_state(swap_id).await?.try_into()?; let state6 = match state { @@ -47,34 +45,69 @@ pub async fn cancel( | BobState::XmrRedeemed { .. } | BobState::BtcPunished { .. } | BobState::SafelyAborted => bail!( - "Cannot cancel swap {} because it is in state {} which is not refundable.", + "Cannot cancel swap {} because it is in state {} which is not cancellable.", swap_id, state ), }; - tracing::info!(%swap_id, "Manually cancelling swap"); + tracing::info!(%swap_id, "Attempting to manually cancel swap"); - let (txid, subscription) = match state6.submit_tx_cancel(bitcoin_wallet.as_ref()).await { - Ok(txid) => txid, + // 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 Err(err) => { - 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"); + // 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 { + 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")); } } - 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( @@ -104,12 +137,51 @@ pub async fn refund( ), }; - tracing::info!(%swap_id, "Manually refunding swap"); - state6.publish_refund_btc(bitcoin_wallet.as_ref()).await?; + tracing::info!(%swap_id, "Attempting to manually refund swap"); - let state = BobState::BtcRefunded(state6); - db.insert_latest_state(swap_id, state.clone().into()) - .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?; - Ok(state) + 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 { + 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 should is unexpected.")); + } + Err(e) => { + bail!(bitcoin_publication_err + .context(e) + .context("Failed to refund swap and could not check timelock status")); + } + } + } + } } diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index 58c1d723..03f56d28 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -646,18 +646,20 @@ impl State6 { tx_cancel_status, )) } - - pub async fn check_for_tx_cancel( - &self, - bitcoin_wallet: &bitcoin::Wallet, - ) -> Result { - let tx_cancel = bitcoin::TxCancel::new( + pub fn construct_tx_cancel(&self) -> Result { + bitcoin::TxCancel::new( &self.tx_lock, self.cancel_timelock, self.A, self.b.public(), self.tx_cancel_fee, - )?; + ) + } + pub async fn check_for_tx_cancel( + &self, + bitcoin_wallet: &bitcoin::Wallet, + ) -> Result { + let tx_cancel = self.construct_tx_cancel()?; let tx = bitcoin_wallet.get_raw_transaction(tx_cancel.txid()).await?; @@ -668,15 +670,10 @@ impl State6 { &self, bitcoin_wallet: &bitcoin::Wallet, ) -> Result<(Txid, Subscription)> { - let transaction = bitcoin::TxCancel::new( - &self.tx_lock, - self.cancel_timelock, - self.A, - self.b.public(), - self.tx_cancel_fee, - )? - .complete_as_bob(self.A, self.b.clone(), self.tx_cancel_sig_a.clone()) - .context("Failed to complete Bitcoin cancel transaction")?; + let transaction = self + .construct_tx_cancel()? + .complete_as_bob(self.A, self.b.clone(), self.tx_cancel_sig_a.clone()) + .context("Failed to complete Bitcoin cancel transaction")?; let (tx_id, subscription) = bitcoin_wallet.broadcast(transaction, "cancel").await?; @@ -691,13 +688,7 @@ impl State6 { } pub fn signed_refund_transaction(&self) -> Result { - let tx_cancel = bitcoin::TxCancel::new( - &self.tx_lock, - self.cancel_timelock, - self.A, - self.b.public(), - self.tx_cancel_fee, - )?; + let tx_cancel = self.construct_tx_cancel()?; let tx_refund = bitcoin::TxRefund::new(&tx_cancel, &self.refund_address, self.tx_refund_fee); diff --git a/swap/tests/alice_and_bob_refund_using_cancel_and_refund_command.rs b/swap/tests/alice_and_bob_refund_using_cancel_and_refund_command.rs index 1870bed4..04cabec4 100644 --- a/swap/tests/alice_and_bob_refund_using_cancel_and_refund_command.rs +++ b/swap/tests/alice_and_bob_refund_using_cancel_and_refund_command.rs @@ -50,7 +50,7 @@ async fn given_alice_and_bob_manually_refund_after_funds_locked_both_refund() { // Bob manually cancels bob_join_handle.abort(); - let (_, _, state) = cli::cancel(bob_swap.id, bob_swap.bitcoin_wallet, bob_swap.db).await?; + let (_, state) = cli::cancel(bob_swap.id, bob_swap.bitcoin_wallet, bob_swap.db).await?; assert!(matches!(state, BobState::BtcCancelled { .. })); let (bob_swap, bob_join_handle) = ctx diff --git a/swap/tests/alice_and_bob_refund_using_cancel_and_refund_command_timelock_not_expired.rs b/swap/tests/alice_and_bob_refund_using_cancel_and_refund_command_timelock_not_expired.rs index 16953866..6584a3d2 100644 --- a/swap/tests/alice_and_bob_refund_using_cancel_and_refund_command_timelock_not_expired.rs +++ b/swap/tests/alice_and_bob_refund_using_cancel_and_refund_command_timelock_not_expired.rs @@ -42,10 +42,10 @@ async fn given_alice_and_bob_manually_cancel_when_timelock_not_expired_errors() let error = cli::cancel(bob_swap.id, bob_swap.bitcoin_wallet, bob_swap.db) .await .unwrap_err(); - assert_eq!( - parse_rpc_error_code(&error).unwrap(), - i64::from(RpcErrorCode::RpcVerifyRejected) - ); + + assert!(error + .to_string() + .contains("Cannot cancel swap because the cancel timelock has not expired yet")); ctx.restart_alice().await; let alice_swap = ctx.alice_next_swap().await; @@ -72,10 +72,9 @@ async fn given_alice_and_bob_manually_cancel_when_timelock_not_expired_errors() let error = cli::refund(bob_swap.id, bob_swap.bitcoin_wallet, bob_swap.db) .await .unwrap_err(); - assert_eq!( - parse_rpc_error_code(&error).unwrap(), - i64::from(RpcErrorCode::RpcVerifyError) - ); + assert!(error + .to_string() + .contains("Cannot refund swap because the cancel timelock has not expired yet")); let (bob_swap, _) = ctx .stop_and_resume_bob_from_db(bob_join_handle, swap_id) diff --git a/swap/tests/alice_manually_punishes_after_bob_dead_and_bob_cancels.rs b/swap/tests/alice_manually_punishes_after_bob_dead_and_bob_cancels.rs new file mode 100644 index 00000000..374d6160 --- /dev/null +++ b/swap/tests/alice_manually_punishes_after_bob_dead_and_bob_cancels.rs @@ -0,0 +1,98 @@ +pub mod harness; + +use harness::alice_run_until::is_xmr_lock_transaction_sent; +use harness::bob_run_until::is_btc_locked; +use harness::FastPunishConfig; +use swap::asb; +use swap::asb::FixedRate; +use swap::cli; +use swap::protocol::alice::AliceState; +use swap::protocol::bob::BobState; +use swap::protocol::{alice, bob}; +/// Bob locks Btc and Alice locks Xmr. Bob does not act; he fails to send Alice +/// the encsig and fail to refund or redeem. Alice punishes using the cancel and +/// punish command. Then Bob tries to refund. +#[tokio::test] +async fn alice_manually_punishes_after_bob_dead_and_bob_cancels() { + harness::setup_test(FastPunishConfig, |mut ctx| async move { + let (bob_swap, bob_join_handle) = ctx.bob_swap().await; + let bob_swap_id = bob_swap.id; + let bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked)); + + let alice_swap = ctx.alice_next_swap().await; + let alice_bitcoin_wallet = alice_swap.bitcoin_wallet.clone(); + + let alice_swap = tokio::spawn(alice::run_until( + alice_swap, + is_xmr_lock_transaction_sent, + FixedRate::default(), + )); + + let bob_state = bob_swap.await??; + assert!(matches!(bob_state, BobState::BtcLocked { .. })); + + let alice_state = alice_swap.await??; + + // Ensure cancel timelock is expired + if let AliceState::XmrLockTransactionSent { state3, .. } = alice_state { + alice_bitcoin_wallet + .subscribe_to(state3.tx_lock) + .await + .wait_until_confirmed_with(state3.cancel_timelock) + .await?; + } else { + panic!("Alice in unexpected state {}", alice_state); + } + + // manual cancel (required to be able to punish) + + ctx.restart_alice().await; + let alice_swap = ctx.alice_next_swap().await; + let (_, alice_state) = + asb::cancel(alice_swap.swap_id, alice_swap.bitcoin_wallet, alice_swap.db).await?; + + // Ensure punish timelock is expired + if let AliceState::BtcCancelled { state3, .. } = alice_state { + alice_bitcoin_wallet + .subscribe_to(state3.tx_cancel()) + .await + .wait_until_confirmed_with(state3.punish_timelock) + .await?; + } else { + panic!("Alice in unexpected state {}", alice_state); + } + + // manual punish + + ctx.restart_alice().await; + let alice_swap = ctx.alice_next_swap().await; + let (_, alice_state) = + asb::punish(alice_swap.swap_id, alice_swap.bitcoin_wallet, alice_swap.db).await?; + ctx.assert_alice_punished(alice_state).await; + // Bob is in wrong state. + let (bob_swap, bob_join_handle) = ctx + .stop_and_resume_bob_from_db(bob_join_handle, bob_swap_id) + .await; + assert!(matches!(bob_swap.state, BobState::BtcLocked { .. })); + bob_join_handle.abort(); + + let (_, state) = cli::cancel(bob_swap_id, bob_swap.bitcoin_wallet, bob_swap.db).await?; + // Bob should be in BtcCancelled state now. + assert!(matches!(state, BobState::BtcCancelled { .. })); + + let (bob_swap, _) = ctx + .stop_and_resume_bob_from_db(bob_join_handle, bob_swap_id) + .await; + assert!(matches!(bob_swap.state, BobState::BtcCancelled { .. })); + // Alice punished Bob, so he should be in the BtcPunished state. + let error = cli::refund(bob_swap_id, bob_swap.bitcoin_wallet, bob_swap.db) + .await + .unwrap_err(); + assert_eq!( + error.to_string(), + "Cannot refund swap because we have already been punished" + ); + Ok(()) + }) + .await; +} From 415323e4fcebc81e7e6ad0fdc50c600914575a36 Mon Sep 17 00:00:00 2001 From: COMIT Botty McBotface <68941619+comit-botty-mc-botface@users.noreply.github.com> Date: Tue, 2 Jul 2024 07:27:00 +1000 Subject: [PATCH 015/108] Prepare release 0.13.2 (#1694) --- CHANGELOG.md | 5 ++++- Cargo.lock | 2 +- swap/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 098db809..6da810b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.13.2] - 2024-07-01 + - 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) @@ -363,7 +365,8 @@ 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.1...HEAD +[unreleased]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.2...HEAD +[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 [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 diff --git a/Cargo.lock b/Cargo.lock index b18965fb..cb3ea136 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4515,7 +4515,7 @@ checksum = "8049cf85f0e715d6af38dde439cb0ccb91f67fb9f5f63c80f8b43e48356e1a3f" [[package]] name = "swap" -version = "0.13.1" +version = "0.13.2" dependencies = [ "anyhow", "async-compression", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index cbb7a802..5c754a53 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swap" -version = "0.13.1" +version = "0.13.2" authors = [ "The COMIT guys " ] edition = "2021" description = "XMR/BTC trustless atomic swaps." From aa9b3c46871258ec8b4cf30adfe52c860ec40889 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 2 Jul 2024 01:20:20 +0200 Subject: [PATCH 016/108] fix: Add a new migration script for creating the buffered_transfer_proofs table (#1695) --- swap/migrations/20210903050345_create_swaps_table.sql | 6 ------ ...20240701231624_create_buffered_transfer_proofs_table.sql | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 swap/migrations/20240701231624_create_buffered_transfer_proofs_table.sql diff --git a/swap/migrations/20210903050345_create_swaps_table.sql b/swap/migrations/20210903050345_create_swaps_table.sql index 84a97d0f..741a45e6 100644 --- a/swap/migrations/20210903050345_create_swaps_table.sql +++ b/swap/migrations/20210903050345_create_swaps_table.sql @@ -22,10 +22,4 @@ CREATE TABLE if NOT EXISTS peer_addresses ( peer_id TEXT NOT NULL, address TEXT NOT NULL -); - -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/migrations/20240701231624_create_buffered_transfer_proofs_table.sql b/swap/migrations/20240701231624_create_buffered_transfer_proofs_table.sql new file mode 100644 index 00000000..32d2c918 --- /dev/null +++ b/swap/migrations/20240701231624_create_buffered_transfer_proofs_table.sql @@ -0,0 +1,5 @@ +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 From 5e735ef4f72cb95f9372cd6d69f39f5f9019283b Mon Sep 17 00:00:00 2001 From: COMIT Botty McBotface <68941619+comit-botty-mc-botface@users.noreply.github.com> Date: Tue, 2 Jul 2024 09:28:07 +1000 Subject: [PATCH 017/108] Prepare release 0.13.2 (#1697) --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6da810b4..0d60a04d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.13.2] - 2024-07-01 +## [0.13.2] - 2024-07-01 + - 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) @@ -366,6 +368,7 @@ It is possible to migrate critical data from the old db to the sqlite but there 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.2...HEAD +[0.13.2]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.2...0.13.2 [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 [0.13.0]: https://github.com/comit-network/xmr-btc-swap/compare/0.12.3...0.13.0 From 26109d6d8a5e90536ec92dd86a0546ffb5970ff7 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 2 Jul 2024 01:51:58 +0200 Subject: [PATCH 018/108] Revert "Prepare release 0.13.2 (#1697)" (#1698) This reverts commit 5e735ef4f72cb95f9372cd6d69f39f5f9019283b. --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d60a04d..6da810b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.13.2] - 2024-07-01 -## [0.13.2] - 2024-07-01 - - 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) @@ -368,7 +366,6 @@ It is possible to migrate critical data from the old db to the sqlite but there 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.2...HEAD -[0.13.2]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.2...0.13.2 [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 [0.13.0]: https://github.com/comit-network/xmr-btc-swap/compare/0.12.3...0.13.0 From 6c1b85e4084b5ca9acb1fe53b9804850220fe9ee Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 2 Jul 2024 01:53:57 +0200 Subject: [PATCH 019/108] Revert "Prepare release 0.13.2 (#1694)" (#1699) This reverts commit 415323e4fcebc81e7e6ad0fdc50c600914575a36. --- CHANGELOG.md | 5 +---- Cargo.lock | 2 +- swap/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6da810b4..098db809 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [0.13.2] - 2024-07-01 - - 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) @@ -365,8 +363,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.2...HEAD -[0.13.2]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.1...0.13.2 +[unreleased]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.1...HEAD [0.13.1]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.0...0.13.1 [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 diff --git a/Cargo.lock b/Cargo.lock index cb3ea136..b18965fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4515,7 +4515,7 @@ checksum = "8049cf85f0e715d6af38dde439cb0ccb91f67fb9f5f63c80f8b43e48356e1a3f" [[package]] name = "swap" -version = "0.13.2" +version = "0.13.1" dependencies = [ "anyhow", "async-compression", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 5c754a53..cbb7a802 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swap" -version = "0.13.2" +version = "0.13.1" authors = [ "The COMIT guys " ] edition = "2021" description = "XMR/BTC trustless atomic swaps." From 5c9185876da7fc01b610bc749be149163ea59c76 Mon Sep 17 00:00:00 2001 From: COMIT Botty McBotface <68941619+comit-botty-mc-botface@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:11:36 +1000 Subject: [PATCH 020/108] Prepare release 0.13.2 (#1700) --- CHANGELOG.md | 5 ++++- Cargo.lock | 2 +- swap/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 098db809..9a2baf45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [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) @@ -363,7 +365,8 @@ 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.1...HEAD +[unreleased]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.2...HEAD +[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 [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 diff --git a/Cargo.lock b/Cargo.lock index b18965fb..cb3ea136 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4515,7 +4515,7 @@ checksum = "8049cf85f0e715d6af38dde439cb0ccb91f67fb9f5f63c80f8b43e48356e1a3f" [[package]] name = "swap" -version = "0.13.1" +version = "0.13.2" dependencies = [ "anyhow", "async-compression", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index cbb7a802..5c754a53 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swap" -version = "0.13.1" +version = "0.13.2" authors = [ "The COMIT guys " ] edition = "2021" description = "XMR/BTC trustless atomic swaps." From c5aa7edb6b55c31014a3110dd23061d68941d022 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 2 Jul 2024 12:03:56 +0200 Subject: [PATCH 021/108] chore: Fix typo (#1701) --- swap/src/cli/cancel_and_refund.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swap/src/cli/cancel_and_refund.rs b/swap/src/cli/cancel_and_refund.rs index e92283ea..5484d7cb 100644 --- a/swap/src/cli/cancel_and_refund.rs +++ b/swap/src/cli/cancel_and_refund.rs @@ -174,7 +174,7 @@ pub async fn refund( ); } Ok(ExpiredTimelocks::Cancel { .. }) => { - bail!(bitcoin_publication_err.context("Failed to refund swap even though cancel timelock has expired. This should is unexpected.")); + bail!(bitcoin_publication_err.context("Failed to refund swap even though cancel timelock has expired. This is unexpected.")); } Err(e) => { bail!(bitcoin_publication_err From d7b649b7a682f83cd2b555cbea801dfec9c55847 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Wed, 3 Jul 2024 19:47:45 +0200 Subject: [PATCH 022/108] feat: Allow for cooperative Monero redeem after Bitcoin punish has happened --- CHANGELOG.md | 2 + .../20240615140942_btcpunished_update.sql | 135 ++++++++++++++++++ swap/src/asb/event_loop.rs | 55 +++++++ swap/src/asb/network.rs | 11 +- swap/src/asb/recovery/cancel.rs | 2 +- swap/src/asb/recovery/punish.rs | 6 +- swap/src/asb/recovery/redeem.rs | 2 +- swap/src/asb/recovery/refund.rs | 2 +- swap/src/asb/recovery/safely_abort.rs | 2 +- swap/src/cli/behaviour.rs | 18 ++- swap/src/cli/cancel_and_refund.rs | 25 +++- swap/src/cli/event_loop.rs | 32 ++++- swap/src/database/alice.rs | 12 +- swap/src/database/bob.rs | 12 +- swap/src/database/sqlite.rs | 15 +- swap/src/network.rs | 1 + .../cooperative_xmr_redeem_after_punish.rs | 113 +++++++++++++++ swap/src/protocol/alice/state.rs | 8 +- swap/src/protocol/alice/swap.rs | 6 +- swap/src/protocol/bob/state.rs | 68 ++++++++- swap/src/protocol/bob/swap.rs | 98 +++++++------ .../alice_manually_punishes_after_bob_dead.rs | 6 +- .../alice_punishes_after_restart_bob_dead.rs | 6 +- swap/tests/harness/mod.rs | 6 +- swap/tests/punish.rs | 6 +- 25 files changed, 548 insertions(+), 101 deletions(-) create mode 100644 swap/migrations/20240615140942_btcpunished_update.sql create mode 100644 swap/src/network/cooperative_xmr_redeem_after_punish.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a2baf45..070c4a51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- 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 + ## [0.13.2] - 2024-07-02 - CLI: Buffer received transfer proofs for later processing if we're currently running a different swap diff --git a/swap/migrations/20240615140942_btcpunished_update.sql b/swap/migrations/20240615140942_btcpunished_update.sql new file mode 100644 index 00000000..b4c9a8a5 --- /dev/null +++ b/swap/migrations/20240615140942_btcpunished_update.sql @@ -0,0 +1,135 @@ +-- 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/src/asb/event_loop.rs b/swap/src/asb/event_loop.rs index 0d6de9a7..8e3ac4c3 100644 --- a/swap/src/asb/event_loop.rs +++ b/swap/src/asb/event_loop.rs @@ -1,5 +1,7 @@ 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; @@ -253,6 +255,59 @@ 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 7b85f8fb..268a3cba 100644 --- a/swap/src/asb/network.rs +++ b/swap/src/asb/network.rs @@ -5,7 +5,9 @@ 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::{encrypted_signature, quote, transfer_proof}; +use crate::network::{ + cooperative_xmr_redeem_after_punish, encrypted_signature, quote, transfer_proof, +}; use crate::protocol::alice::State3; use anyhow::{anyhow, Error, Result}; use futures::FutureExt; @@ -76,6 +78,11 @@ pub mod behaviour { channel: ResponseChannel<()>, peer: PeerId, }, + CooperativeXmrRedeemRequested { + channel: ResponseChannel, + swap_id: Uuid, + peer: PeerId, + }, Rendezvous(libp2p::rendezvous::client::Event), Failure { peer: PeerId, @@ -114,6 +121,7 @@ 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, @@ -160,6 +168,7 @@ 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 8da1508f..f71b3e38 100644 --- a/swap/src/asb/recovery/cancel.rs +++ b/swap/src/asb/recovery/cancel.rs @@ -38,7 +38,7 @@ pub async fn cancel( // Alice already in final state | AliceState::BtcRedeemed | AliceState::XmrRefunded - | AliceState::BtcPunished + | AliceState::BtcPunished { .. } | AliceState::SafelyAborted => bail!("Swap is in state {} which is not cancelable", state), }; diff --git a/swap/src/asb/recovery/punish.rs b/swap/src/asb/recovery/punish.rs index e94abac8..e1d1ad28 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,7 +46,9 @@ pub async fn punish( let txid = state3.punish_btc(&bitcoin_wallet).await?; - let state = AliceState::BtcPunished; + let state = AliceState::BtcPunished { + state3: state3.clone(), + }; 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 e4642feb..47f4a048 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 64e5c3f3..3067a8f6 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 ad162f8d..8a9e1d95 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/cli/behaviour.rs b/swap/src/cli/behaviour.rs index 2ca8448f..72dc5891 100644 --- a/swap/src/cli/behaviour.rs +++ b/swap/src/cli/behaviour.rs @@ -1,7 +1,11 @@ +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::{encrypted_signature, quote, redial, transfer_proof}; +use crate::network::{ + cooperative_xmr_redeem_after_punish, encrypted_signature, quote, redial, transfer_proof, +}; use crate::protocol::bob::State2; use crate::{bitcoin, env}; use anyhow::{anyhow, Error, Result}; @@ -28,6 +32,16 @@ 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, }, @@ -64,6 +78,7 @@ 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, @@ -91,6 +106,7 @@ 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 5484d7cb..7ab4e4b0 100644 --- a/swap/src/cli/cancel_and_refund.rs +++ b/swap/src/cli/cancel_and_refund.rs @@ -31,8 +31,16 @@ pub async fn cancel( let state = db.get_state(swap_id).await?.try_into()?; let state6 = match state { - BobState::BtcLocked { state3, .. } => state3.cancel(), - BobState::XmrLockProofReceived { state, .. } => state.cancel(), + 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::XmrLocked(state4) => state4.cancel(), BobState::EncSigSent(state4) => state4.cancel(), BobState::CancelTimelockExpired(state6) => state6, @@ -81,6 +89,7 @@ pub async fn cancel( // 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()) @@ -118,8 +127,15 @@ pub async fn refund( let state = db.get_state(swap_id).await?.try_into()?; let state6 = match state { - BobState::BtcLocked { state3, .. } => state3.cancel(), - BobState::XmrLockProofReceived { state, .. } => state.cancel(), + 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::XmrLocked(state4) => state4.cancel(), BobState::EncSigSent(state4) => state4.cancel(), BobState::CancelTimelockExpired(state6) => state6, @@ -157,6 +173,7 @@ pub async fn refund( // 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()) diff --git a/swap/src/cli/event_loop.rs b/swap/src/cli/event_loop.rs index fd7b4308..53ee65b8 100644 --- a/swap/src/cli/event_loop.rs +++ b/swap/src/cli/event_loop.rs @@ -1,6 +1,7 @@ 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; @@ -27,6 +28,7 @@ pub struct EventLoop { // 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>, @@ -36,7 +38,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 @@ -60,7 +62,7 @@ impl EventLoop { 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, @@ -68,10 +70,12 @@ 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, }; @@ -80,6 +84,7 @@ impl EventLoop { 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, }; @@ -176,6 +181,16 @@ impl EventLoop { 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; @@ -234,7 +249,14 @@ 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); + }, } } } @@ -250,6 +272,7 @@ pub struct EventLoopHandle { transfer_proof: bmrng::RequestReceiver, encrypted_signature: bmrng::RequestSender, quote: bmrng::RequestSender<(), BidQuote>, + cooperative_xmr_redeem: bmrng::RequestSender, } impl EventLoopHandle { @@ -274,6 +297,9 @@ 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/database/alice.rs b/swap/src/database/alice.rs index 4ed61790..fcf3ead3 100644 --- a/swap/src/database/alice.rs +++ b/swap/src/database/alice.rs @@ -70,12 +70,12 @@ pub enum Alice { Done(AliceEndState), } -#[derive(Copy, Clone, strum::Display, Debug, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Clone, strum::Display, Debug, Deserialize, Serialize, PartialEq)] pub enum AliceEndState { SafelyAborted, BtcRedeemed, XmrRefunded, - BtcPunished, + BtcPunished { state3: alice::State3 }, } impl From for Alice { @@ -173,7 +173,9 @@ impl From for Alice { transfer_proof, state3: state3.as_ref().clone(), }, - AliceState::BtcPunished => Alice::Done(AliceEndState::BtcPunished), + AliceState::BtcPunished { state3 } => Alice::Done(AliceEndState::BtcPunished { + state3: state3.as_ref().clone(), + }), AliceState::SafelyAborted => Alice::Done(AliceEndState::SafelyAborted), } } @@ -277,7 +279,9 @@ impl From for AliceState { AliceEndState::SafelyAborted => AliceState::SafelyAborted, AliceEndState::BtcRedeemed => AliceState::BtcRedeemed, AliceEndState::XmrRefunded => AliceState::XmrRefunded, - AliceEndState::BtcPunished => AliceState::BtcPunished, + AliceEndState::BtcPunished { state3 } => AliceState::BtcPunished { + state3: Box::new(state3), + }, }, } } diff --git a/swap/src/database/bob.rs b/swap/src/database/bob.rs index 25117763..735f45a2 100644 --- a/swap/src/database/bob.rs +++ b/swap/src/database/bob.rs @@ -33,6 +33,10 @@ 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), @@ -44,7 +48,6 @@ pub enum BobEndState { SafelyAborted, XmrRedeemed { tx_lock_id: bitcoin::Txid }, BtcRefunded(Box), - BtcPunished { tx_lock_id: bitcoin::Txid }, } impl From for Bob { @@ -79,13 +82,11 @@ 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), } } @@ -123,11 +124,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 }, }, } } @@ -148,6 +149,7 @@ 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 6cddd50e..576dc362 100644 --- a/swap/src/database/sqlite.rs +++ b/swap/src/database/sqlite.rs @@ -417,9 +417,8 @@ mod tests { let db = setup_test_db().await.unwrap(); let state_1 = State::Alice(AliceState::BtcRedeemed); - let state_2 = State::Alice(AliceState::BtcPunished); - let state_3 = State::Alice(AliceState::SafelyAborted); - let state_4 = State::Bob(BobState::SafelyAborted); + let state_2 = State::Alice(AliceState::SafelyAborted); + let state_3 = State::Bob(BobState::SafelyAborted); let swap_id_1 = Uuid::new_v4(); let swap_id_2 = Uuid::new_v4(); @@ -429,10 +428,7 @@ mod tests { db.insert_latest_state(swap_id_1, state_2.clone()) .await .unwrap(); - db.insert_latest_state(swap_id_1, state_3.clone()) - .await - .unwrap(); - db.insert_latest_state(swap_id_2, state_4.clone()) + db.insert_latest_state(swap_id_2, state_3.clone()) .await .unwrap(); @@ -440,11 +436,10 @@ mod tests { assert_eq!(latest_loaded.len(), 2); - assert!(latest_loaded.contains(&(swap_id_1, state_3))); - assert!(latest_loaded.contains(&(swap_id_2, state_4))); + assert!(latest_loaded.contains(&(swap_id_1, state_2))); + assert!(latest_loaded.contains(&(swap_id_2, state_3))); assert!(!latest_loaded.contains(&(swap_id_1, state_1))); - assert!(!latest_loaded.contains(&(swap_id_1, state_2))); } #[tokio::test] diff --git a/swap/src/network.rs b/swap/src/network.rs index 22243783..527c04fc 100644 --- a/swap/src/network.rs +++ b/swap/src/network.rs @@ -1,6 +1,7 @@ mod impl_from_rr_event; pub mod cbor_request_response; +pub mod cooperative_xmr_redeem_after_punish; pub mod encrypted_signature; pub mod json_pull_codec; pub mod quote; diff --git a/swap/src/network/cooperative_xmr_redeem_after_punish.rs b/swap/src/network/cooperative_xmr_redeem_after_punish.rs new file mode 100644 index 00000000..fb9149e2 --- /dev/null +++ b/swap/src/network/cooperative_xmr_redeem_after_punish.rs @@ -0,0 +1,113 @@ +use crate::monero::Scalar; +use crate::network::cbor_request_response::CborCodec; +use crate::{asb, cli}; +use libp2p::core::ProtocolName; +use libp2p::request_response::{ + ProtocolSupport, RequestResponse, RequestResponseConfig, RequestResponseEvent, + RequestResponseMessage, +}; +use libp2p::PeerId; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +const PROTOCOL: &str = "/comit/xmr/btc/cooperative_xmr_redeem_after_punish/1.0.0"; +type OutEvent = RequestResponseEvent; +type Message = RequestResponseMessage; + +pub type Behaviour = RequestResponse>; + +#[derive(Debug, Clone, Copy, Default)] +pub struct CooperativeXmrRedeemProtocol; + +impl ProtocolName for CooperativeXmrRedeemProtocol { + fn protocol_name(&self) -> &[u8] { + PROTOCOL.as_bytes() + } +} + +#[derive(Debug, thiserror::Error, Clone, Serialize, Deserialize)] +pub enum CooperativeXmrRedeemRejectReason { + #[error("Alice does not have a record of the swap")] + UnknownSwap, + #[error("Alice rejected the request because it deemed it malicious")] + MaliciousRequest, + #[error("Alice is in a state where a cooperative redeem is not possible")] + SwapInvalidState, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Request { + pub swap_id: Uuid, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum Response { + Fullfilled { + swap_id: Uuid, + s_a: Scalar, + }, + Rejected { + swap_id: Uuid, + reason: CooperativeXmrRedeemRejectReason, + }, +} +pub fn alice() -> Behaviour { + Behaviour::new( + CborCodec::default(), + vec![(CooperativeXmrRedeemProtocol, ProtocolSupport::Inbound)], + RequestResponseConfig::default(), + ) +} + +pub fn bob() -> Behaviour { + Behaviour::new( + CborCodec::default(), + vec![(CooperativeXmrRedeemProtocol, ProtocolSupport::Outbound)], + RequestResponseConfig::default(), + ) +} + +impl From<(PeerId, Message)> for asb::OutEvent { + fn from((peer, message): (PeerId, Message)) -> Self { + match message { + Message::Request { + request, channel, .. + } => Self::CooperativeXmrRedeemRequested { + swap_id: request.swap_id, + channel, + peer, + }, + Message::Response { .. } => Self::unexpected_response(peer), + } + } +} + +crate::impl_from_rr_event!(OutEvent, asb::OutEvent, PROTOCOL); + +impl From<(PeerId, Message)> for cli::OutEvent { + fn from((peer, message): (PeerId, Message)) -> Self { + match message { + Message::Request { .. } => Self::unexpected_request(peer), + Message::Response { + response, + request_id, + } => match response { + Response::Fullfilled { swap_id, s_a } => Self::CooperativeXmrRedeemFulfilled { + id: request_id, + swap_id, + s_a, + }, + Response::Rejected { + swap_id, + reason: error, + } => Self::CooperativeXmrRedeemRejected { + id: request_id, + swap_id, + reason: error, + }, + }, + } + } +} + +crate::impl_from_rr_event!(OutEvent, cli::OutEvent, PROTOCOL); diff --git a/swap/src/protocol/alice/state.rs b/swap/src/protocol/alice/state.rs index b4e155a6..f0acab23 100644 --- a/swap/src/protocol/alice/state.rs +++ b/swap/src/protocol/alice/state.rs @@ -74,7 +74,9 @@ pub enum AliceState { transfer_proof: TransferProof, state3: Box, }, - BtcPunished, + BtcPunished { + state3: Box, + }, SafelyAborted, } @@ -98,7 +100,7 @@ impl fmt::Display for AliceState { AliceState::BtcRedeemed => write!(f, "btc is redeemed"), AliceState::BtcCancelled { .. } => write!(f, "btc is cancelled"), AliceState::BtcRefunded { .. } => write!(f, "btc is refunded"), - AliceState::BtcPunished => write!(f, "btc is punished"), + AliceState::BtcPunished { .. } => write!(f, "btc is punished"), AliceState::SafelyAborted => write!(f, "safely aborted"), AliceState::BtcPunishable { .. } => write!(f, "btc is punishable"), AliceState::XmrRefunded => write!(f, "xmr is refunded"), @@ -377,7 +379,7 @@ impl State2 { pub struct State3 { a: bitcoin::SecretKey, B: bitcoin::PublicKey, - s_a: monero::Scalar, + pub s_a: monero::Scalar, S_b_monero: monero::PublicKey, S_b_bitcoin: bitcoin::PublicKey, pub v: monero::PrivateViewKey, diff --git a/swap/src/protocol/alice/swap.rs b/swap/src/protocol/alice/swap.rs index 0eef7dcd..79236563 100644 --- a/swap/src/protocol/alice/swap.rs +++ b/swap/src/protocol/alice/swap.rs @@ -362,7 +362,7 @@ where let punish = state3.punish_btc(bitcoin_wallet).await; match punish { - Ok(_) => AliceState::BtcPunished, + Ok(_) => AliceState::BtcPunished { state3 }, Err(error) => { tracing::warn!("Failed to publish punish transaction: {:#}", error); @@ -392,7 +392,7 @@ where } AliceState::XmrRefunded => AliceState::XmrRefunded, AliceState::BtcRedeemed => AliceState::BtcRedeemed, - AliceState::BtcPunished => AliceState::BtcPunished, + AliceState::BtcPunished { state3 } => AliceState::BtcPunished { state3 }, AliceState::SafelyAborted => AliceState::SafelyAborted, }) } @@ -402,7 +402,7 @@ pub(crate) fn is_complete(state: &AliceState) -> bool { state, AliceState::XmrRefunded | AliceState::BtcRedeemed - | AliceState::BtcPunished + | AliceState::BtcPunished { .. } | AliceState::SafelyAborted ) } diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index 03f56d28..8fe5ca32 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -48,6 +48,7 @@ pub enum BobState { tx_lock_id: bitcoin::Txid, }, BtcPunished { + state: State6, tx_lock_id: bitcoin::Txid, }, SafelyAborted, @@ -421,11 +422,13 @@ impl State3 { } } - pub fn cancel(&self) -> State6 { + pub fn cancel(&self, monero_wallet_restore_blockheight: BlockHeight) -> State6 { State6 { A: self.A, b: self.b.clone(), s_b: self.s_b, + v: self.v, + monero_wallet_restore_blockheight, cancel_timelock: self.cancel_timelock, punish_timelock: self.punish_timelock, refund_address: self.refund_address.clone(), @@ -463,6 +466,19 @@ impl State3 { tx_cancel_status, )) } + pub fn attempt_cooperative_redeem( + &self, + s_a: monero::PrivateKey, + monero_wallet_restore_blockheight: BlockHeight, + ) -> State5 { + State5 { + s_a, + s_b: self.s_b, + v: self.v, + tx_lock: self.tx_lock.clone(), + monero_wallet_restore_blockheight, + } + } } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] @@ -571,6 +587,8 @@ impl State4 { A: self.A, b: self.b, s_b: self.s_b, + v: self.v, + monero_wallet_restore_blockheight: self.monero_wallet_restore_blockheight, cancel_timelock: self.cancel_timelock, punish_timelock: self.punish_timelock, refund_address: self.refund_address, @@ -604,6 +622,43 @@ impl State5 { pub fn tx_lock_id(&self) -> bitcoin::Txid { self.tx_lock.txid() } + pub async fn redeem_xmr( + &self, + monero_wallet: &monero::Wallet, + wallet_file_name: std::string::String, + monero_receive_address: monero::Address, + ) -> Result<()> { + let (spend_key, view_key) = self.xmr_keys(); + + tracing::info!(%wallet_file_name, "Generating and opening Monero wallet from the extracted keys to redeem the Monero"); + if let Err(e) = monero_wallet + .create_from_and_load( + wallet_file_name.clone(), + spend_key, + view_key, + self.monero_wallet_restore_blockheight, + ) + .await + { + // In case we failed to refresh/sweep, when resuming the wallet might already + // exist! This is a very unlikely scenario, but if we don't take care of it we + // might not be able to ever transfer the Monero. + tracing::warn!("Failed to generate monero wallet from keys: {:#}", e); + tracing::info!(%wallet_file_name, + "Falling back to trying to open the wallet if it already exists", + ); + monero_wallet.open(wallet_file_name).await?; + } + + // Ensure that the generated wallet is synced so we have a proper balance + monero_wallet.refresh(20).await?; + // Sweep (transfer all funds) to the given address + let tx_hashes = monero_wallet.sweep_all(monero_receive_address).await?; + for tx_hash in tx_hashes { + tracing::info!(%monero_receive_address, txid=%tx_hash.0, "Successfully transferred XMR to wallet"); + } + Ok(()) + } } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] @@ -611,6 +666,8 @@ pub struct State6 { A: bitcoin::PublicKey, b: bitcoin::SecretKey, s_b: monero::Scalar, + v: monero::PrivateViewKey, + pub monero_wallet_restore_blockheight: BlockHeight, cancel_timelock: CancelTimelock, punish_timelock: PunishTimelock, refund_address: bitcoin::Address, @@ -706,4 +763,13 @@ impl State6 { pub fn tx_lock_id(&self) -> bitcoin::Txid { self.tx_lock.txid() } + pub fn attempt_cooperative_redeem(&self, s_a: monero::PrivateKey) -> State5 { + State5 { + s_a, + s_b: self.s_b, + v: self.v, + tx_lock: self.tx_lock.clone(), + monero_wallet_restore_blockheight: self.monero_wallet_restore_blockheight, + } + } } diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 7a702d77..43c54e4b 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -1,5 +1,6 @@ use crate::bitcoin::{ExpiredTimelocks, TxCancel, TxRefund}; use crate::cli::EventLoopHandle; +use crate::network::cooperative_xmr_redeem_after_punish::Response::{Fullfilled, Rejected}; use crate::network::swap_setup::bob::NewSwap; use crate::protocol::bob::state::*; use crate::protocol::{bob, Database}; @@ -12,10 +13,7 @@ use uuid::Uuid; pub fn is_complete(state: &BobState) -> bool { matches!( state, - BobState::BtcRefunded(..) - | BobState::XmrRedeemed { .. } - | BobState::BtcPunished { .. } - | BobState::SafelyAborted + BobState::BtcRefunded(..) | BobState::XmrRedeemed { .. } | BobState::SafelyAborted ) } @@ -28,7 +26,7 @@ pub async fn run_until( mut swap: bob::Swap, is_target_state: fn(&BobState) -> bool, ) -> Result { - let mut current_state = swap.state; + let mut current_state = swap.state.clone(); while !is_target_state(¤t_state) { current_state = next_state( @@ -41,10 +39,14 @@ pub async fn run_until( swap.monero_receive_address, ) .await?; - swap.db .insert_latest_state(swap.id, current_state.clone().into()) .await?; + if matches!(current_state, BobState::BtcPunished { .. }) + && matches!(swap.state, BobState::BtcPunished { .. }) + { + break; // Stops swap when cooperative redeem fails without preventing resuming swap in BtcPunished state. + }; } Ok(current_state) @@ -159,12 +161,12 @@ async fn next_state( result?; tracing::info!("Alice took too long to lock Monero, cancelling the swap"); - let state4 = state3.cancel(); + let state4 = state3.cancel(monero_wallet_restore_blockheight); BobState::CancelTimelockExpired(state4) }, } } else { - let state4 = state3.cancel(); + let state4 = state3.cancel(monero_wallet_restore_blockheight); BobState::CancelTimelockExpired(state4) } } @@ -188,17 +190,17 @@ async fn next_state( tx_lock_status.wait_until_confirmed_with(state.cancel_timelock).await?; - BobState::CancelTimelockExpired(state.cancel()) + BobState::CancelTimelockExpired(state.cancel(monero_wallet_restore_blockheight)) }, } } result = tx_lock_status.wait_until_confirmed_with(state.cancel_timelock) => { result?; - BobState::CancelTimelockExpired(state.cancel()) + BobState::CancelTimelockExpired(state.cancel(monero_wallet_restore_blockheight)) } } } else { - BobState::CancelTimelockExpired(state.cancel()) + BobState::CancelTimelockExpired(state.cancel(monero_wallet_restore_blockheight)) } } BobState::XmrLocked(state) => { @@ -257,39 +259,9 @@ async fn next_state( } } BobState::BtcRedeemed(state) => { - let (spend_key, view_key) = state.xmr_keys(); - - let wallet_file_name = swap_id.to_string(); - - tracing::info!(%wallet_file_name, "Generating and opening Monero wallet from the extracted keys to redeem the Monero"); - - if let Err(e) = monero_wallet - .create_from_and_load( - wallet_file_name.clone(), - spend_key, - view_key, - state.monero_wallet_restore_blockheight, - ) - .await - { - // In case we failed to refresh/sweep, when resuming the wallet might already - // exist! This is a very unlikely scenario, but if we don't take care of it we - // might not be able to ever transfer the Monero. - tracing::warn!("Failed to generate monero wallet from keys: {:#}", e); - tracing::info!(%wallet_file_name, - "Falling back to trying to open the wallet if it already exists", - ); - monero_wallet.open(wallet_file_name).await?; - } - - // Ensure that the generated wallet is synced so we have a proper balance - monero_wallet.refresh(20).await?; - // Sweep (transfer all funds) to the given address - let tx_hashes = monero_wallet.sweep_all(monero_receive_address).await?; - - for tx_hash in tx_hashes { - tracing::info!(%monero_receive_address, txid=%tx_hash.0, "Successfully transferred XMR to wallet"); - } + state + .redeem_xmr(monero_wallet, swap_id.to_string(), monero_receive_address) + .await?; BobState::XmrRedeemed { tx_lock_id: state.tx_lock_id(), @@ -318,12 +290,48 @@ async fn next_state( tracing::info!("You have been punished for not refunding in time"); BobState::BtcPunished { tx_lock_id: state.tx_lock_id(), + state, } } } } BobState::BtcRefunded(state4) => BobState::BtcRefunded(state4), - BobState::BtcPunished { tx_lock_id } => BobState::BtcPunished { tx_lock_id }, + BobState::BtcPunished { state, tx_lock_id } => { + tracing::info!("Attempting cooperative XMR redeem"); + let response = event_loop_handle + .request_cooperative_xmr_redeem(swap_id) + .await; + + match response { + Ok(Fullfilled { s_a, .. }) => { + tracing::debug!("Alice revealed XMR key to us"); + + let s_a = monero::PrivateKey { scalar: s_a }; + let state5 = state.attempt_cooperative_redeem(s_a); + + match state5 + .redeem_xmr(monero_wallet, swap_id.to_string(), monero_receive_address) + .await + { + Ok(_) => { + return Ok(BobState::XmrRedeemed { tx_lock_id }); + } + Err(error) => { + return Err(error) + .context("Failed to redeem XMR with revealed XMR key"); + } + } + } + Ok(Rejected { reason: error, .. }) => { + return Err(error) + .context("Alice rejected our request for cooperative XMR redeem"); + } + Err(error) => { + return Err(error) + .context("Failed to request cooperative XMR redeem from Alice"); + } + }; + } BobState::SafelyAborted => BobState::SafelyAborted, BobState::XmrRedeemed { tx_lock_id } => BobState::XmrRedeemed { tx_lock_id }, }) diff --git a/swap/tests/alice_manually_punishes_after_bob_dead.rs b/swap/tests/alice_manually_punishes_after_bob_dead.rs index b27904ac..aa747ec9 100644 --- a/swap/tests/alice_manually_punishes_after_bob_dead.rs +++ b/swap/tests/alice_manually_punishes_after_bob_dead.rs @@ -11,7 +11,7 @@ use swap::protocol::{alice, bob}; /// Bob locks Btc and Alice locks Xmr. Bob does not act; he fails to send Alice /// the encsig and fail to refund or redeem. Alice punishes using the cancel and -/// punish command. +/// punish command. Bob then cooperates with Alice and redeems XMR with her key. #[tokio::test] async fn alice_manually_punishes_after_bob_dead() { harness::setup_test(FastPunishConfig, |mut ctx| async move { @@ -78,9 +78,7 @@ async fn alice_manually_punishes_after_bob_dead() { assert!(matches!(bob_swap.state, BobState::BtcLocked { .. })); let bob_state = bob::run(bob_swap).await?; - - ctx.assert_bob_punished(bob_state).await; - + ctx.assert_bob_redeemed(bob_state).await; Ok(()) }) .await; diff --git a/swap/tests/alice_punishes_after_restart_bob_dead.rs b/swap/tests/alice_punishes_after_restart_bob_dead.rs index b049d681..1bf140ee 100644 --- a/swap/tests/alice_punishes_after_restart_bob_dead.rs +++ b/swap/tests/alice_punishes_after_restart_bob_dead.rs @@ -9,7 +9,7 @@ use swap::protocol::bob::BobState; use swap::protocol::{alice, bob}; /// Bob locks Btc and Alice locks Xmr. Bob does not act; he fails to send Alice -/// the encsig and fail to refund or redeem. Alice cancels and punishes. +/// the encsig and fail to refund or redeem. Alice cancels and punishes. Bob then cooperates with Alice and redeems XMR with her key. #[tokio::test] async fn alice_punishes_after_restart_if_bob_dead() { harness::setup_test(FastPunishConfig, |mut ctx| async move { @@ -58,9 +58,7 @@ async fn alice_punishes_after_restart_if_bob_dead() { assert!(matches!(bob_swap.state, BobState::BtcLocked { .. })); let bob_state = bob::run(bob_swap).await?; - - ctx.assert_bob_punished(bob_state).await; - + ctx.assert_bob_redeemed(bob_state).await; Ok(()) }) .await; diff --git a/swap/tests/harness/mod.rs b/swap/tests/harness/mod.rs index 028b0935..4a183084 100644 --- a/swap/tests/harness/mod.rs +++ b/swap/tests/harness/mod.rs @@ -652,7 +652,7 @@ impl TestContext { } pub async fn assert_alice_punished(&self, state: AliceState) { - assert!(matches!(state, AliceState::BtcPunished)); + assert!(matches!(state, AliceState::BtcPunished { .. })); assert_eventual_balance( self.alice_bitcoin_wallet.as_ref(), @@ -698,7 +698,7 @@ impl TestContext { let lock_tx_id = if let BobState::BtcRefunded(state4) = state { state4.tx_lock_id() } else { - panic!("Bob in not in btc refunded state: {:?}", state); + panic!("Bob is not in btc refunded state: {:?}", state); }; let lock_tx_bitcoin_fee = self .bob_bitcoin_wallet @@ -819,7 +819,7 @@ impl TestContext { async fn bob_punished_btc_balance(&self, state: BobState) -> Result { self.bob_bitcoin_wallet.sync().await?; - let lock_tx_id = if let BobState::BtcPunished { tx_lock_id } = state { + let lock_tx_id = if let BobState::BtcPunished { tx_lock_id, .. } = state { tx_lock_id } else { bail!("Bob in not in btc punished state: {:?}", state); diff --git a/swap/tests/punish.rs b/swap/tests/punish.rs index 60eadfe3..79d93d9d 100644 --- a/swap/tests/punish.rs +++ b/swap/tests/punish.rs @@ -7,7 +7,7 @@ use swap::protocol::bob::BobState; use swap::protocol::{alice, bob}; /// Bob locks Btc and Alice locks Xmr. Bob does not act; he fails to send Alice -/// the encsig and fail to refund or redeem. Alice punishes. +/// the encsig and fail to refund or redeem. Alice punishes. Bob then cooperates with Alice and redeems XMR with her key. #[tokio::test] async fn alice_punishes_if_bob_never_acts_after_fund() { harness::setup_test(FastPunishConfig, |mut ctx| async move { @@ -32,9 +32,7 @@ async fn alice_punishes_if_bob_never_acts_after_fund() { assert!(matches!(bob_swap.state, BobState::BtcLocked { .. })); let bob_state = bob::run(bob_swap).await?; - - ctx.assert_bob_punished(bob_state).await; - + ctx.assert_bob_redeemed(bob_state).await; Ok(()) }) .await; From 26e66ce9b95b6f84a9dce459e98cf1fbbac1c37d Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:02:04 +0200 Subject: [PATCH 023/108] Update swap.rs --- swap/src/protocol/bob/swap.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 43c54e4b..b45962ec 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -17,6 +17,15 @@ pub fn is_complete(state: &BobState) -> bool { ) } +// Checks if this is a state where we should exit after +// but we don't want to prevent resuming the swap in this state +// This is currently only used for the BtcPunished state because we might be able to +// recover from this state by attempting a cooperative XMR redeem but it might also fail. +// We want to avoid an infinite retry loop but also allow the user to retry manually by resuming the swap. +pub fn is_exit_early(state: &BobState) -> bool { + matches!(state, BobState::BtcPunished { .. }) +} + #[allow(clippy::too_many_arguments)] pub async fn run(swap: bob::Swap) -> Result { run_until(swap, is_complete).await @@ -39,14 +48,14 @@ pub async fn run_until( swap.monero_receive_address, ) .await?; + swap.db .insert_latest_state(swap.id, current_state.clone().into()) .await?; - if matches!(current_state, BobState::BtcPunished { .. }) - && matches!(swap.state, BobState::BtcPunished { .. }) - { - break; // Stops swap when cooperative redeem fails without preventing resuming swap in BtcPunished state. - }; + + if is_exit_early(¤t_state) { + break; + } } Ok(current_state) From ef75019ac6446f7acd979b2b2241ce7ef8a5c37f Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:12:22 +0200 Subject: [PATCH 024/108] Update swap.rs --- swap/src/protocol/bob/swap.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index b45962ec..341768e1 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -17,12 +17,12 @@ pub fn is_complete(state: &BobState) -> bool { ) } -// Checks if this is a state where we should exit after +// Checks if this is a state where we should exit after reaching it // but we don't want to prevent resuming the swap in this state // This is currently only used for the BtcPunished state because we might be able to // recover from this state by attempting a cooperative XMR redeem but it might also fail. // We want to avoid an infinite retry loop but also allow the user to retry manually by resuming the swap. -pub fn is_exit_early(state: &BobState) -> bool { +pub fn is_run_at_most_once(state: &BobState) -> bool { matches!(state, BobState::BtcPunished { .. }) } @@ -38,7 +38,7 @@ pub async fn run_until( let mut current_state = swap.state.clone(); while !is_target_state(¤t_state) { - current_state = next_state( + let next_state = next_state( swap.id, current_state.clone(), &mut swap.event_loop_handle, @@ -50,12 +50,14 @@ pub async fn run_until( .await?; swap.db - .insert_latest_state(swap.id, current_state.clone().into()) + .insert_latest_state(swap.id, next_state.clone().into()) .await?; - if is_exit_early(¤t_state) { + if is_run_at_most_once(¤t_state) && next_state == current_state { break; } + + current_state = next_state; } Ok(current_state) From 07f788eb81c1c32ac097f9ae2e4e313b8d751bac Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:14:09 +0200 Subject: [PATCH 025/108] Update swap.rs --- swap/src/protocol/bob/swap.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 341768e1..f758ab03 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -17,11 +17,13 @@ pub fn is_complete(state: &BobState) -> bool { ) } -// Checks if this is a state where we should exit after reaching it -// but we don't want to prevent resuming the swap in this state -// This is currently only used for the BtcPunished state because we might be able to -// recover from this state by attempting a cooperative XMR redeem but it might also fail. -// We want to avoid an infinite retry loop but also allow the user to retry manually by resuming the swap. +// Identifies states that should be run at most once before exiting. +// This is used to prevent infinite retry loops while still allowing manual resumption. +// +// Currently, this applies to the BtcPunished state: +// - We want to attempt recovery via cooperative XMR redeem once. +// - If unsuccessful, we exit to avoid an infinite retry loop. +// - The swap can still be manually resumed later and retried if desired. pub fn is_run_at_most_once(state: &BobState) -> bool { matches!(state, BobState::BtcPunished { .. }) } From 2824ebc893958513539363da17bfa905d5ed1223 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:39:49 +0200 Subject: [PATCH 026/108] Update swap.rs --- swap/src/protocol/bob/swap.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index f758ab03..55174d3a 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -310,14 +310,16 @@ async fn next_state( } BobState::BtcRefunded(state4) => BobState::BtcRefunded(state4), BobState::BtcPunished { state, tx_lock_id } => { - tracing::info!("Attempting cooperative XMR redeem"); + tracing::info!("Attempting to cooperatively redeem XMR after being punished"); let response = event_loop_handle .request_cooperative_xmr_redeem(swap_id) .await; match response { Ok(Fullfilled { s_a, .. }) => { - tracing::debug!("Alice revealed XMR key to us"); + tracing::info!( + "Alice has accepted our request to cooperatively redeem the XMR" + ); let s_a = monero::PrivateKey { scalar: s_a }; let state5 = state.attempt_cooperative_redeem(s_a); From 294b658f4327f4b8a2c68e72c347eba622f5d4d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:04:18 +0000 Subject: [PATCH 027/108] build(deps): bump qrcode from 0.14.0 to 0.14.1 Bumps [qrcode](https://github.com/kennytm/qrcode-rust) from 0.14.0 to 0.14.1. - [Release notes](https://github.com/kennytm/qrcode-rust/releases) - [Commits](https://github.com/kennytm/qrcode-rust/commits/v0.14.1) --- updated-dependencies: - dependency-name: qrcode dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb3ea136..94cf9a78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3243,9 +3243,9 @@ dependencies = [ [[package]] name = "qrcode" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e719ca51966ff9f5a8436edb00d6115b3c606a0bb27c8f8ca74a38ff2b036d" +checksum = "d68782463e408eb1e668cf6152704bd856c78c5b6417adaee3203d8f4c1fc9ec" dependencies = [ "image", ] From ab1001a18c190c83cdfc333b037b41b07d0c5609 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:04:38 +0000 Subject: [PATCH 028/108] build(deps): bump serde from 1.0.203 to 1.0.204 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.203 to 1.0.204. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.203...v1.0.204) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb3ea136..80f28d22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3995,9 +3995,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -4024,9 +4024,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", From cd29870e11ae06faf3b238c1ac3bb037af490682 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:04:55 +0000 Subject: [PATCH 029/108] build(deps): bump async-trait from 0.1.80 to 0.1.81 Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.80 to 0.1.81. - [Release notes](https://github.com/dtolnay/async-trait/releases) - [Commits](https://github.com/dtolnay/async-trait/compare/0.1.80...0.1.81) --- updated-dependencies: - dependency-name: async-trait dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb3ea136..9591db36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,9 +154,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", From 2af22c1aba19ec9daab9bf8e505b36cda1de04f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:08:29 +0000 Subject: [PATCH 030/108] build(deps): bump uuid from 1.9.1 to 1.10.0 Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.9.1 to 1.10.0. - [Release notes](https://github.com/uuid-rs/uuid/releases) - [Commits](https://github.com/uuid-rs/uuid/compare/1.9.1...1.10.0) --- updated-dependencies: - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- swap/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dfd9f239..b4ecc30e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5327,9 +5327,9 @@ checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" [[package]] name = "uuid" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "getrandom 0.2.11", "serde", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 5c754a53..a52f79a5 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -67,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.9", features = [ "serde", "v4" ] } +uuid = { version = "1.10", features = [ "serde", "v4" ] } void = "1" [target.'cfg(not(windows))'.dependencies] From 47f8a652090b0318fbcd7488e1d72e23c6e09a5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:19:16 +0000 Subject: [PATCH 031/108] build(deps): bump hyper from 1.3.1 to 1.4.1 Bumps [hyper](https://github.com/hyperium/hyper) from 1.3.1 to 1.4.1. - [Release notes](https://github.com/hyperium/hyper/releases) - [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/hyper/compare/v1.3.1...v1.4.1) --- updated-dependencies: - dependency-name: hyper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ swap/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4ecc30e..a5b9e009 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1763,9 +1763,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", @@ -1789,7 +1789,7 @@ checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.0.0", - "hyper 1.3.1", + "hyper 1.4.1", "hyper-util", "rustls 0.23.10", "rustls-pki-types", @@ -1810,7 +1810,7 @@ dependencies = [ "futures-util", "http 1.0.0", "http-body 1.0.0", - "hyper 1.3.1", + "hyper 1.4.1", "pin-project-lite 0.2.13", "socket2 0.5.5", "tokio", @@ -3497,7 +3497,7 @@ dependencies = [ "http 1.0.0", "http-body 1.0.0", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.1", "hyper-rustls", "hyper-util", "ipnet", @@ -4541,7 +4541,7 @@ dependencies = [ "futures", "get-port", "hex", - "hyper 1.3.1", + "hyper 1.4.1", "itertools 0.13.0", "jsonrpsee", "jsonrpsee-core", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index a52f79a5..8c657d62 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -79,7 +79,7 @@ zip = "0.5" [dev-dependencies] bitcoin-harness = { git = "https://github.com/delta1/bitcoin-harness-rs.git", rev = "80cc8d05db2610d8531011be505b7bee2b5cdf9f" } get-port = "3" -hyper = "1.3" +hyper = "1.4" jsonrpsee = { version = "0.16.2", features = [ "ws-client" ] } mockito = "1.4" monero-harness = { path = "../monero-harness" } From dcb4edf58520c11c887de6da7b8ffcbde67cafb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:19:33 +0000 Subject: [PATCH 032/108] build(deps): bump vergen from 8.3.1 to 8.3.2 Bumps [vergen](https://github.com/rustyhorde/vergen) from 8.3.1 to 8.3.2. - [Release notes](https://github.com/rustyhorde/vergen/releases) - [Commits](https://github.com/rustyhorde/vergen/commits) --- updated-dependencies: - dependency-name: vergen dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4ecc30e..997c31fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1483,9 +1483,9 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "git2" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" +checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" dependencies = [ "bitflags 2.4.0", "libc", @@ -2128,9 +2128,9 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libgit2-sys" -version = "0.16.1+1.7.1" +version = "0.17.0+1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" +checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" dependencies = [ "cc", "libc", @@ -5355,9 +5355,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "vergen" -version = "8.3.1" +version = "8.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" +checksum = "2990d9ea5967266ea0ccf413a4aa5c42a93dbcfda9cb49a97de6931726b12566" dependencies = [ "anyhow", "cfg-if 1.0.0", From 4115a452e303a64c223c512b1a90c783d73ae7ca Mon Sep 17 00:00:00 2001 From: Einliterflasche <81313171+Einliterflasche@users.noreply.github.com> Date: Thu, 11 Jul 2024 09:19:41 +0200 Subject: [PATCH 033/108] allow --change-address to be omitted and default to internal wallet address (#1709) allow --change-address to be omitted and default to internal wallet address (#1709) Co-authored-by: binarybaron <86064887+binarybaron@users.noreply.github.com> Co-authored-by: Byron Hambly --- CHANGELOG.md | 2 ++ docs/cli/README.md | 2 +- swap/src/api.rs | 4 ++++ swap/src/cli/command.rs | 46 +++++++++++++++++++++++++++++------------ 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a2baf45..1b4776b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- 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 diff --git a/docs/cli/README.md b/docs/cli/README.md index d95d90ef..eff9d072 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. +- `--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. - `--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/swap/src/api.rs b/swap/src/api.rs index 340c2e39..fb071cd4 100644 --- a/swap/src/api.rs +++ b/swap/src/api.rs @@ -267,6 +267,10 @@ impl Context { tasks: Arc::new(PendingTaskList::default()), } } + + pub fn bitcoin_wallet(&self) -> Option> { + self.bitcoin_wallet.clone() + } } impl fmt::Debug for Context { diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs index af72df1b..f3d61c92 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -69,6 +69,37 @@ where monero_receive_address, tor, } => { + let context = Context::build( + Some(bitcoin), + Some(monero), + Some(tor), + data, + is_testnet, + debug, + json, + None, + ) + .await?; + + // when no refund 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 monero_receive_address = monero_address::validate_is_testnet(monero_receive_address, is_testnet)?; let bitcoin_change_address = @@ -81,17 +112,6 @@ where swap_id: Uuid::new_v4(), }); - let context = Context::build( - Some(bitcoin), - Some(monero), - Some(tor), - data, - is_testnet, - debug, - json, - None, - ) - .await?; (context, request) } CliCommand::History => { @@ -300,10 +320,10 @@ enum CliCommand { #[structopt( long = "change-address", - help = "The bitcoin address where any form of change or excess funds should be sent to", + 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.", parse(try_from_str = bitcoin_address::parse) )] - bitcoin_change_address: bitcoin::Address, + bitcoin_change_address: Option, #[structopt(flatten)] monero: Monero, From 073baa97526bc82f0e681259ff7fb6d1a3b3bcb1 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Thu, 11 Jul 2024 09:30:48 +0200 Subject: [PATCH 034/108] Update swap.rs --- swap/src/protocol/bob/swap.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 55174d3a..42031007 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -337,11 +337,13 @@ async fn next_state( } } } - Ok(Rejected { reason: error, .. }) => { - return Err(error) + Ok(Rejected { reason, .. }) => { + tracing::error!(?reason, "Alice rejected our request for cooperative XMR redeem"); + return Err(reason) .context("Alice rejected our request for cooperative XMR redeem"); } Err(error) => { + tracing::error!(?error, "Failed to request cooperative XMR redeem from Alice"); return Err(error) .context("Failed to request cooperative XMR redeem from Alice"); } From ee04ff8a3b74c35d380f59f9808f42347b4ad6f8 Mon Sep 17 00:00:00 2001 From: patrini32 Date: Thu, 11 Jul 2024 10:58:07 +0300 Subject: [PATCH 035/108] fix formatting --- swap/src/protocol/bob/swap.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 42031007..dfba763d 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -338,12 +338,18 @@ async fn next_state( } } Ok(Rejected { reason, .. }) => { - tracing::error!(?reason, "Alice rejected our request for cooperative XMR redeem"); + tracing::error!( + ?reason, + "Alice rejected our request for cooperative XMR redeem" + ); return Err(reason) .context("Alice rejected our request for cooperative XMR redeem"); } Err(error) => { - tracing::error!(?error, "Failed to request cooperative XMR redeem from Alice"); + tracing::error!( + ?error, + "Failed to request cooperative XMR redeem from Alice" + ); return Err(error) .context("Failed to request cooperative XMR redeem from Alice"); } From 845b9428b7e56a0fdf1a286fc5ea99a063413545 Mon Sep 17 00:00:00 2001 From: patrini32 Date: Thu, 11 Jul 2024 11:02:23 +0300 Subject: [PATCH 036/108] remove whitespaces --- swap/src/protocol/bob/swap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index dfba763d..5db98690 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -339,7 +339,7 @@ async fn next_state( } Ok(Rejected { reason, .. }) => { tracing::error!( - ?reason, + ?reason, "Alice rejected our request for cooperative XMR redeem" ); return Err(reason) @@ -347,7 +347,7 @@ async fn next_state( } Err(error) => { tracing::error!( - ?error, + ?error, "Failed to request cooperative XMR redeem from Alice" ); return Err(error) From 31d76cbdf4ac975614c6da2a7e69e30765bef91f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:25:56 +0000 Subject: [PATCH 037/108] build(deps): bump thiserror from 1.0.61 to 1.0.62 Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.61 to 1.0.62. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](https://github.com/dtolnay/thiserror/compare/1.0.61...1.0.62) --- updated-dependencies: - dependency-name: thiserror dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e2ebd60..1e1a51f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4682,18 +4682,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" dependencies = [ "proc-macro2", "quote", From 1f322b78c80fc7506223cf853a927a585b396459 Mon Sep 17 00:00:00 2001 From: COMIT Botty McBotface <68941619+comit-botty-mc-botface@users.noreply.github.com> Date: Tue, 16 Jul 2024 00:45:19 +1000 Subject: [PATCH 038/108] Prepare release 0.13.3 (#1714) --- CHANGELOG.md | 5 ++++- Cargo.lock | 2 +- swap/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0e31a9b..96a59b5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [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. @@ -368,7 +370,8 @@ 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.2...HEAD +[unreleased]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.3...HEAD +[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 [0.13.0]: https://github.com/comit-network/xmr-btc-swap/compare/0.12.3...0.13.0 diff --git a/Cargo.lock b/Cargo.lock index 1e1a51f0..75969f20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4515,7 +4515,7 @@ checksum = "8049cf85f0e715d6af38dde439cb0ccb91f67fb9f5f63c80f8b43e48356e1a3f" [[package]] name = "swap" -version = "0.13.2" +version = "0.13.3" dependencies = [ "anyhow", "async-compression", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 8c657d62..6af34a86 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swap" -version = "0.13.2" +version = "0.13.3" authors = [ "The COMIT guys " ] edition = "2021" description = "XMR/BTC trustless atomic swaps." From 60a31777100e72fdba408549a228a599eac483e8 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:43:47 +0200 Subject: [PATCH 039/108] feat: Dockerfile for asb --- Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..7f7dddaf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM rust:1.74 AS builder + +WORKDIR /build + +RUN apt-get update +RUN apt-get install -y git clang cmake libsnappy-dev + +RUN git clone https://github.com/comit-network/xmr-btc-swap . + +RUN cargo build --release --bin=asb + +FROM debian:bullseye-slim + +WORKDIR /data + +COPY --from=builder /build/target/release/asb /bin/asb + +ENTRYPOINT ["asb"] From d55c6e8c1acf4a10329edcb531799e97743937bd Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:11:40 +0200 Subject: [PATCH 040/108] fix(Dockerfile): Use local repo --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7f7dddaf..2dbf5397 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM rust:1.74 AS builder +FROM rust:1.59-slim AS builder WORKDIR /build RUN apt-get update RUN apt-get install -y git clang cmake libsnappy-dev -RUN git clone https://github.com/comit-network/xmr-btc-swap . +COPY . . RUN cargo build --release --bin=asb From eab4b0047835a50712c139627e304dd4d457a9f3 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:19:56 +0200 Subject: [PATCH 041/108] feat: Release Docker image on build --- .github/workflows/build-release-binaries.yml | 34 +++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index 662e3a5e..565d2dbd 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -4,6 +4,9 @@ on: release: types: [created] +env: + DOCKER_IMAGE_NAME: unstoppableswap/asb + jobs: build_binaries: name: Build @@ -82,7 +85,7 @@ jobs: run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help - id: create-archive-name - shell: python # Use python to have a prettier name for the archive on Windows. + shell: python run: | import platform os_info = platform.uname() @@ -122,3 +125,32 @@ jobs: asset_path: ./${{ steps.create-archive-name.outputs.archive }} asset_name: ${{ steps.create-archive-name.outputs.archive }} asset_content_type: application/gzip + + build_and_push_docker: + name: Build and Push Docker Image + runs-on: ubuntu-latest + needs: build_binaries + steps: + - name: Checkout code + uses: actions/checkout@v4.1.7 + with: + ref: ${{ github.event.release.target_commitish }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ${{ env.DOCKER_IMAGE_NAME }}:latest + ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} From c430e89502ae06e888d8482e21a0db11c437132d Mon Sep 17 00:00:00 2001 From: UnstoppableSwap Botty Date: Tue, 16 Jul 2024 09:25:28 +0000 Subject: [PATCH 042/108] Prepare release 0.13.3 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96a59b5f..9ef7653e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.13.3] - 2024-07-16 + ## [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 @@ -370,7 +372,8 @@ 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.3...HEAD +[unreleased]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...HEAD +[0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3 [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 From f5bda640a0f40ba0db886df78a666a9291128cf7 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:31:18 +0200 Subject: [PATCH 043/108] fix: Remove duplicate entry from CHANGELOG.md --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef7653e..6804925c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [0.13.3] - 2024-07-16 - -## [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. From 7c54fb2848d2f9f9c00ff3982b044f9bbe707343 Mon Sep 17 00:00:00 2001 From: UnstoppableSwap Botty Date: Tue, 16 Jul 2024 09:40:03 +0000 Subject: [PATCH 044/108] Prepare release 0.13.3 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6804925c..f66069f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.13.3] - 2024-07-16 + - 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. @@ -370,6 +372,7 @@ It is possible to migrate critical data from the old db to the sqlite but there [unreleased]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...HEAD [0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3 +[0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3 [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 From 85c4db1d7517715d643e31e02a875ce71c103409 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:13:58 +0200 Subject: [PATCH 045/108] fix: Format cooperative redeem reject using thiserror (#1716) --- swap/src/protocol/bob/swap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 5db98690..912181d4 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -339,7 +339,7 @@ async fn next_state( } Ok(Rejected { reason, .. }) => { tracing::error!( - ?reason, + %reason, "Alice rejected our request for cooperative XMR redeem" ); return Err(reason) @@ -347,7 +347,7 @@ async fn next_state( } Err(error) => { tracing::error!( - ?error, + %error, "Failed to request cooperative XMR redeem from Alice" ); return Err(error) From 7c9af191bc4c37e0e5efb6b785cfb3025486b187 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:08:57 +0000 Subject: [PATCH 046/108] build(deps): bump tokio from 1.38.0 to 1.38.1 Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.38.0 to 1.38.1. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.38.0...tokio-1.38.1) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75969f20..b32a5f47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4778,9 +4778,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.38.0" +version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes", From 74af379f80fe682b3ad67d9059389b569b6c92c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:24:12 +0000 Subject: [PATCH 047/108] build(deps): bump toml from 0.8.14 to 0.8.15 Bumps [toml](https://github.com/toml-rs/toml) from 0.8.14 to 0.8.15. - [Commits](https://github.com/toml-rs/toml/compare/toml-v0.8.14...toml-v0.8.15) --- updated-dependencies: - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b32a5f47..0297752a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -743,7 +743,7 @@ dependencies = [ "nom", "pathdiff", "serde", - "toml 0.8.14", + "toml 0.8.15", ] [[package]] @@ -4579,7 +4579,7 @@ dependencies = [ "tokio-tar", "tokio-tungstenite", "tokio-util", - "toml 0.8.14", + "toml 0.8.15", "torut", "tracing", "tracing-appender", @@ -4919,9 +4919,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" dependencies = [ "serde", "serde_spanned", @@ -4940,9 +4940,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.14" +version = "0.22.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" dependencies = [ "indexmap 2.1.0", "serde", From cb8543990591c9366fc32f12112f99c0e1a5d9b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:24:34 +0000 Subject: [PATCH 048/108] build(deps): bump thiserror from 1.0.62 to 1.0.63 Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.62 to 1.0.63. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](https://github.com/dtolnay/thiserror/compare/1.0.62...1.0.63) --- updated-dependencies: - dependency-name: thiserror dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b32a5f47..06d18dd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4682,18 +4682,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.62" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.62" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", From eef78cddb21b64b96bed11ed7ea5edadc9b62c90 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:27:56 +0200 Subject: [PATCH 049/108] CI: Exclude preview releases from "latest" docker release tag --- .github/workflows/build-release-binaries.yml | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index 565d2dbd..4f466ada 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -145,6 +145,15 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set Docker tags + id: docker_tags + run: | + if [[ ${{ github.event.release.tag_name }} == "preview" ]]; then + echo "::set-output name=preview::true" + else + echo "::set-output name=preview::false" + fi + - name: Build and push Docker image uses: docker/build-push-action@v4 with: @@ -152,5 +161,15 @@ jobs: file: ./Dockerfile push: true tags: | - ${{ env.DOCKER_IMAGE_NAME }}:latest ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} + ${{ env.DOCKER_IMAGE_NAME }}:latest + if: steps.docker_tags.outputs.preview == 'false' + + - name: Build and push Docker image without latest tag (preview release) + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} + if: steps.docker_tags.outputs.preview == 'true' From 8ba8e3bd5c7a05468cb425fd4952d29f4495b99a Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:32:04 +0200 Subject: [PATCH 050/108] fix: Revert 0.13.3 release --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f66069f8..5f565027 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [0.13.3] - 2024-07-16 - - 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. From 410fcf211792dfcee9e97bb4f04fab4eaee39807 Mon Sep 17 00:00:00 2001 From: UnstoppableSwap Botty Date: Mon, 22 Jul 2024 14:40:59 +0000 Subject: [PATCH 051/108] Prepare release 0.13.3 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f565027..686c4ed5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.13.3] - 2024-07-22 + - 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. @@ -371,6 +373,7 @@ It is possible to migrate critical data from the old db to the sqlite but there [unreleased]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...HEAD [0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3 [0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3 +[0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3 [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 From ef49b471d8d4d709af71dfa334beb4490a9a7585 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 23 Jul 2024 14:12:44 +0200 Subject: [PATCH 052/108] docs: add binarybaron.asc --- utils/gpg_keys/binarybaron.asc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 utils/gpg_keys/binarybaron.asc diff --git a/utils/gpg_keys/binarybaron.asc b/utils/gpg_keys/binarybaron.asc new file mode 100644 index 00000000..3ed5a155 --- /dev/null +++ b/utils/gpg_keys/binarybaron.asc @@ -0,0 +1,13 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mDMEZp+avRYJKwYBBAHaRw8BAQdAD99LhR+cHlXDsYPjRJr0Ag7BXsjGZKfdWCtx +CPA0fwG0LWJpbmFyeWJhcm9uIDxiaW5hcnliYXJvbkB1bnN0b3BwYWJsZXN3YXAu +bmV0PoiTBBMWCgA7FiEENahE1/S1W8ROGA/xmbddPhR2om4FAmafmr0CGwMFCwkI +BwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQmbddPhR2om5IQQD/d/EmD/yKMKRl +Hw9RSP4bhcALmrZPri8sYkPteus8OhIA+wWTaIxXZJgydpXv95yECTfUXZ0UhuJq +6UH0FQL8mosJuDgEZp+avRIKKwYBBAGXVQEFAQEHQOd1tQ46YVKxyUKluPAvGJLY +LQ+3UWFWQJavLblkrYE2AwEIB4h4BBgWCgAgFiEENahE1/S1W8ROGA/xmbddPhR2 +om4FAmafmr0CGwwACgkQmbddPhR2om6mmQEAn7vufrOp/HSYgn9l5tmJxMkyxJ3W +2WNo9u+JdnSik1IBAMsNcc4zm5ewfFr/qAnTHzHRId7dWR2+hs1oH7JOlf8L +=Rxij +-----END PGP PUBLIC KEY BLOCK----- From c80bdb2d8cbe6e0786158e53da63bdc5b6a46229 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Tue, 23 Jul 2024 14:52:01 +0200 Subject: [PATCH 053/108] fix(asb): Allow history command to be run while asb is running (#1724) Co-authored-by: einliterflasche --- CHANGELOG.md | 2 ++ swap/src/api.rs | 6 +++--- swap/src/bin/asb.rs | 18 +++++++++++++++--- swap/src/database.rs | 15 ++++++++++++--- swap/src/database/sqlite.rs | 20 +++++++++++++++----- swap/tests/harness/mod.rs | 12 ++++++++---- 6 files changed, 55 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96a59b5f..5152d646 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- ASB: The `history` command can now be used while the asb is running. + ## [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 diff --git a/swap/src/api.rs b/swap/src/api.rs index fb071cd4..36c6972f 100644 --- a/swap/src/api.rs +++ b/swap/src/api.rs @@ -1,6 +1,6 @@ pub mod request; use crate::cli::command::{Bitcoin, Monero, Tor}; -use crate::database::open_db; +use crate::database::{open_db, AccessMode}; use crate::env::{Config as EnvConfig, GetConfig, Mainnet, Testnet}; use crate::fs::system_data_dir; use crate::network::rendezvous::XmrBtcNamespace; @@ -224,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")).await?, + db: open_db(data_dir.join("sqlite"), AccessMode::ReadWrite).await?, bitcoin_wallet, monero_wallet, monero_rpc_process, @@ -259,7 +259,7 @@ impl Context { bitcoin_wallet: Some(bob_bitcoin_wallet), monero_wallet: Some(bob_monero_wallet), config, - db: open_db(db_path) + db: open_db(db_path, AccessMode::ReadWrite) .await .expect("Could not open sqlite database"), monero_rpc_process: None, diff --git a/swap/src/bin/asb.rs b/swap/src/bin/asb.rs index ff3b0e4c..0f2f13b5 100644 --- a/swap/src/bin/asb.rs +++ b/swap/src/bin/asb.rs @@ -30,7 +30,7 @@ use swap::asb::config::{ }; use swap::asb::{cancel, punish, redeem, refund, safely_abort, EventLoop, Finality, KrakenRate}; use swap::common::check_latest_version; -use swap::database::open_db; +use swap::database::{open_db, AccessMode}; use swap::network::rendezvous::XmrBtcNamespace; use swap::network::swarm; use swap::protocol::alice::{run, AliceState}; @@ -95,13 +95,13 @@ 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(); @@ -225,6 +225,8 @@ async fn main() -> Result<()> { event_loop.run().await; } Command::History => { + let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadOnly).await?; + let mut table = Table::new(); table.set_header(vec!["SWAP ID", "STATE"]); @@ -270,6 +272,8 @@ 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?; @@ -277,6 +281,8 @@ 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?; @@ -291,6 +297,8 @@ 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?; @@ -298,6 +306,8 @@ 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"); @@ -306,6 +316,8 @@ 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/database.rs b/swap/src/database.rs index 7af16196..7c6185f7 100644 --- a/swap/src/database.rs +++ b/swap/src/database.rs @@ -83,16 +83,25 @@ impl Swap { } } -pub async fn open_db(sqlite_path: impl AsRef) -> Result> { +#[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> { if sqlite_path.as_ref().exists() { tracing::debug!("Using existing sqlite database."); - let sqlite = SqliteDatabase::open(sqlite_path).await?; + let sqlite = SqliteDatabase::open(sqlite_path, access_mode).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).await?; + let sqlite = SqliteDatabase::open(sqlite_path, access_mode).await?; Ok(Arc::new(sqlite)) } } diff --git a/swap/src/database/sqlite.rs b/swap/src/database/sqlite.rs index 576dc362..eb013f66 100644 --- a/swap/src/database/sqlite.rs +++ b/swap/src/database/sqlite.rs @@ -4,7 +4,7 @@ use crate::protocol::{Database, State}; use anyhow::{anyhow, Context, Result}; use async_trait::async_trait; use libp2p::{Multiaddr, PeerId}; -use sqlx::sqlite::Sqlite; +use sqlx::sqlite::{Sqlite, SqliteConnectOptions}; use sqlx::{Pool, SqlitePool}; use std::collections::HashMap; use std::path::Path; @@ -12,19 +12,29 @@ 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) -> Result + pub async fn open(path: impl AsRef, access_mode: AccessMode) -> Result where Self: std::marker::Sized, { + let read_only = matches!(access_mode, AccessMode::ReadOnly); + let path_str = format!("sqlite:{}", path.as_ref().display()); - let pool = SqlitePool::connect(&path_str).await?; + let options = SqliteConnectOptions::from_str(&path_str)?.read_only(read_only); + + let pool = SqlitePool::connect_with(options).await?; let mut sqlite = Self { pool }; - sqlite.run_migrations().await?; + + if !read_only { + sqlite.run_migrations().await?; + } + Ok(sqlite) } @@ -504,7 +514,7 @@ mod tests { // file has to exist in order to connect with sqlite File::create(temp_db.clone()).unwrap(); - let db = SqliteDatabase::open(temp_db).await?; + let db = SqliteDatabase::open(temp_db, AccessMode::ReadWrite).await?; Ok(db) } diff --git a/swap/tests/harness/mod.rs b/swap/tests/harness/mod.rs index 4a183084..989f0d8d 100644 --- a/swap/tests/harness/mod.rs +++ b/swap/tests/harness/mod.rs @@ -16,7 +16,7 @@ use std::sync::Arc; use std::time::Duration; use swap::asb::FixedRate; use swap::bitcoin::{CancelTimelock, PunishTimelock, TxCancel, TxPunish, TxRedeem, TxRefund}; -use swap::database::SqliteDatabase; +use swap::database::{AccessMode, SqliteDatabase}; use swap::env::{Config, GetConfig}; use swap::fs::ensure_directory_exists; use swap::network::rendezvous::XmrBtcNamespace; @@ -231,7 +231,11 @@ async fn start_alice( if !&db_path.exists() { tokio::fs::File::create(&db_path).await.unwrap(); } - let db = Arc::new(SqliteDatabase::open(db_path.as_path()).await.unwrap()); + let db = Arc::new( + SqliteDatabase::open(db_path.as_path(), AccessMode::ReadWrite) + .await + .unwrap(), + ); let min_buy = bitcoin::Amount::from_sat(u64::MIN); let max_buy = bitcoin::Amount::from_sat(u64::MAX); @@ -433,7 +437,7 @@ impl BobParams { if !self.db_path.exists() { tokio::fs::File::create(&self.db_path).await?; } - let db = Arc::new(SqliteDatabase::open(&self.db_path).await?); + let db = Arc::new(SqliteDatabase::open(&self.db_path, AccessMode::ReadWrite).await?); let (event_loop, handle) = self.new_eventloop(swap_id, db.clone()).await?; @@ -463,7 +467,7 @@ impl BobParams { if !self.db_path.exists() { tokio::fs::File::create(&self.db_path).await?; } - let db = Arc::new(SqliteDatabase::open(&self.db_path).await?); + let db = Arc::new(SqliteDatabase::open(&self.db_path, AccessMode::ReadWrite).await?); let (event_loop, handle) = self.new_eventloop(swap_id, db.clone()).await?; From 75cfc6b0d4169d72f136266af122381a05bb9efe Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Thu, 25 Jul 2024 00:13:15 +0200 Subject: [PATCH 054/108] fix(cli): allow bitcoin-change-address to be omitted when making request to rpc server (#1728) --- swap/src/api.rs | 2 +- swap/src/api/request.rs | 21 ++++++++++++++++++++- swap/src/cli/command.rs | 24 +++--------------------- swap/src/rpc/methods.rs | 29 +++++++++++++++++++---------- 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/swap/src/api.rs b/swap/src/api.rs index 36c6972f..5640c833 100644 --- a/swap/src/api.rs +++ b/swap/src/api.rs @@ -437,7 +437,7 @@ pub mod api_test { Request::new(Method::BuyXmr { seller, - bitcoin_change_address, + bitcoin_change_address: Some(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 50274ab1..b1e9c68c 100644 --- a/swap/src/api/request.rs +++ b/swap/src/api/request.rs @@ -31,7 +31,7 @@ pub struct Request { pub enum Method { BuyXmr { seller: Multiaddr, - bitcoin_change_address: bitcoin::Address, + bitcoin_change_address: Option, monero_receive_address: monero::Address, swap_id: Uuid, }, @@ -335,6 +335,25 @@ 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")?; diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs index f3d61c92..4881d94e 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -81,29 +81,11 @@ where ) .await?; - // when no refund 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 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 bitcoin_change_address = bitcoin_change_address + .map(|address| bitcoin_address::validate_is_testnet(address, is_testnet)) + .transpose()?; let request = Request::new(Method::BuyXmr { seller, diff --git a/swap/src/rpc/methods.rs b/swap/src/rpc/methods.rs index 83100d4a..f804e085 100644 --- a/swap/src/rpc/methods.rs +++ b/swap/src/rpc/methods.rs @@ -135,16 +135,25 @@ pub fn register_modules(context: Arc) -> Result> module.register_async_method("buy_xmr", |params_raw, context| async move { let params: HashMap = params_raw.parse()?; - let bitcoin_change_address = - bitcoin::Address::from_str(params.get("bitcoin_change_address").ok_or_else(|| { - jsonrpsee_core::Error::Custom("Does not contain bitcoin_change_address".to_string()) - })?) - .map_err(|err| jsonrpsee_core::Error::Custom(err.to_string()))?; - - let bitcoin_change_address = bitcoin_address::validate( - bitcoin_change_address, - context.config.env_config.bitcoin_network, - )?; + let bitcoin_change_address = params + .get("bitcoin_change_address") + .map(|addr_str| { + bitcoin::Address::from_str(addr_str) + .map_err(|err| { + jsonrpsee_core::Error::Custom(format!( + "Could not parse bitcoin address: {}", + err + )) + }) + .and_then(|address| { + bitcoin_address::validate( + address, + context.config.env_config.bitcoin_network, + ) + .map_err(|err| jsonrpsee_core::Error::Custom(err.to_string())) + }) + }) + .transpose()?; let monero_receive_address = monero::Address::from_str(params.get("monero_receive_address").ok_or_else(|| { From 2eda2476ebd4953858f951cf2a401264319f868b Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:01:12 +0200 Subject: [PATCH 055/108] Revert "Merge branch 'master' into master" (#1730) This reverts commit ce8d3afe60f520523fe6ab6b8d1b3de3d07e2027, reversing changes made to 75cfc6b0d4169d72f136266af122381a05bb9efe. --- .github/workflows/build-release-binaries.yml | 53 +------------------- CHANGELOG.md | 7 +-- Dockerfile | 18 ------- 3 files changed, 3 insertions(+), 75 deletions(-) delete mode 100644 Dockerfile diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index 4f466ada..662e3a5e 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -4,9 +4,6 @@ on: release: types: [created] -env: - DOCKER_IMAGE_NAME: unstoppableswap/asb - jobs: build_binaries: name: Build @@ -85,7 +82,7 @@ jobs: run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help - id: create-archive-name - shell: python + shell: python # Use python to have a prettier name for the archive on Windows. run: | import platform os_info = platform.uname() @@ -125,51 +122,3 @@ jobs: asset_path: ./${{ steps.create-archive-name.outputs.archive }} asset_name: ${{ steps.create-archive-name.outputs.archive }} asset_content_type: application/gzip - - build_and_push_docker: - name: Build and Push Docker Image - runs-on: ubuntu-latest - needs: build_binaries - steps: - - name: Checkout code - uses: actions/checkout@v4.1.7 - with: - ref: ${{ github.event.release.target_commitish }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set Docker tags - id: docker_tags - run: | - if [[ ${{ github.event.release.tag_name }} == "preview" ]]; then - echo "::set-output name=preview::true" - else - echo "::set-output name=preview::false" - fi - - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - push: true - tags: | - ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} - ${{ env.DOCKER_IMAGE_NAME }}:latest - if: steps.docker_tags.outputs.preview == 'false' - - - name: Build and push Docker image without latest tag (preview release) - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - push: true - tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} - if: steps.docker_tags.outputs.preview == 'true' diff --git a/CHANGELOG.md b/CHANGELOG.md index eaa3ad2a..5152d646 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - ASB: The `history` command can now be used while the asb is running. -## [0.13.3] - 2024-07-22 +## [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. @@ -372,10 +372,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/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...HEAD -[0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3 -[0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3 -[0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3 +[unreleased]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.3...HEAD [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 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2dbf5397..00000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM rust:1.59-slim AS builder - -WORKDIR /build - -RUN apt-get update -RUN apt-get install -y git clang cmake libsnappy-dev - -COPY . . - -RUN cargo build --release --bin=asb - -FROM debian:bullseye-slim - -WORKDIR /data - -COPY --from=builder /build/target/release/asb /bin/asb - -ENTRYPOINT ["asb"] From 2fe428779a27aecea220204f09c24e6ea702ca37 Mon Sep 17 00:00:00 2001 From: Einliterflasche <81313171+Einliterflasche@users.noreply.github.com> Date: Thu, 25 Jul 2024 23:06:50 +0200 Subject: [PATCH 056/108] feat(asb): Retry locking Monero (#1731) We retry to lock the Monero wallet until we succeed or until the cancel timelock expires. This is necessary because the monero-wallet-rpc can sometimes error out due to various reasons, such as - no connection to the daemon - "failed to get output distribution" See https://github.com/comit-network/xmr-btc-swap/issues/1726 --- CHANGELOG.md | 1 + swap/src/protocol/alice/swap.rs | 61 ++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5152d646..e496e3cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - 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 diff --git a/swap/src/protocol/alice/swap.rs b/swap/src/protocol/alice/swap.rs index 79236563..3848a2e1 100644 --- a/swap/src/protocol/alice/swap.rs +++ b/swap/src/protocol/alice/swap.rs @@ -1,11 +1,14 @@ //! Run an XMR/BTC swap in the role of Alice. //! Alice holds XMR and wishes receive BTC. +use std::time::Duration; + use crate::asb::{EventLoopHandle, LatestRate}; use crate::bitcoin::ExpiredTimelocks; use crate::env::Config; use crate::protocol::alice::{AliceState, Swap}; use crate::{bitcoin, monero}; use anyhow::{bail, Context, Result}; +use backoff::ExponentialBackoffBuilder; use tokio::select; use tokio::time::timeout; use uuid::Uuid; @@ -111,23 +114,63 @@ where } } AliceState::BtcLocked { state3 } => { - match state3.expired_timelocks(bitcoin_wallet).await? { - ExpiredTimelocks::None { .. } => { - // Record the current monero wallet block height so we don't have to scan from - // block 0 for scenarios where we create a refund wallet. - let monero_wallet_restore_blockheight = monero_wallet.block_height().await?; + // We retry to lock the Monero wallet until we succeed or until the cancel timelock expires. + // + // This is necessary because the monero-wallet-rpc can sometimes error out due to various reasons, such as + // - no connection to the daemon + // - "failed to get output distribution" + // See https://github.com/comit-network/xmr-btc-swap/issues/1726 + let backoff = ExponentialBackoffBuilder::new() + .with_initial_interval(Duration::from_secs(5)) + .with_max_interval(Duration::from_secs(60 * 3)) + .with_max_elapsed_time(None) + .build(); - let transfer_proof = monero_wallet - .transfer(state3.lock_xmr_transfer_request()) - .await?; + let result = backoff::future::retry_notify( + backoff, + || async { + match state3.expired_timelocks(bitcoin_wallet).await { + Ok(ExpiredTimelocks::None { .. }) => { + // Record the current monero wallet block height so we don't have to scan from + // block 0 for scenarios where we create a refund wallet. + let monero_wallet_restore_blockheight = monero_wallet + .block_height() + .await + .map_err(backoff::Error::transient)?; + let transfer_proof = monero_wallet + .transfer(state3.lock_xmr_transfer_request()) + .await + .map_err(backoff::Error::transient)?; + + Ok(Some((monero_wallet_restore_blockheight, transfer_proof))) + } + Ok(_) => Ok(None), + Err(e) => Err(backoff::Error::transient(e)), + } + }, + |err, delay: Duration| { + tracing::warn!( + %err, + delay_secs = delay.as_secs(), + "Failed to lock XMR. We will retry after a delay" + ); + }, + ) + .await; + + match result { + Ok(Some((monero_wallet_restore_blockheight, transfer_proof))) => { AliceState::XmrLockTransactionSent { monero_wallet_restore_blockheight, transfer_proof, state3, } } - _ => AliceState::SafelyAborted, + Ok(None) => AliceState::SafelyAborted, + Err(e) => { + unreachable!("We should retry forever until the cancel timelock expires. But we got an error: {:#}", e); + } } } AliceState::XmrLockTransactionSent { From 33ad3c374a6472210e878041435e2b6a145c4bc4 Mon Sep 17 00:00:00 2001 From: COMIT Botty McBotface <68941619+comit-botty-mc-botface@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:14:31 +1000 Subject: [PATCH 057/108] Prepare release 0.13.4 (#1734) --- CHANGELOG.md | 5 ++++- Cargo.lock | 2 +- swap/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e496e3cc..bb8e53e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [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 @@ -373,7 +375,8 @@ 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.3...HEAD +[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 diff --git a/Cargo.lock b/Cargo.lock index 4c2826b8..6ef8e322 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4515,7 +4515,7 @@ checksum = "8049cf85f0e715d6af38dde439cb0ccb91f67fb9f5f63c80f8b43e48356e1a3f" [[package]] name = "swap" -version = "0.13.3" +version = "0.13.4" dependencies = [ "anyhow", "async-compression", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 6af34a86..a75c29a7 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swap" -version = "0.13.3" +version = "0.13.4" authors = [ "The COMIT guys " ] edition = "2021" description = "XMR/BTC trustless atomic swaps." From 0ad78e4f30562b87942fc3357e1caf4669dcdd14 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:20:17 +0200 Subject: [PATCH 058/108] revert: Update CHANGELOG.md --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb8e53e6..721f9fc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [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 From 8284bea778fb4003d339d6fc4ca93f6d8299e635 Mon Sep 17 00:00:00 2001 From: UnstoppableSwap Botty Date: Thu, 25 Jul 2024 22:31:14 +0000 Subject: [PATCH 059/108] Prepare release 0.13.4 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 721f9fc2..7127c424 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [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 @@ -373,7 +375,8 @@ 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 +[unreleased]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.4...HEAD +[0.13.4]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.4...0.13.4 [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 From 49cae19059f09b5eadb72b4f73fef7c82c9913e0 Mon Sep 17 00:00:00 2001 From: binarybaron Date: Fri, 26 Jul 2024 11:40:16 +0200 Subject: [PATCH 060/108] fix: Reintroduce docker build action --- .github/workflows/build-release-binaries.yml | 53 +++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index 662e3a5e..4f466ada 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -4,6 +4,9 @@ on: release: types: [created] +env: + DOCKER_IMAGE_NAME: unstoppableswap/asb + jobs: build_binaries: name: Build @@ -82,7 +85,7 @@ jobs: run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help - id: create-archive-name - shell: python # Use python to have a prettier name for the archive on Windows. + shell: python run: | import platform os_info = platform.uname() @@ -122,3 +125,51 @@ jobs: asset_path: ./${{ steps.create-archive-name.outputs.archive }} asset_name: ${{ steps.create-archive-name.outputs.archive }} asset_content_type: application/gzip + + build_and_push_docker: + name: Build and Push Docker Image + runs-on: ubuntu-latest + needs: build_binaries + steps: + - name: Checkout code + uses: actions/checkout@v4.1.7 + with: + ref: ${{ github.event.release.target_commitish }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set Docker tags + id: docker_tags + run: | + if [[ ${{ github.event.release.tag_name }} == "preview" ]]; then + echo "::set-output name=preview::true" + else + echo "::set-output name=preview::false" + fi + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} + ${{ env.DOCKER_IMAGE_NAME }}:latest + if: steps.docker_tags.outputs.preview == 'false' + + - name: Build and push Docker image without latest tag (preview release) + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} + if: steps.docker_tags.outputs.preview == 'true' From 77a43ba28cca49d269f22ba7dce13c19c5b435a7 Mon Sep 17 00:00:00 2001 From: binarybaron Date: Fri, 26 Jul 2024 11:45:48 +0200 Subject: [PATCH 061/108] fix: Reintroduce Dockerfile --- Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2dbf5397 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM rust:1.59-slim AS builder + +WORKDIR /build + +RUN apt-get update +RUN apt-get install -y git clang cmake libsnappy-dev + +COPY . . + +RUN cargo build --release --bin=asb + +FROM debian:bullseye-slim + +WORKDIR /data + +COPY --from=builder /build/target/release/asb /bin/asb + +ENTRYPOINT ["asb"] From b52e07ace9e6d7853fbc20bc965141db7d7756fb Mon Sep 17 00:00:00 2001 From: binarybaron Date: Fri, 26 Jul 2024 11:46:19 +0200 Subject: [PATCH 062/108] Revert "fix: Reintroduce docker build action" This reverts commit 49cae19059f09b5eadb72b4f73fef7c82c9913e0. --- .github/workflows/build-release-binaries.yml | 53 +------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index 4f466ada..662e3a5e 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -4,9 +4,6 @@ on: release: types: [created] -env: - DOCKER_IMAGE_NAME: unstoppableswap/asb - jobs: build_binaries: name: Build @@ -85,7 +82,7 @@ jobs: run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help - id: create-archive-name - shell: python + shell: python # Use python to have a prettier name for the archive on Windows. run: | import platform os_info = platform.uname() @@ -125,51 +122,3 @@ jobs: asset_path: ./${{ steps.create-archive-name.outputs.archive }} asset_name: ${{ steps.create-archive-name.outputs.archive }} asset_content_type: application/gzip - - build_and_push_docker: - name: Build and Push Docker Image - runs-on: ubuntu-latest - needs: build_binaries - steps: - - name: Checkout code - uses: actions/checkout@v4.1.7 - with: - ref: ${{ github.event.release.target_commitish }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set Docker tags - id: docker_tags - run: | - if [[ ${{ github.event.release.tag_name }} == "preview" ]]; then - echo "::set-output name=preview::true" - else - echo "::set-output name=preview::false" - fi - - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - push: true - tags: | - ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} - ${{ env.DOCKER_IMAGE_NAME }}:latest - if: steps.docker_tags.outputs.preview == 'false' - - - name: Build and push Docker image without latest tag (preview release) - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - push: true - tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} - if: steps.docker_tags.outputs.preview == 'true' From f29bf20e8d694ae29a7202efe2cc0f014a6f7248 Mon Sep 17 00:00:00 2001 From: binarybaron Date: Fri, 26 Jul 2024 11:46:27 +0200 Subject: [PATCH 063/108] Revert "fix: Reintroduce Dockerfile" This reverts commit 77a43ba28cca49d269f22ba7dce13c19c5b435a7. --- Dockerfile | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2dbf5397..00000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM rust:1.59-slim AS builder - -WORKDIR /build - -RUN apt-get update -RUN apt-get install -y git clang cmake libsnappy-dev - -COPY . . - -RUN cargo build --release --bin=asb - -FROM debian:bullseye-slim - -WORKDIR /data - -COPY --from=builder /build/target/release/asb /bin/asb - -ENTRYPOINT ["asb"] From 45e14c5a1e1b13807db182abfbe2885e5f8cf9f7 Mon Sep 17 00:00:00 2001 From: binarybaron Date: Fri, 26 Jul 2024 11:51:33 +0200 Subject: [PATCH 064/108] Revert: 8284bea778fb4003d339d6fc4ca93f6d8299e635 --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7127c424..bb8e53e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -375,8 +375,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/UnstoppableSwap/xmr-btc-swap/compare/0.13.4...HEAD -[0.13.4]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.4...0.13.4 +[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 From f3640aceb2d5e412e650a098957e366836f82351 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:23:43 +0000 Subject: [PATCH 065/108] build(deps): bump toml from 0.8.15 to 0.8.16 Bumps [toml](https://github.com/toml-rs/toml) from 0.8.15 to 0.8.16. - [Commits](https://github.com/toml-rs/toml/compare/toml-v0.8.15...toml-v0.8.16) --- updated-dependencies: - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ef8e322..73be37fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -743,7 +743,7 @@ dependencies = [ "nom", "pathdiff", "serde", - "toml 0.8.15", + "toml 0.8.16", ] [[package]] @@ -4046,9 +4046,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -4579,7 +4579,7 @@ dependencies = [ "tokio-tar", "tokio-tungstenite", "tokio-util", - "toml 0.8.15", + "toml 0.8.16", "torut", "tracing", "tracing-appender", @@ -4919,9 +4919,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" +checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" dependencies = [ "serde", "serde_spanned", @@ -4931,18 +4931,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.16" +version = "0.22.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" +checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" dependencies = [ "indexmap 2.1.0", "serde", From 011aa0cb9cd62a0c06ee80b5e7570a71924c969d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:25:26 +0000 Subject: [PATCH 066/108] build(deps): bump thomaseizinger/keep-a-changelog-new-release Bumps [thomaseizinger/keep-a-changelog-new-release](https://github.com/thomaseizinger/keep-a-changelog-new-release) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/thomaseizinger/keep-a-changelog-new-release/releases) - [Changelog](https://github.com/thomaseizinger/keep-a-changelog-new-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/thomaseizinger/keep-a-changelog-new-release/compare/3.0.0...3.1.0) --- updated-dependencies: - dependency-name: thomaseizinger/keep-a-changelog-new-release dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/draft-new-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/draft-new-release.yml b/.github/workflows/draft-new-release.yml index 74ff34ba..9b9c849d 100644 --- a/.github/workflows/draft-new-release.yml +++ b/.github/workflows/draft-new-release.yml @@ -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.0.0 + uses: thomaseizinger/keep-a-changelog-new-release@3.1.0 with: version: ${{ github.event.inputs.version }} changelogPath: CHANGELOG.md From 254874276c99bbb7ef6f2c7c5cf75c8fb1d63cc5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 12:00:29 +0000 Subject: [PATCH 067/108] build(deps): bump serde_json from 1.0.118 to 1.0.121 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.118 to 1.0.121. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.118...v1.0.121) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73be37fc..48d0552a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4035,11 +4035,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.118" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] From 9700d192b2623f35fbb5549d056ee76db5a5546a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 12:02:43 +0000 Subject: [PATCH 068/108] build(deps): bump tokio-socks from 0.5.1 to 0.5.2 Bumps [tokio-socks](https://github.com/sticnarf/tokio-socks) from 0.5.1 to 0.5.2. - [Release notes](https://github.com/sticnarf/tokio-socks/releases) - [Changelog](https://github.com/sticnarf/tokio-socks/blob/master/CHANGELOG.md) - [Commits](https://github.com/sticnarf/tokio-socks/compare/v0.5.1...v0.5.2) --- updated-dependencies: - dependency-name: tokio-socks dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73be37fc..b6804d26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4841,9 +4841,9 @@ dependencies = [ [[package]] name = "tokio-socks" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f" dependencies = [ "either", "futures-util", From 6e09c73cf369c2a9ae5620e9c88fcb80e11ef031 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:39:26 +0000 Subject: [PATCH 069/108] build(deps): bump toml from 0.8.16 to 0.8.17 Bumps [toml](https://github.com/toml-rs/toml) from 0.8.16 to 0.8.17. - [Commits](https://github.com/toml-rs/toml/compare/toml-v0.8.16...toml-v0.8.17) --- updated-dependencies: - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb01de1b..78413bfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -743,7 +743,7 @@ dependencies = [ "nom", "pathdiff", "serde", - "toml 0.8.16", + "toml 0.8.17", ] [[package]] @@ -4580,7 +4580,7 @@ dependencies = [ "tokio-tar", "tokio-tungstenite", "tokio-util", - "toml 0.8.16", + "toml 0.8.17", "torut", "tracing", "tracing-appender", @@ -4920,9 +4920,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" +checksum = "7a44eede9b727419af8095cb2d72fab15487a541f54647ad4414b34096ee4631" dependencies = [ "serde", "serde_spanned", @@ -4932,18 +4932,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.17" +version = "0.22.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" +checksum = "1490595c74d930da779e944f5ba2ecdf538af67df1a9848cbd156af43c1b7cf0" dependencies = [ "indexmap 2.1.0", "serde", @@ -5767,9 +5767,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.6.5" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" dependencies = [ "memchr", ] From 587212abc7e4c5d81bea31b9e236b3ef33f58e4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:38:09 +0000 Subject: [PATCH 070/108] build(deps): bump mockito from 1.4.0 to 1.5.0 Bumps [mockito](https://github.com/lipanski/mockito) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/lipanski/mockito/releases) - [Commits](https://github.com/lipanski/mockito/compare/1.4.0...1.5.0) --- updated-dependencies: - dependency-name: mockito dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 14 ++++++++++---- swap/Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 78413bfc..d75c78d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1774,6 +1774,7 @@ dependencies = [ "http 1.0.0", "http-body 1.0.0", "httparse", + "httpdate", "itoa", "pin-project-lite 0.2.13", "smallvec", @@ -2593,14 +2594,19 @@ dependencies = [ [[package]] name = "mockito" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f6e023aa5bdf392aa06c78e4a4e6d498baab5138d0c993503350ebbc37bf1e" +checksum = "09b34bd91b9e5c5b06338d392463e1318d683cf82ec3d3af4014609be6e2108d" dependencies = [ "assert-json-diff", + "bytes", "colored", - "futures-core", - "hyper 0.14.28", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.4.1", + "hyper-util", "log", "rand 0.8.3", "regex", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index a75c29a7..f7837c6a 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -81,7 +81,7 @@ bitcoin-harness = { git = "https://github.com/delta1/bitcoin-harness-rs.git", re get-port = "3" hyper = "1.4" jsonrpsee = { version = "0.16.2", features = [ "ws-client" ] } -mockito = "1.4" +mockito = "1.5" monero-harness = { path = "../monero-harness" } port_check = "0.2" proptest = "1" From af6bc47ed344055cc9e5e6a6a9ab15d8eb20528b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:39:35 +0000 Subject: [PATCH 071/108] build(deps): bump toml from 0.8.17 to 0.8.19 Bumps [toml](https://github.com/toml-rs/toml) from 0.8.17 to 0.8.19. - [Commits](https://github.com/toml-rs/toml/compare/toml-v0.8.17...toml-v0.8.19) --- updated-dependencies: - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 78413bfc..fcb20f9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -743,7 +743,7 @@ dependencies = [ "nom", "pathdiff", "serde", - "toml 0.8.17", + "toml 0.8.19", ] [[package]] @@ -4580,7 +4580,7 @@ dependencies = [ "tokio-tar", "tokio-tungstenite", "tokio-util", - "toml 0.8.17", + "toml 0.8.19", "torut", "tracing", "tracing-appender", @@ -4920,9 +4920,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a44eede9b727419af8095cb2d72fab15487a541f54647ad4414b34096ee4631" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", @@ -4941,9 +4941,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.18" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1490595c74d930da779e944f5ba2ecdf538af67df1a9848cbd156af43c1b7cf0" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ "indexmap 2.1.0", "serde", @@ -5767,9 +5767,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.6.16" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] From cc854be8f4f2568905703b12a728320987ee9f5f Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Thu, 1 Aug 2024 18:35:03 +0200 Subject: [PATCH 072/108] feat: Enhance history command with more swap details (#1725) --- swap/src/api.rs | 4 ++ swap/src/api/request.rs | 98 ++++++++++++++++++++++++++++++-- swap/src/asb/command.rs | 24 ++++++-- swap/src/bin/asb.rs | 86 +++++++++++++++++++++++++--- swap/src/cli/command.rs | 30 ++++++++-- swap/src/monero.rs | 15 +++-- swap/src/protocol/alice/state.rs | 4 +- swap/src/protocol/alice/swap.rs | 2 +- swap/src/protocol/bob/state.rs | 2 +- swap/tests/rpc.rs | 19 ++++++- 10 files changed, 248 insertions(+), 36 deletions(-) diff --git a/swap/src/api.rs b/swap/src/api.rs index 5640c833..a87db7c5 100644 --- a/swap/src/api.rs +++ b/swap/src/api.rs @@ -167,6 +167,7 @@ pub struct Context { pub swap_lock: Arc, pub config: Config, pub tasks: Arc, + pub is_daemon: bool, } #[allow(clippy::too_many_arguments)] @@ -180,6 +181,7 @@ 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); @@ -241,6 +243,7 @@ impl Context { }, swap_lock: Arc::new(SwapLock::new()), tasks: Arc::new(PendingTaskList::default()), + is_daemon, }; Ok(context) @@ -265,6 +268,7 @@ impl Context { monero_rpc_process: None, swap_lock: Arc::new(SwapLock::new()), tasks: Arc::new(PendingTaskList::default()), + is_daemon: true, } } diff --git a/swap/src/api/request.rs b/swap/src/api/request.rs index b1e9c68c..d47e9a0d 100644 --- a/swap/src/api/request.rs +++ b/swap/src/api/request.rs @@ -8,9 +8,12 @@ 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; @@ -638,14 +641,97 @@ impl Request { }) } Method::History => { - 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())); + 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") + } + } } - Ok(json!({ "swaps": vec })) + if !context.config.json && !context.is_daemon { + println!("{}", table); + } + + Ok(json!({"swaps": json_results})) } Method::GetRawStates => { let raw_history = context.db.raw_all().await?; diff --git a/swap/src/asb/command.rs b/swap/src/asb/command.rs index f22e1500..260b5e9d 100644 --- a/swap/src/asb/command.rs +++ b/swap/src/asb/command.rs @@ -33,13 +33,13 @@ where env_config: env_config(testnet), cmd: Command::Start { resume_only }, }, - RawCommand::History => Arguments { + RawCommand::History { only_unfinished } => Arguments { testnet, json, disable_timestamp, config_path: config_path(config, testnet)?, env_config: env_config(testnet), - cmd: Command::History, + cmd: Command::History { only_unfinished }, }, RawCommand::WithdrawBtc { amount, address } => Arguments { testnet, @@ -195,7 +195,9 @@ pub enum Command { Start { resume_only: bool, }, - History, + History { + only_unfinished: bool, + }, Config, WithdrawBtc { amount: Option, @@ -269,7 +271,13 @@ pub enum RawCommand { resume_only: bool, }, #[structopt(about = "Prints swap-id and the state of each swap ever made.")] - History, + History { + #[structopt( + long = "only-unfinished", + help = "If set, only unfinished swaps will be printed." + )] + only_unfinished: bool, + }, #[structopt(about = "Prints the current config")] Config, #[structopt(about = "Allows withdrawing BTC from the internal Bitcoin wallet.")] @@ -387,7 +395,9 @@ mod tests { disable_timestamp: false, config_path: default_mainnet_conf_path, env_config: mainnet_env_config, - cmd: Command::History, + cmd: Command::History { + only_unfinished: false, + }, }; let args = parse_args(raw_ars).unwrap(); assert_eq!(expected_args, args); @@ -570,7 +580,9 @@ mod tests { disable_timestamp: false, config_path: default_testnet_conf_path, env_config: testnet_env_config, - cmd: Command::History, + cmd: Command::History { + only_unfinished: false, + }, }; let args = parse_args(raw_ars).unwrap(); assert_eq!(expected_args, args); diff --git a/swap/src/bin/asb.rs b/swap/src/bin/asb.rs index 0f2f13b5..66630b88 100644 --- a/swap/src/bin/asb.rs +++ b/swap/src/bin/asb.rs @@ -18,6 +18,8 @@ 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}; @@ -33,7 +35,9 @@ use swap::common::check_latest_version; use swap::database::{open_db, AccessMode}; 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::{asb, bitcoin, kraken, monero, tor}; @@ -224,19 +228,87 @@ async fn main() -> Result<()> { event_loop.run().await; } - Command::History => { + Command::History { only_unfinished } => { let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadOnly).await?; + let mut table: Table = Table::new(); - 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); - 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 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"); + } } - println!("{}", table); + if !json { + println!("{}", table); + } } Command::Config => { let config_json = serde_json::to_string_pretty(&config)?; diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs index 4881d94e..6c460f82 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -78,6 +78,7 @@ where debug, json, None, + false, ) .await?; @@ -100,14 +101,16 @@ where let request = Request::new(Method::History); let context = - Context::build(None, None, None, data, is_testnet, debug, json, None).await?; + Context::build(None, None, None, data, is_testnet, debug, json, None, false) + .await?; (context, request) } CliCommand::Config => { let request = Request::new(Method::Config); let context = - Context::build(None, None, None, data, is_testnet, debug, json, None).await?; + Context::build(None, None, None, data, is_testnet, debug, json, None, false) + .await?; (context, request) } CliCommand::Balance { bitcoin } => { @@ -124,6 +127,7 @@ where debug, json, None, + false, ) .await?; (context, request) @@ -145,6 +149,7 @@ where debug, json, server_address, + true, ) .await?; (context, request) @@ -166,6 +171,7 @@ where debug, json, None, + false, ) .await?; (context, request) @@ -187,6 +193,7 @@ where debug, json, None, + false, ) .await?; (context, request) @@ -207,6 +214,7 @@ where debug, json, None, + false, ) .await?; (context, request) @@ -217,8 +225,18 @@ where } => { let request = Request::new(Method::ListSellers { rendezvous_point }); - let context = - Context::build(None, None, Some(tor), data, is_testnet, debug, json, None).await?; + let context = Context::build( + None, + None, + Some(tor), + data, + is_testnet, + debug, + json, + None, + false, + ) + .await?; (context, request) } @@ -234,6 +252,7 @@ where debug, json, None, + false, ) .await?; (context, request) @@ -244,7 +263,8 @@ where let request = Request::new(Method::MoneroRecovery { swap_id }); let context = - Context::build(None, None, None, data, is_testnet, debug, json, None).await?; + Context::build(None, None, None, data, is_testnet, debug, json, None, false) + .await?; (context, request) } diff --git a/swap/src/monero.rs b/swap/src/monero.rs index 8205e75f..e5dd9e80 100644 --- a/swap/src/monero.rs +++ b/swap/src/monero.rs @@ -142,6 +142,14 @@ impl Amount { Decimal::from(self.as_piconero()) } + pub fn as_xmr(&self) -> Decimal { + let mut decimal = Decimal::from(self.0); + decimal + .set_scale(12) + .expect("12 is smaller than max precision of 28"); + decimal + } + fn from_decimal(amount: Decimal) -> Result { let piconeros_dec = amount.mul(Decimal::from_u64(PICONERO_OFFSET).expect("constant to fit into u64")); @@ -184,11 +192,8 @@ impl From for u64 { impl fmt::Display for Amount { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut decimal = Decimal::from(self.0); - decimal - .set_scale(12) - .expect("12 is smaller than max precision of 28"); - write!(f, "{} XMR", decimal) + let xmr_value = self.as_xmr(); + write!(f, "{} XMR", xmr_value) } } diff --git a/swap/src/protocol/alice/state.rs b/swap/src/protocol/alice/state.rs index f0acab23..7627a529 100644 --- a/swap/src/protocol/alice/state.rs +++ b/swap/src/protocol/alice/state.rs @@ -384,8 +384,8 @@ pub struct State3 { S_b_bitcoin: bitcoin::PublicKey, pub v: monero::PrivateViewKey, #[serde(with = "::bitcoin::util::amount::serde::as_sat")] - btc: bitcoin::Amount, - xmr: monero::Amount, + pub btc: bitcoin::Amount, + pub xmr: monero::Amount, pub cancel_timelock: CancelTimelock, pub punish_timelock: PunishTimelock, refund_address: bitcoin::Address, diff --git a/swap/src/protocol/alice/swap.rs b/swap/src/protocol/alice/swap.rs index 3848a2e1..14f718d3 100644 --- a/swap/src/protocol/alice/swap.rs +++ b/swap/src/protocol/alice/swap.rs @@ -440,7 +440,7 @@ where }) } -pub(crate) fn is_complete(state: &AliceState) -> bool { +pub fn is_complete(state: &AliceState) -> bool { matches!( state, AliceState::XmrRefunded diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index 8fe5ca32..04e7778e 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -369,7 +369,7 @@ pub struct State3 { S_a_monero: monero::PublicKey, S_a_bitcoin: bitcoin::PublicKey, v: monero::PrivateViewKey, - xmr: monero::Amount, + pub xmr: monero::Amount, pub cancel_timelock: CancelTimelock, punish_timelock: PunishTimelock, refund_address: bitcoin::Address, diff --git a/swap/tests/rpc.rs b/swap/tests/rpc.rs index 5dc640d4..553ccf46 100644 --- a/swap/tests/rpc.rs +++ b/swap/tests/rpc.rs @@ -103,13 +103,26 @@ mod test { let (client, _, _) = setup_daemon(harness_ctx).await; - let response: HashMap> = client + let response: HashMap> = client .request("get_history", ObjectParams::new()) .await .unwrap(); - let swaps: Vec<(Uuid, String)> = vec![(bob_swap_id, "btc is locked".to_string())]; - assert_eq!(response, HashMap::from([("swaps".to_string(), swaps)])); + let swaps = response.get("swaps").unwrap(); + assert_eq!(swaps.len(), 1); + + assert_has_keys_serde( + swaps[0].as_object().unwrap(), + &[ + "swapId", + "startDate", + "state", + "btcAmount", + "xmrAmount", + "exchangeRate", + "tradingPartnerPeerId", + ], + ); let response: HashMap>> = client .request("get_raw_states", ObjectParams::new()) From 9aaa7d358f565384eda5592914ecea9122a79d46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:39:10 +0000 Subject: [PATCH 073/108] build(deps): bump serde_json from 1.0.121 to 1.0.122 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.121 to 1.0.122. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.121...v1.0.122) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f374293..c95f4443 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4041,9 +4041,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", "memchr", From 6a76e9efbe2c06febd2da3263b6e789308b46cd8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:18:44 +0000 Subject: [PATCH 074/108] build(deps): bump tempfile from 3.10.1 to 3.11.0 Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.10.1 to 3.11.0. - [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md) - [Commits](https://github.com/Stebalien/tempfile/compare/v3.10.1...v3.11.0) --- updated-dependencies: - dependency-name: tempfile dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c95f4443..233be0d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4641,12 +4641,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if 1.0.0", "fastrand", + "once_cell", "rustix", "windows-sys 0.52.0", ] From 952fb71a6a22598c5f00ca3fe02bfb1ccb0ac65f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:15:11 +0000 Subject: [PATCH 075/108] build(deps): bump tempfile from 3.11.0 to 3.12.0 Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.11.0 to 3.12.0. - [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md) - [Commits](https://github.com/Stebalien/tempfile/commits) --- updated-dependencies: - dependency-name: tempfile dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 70 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 233be0d3..2addb45b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4641,15 +4641,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if 1.0.0", "fastrand", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5625,7 +5625,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "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", ] [[package]] @@ -5645,17 +5654,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "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", + "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", ] [[package]] @@ -5666,9 +5676,9 @@ checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -5684,9 +5694,9 @@ checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -5702,9 +5712,15 @@ checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -5720,9 +5736,9 @@ checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -5738,9 +5754,9 @@ checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -5750,9 +5766,9 @@ checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -5768,9 +5784,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" From f799da5203e9c27a91581aa444d02a42e62cbd87 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:50:16 +0000 Subject: [PATCH 076/108] build(deps): bump serde from 1.0.204 to 1.0.205 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.204 to 1.0.205. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.204...v1.0.205) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 233be0d3..9d4b3d1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4001,9 +4001,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" dependencies = [ "serde_derive", ] @@ -4030,9 +4030,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" dependencies = [ "proc-macro2", "quote", From c8cbd27b795947c4950d75f71ebd5f264de2d05a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:07:36 +0000 Subject: [PATCH 077/108] build(deps): bump serde_json from 1.0.122 to 1.0.124 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.122 to 1.0.124. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.122...v1.0.124) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35962604..a4c51e62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4041,9 +4041,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" dependencies = [ "itoa", "memchr", From 33901a2ea9c3067b54025731eb7cbae6285fec69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:07:58 +0000 Subject: [PATCH 078/108] build(deps): bump serde from 1.0.205 to 1.0.206 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.205 to 1.0.206. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.205...v1.0.206) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35962604..f5f1b250 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4001,9 +4001,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.205" +version = "1.0.206" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" +checksum = "5b3e4cd94123dd520a128bcd11e34d9e9e423e7e3e50425cb1b4b1e3549d0284" dependencies = [ "serde_derive", ] @@ -4030,9 +4030,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.205" +version = "1.0.206" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" +checksum = "fabfb6138d2383ea8208cf98ccf69cdfb1aff4088460681d84189aa259762f97" dependencies = [ "proc-macro2", "quote", From 4eff6fe503e6a39fdee543703e974d1ffc5109ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:04:29 +0000 Subject: [PATCH 079/108] build(deps): bump serde from 1.0.206 to 1.0.208 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.206 to 1.0.208. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.206...v1.0.208) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99040c5c..44e21ae8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4001,9 +4001,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.206" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b3e4cd94123dd520a128bcd11e34d9e9e423e7e3e50425cb1b4b1e3549d0284" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] @@ -4030,9 +4030,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.206" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabfb6138d2383ea8208cf98ccf69cdfb1aff4088460681d84189aa259762f97" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", From 3cebddf5936426680257bf88ad5834cb4e95e1fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:31:40 +0000 Subject: [PATCH 080/108] build(deps): bump reqwest from 0.12.5 to 0.12.7 Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.12.5 to 0.12.7. - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/reqwest/compare/v0.12.5...v0.12.7) --- updated-dependencies: - dependency-name: reqwest dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44e21ae8..f6ef4952 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1906,7 +1906,7 @@ dependencies = [ "socket2 0.3.19", "widestring", "winapi", - "winreg 0.6.2", + "winreg", ] [[package]] @@ -3491,9 +3491,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "base64 0.22.1", "bytes", @@ -3532,7 +3532,7 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots 0.26.1", - "winreg 0.52.0", + "windows-registry", ] [[package]] @@ -4626,6 +4626,9 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "synstructure" @@ -5597,6 +5600,36 @@ 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" @@ -5806,16 +5839,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if 1.0.0", - "windows-sys 0.48.0", -] - [[package]] name = "x25519-dalek" version = "1.1.0" From 7871cf256b62d7d6fcb056c6b12d3470934f02fa Mon Sep 17 00:00:00 2001 From: Einliterflasche <81313171+Einliterflasche@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:33:04 +0200 Subject: [PATCH 081/108] feat(asb + cli): Redact logs + unify tracing infrastructure (#1733) --- .cargo/config.toml | 4 + CHANGELOG.md | 3 + Cargo.lock | 39 ++++-- monero-harness/Cargo.toml | 2 +- swap/Cargo.toml | 2 + swap/src/api.rs | 14 +- swap/src/api/request.rs | 28 ++++ swap/src/asb.rs | 1 - swap/src/asb/command.rs | 69 +++++----- swap/src/asb/tracing.rs | 30 ----- swap/src/bin/asb.rs | 47 +++++-- swap/src/cli.rs | 1 - swap/src/cli/command.rs | 35 +++++ swap/src/cli/tracing.rs | 112 ---------------- swap/src/common.rs | 56 -------- swap/src/common/mod.rs | 221 ++++++++++++++++++++++++++++++++ swap/src/common/tracing_util.rs | 64 +++++++++ swap/src/database/sqlite.rs | 5 +- swap/src/rpc/methods.rs | 28 +++- swap/src/seed.rs | 4 +- 20 files changed, 505 insertions(+), 260 deletions(-) delete mode 100644 swap/src/asb/tracing.rs delete mode 100644 swap/src/cli/tracing.rs delete mode 100644 swap/src/common.rs create mode 100644 swap/src/common/mod.rs create mode 100644 swap/src/common/tracing_util.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index 0c1c209f..b707df9d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,6 @@ [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/CHANGELOG.md b/CHANGELOG.md index bb8e53e6..c22e533e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ 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. diff --git a/Cargo.lock b/Cargo.lock index f6ef4952..f0997737 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,6 +78,15 @@ 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" @@ -1500,7 +1509,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.18", "bstr", "fnv", "log", @@ -2508,7 +2517,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata", + "regex-automata 0.1.9", ] [[package]] @@ -2517,7 +2526,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.9", ] [[package]] @@ -2653,7 +2662,7 @@ dependencies = [ "testcontainers", "tokio", "tracing", - "tracing-subscriber 0.2.25", + "tracing-subscriber 0.3.18", ] [[package]] @@ -3449,13 +3458,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.3" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ - "aho-corasick", + "aho-corasick 1.1.3", "memchr", - "regex-syntax 0.6.29", + "regex-automata 0.4.7", + "regex-syntax 0.8.2", ] [[package]] @@ -3468,6 +3478,17 @@ dependencies = [ "regex-syntax 0.6.29", ] +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick 1.1.3", + "memchr", + "regex-syntax 0.8.2", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -4557,12 +4578,14 @@ 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", diff --git a/monero-harness/Cargo.toml b/monero-harness/Cargo.toml index 1151f47a..e15c751d 100644 --- a/monero-harness/Cargo.toml +++ b/monero-harness/Cargo.toml @@ -13,4 +13,4 @@ rand = "0.7" testcontainers = "0.15" tokio = { version = "1", default-features = false, features = [ "rt-multi-thread", "time", "macros" ] } tracing = "0.1" -tracing-subscriber = { version = "0.2", default-features = false, features = [ "fmt", "ansi", "env-filter", "tracing-log" ] } +tracing-subscriber = { version = "0.3", default-features = false, features = [ "fmt", "ansi", "env-filter", "tracing-log" ] } diff --git a/swap/Cargo.toml b/swap/Cargo.toml index f7837c6a..8354ec0a 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -37,11 +37,13 @@ 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.19" pem = "3.0" proptest = "1" qrcode = "0.14" rand = "0.8" rand_chacha = "0.3" +regex = "1.10" reqwest = { version = "0.12", features = [ "http2", "rustls-tls", "stream", "socks" ], default-features = false } rust_decimal = { version = "1", features = [ "serde-float" ] } rust_decimal_macros = "1" diff --git a/swap/src/api.rs b/swap/src/api.rs index a87db7c5..ea87aae3 100644 --- a/swap/src/api.rs +++ b/swap/src/api.rs @@ -1,12 +1,13 @@ pub mod request; use crate::cli::command::{Bitcoin, Monero, Tor}; +use crate::common::tracing_util::Format; use crate::database::{open_db, AccessMode}; 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, cli, monero}; +use crate::{bitcoin, common, monero}; use anyhow::{bail, Context as AnyContext, Error, Result}; use futures::future::try_join_all; use std::fmt; @@ -16,6 +17,8 @@ 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(); @@ -186,8 +189,15 @@ impl Context { 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 _ = cli::tracing::init(debug, json, data_dir.join("logs")); + let _ = common::tracing_util::init(level_filter, format, data_dir.join("logs")); }); let seed = Seed::from_file_or_generate(data_dir.as_path()) diff --git a/swap/src/api/request.rs b/swap/src/api/request.rs index d47e9a0d..33e261d3 100644 --- a/swap/src/api/request.rs +++ b/swap/src/api/request.rs @@ -1,6 +1,7 @@ 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; @@ -19,6 +20,7 @@ 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}; @@ -48,6 +50,11 @@ pub enum Method { swap_id: Uuid, }, History, + Logs { + logs_dir: Option, + redact: bool, + swap_id: Option, + }, Config, WithdrawBtc { amount: Option, @@ -125,6 +132,13 @@ 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", @@ -733,6 +747,20 @@ impl Request { 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 })) + } Method::GetRawStates => { let raw_history = context.db.raw_all().await?; diff --git a/swap/src/asb.rs b/swap/src/asb.rs index b5ed8ac1..404a3b61 100644 --- a/swap/src/asb.rs +++ b/swap/src/asb.rs @@ -4,7 +4,6 @@ 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 260b5e9d..67565065 100644 --- a/swap/src/asb/command.rs +++ b/swap/src/asb/command.rs @@ -19,7 +19,6 @@ 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; @@ -28,7 +27,6 @@ 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 }, @@ -36,15 +34,28 @@ where RawCommand::History { only_unfinished } => 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, + }, + }, RawCommand::WithdrawBtc { amount, address } => Arguments { testnet, json, - disable_timestamp, config_path: config_path(config, testnet)?, env_config: env_config(testnet), cmd: Command::WithdrawBtc { @@ -55,7 +66,6 @@ where RawCommand::Balance => Arguments { testnet, json, - disable_timestamp, config_path: config_path(config, testnet)?, env_config: env_config(testnet), cmd: Command::Balance, @@ -63,7 +73,6 @@ where RawCommand::Config => Arguments { testnet, json, - disable_timestamp, config_path: config_path(config, testnet)?, env_config: env_config(testnet), cmd: Command::Config, @@ -71,7 +80,6 @@ where RawCommand::ExportBitcoinWallet => Arguments { testnet, json, - disable_timestamp, config_path: config_path(config, testnet)?, env_config: env_config(testnet), cmd: Command::ExportBitcoinWallet, @@ -82,7 +90,6 @@ where }) => Arguments { testnet, json, - disable_timestamp, config_path: config_path(config, testnet)?, env_config: env_config(testnet), cmd: Command::Redeem { @@ -96,7 +103,6 @@ where }) => Arguments { testnet, json, - disable_timestamp, config_path: config_path(config, testnet)?, env_config: env_config(testnet), cmd: Command::Cancel { swap_id }, @@ -106,7 +112,6 @@ where }) => Arguments { testnet, json, - disable_timestamp, config_path: config_path(config, testnet)?, env_config: env_config(testnet), cmd: Command::Refund { swap_id }, @@ -116,7 +121,6 @@ where }) => Arguments { testnet, json, - disable_timestamp, config_path: config_path(config, testnet)?, env_config: env_config(testnet), cmd: Command::Punish { swap_id }, @@ -124,7 +128,6 @@ 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 }, @@ -184,7 +187,6 @@ 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, @@ -199,6 +201,11 @@ pub enum Command { only_unfinished: bool, }, Config, + Logs { + logs_dir: Option, + swap_id: Option, + redact: bool, + }, WithdrawBtc { amount: Option, address: Address, @@ -270,6 +277,25 @@ 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( @@ -374,7 +400,6 @@ 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 }, @@ -392,7 +417,6 @@ 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 { @@ -412,7 +436,6 @@ 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, @@ -434,7 +457,6 @@ 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 { @@ -461,7 +483,6 @@ 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 { @@ -487,7 +508,6 @@ 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 { @@ -513,7 +533,6 @@ 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 { @@ -539,7 +558,6 @@ 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 { @@ -559,7 +577,6 @@ 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 }, @@ -577,7 +594,6 @@ 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 { @@ -597,7 +613,6 @@ 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, @@ -621,7 +636,6 @@ 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 { @@ -648,7 +662,6 @@ 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 { @@ -675,7 +688,6 @@ 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 { @@ -702,7 +714,6 @@ 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 { @@ -729,7 +740,6 @@ 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 { @@ -749,7 +759,6 @@ 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/tracing.rs b/swap/src/asb/tracing.rs deleted file mode 100644 index c21c1e70..00000000 --- a/swap/src/asb/tracing.rs +++ /dev/null @@ -1,30 +0,0 @@ -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 66630b88..3a0d2dd4 100644 --- a/swap/src/bin/asb.rs +++ b/swap/src/bin/asb.rs @@ -31,7 +31,8 @@ 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::check_latest_version; +use swap::common::tracing_util::Format; +use swap::common::{self, check_latest_version, get_logs}; use swap::database::{open_db, AccessMode}; use swap::network::rendezvous::XmrBtcNamespace; use swap::network::swarm; @@ -40,44 +41,40 @@ use swap::protocol::alice::{run, AliceState}; use swap::protocol::State; use swap::seed::Seed; use swap::tor::AuthenticatedClient; -use swap::{asb, bitcoin, kraken, monero, tor}; +use swap::{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::() { - match clap_err.kind { - ErrorKind::HelpDisplayed | ErrorKind::VersionDisplayed => { - println!("{}", clap_err.message); - std::process::exit(0); - } - _ => { - bail!(e); - } + if let ErrorKind::HelpDisplayed | ErrorKind::VersionDisplayed = clap_err.kind { + println!("{}", clap_err.message); + std::process::exit(0); } } 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); } - asb::tracing::init(LevelFilter::DEBUG, json, !disable_timestamp).expect("initialize tracing"); - + // read config from the specified path let config = match read_config(config_path.clone())? { Ok(config) => config, Err(ConfigNotInitialized {}) => { @@ -86,6 +83,12 @@ 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 {:?}", @@ -112,6 +115,7 @@ async fn main() -> Result<()> { 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.", @@ -119,9 +123,12 @@ 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, _) => { @@ -144,6 +151,7 @@ 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"); @@ -314,6 +322,19 @@ async fn main() -> Result<()> { 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?; diff --git a/swap/src/cli.rs b/swap/src/cli.rs index f0faf146..6085eca0 100644 --- a/swap/src/cli.rs +++ b/swap/src/cli.rs @@ -3,7 +3,6 @@ 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/command.rs b/swap/src/cli/command.rs index 6c460f82..acce7a50 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -105,6 +105,22 @@ where .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, request) + } CliCommand::Config => { let request = Request::new(Method::Config); @@ -341,6 +357,25 @@ 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/tracing.rs b/swap/src/cli/tracing.rs deleted file mode 100644 index 6b6de60f..00000000 --- a/swap/src/cli/tracing.rs +++ /dev/null @@ -1,112 +0,0 @@ -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 deleted file mode 100644 index 98b9b99d..00000000 --- a/swap/src/common.rs +++ /dev/null @@ -1,56 +0,0 @@ -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 new file mode 100644 index 00000000..bae1c0f4 --- /dev/null +++ b/swap/src/common/mod.rs @@ -0,0 +1,221 @@ +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 new file mode 100644 index 00000000..191c43bf --- /dev/null +++ b/swap/src/common/tracing_util.rs @@ -0,0 +1,64 @@ +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/sqlite.rs b/swap/src/database/sqlite.rs index eb013f66..ce455b6c 100644 --- a/swap/src/database/sqlite.rs +++ b/swap/src/database/sqlite.rs @@ -5,7 +5,7 @@ use anyhow::{anyhow, Context, Result}; use async_trait::async_trait; use libp2p::{Multiaddr, PeerId}; use sqlx::sqlite::{Sqlite, SqliteConnectOptions}; -use sqlx::{Pool, SqlitePool}; +use sqlx::{ConnectOptions, Pool, SqlitePool}; use std::collections::HashMap; use std::path::Path; use std::str::FromStr; @@ -26,7 +26,8 @@ impl SqliteDatabase { let read_only = matches!(access_mode, AccessMode::ReadOnly); let path_str = format!("sqlite:{}", path.as_ref().display()); - let options = SqliteConnectOptions::from_str(&path_str)?.read_only(read_only); + let mut options = SqliteConnectOptions::from_str(&path_str)?.read_only(read_only); + options.disable_statement_logging(); let pool = SqlitePool::connect_with(options).await?; let mut sqlite = Self { pool }; diff --git a/swap/src/rpc/methods.rs b/swap/src/rpc/methods.rs index f804e085..dd3d9a62 100644 --- a/swap/src/rpc/methods.rs +++ b/swap/src/rpc/methods.rs @@ -7,7 +7,9 @@ use anyhow::Result; use jsonrpsee::server::RpcModule; use jsonrpsee::types::Params; use libp2p::core::Multiaddr; +use serde::Deserialize; use std::collections::HashMap; +use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; use uuid::Uuid; @@ -48,8 +50,30 @@ pub fn register_modules(context: Arc) -> Result> execute_request(params_raw, Method::Balance { force_refresh }, &context).await })?; - module.register_async_method("get_history", |params, context| async move { - execute_request(params, Method::History, &context).await + module.register_async_method("get_history", |params_raw, context| async move { + execute_request(params_raw, Method::History, &context).await + })?; + + module.register_async_method("get_logs", |params_raw, context| async move { + #[derive(Debug, Clone, Deserialize)] + struct Params { + swap_id: Option, + logs_dir: Option, + redact: bool, + } + + let params: Params = params_raw.parse()?; + + execute_request( + params_raw, + Method::Logs { + swap_id: params.swap_id, + logs_dir: params.logs_dir, + redact: params.redact, + }, + &context, + ) + .await })?; module.register_async_method("get_raw_states", |params, context| async move { diff --git a/swap/src/seed.rs b/swap/src/seed.rs index aa363905..a17a7964 100644 --- a/swap/src/seed.rs +++ b/swap/src/seed.rs @@ -1,9 +1,9 @@ use crate::fs::ensure_directory_exists; -use ::bitcoin::secp256k1::constants::SECRET_KEY_SIZE; -use ::bitcoin::secp256k1::{self, SecretKey}; use anyhow::{Context, Result}; use bdk::bitcoin::util::bip32::ExtendedPrivKey; use bitcoin::hashes::{sha256, Hash, HashEngine}; +use bitcoin::secp256k1::constants::SECRET_KEY_SIZE; +use bitcoin::secp256k1::{self, SecretKey}; use libp2p::identity; use pem::{encode, Pem}; use rand::prelude::*; From 2faf7561bd279fc152de5ff4df776c308ebc1c4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:57:24 +0000 Subject: [PATCH 082/108] build(deps): bump regex from 1.10.5 to 1.10.6 Bumps [regex](https://github.com/rust-lang/regex) from 1.10.5 to 1.10.6. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.10.5...1.10.6) --- updated-dependencies: - dependency-name: regex dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f0997737..44dfaae1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3458,9 +3458,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick 1.1.3", "memchr", From 29ee6acb95408f140b96e4e103a4dc186c89af5f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 11:31:16 +0000 Subject: [PATCH 083/108] build(deps): bump async-trait from 0.1.81 to 0.1.82 Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.81 to 0.1.82. - [Release notes](https://github.com/dtolnay/async-trait/releases) - [Commits](https://github.com/dtolnay/async-trait/compare/0.1.81...0.1.82) --- updated-dependencies: - dependency-name: async-trait dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44dfaae1..6095ec0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", From a8a99db73868631ecfa51adfc44a335da1b1e805 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:47:01 +0000 Subject: [PATCH 084/108] build(deps): bump serde_json from 1.0.124 to 1.0.128 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.124 to 1.0.128. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.124...1.0.128) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44dfaae1..9df5e994 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4062,9 +4062,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.124" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", From ff9f3498892964c3f375697e467e94dbe6f99f2f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:47:31 +0000 Subject: [PATCH 085/108] build(deps): bump tokio-util from 0.7.11 to 0.7.12 Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.7.11 to 0.7.12. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-util-0.7.11...tokio-util-0.7.12) --- updated-dependencies: - dependency-name: tokio-util dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44dfaae1..8801db02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4930,9 +4930,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", From 4114772bb78b14a7dedde9a7931a44d874c91b67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:02:58 +0000 Subject: [PATCH 086/108] build(deps): bump serde from 1.0.208 to 1.0.210 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.208 to 1.0.210. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.208...v1.0.210) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44dfaae1..a046bc24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4022,9 +4022,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -4051,9 +4051,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", From 8022d8b423ad15e1def0b20a154bfff143410128 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:08:00 +0000 Subject: [PATCH 087/108] build(deps): bump anyhow from 1.0.86 to 1.0.88 Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.86 to 1.0.88. - [Release notes](https://github.com/dtolnay/anyhow/releases) - [Commits](https://github.com/dtolnay/anyhow/compare/1.0.86...1.0.88) --- updated-dependencies: - dependency-name: anyhow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44dfaae1..d5052cb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" [[package]] name = "arrayref" From fe77b5af95567ed4ef9663a5e37206a48f968198 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:14:20 +0000 Subject: [PATCH 088/108] build(deps): bump anyhow from 1.0.88 to 1.0.89 Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.88 to 1.0.89. - [Release notes](https://github.com/dtolnay/anyhow/releases) - [Commits](https://github.com/dtolnay/anyhow/compare/1.0.88...1.0.89) --- updated-dependencies: - dependency-name: anyhow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 69053647..6bc9e794 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "arrayref" From e3f31af88a48b6448739f1a003c4755abbf0e12f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:15:38 +0000 Subject: [PATCH 089/108] build(deps): bump once_cell from 1.19.0 to 1.20.0 Bumps [once_cell](https://github.com/matklad/once_cell) from 1.19.0 to 1.20.0. - [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md) - [Commits](https://github.com/matklad/once_cell/compare/v1.19.0...v1.20.0) --- updated-dependencies: - dependency-name: once_cell dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- swap/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 69053647..efc263cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2848,9 +2848,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" [[package]] name = "opaque-debug" diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 8354ec0a..ec496e45 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -37,7 +37,7 @@ 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.19" +once_cell = "1.20" pem = "3.0" proptest = "1" qrcode = "0.14" From e01986bb5018e39944753d764d41fa7a2e6dfcb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:42:15 +0000 Subject: [PATCH 090/108] build(deps): bump thiserror from 1.0.63 to 1.0.64 Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.63 to 1.0.64. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](https://github.com/dtolnay/thiserror/compare/1.0.63...1.0.64) --- updated-dependencies: - dependency-name: thiserror dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6bc9e794..4c3a59e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4716,18 +4716,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", From 523adc6d26dad1529d2e0c8c46732ceb9eecf112 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:18:25 +0000 Subject: [PATCH 091/108] build(deps): bump async-trait from 0.1.82 to 0.1.83 Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.82 to 0.1.83. - [Release notes](https://github.com/dtolnay/async-trait/releases) - [Commits](https://github.com/dtolnay/async-trait/compare/0.1.82...0.1.83) --- updated-dependencies: - dependency-name: async-trait dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6bc9e794..169ad3f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", From 6abd951b4631f9bd1a42415a4084af2763f29989 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:36:32 +0000 Subject: [PATCH 092/108] build(deps): bump regex from 1.10.6 to 1.11.0 Bumps [regex](https://github.com/rust-lang/regex) from 1.10.6 to 1.11.0. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.10.6...1.11.0) --- updated-dependencies: - dependency-name: regex dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- swap/Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10d3cb5a..f4c5efde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3177,7 +3177,7 @@ dependencies = [ "rand 0.8.3", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax 0.8.2", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -3458,14 +3458,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick 1.1.3", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.2", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -3480,13 +3480,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick 1.1.3", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.5", ] [[package]] @@ -3497,9 +3497,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rend" diff --git a/swap/Cargo.toml b/swap/Cargo.toml index ec496e45..d7d06387 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -43,7 +43,7 @@ proptest = "1" qrcode = "0.14" rand = "0.8" rand_chacha = "0.3" -regex = "1.10" +regex = "1.11" reqwest = { version = "0.12", features = [ "http2", "rustls-tls", "stream", "socks" ], default-features = false } rust_decimal = { version = "1", features = [ "serde-float" ] } rust_decimal_macros = "1" From 12c6974458a0013caa1fd21b2f85ca3a999be34f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:37:04 +0000 Subject: [PATCH 093/108] build(deps): bump tempfile from 3.12.0 to 3.13.0 Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.12.0 to 3.13.0. - [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md) - [Commits](https://github.com/Stebalien/tempfile/compare/v3.12.0...v3.13.0) --- updated-dependencies: - dependency-name: tempfile dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10d3cb5a..b673ddce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1224,9 +1224,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "filetime" @@ -2132,9 +2132,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libgit2-sys" @@ -2468,9 +2468,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" @@ -3677,9 +3677,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.4.0", "errno", @@ -4667,9 +4667,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if 1.0.0", "fastrand", From a3ffd35fc0ba0bc0416fb8f29af23e64df90cbf2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:09:42 +0000 Subject: [PATCH 094/108] build(deps): bump reqwest from 0.12.7 to 0.12.8 Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.12.7 to 0.12.8. - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/reqwest/compare/v0.12.7...v0.12.8) --- updated-dependencies: - dependency-name: reqwest dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10d3cb5a..24dc7bac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3512,9 +3512,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", From 88e61127363d71e267263020fe7f4dfa994e707f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:39:41 +0000 Subject: [PATCH 095/108] build(deps): bump once_cell from 1.20.0 to 1.20.2 Bumps [once_cell](https://github.com/matklad/once_cell) from 1.20.0 to 1.20.2. - [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md) - [Commits](https://github.com/matklad/once_cell/compare/v1.20.0...v1.20.2) --- updated-dependencies: - dependency-name: once_cell dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10d3cb5a..52d43f60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2848,9 +2848,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" From 851086c5a24eea17147af09737bff88a3559584f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 11:47:11 +0000 Subject: [PATCH 096/108] build(deps): bump actions/checkout from 4.1.7 to 4.2.1 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4.1.7...v4.2.1) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build-release-binaries.yml | 2 +- .github/workflows/ci.yml | 16 ++++++++-------- .github/workflows/create-release.yml | 2 +- .github/workflows/draft-new-release.yml | 2 +- .github/workflows/preview-release.yml | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index 662e3a5e..b0fefb92 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -54,7 +54,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout tagged commit - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 with: ref: ${{ github.event.release.target_commitish }} token: ${{ secrets.BOTTY_GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3f742fc..732c2491 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 - uses: dtolnay/rust-toolchain@master with: @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 - uses: Swatinem/rust-cache@v2.7.3 @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 - uses: Swatinem/rust-cache@v2.7.3 @@ -78,7 +78,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 - uses: Swatinem/rust-cache@v2.7.3 @@ -131,7 +131,7 @@ jobs: tool-cache: false - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 - uses: Swatinem/rust-cache@v2.7.3 @@ -171,7 +171,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 - uses: Swatinem/rust-cache@v2.7.3 @@ -182,7 +182,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 - uses: Swatinem/rust-cache@v2.7.3 @@ -193,7 +193,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 - uses: dtolnay/rust-toolchain@stable diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 443c4418..3dcd492d 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.1.7 + - uses: actions/checkout@v4.2.1 - 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 9b9c849d..bd926d53 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.1.7 + - uses: actions/checkout@v4.2.1 with: token: ${{ secrets.BOTTY_GITHUB_TOKEN }} diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml index ccd7e641..b216d283 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.1.7 + - uses: actions/checkout@v4.2.1 - name: Delete 'preview' release uses: larryjoelane/delete-release-action@v1.0.24 From 19710e296d7680d7a3b4f3ef0c7affd84e9d5e7b Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:58:27 +0600 Subject: [PATCH 097/108] docs: Add notice to ReadMe about status of maintenance (#1790) docs: Add notice to ReadMe about status of maintenance and reference community fork at UnstoppableSwap/core --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 35adc5f0..1c0226b2 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ Currently, swaps are only offered in one direction with the `swap` CLI on the bu We are working on implementing a protocol where XMR moves first, but are currently blocked by advances on Monero itself. You can read [this blogpost](https://comit.network/blog/2021/07/02/transaction-presigning) for more information. +## Maintenance + +This repository is currently maintained by community volunteers. While it remains safe to use, the original developers (@comit-network) have stopped contributing. For a more actively maintained version that includes a GUI, please check out this community fork: https://github.com/UnstoppableSwap/core + ## Quick Start 1. Download the [latest `swap` binary release](https://github.com/comit-network/xmr-btc-swap/releases/latest) for your operating system. From 3d4bc971a2874ac1676aaa7ede4abeb0a4dbbac9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:07:29 +0000 Subject: [PATCH 098/108] build(deps): bump Swatinem/rust-cache from 2.7.3 to 2.7.5 Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.7.3 to 2.7.5. - [Release notes](https://github.com/swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md) - [Commits](https://github.com/swatinem/rust-cache/compare/v2.7.3...v2.7.5) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/build-release-binaries.yml | 2 +- .github/workflows/ci.yml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index 662e3a5e..6b8cae14 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -59,7 +59,7 @@ jobs: ref: ${{ github.event.release.target_commitish }} token: ${{ secrets.BOTTY_GITHUB_TOKEN }} - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2.7.5 - uses: dtolnay/rust-toolchain@master with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3f742fc..3cc27914 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: toolchain: "1.74" components: clippy,rustfmt - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2.7.5 - name: Check formatting uses: dprint/check@v2.2 @@ -37,7 +37,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4.1.7 - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2.7.5 - name: Build swap run: cargo build --bin swap @@ -51,7 +51,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4.1.7 - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2.7.5 - name: Install sqlx-cli run: cargo install --locked --version 0.6.3 sqlx-cli @@ -80,7 +80,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4.1.7 - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2.7.5 - uses: dtolnay/rust-toolchain@master with: @@ -133,7 +133,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4.1.7 - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2.7.5 - name: Build tests run: cargo build --tests --workspace --all-features @@ -173,7 +173,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4.1.7 - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2.7.5 - name: Run test ${{ matrix.test_name }} run: cargo test --package swap --all-features --test ${{ matrix.test_name }} -- --nocapture @@ -184,7 +184,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4.1.7 - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2.7.5 - name: Run RPC server tests run: cargo test --package swap --all-features --test rpc -- --nocapture @@ -197,7 +197,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2.7.5 - name: Run cargo check on stable rust run: cargo check --all-targets From 61c7afb35886dba5a9ce46f1aa6defcf367e4a7a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:32:11 +0000 Subject: [PATCH 099/108] build(deps): bump futures from 0.3.30 to 0.3.31 Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.30 to 0.3.31. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.30...0.3.31) --- updated-dependencies: - dependency-name: futures dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 66 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0821b73f..17eb7fc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -169,7 +169,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", ] [[package]] @@ -1310,9 +1310,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1325,9 +1325,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1335,15 +1335,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1364,19 +1364,19 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", ] [[package]] @@ -1392,15 +1392,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-timer" @@ -1410,9 +1410,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -3156,9 +3156,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.74" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -4057,7 +4057,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", ] [[package]] @@ -4137,7 +4137,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", ] [[package]] @@ -4526,7 +4526,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.46", + "syn 2.0.79", ] [[package]] @@ -4635,9 +4635,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.46" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -4731,7 +4731,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", ] [[package]] @@ -4837,7 +4837,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", ] [[package]] @@ -5063,7 +5063,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", ] [[package]] @@ -5470,7 +5470,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -5504,7 +5504,7 @@ checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5915,7 +5915,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.79", ] [[package]] From ec567ccba1eb295ca11aa43aa8debfc51dcfbbec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:55:59 +0000 Subject: [PATCH 100/108] build(deps): bump uuid from 1.10.0 to 1.11.0 Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.10.0 to 1.11.0. - [Release notes](https://github.com/uuid-rs/uuid/releases) - [Commits](https://github.com/uuid-rs/uuid/compare/1.10.0...1.11.0) --- updated-dependencies: - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- swap/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0821b73f..608c302d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5361,9 +5361,9 @@ checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom 0.2.11", "serde", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index d7d06387..d38d2c81 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -69,7 +69,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.10", features = [ "serde", "v4" ] } +uuid = { version = "1.11", features = [ "serde", "v4" ] } void = "1" [target.'cfg(not(windows))'.dependencies] From d521815e913c3c50775009b5b93d260452d3c647 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:58:25 +0000 Subject: [PATCH 101/108] build(deps): bump hyper from 1.4.1 to 1.5.0 Bumps [hyper](https://github.com/hyperium/hyper) from 1.4.1 to 1.5.0. - [Release notes](https://github.com/hyperium/hyper/releases) - [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/hyper/compare/v1.4.1...v1.5.0) --- updated-dependencies: - dependency-name: hyper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 14 +++++++------- swap/Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0821b73f..37acc516 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1772,9 +1772,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", @@ -1799,7 +1799,7 @@ checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.0.0", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", "rustls 0.23.10", "rustls-pki-types", @@ -1820,7 +1820,7 @@ dependencies = [ "futures-util", "http 1.0.0", "http-body 1.0.0", - "hyper 1.4.1", + "hyper 1.5.0", "pin-project-lite 0.2.13", "socket2 0.5.5", "tokio", @@ -2614,7 +2614,7 @@ dependencies = [ "http 1.0.0", "http-body 1.0.0", "http-body-util", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", "log", "rand 0.8.3", @@ -3524,7 +3524,7 @@ dependencies = [ "http 1.0.0", "http-body 1.0.0", "http-body-util", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-rustls", "hyper-util", "ipnet", @@ -4569,7 +4569,7 @@ dependencies = [ "futures", "get-port", "hex", - "hyper 1.4.1", + "hyper 1.5.0", "itertools 0.13.0", "jsonrpsee", "jsonrpsee-core", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index d7d06387..6bbdf8ea 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -81,7 +81,7 @@ zip = "0.5" [dev-dependencies] bitcoin-harness = { git = "https://github.com/delta1/bitcoin-harness-rs.git", rev = "80cc8d05db2610d8531011be505b7bee2b5cdf9f" } get-port = "3" -hyper = "1.4" +hyper = "1.5" jsonrpsee = { version = "0.16.2", features = [ "ws-client" ] } mockito = "1.5" monero-harness = { path = "../monero-harness" } From de7c8aec0a79a21280d53ebf41c271cdb2d50fec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:44:43 +0000 Subject: [PATCH 102/108] build(deps): bump anyhow from 1.0.89 to 1.0.90 Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.89 to 1.0.90. - [Release notes](https://github.com/dtolnay/anyhow/releases) - [Commits](https://github.com/dtolnay/anyhow/compare/1.0.89...1.0.90) --- updated-dependencies: - dependency-name: anyhow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0821b73f..109f8dfb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" [[package]] name = "arrayref" From 7b1b5ec3a5323049d1165683d6bf98d647b215f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:45:16 +0000 Subject: [PATCH 103/108] build(deps): bump serde_json from 1.0.128 to 1.0.132 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.128 to 1.0.132. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/1.0.128...1.0.132) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0821b73f..c020f4e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4062,9 +4062,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", From 02a3711cc939462f75b6f1246a048ddf75d70c85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:45:51 +0000 Subject: [PATCH 104/108] build(deps): bump anyhow from 1.0.90 to 1.0.91 Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.90 to 1.0.91. - [Release notes](https://github.com/dtolnay/anyhow/releases) - [Commits](https://github.com/dtolnay/anyhow/compare/1.0.90...1.0.91) --- updated-dependencies: - dependency-name: anyhow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b7e33323..5749a8e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "arrayref" From fac5df93faf0a1ed3c255b570a06941a46f80677 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:46:56 +0000 Subject: [PATCH 105/108] build(deps): bump thiserror from 1.0.64 to 1.0.65 Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.64 to 1.0.65. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](https://github.com/dtolnay/thiserror/compare/1.0.64...1.0.65) --- updated-dependencies: - dependency-name: thiserror dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b7e33323..b5d26f34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4716,18 +4716,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", From 44fafc792e7427e8ad3f7cb8061ee0095171e811 Mon Sep 17 00:00:00 2001 From: Binarybaron Date: Mon, 11 Nov 2024 16:02:55 +0100 Subject: [PATCH 106/108] feat(asb): Add Dockerfile --- Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..05e5d64c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# 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"] From a2cc3591b158e6695f318f4b816068cd5a9ad7be Mon Sep 17 00:00:00 2001 From: Binarybaron Date: Mon, 11 Nov 2024 16:03:15 +0100 Subject: [PATCH 107/108] fix: do not panic if electrum server does not support fee estimation --- swap/src/bitcoin/wallet.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index 9748d740..55a05b73 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -468,6 +468,7 @@ 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) @@ -871,6 +872,11 @@ 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)) From 81b89d63c28562476d05c5a39c952bfbe2d7c995 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:24:06 +0100 Subject: [PATCH 108/108] docs: Add notice about breaking backwards compatability --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c0226b2..80612c4f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ You can read [this blogpost](https://comit.network/blog/2021/07/02/transaction-p ## Maintenance -This repository is currently maintained by community volunteers. While it remains safe to use, the original developers (@comit-network) have stopped contributing. For a more actively maintained version that includes a GUI, please check out this community fork: https://github.com/UnstoppableSwap/core +**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. ## Quick Start