diff --git a/Cargo.lock b/Cargo.lock index c8d4b419..2661fef3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,17 +404,6 @@ dependencies = [ "opaque-debug 0.3.0", ] -[[package]] -name = "blake2b_simd" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] - [[package]] name = "block-buffer" version = "0.7.3" @@ -462,18 +451,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" -[[package]] -name = "bstr" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata", - "serde", -] - [[package]] name = "bumpalo" version = "3.6.1" @@ -632,6 +609,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "comfy-table" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ac47a9f5b89127ada154ad504ab5f8eea37e3679ab63d52a694617d0f9e2018" +dependencies = [ + "crossterm", + "strum", + "strum_macros", +] + [[package]] name = "config" version = "0.11.0" @@ -680,12 +668,6 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "cpufeatures" version = "0.1.4" @@ -744,6 +726,31 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "crossterm" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ebde6a9dd5e331cd6c6f48253254d117642c31653baa475e394657c59c1f7d" +dependencies = [ + "bitflags", + "crossterm_winapi", + "libc", + "mio", + "parking_lot 0.11.1", + "signal-hook", + "signal-hook-mio", + "winapi 0.3.9", +] + +[[package]] +name = "crossterm_winapi" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6966607622438301997d3dac0d2f6e9a90c68bb6bc1785ea98456ab93c0507" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -780,28 +787,6 @@ dependencies = [ "subtle 2.4.0", ] -[[package]] -name = "csv" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" -dependencies = [ - "bstr", - "csv-core", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "csv-core" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" -dependencies = [ - "memchr", -] - [[package]] name = "ctr" version = "0.7.0" @@ -909,17 +894,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" -dependencies = [ - "libc", - "redox_users 0.3.5", - "winapi 0.3.9", -] - [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -927,7 +901,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", - "redox_users 0.4.0", + "redox_users", "winapi 0.3.9", ] @@ -2679,20 +2653,6 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" -[[package]] -name = "prettytable-rs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd04b170004fa2daccf418a7f8253aaf033c27760b5f225889024cf66d7ac2e" -dependencies = [ - "atty", - "csv", - "encode_unicode", - "lazy_static", - "term", - "unicode-width", -] - [[package]] name = "primitive-types" version = "0.9.0" @@ -3121,17 +3081,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "redox_users" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" -dependencies = [ - "getrandom 0.1.16", - "redox_syscall 0.1.57", - "rust-argon2", -] - [[package]] name = "redox_users" version = "0.4.0" @@ -3240,18 +3189,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "rust-argon2" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" -dependencies = [ - "base64 0.13.0", - "blake2b_simd", - "constant_time_eq", - "crossbeam-utils", -] - [[package]] name = "rust_decimal" version = "1.14.3" @@ -3632,10 +3569,31 @@ dependencies = [ ] [[package]] -name = "signal-hook-registry" -version = "1.3.0" +name = "signal-hook" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +checksum = "470c5a6397076fae0094aaf06a08e6ba6f37acb77d3b1b91ea92b4d6c8650c39" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29fd5867f1c4f2c5be079aee7a2adf1152ebb04a4bc4d341f504b7dece607ed4" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" dependencies = [ "libc", ] @@ -3905,6 +3863,7 @@ dependencies = [ "bitcoin", "bitcoin-harness", "bmrng", + "comfy-table", "config", "conquer-once", "curve25519-dalek-ng", @@ -3924,7 +3883,6 @@ dependencies = [ "monero-rpc", "pem", "port_check", - "prettytable-rs", "proptest", "qrcode", "rand 0.8.3", @@ -4010,17 +3968,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "term" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" -dependencies = [ - "byteorder", - "dirs", - "winapi 0.3.9", -] - [[package]] name = "terminal_size" version = "0.1.16" diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 46deee8a..08bd201e 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -19,6 +19,7 @@ bdk = "0.8" big-bytes = "1" bitcoin = { version = "0.26", features = [ "rand", "use-serde" ] } bmrng = "0.5" +comfy-table = "4.0.0" config = { version = "0.11", default-features = false, features = [ "toml" ] } conquer-once = "0.3" curve25519-dalek = { package = "curve25519-dalek-ng", version = "4" } @@ -34,7 +35,6 @@ miniscript = { version = "5", features = [ "serde" ] } monero = { version = "0.12", features = [ "serde_support" ] } monero-rpc = { path = "../monero-rpc" } pem = "0.8" -prettytable-rs = "0.8" proptest = "1" qrcode = "0.12" rand = "0.8" diff --git a/swap/src/bin/asb.rs b/swap/src/bin/asb.rs index 2fb470a9..16b47367 100644 --- a/swap/src/bin/asb.rs +++ b/swap/src/bin/asb.rs @@ -13,10 +13,10 @@ #![allow(non_snake_case)] use anyhow::{bail, Context, Result}; +use comfy_table::Table; use libp2p::core::multiaddr::Protocol; use libp2p::core::Multiaddr; use libp2p::Swarm; -use prettytable::{row, Table}; use std::env; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::sync::Arc; @@ -37,9 +37,6 @@ use swap::{asb, bitcoin, kraken, monero, tor}; use tracing::{debug, info, warn}; use tracing_subscriber::filter::LevelFilter; -#[macro_use] -extern crate prettytable; - const DEFAULT_WALLET_NAME: &str = "asb-wallet"; #[tokio::main] @@ -194,14 +191,13 @@ async fn main() -> Result<()> { Command::History => { let mut table = Table::new(); - table.add_row(row!["SWAP ID", "STATE"]); + table.set_header(vec!["SWAP ID", "STATE"]); for (swap_id, state) in db.all_alice()? { - table.add_row(row![swap_id, state]); + table.add_row(vec![swap_id.to_string(), state.to_string()]); } - // Print the table to stdout - table.printstd(); + println!("{}", table); } Command::WithdrawBtc { amount, address } => { let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?; diff --git a/swap/src/bin/swap.rs b/swap/src/bin/swap.rs index 80cbff7a..15c24a43 100644 --- a/swap/src/bin/swap.rs +++ b/swap/src/bin/swap.rs @@ -13,7 +13,7 @@ #![allow(non_snake_case)] use anyhow::{bail, Context, Result}; -use prettytable::{row, Table}; +use comfy_table::Table; use qrcode::render::unicode; use qrcode::QrCode; use std::cmp::min; @@ -38,9 +38,6 @@ use tracing::{debug, error, info, warn}; use url::Url; use uuid::Uuid; -#[macro_use] -extern crate prettytable; - #[tokio::main] async fn main() -> Result<()> { let Arguments { @@ -144,14 +141,13 @@ async fn main() -> Result<()> { let mut table = Table::new(); - table.add_row(row!["SWAP ID", "STATE"]); + table.set_header(vec!["SWAP ID", "STATE"]); for (swap_id, state) in db.all_bob()? { - table.add_row(row![swap_id, state]); + table.add_row(vec![swap_id.to_string(), state.to_string()]); } - // Print the table to stdout - table.printstd(); + println!("{}", table); } Command::Resume { swap_id,