Commit Graph

1040 Commits

Author SHA1 Message Date
Einliterflasche
7871cf256b
feat(asb + cli): Redact logs + unify tracing infrastructure (#1733) 2024-08-21 16:33:04 +02:00
binarybaron
cc854be8f4
feat: Enhance history command with more swap details (#1725) 2024-08-01 18:35:03 +02:00
Einliterflasche
2fe428779a
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
2024-07-25 23:06:50 +02:00
binarybaron
75cfc6b0d4
fix(cli): allow bitcoin-change-address to be omitted when making request to rpc server (#1728) 2024-07-25 00:13:15 +02:00
binarybaron
c80bdb2d8c
fix(asb): Allow history command to be run while asb is running (#1724)
Co-authored-by: einliterflasche <einliterflasche@pm.me>
2024-07-23 14:52:01 +02:00
binarybaron
85c4db1d75
fix: Format cooperative redeem reject using thiserror (#1716) 2024-07-16 20:13:58 +02:00
patrini32
845b9428b7
remove whitespaces 2024-07-11 11:02:23 +03:00
patrini32
ee04ff8a3b
fix formatting 2024-07-11 10:58:07 +03:00
binarybaron
f8c3276642 Merge branch 'cooperative-release-of-funds' of https://github.com/patrini32/xmr-btc-swap into pr/1676 2024-07-11 09:30:49 +02:00
binarybaron
073baa9752 Update swap.rs 2024-07-11 09:30:48 +02:00
binarybaron
f72005312c
Merge branch 'master' into cooperative-release-of-funds 2024-07-11 09:23:38 +02:00
Einliterflasche
4115a452e3
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 <byron@hambly.dev>
2024-07-11 09:19:41 +02:00
binarybaron
2824ebc893 Update swap.rs 2024-07-03 20:39:49 +02:00
binarybaron
07f788eb81 Update swap.rs 2024-07-03 20:14:09 +02:00
binarybaron
ef75019ac6 Update swap.rs 2024-07-03 20:12:22 +02:00
binarybaron
26e66ce9b9 Update swap.rs 2024-07-03 20:02:04 +02:00
binarybaron
d7b649b7a6 feat: Allow for cooperative Monero redeem after Bitcoin punish has happened 2024-07-03 19:47:45 +02:00
binarybaron
c5aa7edb6b
chore: Fix typo (#1701) 2024-07-02 12:03:56 +02:00
patrini32
173d077751
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
2024-07-01 23:14:44 +02:00
binarybaron
23a27680a4
feat (Bob): Buffer transfer proof to database when we are running a different swap (#1669) 2024-06-28 21:39:30 +02:00
binarybaron
4c9d1e8d8d
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.
2024-06-27 14:24:27 +02:00
dependabot[bot]
4d557d1ef9
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] <support@github.com>

* fix: breaking change in mockito async

* bump mockito to 1.4

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Byron Hambly <byron@hambly.dev>
2024-06-19 15:35:05 +02:00
Byron Hambly
90494ba4a5
fix: monero wallet refresh (#1596)
This PR changes the following behaviour in the refresh functionality of the monero wallet
- Allows for multiple retries because in some cases users have experienced an issue where the wallet rpc returns `no connection to daemon` even though the daemon is available. I'm not 100% sure why this happens but retrying often fixes the issue
- Print the current sync height after each failed attempt at syncing to see how far we've come
- The `monero-wallet-rpc` is started with the `--no-initial-sync` flag which ensures that as soon as it's started, it's ready to respond to requests
- The `monero-wallet-rpc` was upgraded to `v0.18.3.1` because this PR https://github.com/monero-project/monero/pull/8941 has improved some of the issues mentioned above


This PR is part of a larger effort to fix this issue https://github.com/comit-network/xmr-btc-swap/issues/1432
2024-06-10 18:53:52 +02:00
binarybaron
55b67d31d4 feat (Bob): Log extensive information about deposit requirements 2024-06-06 15:21:48 +02:00
chengehe
49a7f7eed6
chore: remove repeat word (#1671)
Signed-off-by: chengehe <hechenge@yeah.net>
2024-06-06 12:10:19 +02:00
pokkst
9635c0b551
fix (Bob): Check if Bitcoin redeem transaction was published before transitioning to CancelTimelockExpired (#1427)
* fix (Bob): Check if Bitcoin redeem transaction was published before transitioning to CancelTimelockExpired

---------

Co-authored-by: binarybaron <86064887+binarybaron@users.noreply.github.com>
Co-authored-by: Byron Hambly <bhambly@blockstream.com>
2024-06-04 12:49:15 +02:00
Byron Hambly
796863359f
upgrade secp256kfun (#1466)
* ci: add cargo check on rust stable

* refactor: upgrade secp256kfun and fix resulting issues

* build(deps): update sigma_fun and ecdsa_fun to a52142cf7f

 #1520
 #1521

* chore: fix clippy issue

* update to 91112f80b24

* bump to 294de1721add

* chore(deps): remove spectral

spectral fails to compile on rust stable 1.76 due to dep on deprecated
rustc-serialize

* secp256kfun: update to 7da9d277 and set rev in manifest

* update to 6fdc5d8

* switch to crates.io versions of ecdsa_fun and sigma_fun

* ci: update toolchain to 1.74 and fix draft action

* clippy fixes

---------

Co-authored-by: binarybaron <86064887+binarybaron@users.noreply.github.com>
2024-05-27 11:03:20 +02:00
binarybaron
32ca0b1a4a CLI: Upgrade monero-wallet-rpc to 0.18.3.1, clarify a few log. messages 2024-05-25 18:22:17 +02:00
binarybaron
c433bd2389
CLI: Initiate tracing earlier to avoid lost logs (#1646) 2024-05-25 17:59:12 +02:00
binarybaron
0ca98cd0b7
Make tracing file appender blocking (#1643) 2024-05-25 14:43:22 +02:00
binarybaron
0c4b7d50c2
Lower DEFAULT_BITCOIN_CONFIRMATION_TARGET to 1 to ensure timely confirmation of bitcoin transactions (#1640) 2024-05-24 18:02:29 +02:00
yamabiiko
5ff46be279
RPC server for API Interface (#1276)
* saving: implementing internal api shared by cli and rpc server

* writing async rpc methods and using arc for shared struct references

* cleaning up, renamed Init to Context

* saving: cleaning up and initial work for tests

* Respond with bitcoin withdraw txid

* Print RPC server address

* Cleanup, formatting, add `get_seller`, `get_swap_start_date` RPC endpoints

* fixing tests in cli module

* uncommenting and fixing more tests

* split api module and propagate errors with rpc server

* moving methods to api and validating addresses for rpc

* add broadcast channel to handle shutdowns gracefully and prepare for RPC server test

* added files

* Update rpc.rs

* adding new unfinished RPC tests

* updating rpc-server tests

* fixing warnings

* fixing formatting and cargo clippy warnings

* fix missing import in test

* fix: add data_dir to config to make config command work

* set server listen address manually and return file locations in JSON on Config

* Add called api method and swap_id to tracing for context, reduced boilerplate

* Pass server_address properly to RpcServer

* Update Cargo.lock

* dprint fmt

* Add cancel_refund RPC endpoint

* Combine Cmd and Params

* Disallow concurrent swaps

* Use RwLock instead of Mutex to allow for parallel reads and add get_current_swap endpoint

* Return wallet descriptor to RPC API caller

* Append all cli logs to single log file

After careful consideration, I've concluded that it's not practical/possible to ensure that the previous behaviour (one log file per swap) is preserved due to limitations of the tracing-subscriber crate and a big in the built in JSON formatter

* Add get_swap_expired_timelock timelock, other small refactoring

- Add get_swap_expired_timelock endpoint to return expired timelock if one exists. Fails if bitcoin lock tx has not yet published or if swap is already finished.
- Rename current_epoch to expired_timelock to enforce consistent method names
- Add blocks left until current expired timelock expires (next timelock expires) to ExpiredTimelock struct
- Change .expect() to .unwrap() in rpc server method register because those will only fail if we register the same method twice which will never happen

* initiating swaps in a separate task and handling shutdown signals with broadcast queues

* Replace get_swap_start_date, get_seller, get_expired_timelock with one get_swap_info rpc method

* WIP: Struct for concurrent swaps manager

* Ensure correct tracing spans

* Add note regarding Request, Method structs

* Update request.rs

* Add tracing span attribute log_reference_id to logs caused by rpc call

* Sync bitcoin wallet before initial max_giveable call

* use Span::current() to pass down to tracing span to spawned tasks

* Remove unused shutdown channel

* Add `get_monero_recovery_info` RPC endpoint

- Add `get_monero_recovery_info` RPC endpoint
- format PrivateViewKey using Display

* Rename `Method::RawHistory` to `Method::GetRawStates`

* Wait for swap to be suspended after sending signal

* Remove notes

* Add tracing span attribute log_reference_id to logs caused by rpc call

* Sync bitcoin wallet before initial max_giveable call

* use Span::current() to pass down to tracing span to spawned tasks

* Remove unused shutdown channel

* Add `get_monero_recovery_info` RPC endpoint

- Add `get_monero_recovery_info` RPC endpoint
- format PrivateViewKey using Display

* Rename `Method::RawHistory` to `Method::GetRawStates`

* Wait for swap to be suspended after sending signal

* Return additonal info on GetSwapInfo

* Update wallet.rs

* fix compile issues for tests and use serial_test crate

* fix rpc tests, only check for RPC errors and not returned values

* Rename `get_raw_history` tp `get_raw_states`

* Fix typo in rpc server stopped tracing log

* Remove unnecessary success property on suspend_current_swap response

* fixing test_cli_arguments and other tests

* WIP: RPC server integration tests

* WIP: Integration tests for RPC server

* Update rpc tests

* fix compile and warnings in tests/rpc.rs

* test: fix assert

* clippy --fix

* remove otp file

* cargo clippy fixes

* move resume swap initialization code out of spawned task

* Use `in_current_span` to pass down tracing span to spawned tasks

* moving buy_xmr initialization code out of spawned tasks

* cargo fmt

* Moving swap initialization code inside tokio select block to handle swap lock release logic

* Remove unnecessary swap suspension listener from determine_btc_to_swap call in BuyXmr

* Spawn event loop before requesting quote

* Release swap lock after receiving shutdown signal

* Remove inner tokio::select in BuyXmr and Resume

* Improve debug text for swap resume

* Return error to API caller if bid quote request fails

* Print error if one occurs during process invoked by API call

* Return bid quote to API caller

* Use type safe query! macro for database retrieval of states

* Return tx_lock_fee to API caller on GetSwapInfo call

Update request.rs

* Allow API caller to retrieve last synced bitcoin balane and avoid costly sync

* Return restore height on MoneroRecovery command to API Caller

* Include entire error cause-chain in API response

* Add span to bitcoin wallet logs

* Log event loop connection properties as tracing fields

* Wait for background tasks to complete before exiting CLI

* clippy

* specify sqlx patch version explicitly

* remove mem::forget and replace with _guard

* ci: add rpc test job

* test: wrap rpc test in #[cfg(test)]

* add missing tokio::test attribute

* fix and merge rpc tests, parse uuuid and multiaddr from serde_json value

* default Tor socks port to 9050, Cargo fmt

* Update swap/sqlite_dev_setup.sh: add version

Co-authored-by: Byron Hambly <byron@hambly.dev>

* ci: free up space on ubuntu test job

* Update swap/src/bitcoin/wallet.rs

Co-authored-by: Byron Hambly <byron@hambly.dev>

* Update swap/src/bitcoin/wallet.rs

Co-authored-by: Byron Hambly <byron@hambly.dev>

* fmt

---------

Co-authored-by: binarybaron <86064887+binarybaron@users.noreply.github.com>
Co-authored-by: Byron Hambly <byron@hambly.dev>
2024-05-22 15:12:58 +02:00
Byron Hambly
a19501a002
Revert "Monero wallet refresh fix (#1487)"
This reverts commit d8dacbdee9.
2024-03-26 09:06:31 +02:00
binarybaron
d8dacbdee9
Monero wallet refresh fix (#1487)
* Upgrade monero-wallet-rpc to `v0.18.3.1`

* Give feedback to user about state of monero refresh and retry if fails

This commit changes the following behaviour in the refresh functionality of the monero wallet
- Allows for multiple retries because in some cases users have experienced an issue where the wallet rpc returns `no connection to daemon` even though the daemon is available. I'm not 100% sure why this happens but retrying often fixes the issue
- Attempt to print the current sync height while the wallet is syncing. This only works to some degree because the `monero-wallet-rpc` stops responding (or takes a long time to respond) while it's refreshing
- The `monero-wallet-rpc` is started with the `--no-initial-sync` flag which ensures that as soon as it's started, it's ready to respond to requests
---------

Co-authored-by: Byron Hambly <bhambly@blockstream.com>
Co-authored-by: Byron Hambly <byron@hambly.dev>
2024-03-25 15:08:54 +01:00
Ian McKenzie
eb15f477fa
Verify hashes of monero cli on download (#1572)
* Bump Monero CLI for macos aarch64 to match other platforms

* Check hash on download of monero cli

* change panic to bail

---------

Co-authored-by: Byron Hambly <bhambly@blockstream.com>
2024-03-22 11:18:40 +02:00
Ian McKenzie
140dc6dc04
Upgrade to vergen 8.3, move to git describe --dirty --tags for semver (#1543)
* Upgrade to vergen 8.3, move to git describe --dirty --tags for semver

* Add newline to build.rs
2024-02-04 08:43:59 +02:00
Byron Hambly
dcf9f24b77
build(deps): bump pem to 3.0
replaces #1415

also fixes the `seed_from_pem_fails_for_long_seed` unit test, which was
"passing" but not actually testing what it meant to.
2023-10-23 11:21:04 +02:00
pokkst
5182b4f53a
Update lock timeout to 10 min 2023-09-29 08:08:25 -05:00
binarybaron
3467523849 Dynamically choose monero daemon to connect to 2023-09-07 19:10:23 +02:00
binarybaron
2e1909685d
Revert "Refresh monero monitoring wallet at startup to ensure daemon is is av…" 2023-09-01 17:36:00 +02:00
binarybaron
844ebc7de3 Refresh monero monitoring wallet at startup to ensure daemon is is available 2023-08-31 00:47:18 +02:00
bors[bot]
d0a35ab21b
Merge #1428
1428: Fix issue where Windows cannot open ASB wallet to create lock XMR transaction r=delta1 a=pokkst

It seems on Windows that opening an already opened wallet results in an error/crash. This does not seem to be the case for Linux and macOS. Removing this line fixed the issue on Windows, and had no regressions on macOS/Linux from my testing.

Co-authored-by: pokkst <pokkst@protonmail.com>
2023-08-14 11:38:10 +00:00
binarybaron
2e181dac9c Immediately sync bitcoin tx status upon subscribing 2023-08-13 14:33:49 +02:00
pokkst
d7d87d96ac
Maybe fix issue on Windows where the wallet cannot open during XMR locking phase
(cherry picked from commit 879cb8bc0131b8a059466ca00ae9f7842c4ac018)
2023-08-08 18:25:30 -05:00
Byron Hambly
5e192acac2
feat(asb): allow asb to register with mulitple rendezvous nodes 2023-08-04 15:04:58 +02:00
Byron Hambly
acdba8474b
build(deps): update rust-toolchain to 1.67 and bump uuid to 1.4
some of the dependency updates are requiring a higher version of the
rust toolchain. bump to 1.67 and fix new clippy lints.

also fix dprint to 0.39.1 because 0.40 has breaking changes.
2023-07-31 11:49:28 +02:00
Byron Hambly
00cfce57c7
chore: fix dprint config and run fmt 2023-03-15 14:19:57 +02:00
Byron Hambly
43f06f0705
build(deps): bump base64 to 0.21
closes #1271
2023-01-11 19:52:14 +02:00
Byron Hambly
4ca1f8da5e
ci: update msrv and github actions toolchains 2023-01-10 14:57:09 +02:00
Byron Hambly
9346cb7baf
fix: add debug log for opening monero wallet error 2023-01-10 13:49:32 +02:00