Commit Graph

130 Commits (master)

Author SHA1 Message Date
rishflab e42812ba37 Add subcommand to print internal bitcoin wallet descriptor
Example:

 cargo run --package swap --bin swap -- export-bitcoin-wallet

{"descriptor":"wpkh(xprv9s21ZrQH143K2q85eUf2ppCtti2Zar6aDCW5dCC5DG9VvutJ3cpe3Qf9wZpQeraNf9JEuGem1RyJZQMEWCN2DpWyL5WbsvmSW6wbL7Jq53H/84'/0'/0'/0/*)","blockheight":0,"label":"cli-bitcoin"}
3 years ago
rishflab 394adb0a4f Add subcommand to print config
This subcommand has been introduced to make it easy for users to find
the location of the deprecated sled database in case they wish to delete
it. This feature should also resolve difficulties users were facing when
 trying to find where xmr-btc-swap was storing their data.
3 years ago
rishflab 05a28dc37a Add --sled flag to use deprecated sled db 3 years ago
bors[bot] e860c051d3
Merge #769
769: Change message log level to debug to allow enabling through flag r=rishflab a=rishflab

We do not have a way to enable tracing through a command line
argument so it did not make sense to have these messages set to
trace. Ideally a trace flag should be added but it is not that
straightforward with structopt. We could add a --log-level arg
that allows you select a log level but this is verbose.

Closes #759


Co-authored-by: rishflab <rishflab@hotmail.com>
3 years ago
rishflab 3ba1ed2bcb Change message log level to debug to allow enabling through flag
We do not have a way to enable tracing through a command line
argument so it did not make sense to have these messages set to
trace. Ideally a trace flag should be added but it is not that
straightforward with structopt. We could add a --log-level arg
that allows you select a log level but this is verbose.
3 years ago
rishflab ee6524a75f Timestamp logs by default on the ASB
Disable timestamps using the command line flag
3 years ago
rishflab 679b155db1 Enable log timestamps using explicit command line flag
Previously logs were only timestamped when the ASB was run in an
interactive terminal or if the logs were output as JSON. JSON logs and
ASB output in an interactive terminal are no longer timestamped by
default.
3 years ago
rishflab f511ff093c Make --force the default behaviour for manual recovery
Remove the force flag. There is a resume command that tries to
gracefully restarts the protocol and tries to execute the happy path.
Remove e2e tests which test the --force flag.
3 years ago
COMIT Botty McBotface 4ff74a3940 Prepare release 0.8.3 3 years ago
rishflab 2d64a8d356
Revert "Release version 0.8.3" 3 years ago
rishflab 27b1e60f0b
Revert "Release version 0.8.3" 3 years ago
COMIT Botty McBotface deadb7d4c8 Prepare release 0.8.3 3 years ago
COMIT Botty McBotface 2a4ffaeacb Prepare release 0.8.3 3 years ago
bors[bot] 1f371ecfee
Merge #724
724: Handle errors when waiting for subscriptions r=rishflab a=rishflab

We were not thorough enough in PR #705 and there were some remaining
unhandled errors.

Co-authored-by: rishflab <rishflab@hotmail.com>
3 years ago
rishflab ce58b8b333 Handle errors when waiting for subscriptions
We were not thorough enough in PR #705 and there were some remaining
unhandled errors.

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
rishflab 5e35a2e575 Fix duplication of entry in CHANGELOG.md 3 years ago
COMIT Botty McBotface d482db4e67 Prepare release 0.8.2 3 years ago
devbordecraft 7a12a847a0 Fetch multiple UTXOs when we do max_giveable 3 years ago
devbordecraft f2df838a3c Allow withdrawing and viewing of the bitcoin balance on swap-cli 3 years ago
bors[bot] 51d8623ed7
Merge #704
704: Allow withdrawing and viewing of the bitcoin balance on swap-cli r=rishflab a=devbordecraft

Same mechanics of the ASB but on swap-cli as discussed in #694

Co-authored-by: devbordecraft <devbordecraft>
3 years ago
devbordecraft e8a6af1517 Allow withdrawing and viewing of the bitcoin balance on swap-cli
Fix formatting issue

Fix after review
3 years ago
rishflab 8598bcade1 Configure electrum client to retry 5 times 3 years ago
Daniel Karzel 18faa786d6 Fail if something goes wrong when checking tx lock status
Probably a failure when interacting with the electrum node to get script
 status updates
3 years ago
Thomas Eizinger 25b123d6ed
Load wallet in `monero-wallet-rpc` on demand if necessary
Previously, we relied on the wallet in the `monero-wallet-rpc` daemon
to be loaded as we do on startup. As a consequence of this expectation,
restarting `monero-wallet-rpc` to fix bugs like #652 resulted in the
ASB no longer operating correctly.

To fix this, we now load the wallet on-demand in case the daemon responds
with the error code -13.

Ideally, we would implement this behaviour generically using the proxy
pattern on the `MoneroWalletRpc` trait. Unfortunately, when attempting
to do so we uncover a limitation in the design of `jsonrpc_client`.
This limitation is tracked in https://github.com/thomaseizinger/rust-jsonrpc-client/issues/47.
Once fixed, we can implement this logic in a more robust way that is not
tied to the `check_tx_key` RPC call but applies to any RPC call automatically.
3 years ago
Thomas Eizinger c04d2dc944
Merge two `CHANGED` sections in old changelog entry 3 years ago
Thomas Eizinger 6c446825b7
Instruct `Ping` to keep the connection alive 3 years ago
COMIT Botty McBotface 7126d77dc1 Prepare release 0.8.1 3 years ago
Thomas Eizinger 0296509110
Upgrade to bdk 0.10
This fixes #546. I don't know why, but I can't reproduce the problem
with the updated dependency.
3 years ago
Thomas Eizinger 5c4aec6ae3
Rendezvous point is not defaulted 3 years ago
COMIT Botty McBotface 403e3d2b33 Prepare release 0.8.0 3 years ago
Daniel Karzel 0dc3943d9c
Update default Monero node URLs and info
xmr.to nodes are not served at the xmr.to domain but moved to melo.tools
3 years ago
Daniel Karzel ab24f7bce5
Revert "Prepare release 0.8.0"
This reverts commit 50da9580
3 years ago
COMIT Botty McBotface 50da958078 Prepare release 0.8.0 3 years ago
Thomas Eizinger 40eccd089f
Change `--data-dir` for `--data-base-dir` 3 years ago
Thomas Eizinger acfd2dd6bb
Store Monero receive address in database and load it on resume 3 years ago
Thomas Eizinger 5463bde4f8
Add a mandatory `--change-address` parameter to `buy-xmr`
Fixes #513.
3 years ago
Daniel Karzel 625ff4868a
Changelog entry for the rendezvous integration 3 years ago
Thomas Eizinger ec4234fbb9
Merge `--seller-addr` and `--seller-peer-id` into `--seller` parameter
This simplifies the CLI's interface.
3 years ago
Thomas Eizinger bb8e841b0d
Make CHANGELOG.md follow the semantic newline spec 3 years ago
Your Name 665ea503d2 Make price ticker ws url configurable 3 years ago
Daniel Karzel 8e80628a71
Changelog entry for price guarantee changes 3 years ago
Thomas Eizinger 8a30ef725c
Refactor transports to construct them specific for each application
Instead of splitting up the transports into capabilities, we compose
them directly for each application. This allows us to remove the
websocket transport for the CLI which is really only needed for the
ASB to allow retrieval of quotes via the browser.
3 years ago
xscd 03857ca835 Print the Bitcoin address to the terminal as a QR code 3 years ago
COMIT Botty McBotface 7e6ff81efb Prepare release 0.7.0 3 years ago
Daniel Karzel 202f6d1fa0
Bitcoin network check when building PSBT
This ensures that funds are not sent to an address on the wrong network.
3 years ago
Daniel Karzel c9064d5a37
Add ping protocol to ensure connection is alive
Adds the ping behaviour to both ASB and CLI behaviour that periodically pings a connected party to ensure that the underlying network connection is still alive.
This fixes problems with long-running connections that become dead without a connection closure being reported back to the swarm.
3 years ago
COMIT Botty McBotface 3f2d094f65
Prepare release 0.6.0 3 years ago
Daniel Karzel 01af9a5676
Bitcoin transaction published state
This improves the error handling on the ASB.
Once the Bitcoin redeem transaction is seen in mempool, the state machine cannot transition to a cancel scenario anymore because at that point the CLI will have redeemed the Monero.
The additional state then waits for transaction finality.
3 years ago
Daniel Karzel 7ec323ea1f
Mainnet changelog entry 3 years ago
Daniel Karzel 1cdc23de32
Explicitly specify `monero-wallet-rpc` deamon port
In order to allow people to plug into public nodes / be more flexible with their own setup we now enforce specifying the monero daemon port to be used by the `monero-wallet-rpc`.
3 years ago
Philipp Hoenisch fc0cceb180
Toggle json logs using commandline flag. 3 years ago
Daniel Karzel 652aae9590
Introduce a minimum buy amount
Introduces a minimum buy Bitcoin amount similar to the maximum amount already present.
For the CLI the minimum amount is enforced by waiting until at least the minimum is available as max-giveable amount.
3 years ago
Daniel Karzel 1d62f4916c
Move `max_buy` and `ask_spread` into config
Max-buy and spread is not something that one would configure on every run.
More convenient to keep this in the config.

The max-buy Bitcoin value was adapted to `0.02` which is more reasonable for mainnet.
Activated feature `serde-float` to serialize the spread (Decimal) as float instead of string.

```
...

[maker]
max_buy_btc = 0.02
ask_spread = 0.02
```
3 years ago
Daniel Karzel daa572e5bf
Move recovery commands in dedicated module
Less clutter in the folder structure.
3 years ago
Daniel Karzel 4deb96a3c5
ASB manual recovery commands
Adds `cancel`, `refund`, `punish`, `redeem` and `safely-abort` commands to the ASB that can be used to trigger the specific scenario for the swap by ID.
3 years ago
Daniel Karzel ea76ae5821
Return proper error to CLI for all expected scenarios
When a CLI requests a spot price have some errors that are expected, where we can provide a proper error message for the CLI:
- Balance of ASB too low
- Buy amount sent by CLI exceeds maximum buy amount accepted by ASB
- ASB is running in maintenance mode and does not accept incoming swap requests

All of these errors returns a proper error to the CLI and prints a warning in the ASB logs.
Any other unexpected error will result in closing the channel with the CLI and printing an error in the ASB logs.
3 years ago
Daniel Karzel f6497778ed
Add resume-only mode for the ASB
Resume-only is a maintenance mode where no swaps are accepted but unfinished swaps are resumed.
This is achieve by ignoring incoming spot-price requests (that would lead to execution setup) in the event-loop.
3 years ago
Daniel Karzel 69f7565746
!fixup Different default directories for CLI and ASB
Using the same default directory as data-/config-dir has caused unwanted side effects when running both applications on the same machine.
Use these directory names:
- ASB: xmr-btc-swap/asb
- CLI: xmr-btc-swap/cli

Since the functionality is now application specific the respective functions were moved into the appropriate module of the application.
3 years ago
Daniel Karzel b0ffeeab1d
Different default directories for CLI and ASB
Using the same default directory as data-/config-dir has caused unwanted side effects when running both applications on the same machine.
Use these directory names:
- ASB: xmr-btc-swap-asb
- CLI: xmr-btc-swap-cli

Since the functionality is now application specific the respective functions were moved into the appropriate module of the application.
3 years ago
Philipp Hoenisch 99db8c9108
Apply suggestions from code review
Co-authored-by: Daniel Karzel <daniel.karzel@coblox.tech>
3 years ago
Philipp Hoenisch 632293cf91
Add support for swapping through Tor.
This PR does a few things.
* It adds a TorTransport which either dials through Tor's socks5 proxy or via clearnet.
* It enables ASB to register hidden services for each network it is listening on. We assume that we only care about different ports and re-use the same onion-address for all of them. The ASB requires to have access to Tor's control port.
* It adds support to dial through a local Tor socks5 proxy. We assume that Tor is always available on localhost.  Swap cli only requires Tor to be running so that it can send messages via Tor's socks5 proxy.
* It adds a new e2e test which swaps through Tor. For this we assume that Tor is currently running on localhost. All other tests are running via clear net.
3 years ago
COMIT Botty McBotface 43dc74cd9d Prepare release 0.5.0 3 years ago
Daniel Karzel a114460520
Better wording 3 years ago
Thomas Eizinger d1bc7e8fc2
Add changelog entry for redial fix 3 years ago
Thomas Eizinger e957cbd909
Rewrite changelog entry as fix rather than a change 3 years ago
Daniel Karzel c1e993deb2
Json codec for quote protocol
A `RequestResponseCodec` for pull-based protocols where the response is encoded using JSON.
This was added to more properly express the behavior of the quote protocol, where the dialer
doesn't send any message and expects the listener to directly send the response.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
Daniel Karzel f70e2aa8d6
Listen on tcp and websocket transports
- Listen on both tcp and websockets as default
- Listening addresses in config as array
- Configure fallback transport using `or_transport` - if listening on a given address fails on WS, we fall back to TCP.
3 years ago
Daniel Karzel c976358c37
Multiple swaps with the same peer
- Swap-id is exchanged during execution setup. CLI (Bob) sends the swap-id to be used in his first message.
- Transfer poof and encryption signature messages include the swap-id so it can be properly associated with the correct swap.
- ASB: Encryption signatures are associated with swaps by swap-id, not peer-id.
- ASB: Transfer proofs are still associated to peer-ids (because they have to be sent to the respective peer), but the ASB can buffer multiple
- CLI: Incoming transfer proofs are checked for matching swap-id. If a transfer proof with a different swap-id than the current executing swap is received it will be ignored. We can change this to saving into the database.

Includes concurrent swap tests with the same Bob.

- One test that pauses and starts an additional swap after the transfer proof was received. Results in both swaps being redeemed after resuming the first swap.
- One test that pauses and starts an additional swap before the transfer proof is sent (just after BTC locked). Results in the second swap redeeming and the first swap being refunded (because the transfer proof on Bob's side is lost). Once we store transfer proofs that we receive during executing a different swap into the database both swaps should redeem.

Note that the monero harness was adapted to allow creating wallets with multiple outputs, which is needed for Alice.
3 years ago
Daniel Karzel cf4d369b9c
Replace commit hash with old versioning scheme v0.3 3 years ago
COMIT Botty McBotface 1687f84aa1 Prepare release 0.4.0 3 years ago
bors[bot] 32912ebd4a
Merge #394
394: Add a configurable spread to the ASB r=thomaseizinger a=thomaseizinger

Fixes #381.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
rishflab 9b0467d43a Remove default connection details from CLI
Connecting buyers to us by default is not consistent with our vision of
a decentralised network of sellers.

Closes #395
3 years ago
Thomas Eizinger a99d12b9df
Add a configurable spread to the ASB
Fixes #381.
3 years ago
bors[bot] d144405182
Merge #376
376: ASB resumes unfinished swaps after startup r=da-kami a=da-kami

Fixes #374 

- [x] Save Bob peer-id in database for Alice
- [x]  Alice: Wait for `10` Monero confirmations in `BtcRefunded` instead of `XmrLocked` (requires extending the RPC to distinguish locked / unlocked balance)
- [x] Save Alice peer-id in database for Bob ~~(+ multiaddress and remove params from resume)~~
- [ ] ~~Refactor Bob in test setup (handle event-loop in test setup similar to Alice)~~

I decided against refactoring Bob in the test setup, because eventually we might still want to add concurrent swap tests with multiple Bobs. The refactoring I had in mind would not allow such kind of tests. 
Generally, the current state of the changes already contains enough added value to open the PR :)

Follow ups out of scope

- [ ] Parametrize database with role (Alice / Bob) and remove all the (currently useless) mapping between DB and protocol types.
- [ ]  Alice: Wait for transfer proof ack before transitioning to new `XmrLocked`

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Daniel Karzel 2135a6e53e
Alice resumes swaps 3 years ago
Daniel Karzel d90496931b
Save Alice's peer-id in the db for Bob
This allows loading the seller-peer-id from the database upon resuming a swap.
Thus, the parameters `--seller-peer-id` is removed for the `resume` command.
Other than the peer-id the multi address of a seller can change and thus is
still a parameter. This parameter might become optional once we add DHT support.
3 years ago
Thomas Eizinger e27c153c4a
Re-word changelog entry for bad readiness check of monero-wallet-rpc 3 years ago
Thomas Eizinger 52b9a78de2
Alice to validate Bob's PSBT for correctness
In order for the re-construction of TxLock to be meaningful, we limit
`Message2` to the PSBT instead of the full struct. This is a breaking
change in the network layer.

The PSBT is valid if:

- It has at most two outputs (we allow a change output)
- One of the outputs pays the agreed upon amount to a shared output script

Resolves #260.
3 years ago
rishflab bc902ea63a Use language agnostic heuristic to check if monero_wallet_rpc is ready
Our strategy of searching for a english string to determine if
monero_wallet_rpc is ready is not compatible with languages other than
english. Instead we assume the monero rpc is ready if it has stopped
writing to stdout. We make a json rpc request to confirm this. A better
solution would have been to configure the monero_wallet_rpc to always
output in english but there is not command line argument to configure
the language.

Closes #353.
3 years ago
Thomas Eizinger b25d21282d
Add CHANGELOG file 3 years ago