mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 15:09:35 -05:00
Merge branch 'cooperative-release-of-funds' of https://github.com/patrini32/xmr-btc-swap into pr/1676
This commit is contained in:
commit
f8c3276642
@ -8,6 +8,7 @@ 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
|
||||
- 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
|
||||
|
||||
|
44
Cargo.lock
generated
44
Cargo.lock
generated
@ -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",
|
||||
@ -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",
|
||||
@ -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",
|
||||
@ -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",
|
||||
@ -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",
|
||||
]
|
||||
@ -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",
|
||||
@ -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",
|
||||
@ -4541,7 +4541,7 @@ dependencies = [
|
||||
"futures",
|
||||
"get-port",
|
||||
"hex",
|
||||
"hyper 1.3.1",
|
||||
"hyper 1.4.1",
|
||||
"itertools 0.13.0",
|
||||
"jsonrpsee",
|
||||
"jsonrpsee-core",
|
||||
@ -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",
|
||||
@ -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",
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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]
|
||||
@ -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" }
|
||||
|
@ -267,6 +267,10 @@ impl Context {
|
||||
tasks: Arc::new(PendingTaskList::default()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bitcoin_wallet(&self) -> Option<Arc<bitcoin::Wallet>> {
|
||||
self.bitcoin_wallet.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Context {
|
||||
|
@ -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<bitcoin::Address>,
|
||||
|
||||
#[structopt(flatten)]
|
||||
monero: Monero,
|
||||
|
Loading…
Reference in New Issue
Block a user