Skip to content

Commit

Permalink
feat: lightning ordermatching wip + library updates and more unit tes…
Browse files Browse the repository at this point in the history
…ts (#1655)

* add a unit test to test lightning taker getting swap preimage from the chain, test is failing for now

* update rust-lightning to v0.0.111 wip

* update rust-lightning to v0.0.113 wip

* update uuid to v1.2.2, use uuid instead of rpc_channel_id for lightning channels

* add unit tests for mpp and claiming swaps on-chain

* Add channel confirmation details to rpc response

* add test_lightning_maker_swap_mpp

* wip: use protocol info to not match with lightning orders if there are not routes between swap parties

* wip: add amount to protocol info route check

* wip: refactor lightning protocol info code

* Add max_total_cltv_expiry_delta and final_cltv_expiry_delta to route check in lightning protocol info check

* Fix funding_generated_in_block is Null in DB error when 0 conf is enabled and channel is closed before funding tx is confirmed

* remove some unneeded todos, write better todos

* remove more todos

* review fixes: use bech32 0.9.1, return error instead of using expect for current_time

* review fixes: use macro to simplify code, sort by short_channel_id

* review fixes: add doc comments for uuid and channel_id

* Fix channel was closed issue but closing transaction wasn't broadcasted due to a network error (all electrums were down, etc..)

* fix issue in db when retrying to pay an invoice

* move converting tx hex to bytes outside send transaction loop in BroadcasterInterface

* import uuid::Error as UuidError in my_swaps.rs

---------

Reviewed-by: ozkanonur <work@onurozkan.dev>, borngraced <samiodev@icloud.com>, caglaryucekaya <caglaryucekaya@gmail.com>
  • Loading branch information
shamardy authored Mar 10, 2023
1 parent 45d7285 commit ebdc8c2
Show file tree
Hide file tree
Showing 56 changed files with 1,526 additions and 908 deletions.
91 changes: 46 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions mm2src/coins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async-trait = "0.1.52"
base64 = "0.10.0"
base58 = "0.2.0"
bip32 = { version = "0.2.2", default-features = false, features = ["alloc", "secp256k1-ffi"] }
bitcoin_hashes = "0.10.0"
bitcoin_hashes = "0.11"
bitcrypto = { path = "../mm2_bitcoin/crypto" }
bincode = "1.3.3"
byteorder = "1.3"
Expand Down Expand Up @@ -90,7 +90,7 @@ utxo_signer = { path = "utxo_signer" }
# using the same version as cosmrs
tendermint-rpc = { version = "=0.23.7", default-features = false }
tiny-bip39 = "0.8.0"
uuid = { version = "0.7", features = ["serde", "v4"] }
uuid = { version = "1.2.2", features = ["fast-rng", "serde", "v4"] }
# One of web3 dependencies is the old `tokio-uds 0.1.7` which fails cross-compiling to ARM.
# We don't need the default web3 features at all since we added our own web3 transport using shared HYPER instance.
web3 = { git = "https://github.com/KomodoPlatform/rust-web3", tag = "v0.19.0", default-features = false }
Expand All @@ -115,28 +115,27 @@ web-sys = { version = "0.3.55", features = ["console", "Headers", "Request", "Re

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
dirs = { version = "1" }
bitcoin = "0.28.1"
bitcoin = "0.29"
hyper = { version = "0.14.11", features = ["client", "http2", "server", "tcp"] }
# using webpki-tokio to avoid rejecting valid certificates
# got "invalid certificate: UnknownIssuer" for https://ropsten.infura.io on iOS using default-features
hyper-rustls = { version = "0.23", default-features = false, features = ["http1", "http2", "webpki-tokio"] }
lightning = "0.0.110"
lightning-background-processor = "0.0.110"
lightning-invoice = { version = "0.18.0", features = ["serde"] }
lightning-net-tokio = "0.0.110"
lightning-rapid-gossip-sync = "0.0.110"
lightning = "0.0.113"
lightning-background-processor = "0.0.113"
lightning-invoice = { version = "0.21.0", features = ["serde"] }
lightning-net-tokio = "0.0.113"
rust-ini = { version = "0.13" }
rustls = { version = "0.20", features = ["dangerous_configuration"] }
secp256k1v22 = { version = "0.22", package = "secp256k1" }
secp256k1v24 = { version = "0.24", package = "secp256k1" }
tendermint-config = { version = "0.23.7", default-features = false }
tokio = { version = "1.20" }
tokio-rustls = { version = "0.23" }
tonic = { version = "0.7", features = ["tls", "tls-webpki-roots", "compression"] }
webpki-roots = { version = "0.22" }
zcash_client_backend = { git = "https://github.com/KomodoPlatform/librustzcash.git" }
zcash_client_sqlite = { git = "https://github.com/KomodoPlatform/librustzcash.git" }
zcash_primitives = { features = ["transparent-inputs"], git = "https://github.com/KomodoPlatform/librustzcash.git" }
zcash_proofs = { git = "https://github.com/KomodoPlatform/librustzcash.git" }
zcash_client_backend = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
zcash_client_sqlite = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
zcash_primitives = { features = ["transparent-inputs"], git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
zcash_proofs = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }

[target.'cfg(windows)'.dependencies]
winapi = "0.3"
Expand Down
12 changes: 10 additions & 2 deletions mm2src/coins/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4242,9 +4242,17 @@ impl MmCoin for EthCoin {

fn mature_confirmations(&self) -> Option<u32> { None }

fn coin_protocol_info(&self) -> Vec<u8> { Vec::new() }
fn coin_protocol_info(&self, _amount_to_receive: Option<MmNumber>) -> Vec<u8> { Vec::new() }

fn is_coin_protocol_supported(&self, _info: &Option<Vec<u8>>) -> bool { true }
fn is_coin_protocol_supported(
&self,
_info: &Option<Vec<u8>>,
_amount_to_send: Option<MmNumber>,
_locktime: u64,
_is_maker: bool,
) -> bool {
true
}

fn on_disabled(&self) -> Result<(), AbortedError> { AbortableSystem::abort_all(&self.abortable_system) }

Expand Down
Loading

0 comments on commit ebdc8c2

Please sign in to comment.