diff --git a/Cargo.lock b/Cargo.lock index 8afd0d1cf..d43afaca8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -495,6 +495,22 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "config" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1b9d958c2b1368a663f05538fc1b5975adce1e19f435acceae987aceeeb369" +dependencies = [ + "lazy_static", + "nom", + "rust-ini", + "serde 1.0.127", + "serde-hjson", + "serde_json", + "toml 0.5.8", + "yaml-rust", +] + [[package]] name = "configure_me" version = "0.4.0" @@ -933,7 +949,8 @@ dependencies = [ "clap", "clap_generate", "colored", - "config", + "config 0.10.1", + "config 0.11.0", "configure_me", "configure_me_codegen", "dotenv", @@ -951,6 +968,7 @@ dependencies = [ "monero", "monero-rpc", "nix", + "ntest", "paste", "regex", "serde 1.0.127", @@ -1665,7 +1683,7 @@ checksum = "0c9bab278af135e56ad7fa62a0589680ba0de52c749bb865467fe09324d0b9bf" dependencies = [ "amplify", "clap", - "config", + "config 0.10.1", "env_logger", "internet2", "lightning_encoding", @@ -1802,6 +1820,47 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "ntest" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "984caf6c8aa869418ef88062fc685d07d50c04308e63f7eaff6a395b1f5aff33" +dependencies = [ + "ntest_proc_macro_helper", + "ntest_test_cases", + "ntest_timeout", +] + +[[package]] +name = "ntest_proc_macro_helper" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115562228962147ca51748d19446a4261535a7b6a7b5ff02681e527dcefc22f7" + +[[package]] +name = "ntest_test_cases" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03e3201148714c580c5cf1ef68b1ed4039203068193197834a43503164b8237" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ntest_timeout" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a870300c30d4224cb16022a4660fd8084d6cb4d29618563c3016b50cc757d1e7" +dependencies = [ + "ntest_proc_macro_helper", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -1977,6 +2036,15 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml 0.5.8", +] + [[package]] name = "proc-macro-error" version = "1.0.4" diff --git a/Cargo.toml b/Cargo.toml index 4c32cc64d..c3f67af2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ bech32 = { version = "0.7", optional = true } bitcoin = "0.27" bitcoincore-rpc = "0.14.0" chrono = "0.4" +config = "0.11" clap = { version = "3.0.0-beta.4", optional = true } colored = { version = "2", optional = true } configure_me = { version = "0.4", optional = true } @@ -127,6 +128,9 @@ version = "0.5.0-alpha.1" default-features = false features = ['peer'] +[dev-dependencies] +ntest = "0.7.3" + [build-dependencies.microservices] # path = '../ext/rust-internet2' version = "0.5.0-alpha.1" diff --git a/farcasterd.toml b/farcasterd.toml new file mode 100644 index 000000000..947c1bf28 --- /dev/null +++ b/farcasterd.toml @@ -0,0 +1,14 @@ +[syncers.mainnet] +electrum_server = "ssl://blockstream.info:700" +monero_daemon = "http://node.monerooutreach.org:18081" +monero_rpc_wallet = "http://localhost:18083" + +[syncers.testnet] +electrum_server = "ssl://blockstream.info:993" +monero_daemon = "http://stagenet.melo.tools:38081" +monero_rpc_wallet = "http://localhost:38083" + +[syncers.local] +electrum_server = "tcp://localhost:50001" +monero_daemon = "http://localhost:18081" +monero_rpc_wallet = "http://localhost:18083" diff --git a/shell/_farcasterd b/shell/_farcasterd index 10d1f3e7b..98b448208 100644 --- a/shell/_farcasterd +++ b/shell/_farcasterd @@ -17,19 +17,14 @@ _farcasterd() { _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ +'-c+[Path to the configuration file]: :_files' \ +'--config=[Path to the configuration file]: :_files' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ diff --git a/shell/_farcasterd.ps1 b/shell/_farcasterd.ps1 index da7b399cc..b2909fa65 100644 --- a/shell/_farcasterd.ps1 +++ b/shell/_farcasterd.ps1 @@ -22,19 +22,14 @@ Register-ArgumentCompleter -Native -CommandName 'farcasterd' -ScriptBlock { 'farcasterd' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') + [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') + [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') diff --git a/shell/_peerd b/shell/_peerd index 4e5e5fdff..10cc87316 100644 --- a/shell/_peerd +++ b/shell/_peerd @@ -24,22 +24,15 @@ _peerd() { '-o+[Overlay peer communications through different transport protocol]: :(tcp zmq http websocket smtp)' \ '--overlay=[Overlay peer communications through different transport protocol]: :(tcp zmq http websocket smtp)' \ '--peer-secret-key=[]' \ -'--wallet-token=[]' \ +'--token=[Token used to authentify calls]' \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ diff --git a/shell/_peerd.ps1 b/shell/_peerd.ps1 index c13262a94..bd60f5d9c 100644 --- a/shell/_peerd.ps1 +++ b/shell/_peerd.ps1 @@ -29,22 +29,15 @@ Register-ArgumentCompleter -Native -CommandName 'peerd' -ScriptBlock { [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Overlay peer communications through different transport protocol') [CompletionResult]::new('--overlay', 'overlay', [CompletionResultType]::ParameterName, 'Overlay peer communications through different transport protocol') [CompletionResult]::new('--peer-secret-key', 'peer-secret-key', [CompletionResultType]::ParameterName, 'peer-secret-key') - [CompletionResult]::new('--wallet-token', 'wallet-token', [CompletionResultType]::ParameterName, 'wallet-token') + [CompletionResult]::new('--token', 'token', [CompletionResultType]::ParameterName, 'Token used to authentify calls') [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') diff --git a/shell/_swap-cli b/shell/_swap-cli index 57d3941c0..fafbcea32 100644 --- a/shell/_swap-cli +++ b/shell/_swap-cli @@ -17,19 +17,12 @@ _swap-cli() { _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ @@ -55,19 +48,12 @@ _arguments "${_arguments_options[@]}" \ '--overlay=[Use overlay protocol (http, websocket etc)]' \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ @@ -80,19 +66,12 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ @@ -106,19 +85,12 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ @@ -132,19 +104,12 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ @@ -158,19 +123,12 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ @@ -183,19 +141,12 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ @@ -208,19 +159,12 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ @@ -248,19 +192,12 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-w[Accept Offer without validation]' \ '--without-validation[Accept Offer without validation]' \ '-h[Print help information]' \ @@ -278,19 +215,12 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ @@ -304,19 +234,12 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ diff --git a/shell/_swap-cli.ps1 b/shell/_swap-cli.ps1 index 4c454fac9..dafd26132 100644 --- a/shell/_swap-cli.ps1 +++ b/shell/_swap-cli.ps1 @@ -22,19 +22,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') @@ -62,19 +55,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { [CompletionResult]::new('--overlay', 'overlay', [CompletionResultType]::ParameterName, 'Use overlay protocol (http, websocket etc)') [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') @@ -86,19 +72,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli;connect' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') @@ -110,19 +89,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli;ping' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') @@ -134,19 +106,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli;info' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') @@ -158,19 +123,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli;peers' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') @@ -182,19 +140,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli;ls' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') @@ -206,19 +157,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli;make' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') @@ -230,19 +174,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli;take' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Accept Offer without validation') [CompletionResult]::new('--without-validation', 'without-validation', [CompletionResultType]::ParameterName, 'Accept Offer without validation') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') @@ -256,19 +193,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli;progress' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') @@ -280,19 +210,12 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock { 'swap-cli;help' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') diff --git a/shell/_swapd b/shell/_swapd index 9115c621a..0b2566c5d 100644 --- a/shell/_swapd +++ b/shell/_swapd @@ -17,26 +17,19 @@ _swapd() { _arguments "${_arguments_options[@]}" \ '-d+[Data directory path]: :_files -/' \ '--data-dir=[Data directory path]: :_files -/' \ -'-c+[Path to the configuration file]: :_files' \ -'--config=[Path to the configuration file]: :_files' \ '-T+[Use Tor]: :_hosts' \ '--tor-proxy=[Use Tor]: :_hosts' \ -'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ -'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \ +'-m+[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ +'--msg-socket=[ZMQ socket name/address to forward all incoming protocol messages]: :_files' \ '-x+[ZMQ socket name/address for daemon control interface]: :_files' \ '--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \ -'-n+[Blockchain to use]' \ -'--chain=[Blockchain to use]' \ -'--electrum-server=[Electrum server to use]' \ -'--monero-daemon=[Monero daemon to use]' \ -'--monero-rpc-wallet=[Monero rpc wallet to use]' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ '--version[Print version information]' \ '*-v[Set verbosity level]' \ '*--verbose[Set verbosity level]' \ -':swap-id -- Channel id:' \ +':swap-id -- Swap id:' \ ':public-offer -- Public offer to initiate swapd runtime:' \ ':trade-role -- Trade role of participant (Maker or Taker):' \ && ret=0 diff --git a/shell/_swapd.ps1 b/shell/_swapd.ps1 index d615840e7..c3d2c77a9 100644 --- a/shell/_swapd.ps1 +++ b/shell/_swapd.ps1 @@ -22,19 +22,12 @@ Register-ArgumentCompleter -Native -CommandName 'swapd' -ScriptBlock { 'swapd' { [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path') [CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file') [CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor') [CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor') - [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') - [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages') + [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') + [CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming protocol messages') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') [CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface') - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use') - [CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use') - [CompletionResult]::new('--monero-daemon', 'monero-daemon', [CompletionResultType]::ParameterName, 'Monero daemon to use') - [CompletionResult]::new('--monero-rpc-wallet', 'monero-rpc-wallet', [CompletionResultType]::ParameterName, 'Monero rpc wallet to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') diff --git a/shell/farcasterd.bash b/shell/farcasterd.bash index 22ea94426..cb47347a1 100644 --- a/shell/farcasterd.bash +++ b/shell/farcasterd.bash @@ -20,7 +20,7 @@ _farcasterd() { case "${cmd}" in farcasterd) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x -c --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket --config " if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -35,14 +35,6 @@ _farcasterd() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -67,23 +59,11 @@ _farcasterd() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) + --config) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --monero-rpc-wallet) + -c) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; diff --git a/shell/peerd.bash b/shell/peerd.bash index bf020b889..494030201 100644 --- a/shell/peerd.bash +++ b/shell/peerd.bash @@ -20,7 +20,7 @@ _peerd() { case "${cmd}" in peerd) - opts=" -h -V -L -C -p -o -d -c -v -T -m -x -n --help --version --listen --connect --port --overlay --peer-secret-key --wallet-token --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -L -C -p -o -d -v -T -m -x --help --version --listen --connect --port --overlay --peer-secret-key --token --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -63,7 +63,7 @@ _peerd() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --wallet-token) + --token) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; @@ -75,14 +75,6 @@ _peerd() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -107,26 +99,6 @@ _peerd() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; diff --git a/shell/swap-cli.bash b/shell/swap-cli.bash index e9b7e28c3..6fb04aa1d 100644 --- a/shell/swap-cli.bash +++ b/shell/swap-cli.bash @@ -50,7 +50,7 @@ _swap-cli() { case "${cmd}" in swap__cli) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet listen connect ping info peers ls make take progress help" + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket listen connect ping info peers ls make take progress help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -65,14 +65,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -97,26 +89,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -126,7 +98,7 @@ _swap-cli() { ;; swap__cli__connect) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -141,14 +113,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -173,26 +137,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -201,7 +145,7 @@ _swap-cli() { return 0 ;; swap__cli__help) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -216,14 +160,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -248,26 +184,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -276,7 +192,7 @@ _swap-cli() { return 0 ;; swap__cli__info) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -291,14 +207,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -323,26 +231,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -351,7 +239,7 @@ _swap-cli() { return 0 ;; swap__cli__listen) - opts=" -i -p -o -h -V -d -c -v -T -m -x -n --ip --port --overlay --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -i -p -o -h -V -d -v -T -m -x --ip --port --overlay --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -390,14 +278,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -422,26 +302,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -450,7 +310,7 @@ _swap-cli() { return 0 ;; swap__cli__ls) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -465,14 +325,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -497,26 +349,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -525,7 +357,7 @@ _swap-cli() { return 0 ;; swap__cli__make) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -540,14 +372,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -572,26 +396,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -600,7 +404,7 @@ _swap-cli() { return 0 ;; swap__cli__peers) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -615,14 +419,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -647,26 +443,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -675,7 +451,7 @@ _swap-cli() { return 0 ;; swap__cli__ping) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -690,14 +466,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -722,26 +490,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -750,7 +498,7 @@ _swap-cli() { return 0 ;; swap__cli__progress) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -765,14 +513,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -797,26 +537,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; @@ -825,7 +545,7 @@ _swap-cli() { return 0 ;; swap__cli__take) - opts=" -w -h -V -d -c -v -T -m -x -n --without-validation --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -w -h -V -d -v -T -m -x --without-validation --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -840,14 +560,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -872,26 +584,6 @@ _swap-cli() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; diff --git a/shell/swapd.bash b/shell/swapd.bash index 9db77e38e..a01cdc55b 100644 --- a/shell/swapd.bash +++ b/shell/swapd.bash @@ -20,7 +20,7 @@ _swapd() { case "${cmd}" in swapd) - opts=" -h -V -d -c -v -T -m -x -n --help --version --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --electrum-server --monero-daemon --monero-rpc-wallet " + opts=" -h -V -d -v -T -m -x --help --version --data-dir --verbose --tor-proxy --msg-socket --ctl-socket " if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -35,14 +35,6 @@ _swapd() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -c) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --tor-proxy) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -67,26 +59,6 @@ _swapd() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --chain) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -n) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --electrum-server) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-daemon) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --monero-rpc-wallet) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; *) COMPREPLY=() ;; diff --git a/src/bin/farcasterd.rs b/src/bin/farcasterd.rs index a752af791..18e0ebd18 100644 --- a/src/bin/farcasterd.rs +++ b/src/bin/farcasterd.rs @@ -35,31 +35,35 @@ use bitcoin::secp256k1::rand::RngCore; use clap::Clap; -use farcaster_node::Config; +use farcaster_node::ServiceConfig; use farcaster_node::{ + config::parse_config, farcasterd::{self, Opts}, rpc::request::Token, }; -fn main() { - println!("farcasterd: farcaster node management microservice"); - +fn main() -> Result<(), config::ConfigError> { let mut opts = Opts::parse(); trace!("Command-line arguments: {:?}", &opts); opts.process(); trace!("Processed arguments: {:?}", &opts); - let config: Config = opts.shared.clone().into(); - trace!("Daemon configuration: {:?}", &config); - debug!("MSG RPC socket {}", &config.msg_endpoint); - debug!("CTL RPC socket {}", &config.ctl_endpoint); + let service_config: ServiceConfig = opts.shared.clone().into(); + trace!("Daemon configuration: {:#?}", &service_config); + debug!("MSG RPC socket {}", &service_config.msg_endpoint); + debug!("CTL RPC socket {}", &service_config.ctl_endpoint); + + debug!("Config file path: {}", &opts.config); + let config = parse_config(&opts.config)?; + debug!("Configuration: {:#?}", &config); + // Generate runtime token let mut dest = [0u8; 16]; thread_rng().fill_bytes(&mut dest); - let wallet_token = Token(dest.to_hex()); + let token = Token(dest.to_hex()); debug!("Starting runtime ..."); - farcasterd::run(config, wallet_token).expect("Error running farcasterd runtime"); + farcasterd::run(service_config, config, opts, token).expect("Error running farcasterd runtime"); unreachable!() } diff --git a/src/bin/peerd.rs b/src/bin/peerd.rs index d8eb6315f..a7408e5e3 100644 --- a/src/bin/peerd.rs +++ b/src/bin/peerd.rs @@ -103,7 +103,8 @@ use std::time::Duration; use bitcoin::secp256k1::PublicKey; use farcaster_node::peerd::{self, Opts}; -use farcaster_node::{Config, LogStyle}; +use farcaster_node::LogStyle; +use farcaster_node::ServiceConfig; use internet2::{session, FramingProtocol, NodeAddr, RemoteNodeAddr, RemoteSocketAddr}; use microservices::peer::PeerConnection; @@ -156,17 +157,15 @@ impl From for PeerSocket { } fn main() { - println!("peerd: lightning peer network connection microservice"); - let mut opts = Opts::parse(); trace!("Command-line arguments: {:?}", &opts); opts.process(); trace!("Processed arguments: {:?}", &opts); - let config: Config = opts.shared.clone().into(); - trace!("Daemon configuration: {:?}", &config); - debug!("MSG RPC socket {}", &config.msg_endpoint); - debug!("CTL RPC socket {}", &config.ctl_endpoint); + let service_config: ServiceConfig = opts.shared.clone().into(); + trace!("Daemon configuration: {:#?}", &service_config); + debug!("MSG RPC socket {}", &service_config.msg_endpoint); + debug!("CTL RPC socket {}", &service_config.ctl_endpoint); /* use self::internal::ResultExt; @@ -256,7 +255,7 @@ fn main() { debug!("Starting runtime ..."); peerd::run( - config, + service_config, connection, id, local_id, diff --git a/src/bin/swap-cli.rs b/src/bin/swap-cli.rs index f5d2211aa..ef8df27c8 100644 --- a/src/bin/swap-cli.rs +++ b/src/bin/swap-cli.rs @@ -21,23 +21,22 @@ use clap::Clap; use farcaster_node::cli::Opts; use farcaster_node::rpc::Client; -use farcaster_node::{Config, LogStyle}; +use farcaster_node::LogStyle; +use farcaster_node::ServiceConfig; use microservices::shell::Exec; fn main() { - println!("swap-cli: command-line tool for working with Farcaster node"); - let mut opts = Opts::parse(); trace!("Command-line arguments: {:?}", &opts); opts.process(); trace!("Processed arguments: {:?}", &opts); - let config: Config = opts.shared.clone().into(); - trace!("Tool configuration: {:?}", &config); - debug!("MSG RPC socket {}", &config.msg_endpoint); - debug!("CTL RPC socket {}", &config.ctl_endpoint); + let service_config: ServiceConfig = opts.shared.clone().into(); + trace!("Daemon configuration: {:#?}", &service_config); + debug!("MSG RPC socket {}", &service_config.msg_endpoint); + debug!("CTL RPC socket {}", &service_config.ctl_endpoint); - let mut client = Client::with(config, opts.shared.chain).expect("Error initializing client"); + let mut client = Client::with(service_config).expect("Error initializing client"); trace!("Executing command: {:?}", opts.command); opts.command diff --git a/src/bin/swapd.rs b/src/bin/swapd.rs index f8925d6e7..ec79477b7 100644 --- a/src/bin/swapd.rs +++ b/src/bin/swapd.rs @@ -32,20 +32,18 @@ extern crate log; use clap::Clap; use farcaster_node::swapd::{self, Opts}; -use farcaster_node::Config; +use farcaster_node::ServiceConfig; fn main() { - println!("swapd: farcaster swap microservice"); - let mut opts = Opts::parse(); trace!("Command-line arguments: {:?}", &opts); opts.process(); trace!("Processed arguments: {:?}", &opts); - let config: Config = opts.shared.clone().into(); - trace!("Daemon configuration: {:?}", &config); - debug!("MSG RPC socket {}", &config.msg_endpoint); - debug!("CTL RPC socket {}", &config.ctl_endpoint); + let service_config: ServiceConfig = opts.shared.clone().into(); + trace!("Daemon configuration: {:#?}", &service_config); + debug!("MSG RPC socket {}", &service_config.msg_endpoint); + debug!("CTL RPC socket {}", &service_config.ctl_endpoint); /* use self::internal::ResultExt; @@ -58,9 +56,8 @@ fn main() { debug!("Starting runtime ..."); swapd::run( - config, + service_config, opts.swap_id, - opts.shared.chain, opts.public_offer, opts.trade_role, ) diff --git a/src/bin/syncerd.rs b/src/bin/syncerd.rs index 2875039c6..dadb8ead8 100644 --- a/src/bin/syncerd.rs +++ b/src/bin/syncerd.rs @@ -32,29 +32,20 @@ extern crate log; use clap::Clap; use farcaster_node::syncerd::{self, Opts}; -use farcaster_node::Config; +use farcaster_node::ServiceConfig; fn main() { - println!("syncerd: blockchain tasks management microservice"); - let mut opts = Opts::parse(); trace!("Command-line arguments: {:?}", &opts); opts.process(); trace!("Processed arguments: {:?}", &opts); - let config: Config = opts.shared.clone().into(); - trace!("Daemon configuration: {:?}", &config); - debug!("MSG RPC socket {}", &config.msg_endpoint); - debug!("CTL RPC socket {}", &config.ctl_endpoint); + let service_config: ServiceConfig = opts.shared.clone().into(); + trace!("Daemon configuration: {:#?}", &service_config); + debug!("MSG RPC socket {}", &service_config.msg_endpoint); + debug!("CTL RPC socket {}", &service_config.ctl_endpoint); debug!("Starting runtime ..."); - let syncer_servers = syncerd::SyncerServers { - electrum_server: opts.shared.electrum_server, - monero_daemon: opts.shared.monero_daemon, - monero_rpc_wallet: opts.shared.monero_rpc_wallet, - }; - syncerd::run(config, opts.coin, opts.network, syncer_servers) - .expect("Error running syncerd runtime"); - + syncerd::run(service_config, opts).expect("Error running syncerd runtime"); unreachable!() } diff --git a/src/bin/walletd.rs b/src/bin/walletd.rs index b60cf270b..3b0568fb8 100644 --- a/src/bin/walletd.rs +++ b/src/bin/walletd.rs @@ -24,14 +24,14 @@ missing_docs )] -//! Main executable for walletd: farcaster node wallet microservice. +//! Main executable for walletd: farcaster node wallet microservice. #[macro_use] extern crate log; use clap::Clap; -use farcaster_node::Config; +use farcaster_node::ServiceConfig; use farcaster_node::{ rpc::request::Token, walletd::{self, NodeSecrets, Opts}, @@ -43,18 +43,18 @@ fn main() { opts.process(); trace!("Processed arguments: {:?}", &opts); - let config: Config = opts.shared.clone().into(); - trace!("Daemon configuration: {:?}", &config); - debug!("MSG RPC socket {}", &config.msg_endpoint); - debug!("CTL RPC socket {}", &config.ctl_endpoint); + let service_config: ServiceConfig = opts.shared.clone().into(); + trace!("Daemon configuration: {:#?}", &service_config); + debug!("MSG RPC socket {}", &service_config.msg_endpoint); + debug!("CTL RPC socket {}", &service_config.ctl_endpoint); - let wallet_token = Token(opts.token.wallet_token); + let wallet_token = Token(opts.wallet_token.token); let node_secrets = NodeSecrets::new(opts.key_opts.key_file.clone()); let node_id = node_secrets.node_id(); debug!("Starting runtime ..."); - walletd::run(config, wallet_token, node_secrets, node_id) + walletd::run(service_config, wallet_token, node_secrets, node_id) .expect("Error running walletd runtime"); unreachable!() diff --git a/src/config.rs b/src/config.rs index 7a5490bab..04528d6ef 100644 --- a/src/config.rs +++ b/src/config.rs @@ -12,35 +12,102 @@ // along with this software. // If not, see . +use crate::Error; +use farcaster_core::blockchain::Network; use internet2::NodeAddr; -use lnpbp::chain::Chain; +use std::path::Path; + +use serde::{Deserialize, Serialize}; + +pub const FARCASTER_MAINNET_ELECTRUM_SERVER: &str = "ssl://blockstream.info:700"; +pub const FARCASTER_MAINNET_MONERO_DAEMON: &str = "http://node.monerooutreach.org:18081"; +pub const FARCASTER_MAINNET_MONERO_RPC_WALLET: &str = "http://localhost:18083"; + +pub const FARCASTER_TESTNET_ELECTRUM_SERVER: &str = "ssl://blockstream.info:993"; +pub const FARCASTER_TESTNET_MONERO_DAEMON: &str = "http://stagenet.melo.tools:38081"; +pub const FARCASTER_TESTNET_MONERO_RPC_WALLET: &str = "http://localhost:38083"; #[cfg(feature = "shell")] use crate::opts::Opts; -/// Final configuration resulting from data contained in config file environment -/// variables and command-line options. For security reasons node key is kept -/// separately. -#[derive(Clone, PartialEq, Eq, Debug, Display)] -#[display(Debug)] +#[derive(Deserialize, Serialize, Debug, Clone)] +#[serde(crate = "serde_crate")] pub struct Config { - /// Bitcoin blockchain to use (mainnet, testnet, signet, liquid etc) - pub chain: Chain, - - /// ZMQ socket for lightning peer network message bus - pub msg_endpoint: NodeAddr, + /// Syncer configuration + pub syncers: Option, +} - /// ZMQ socket for internal service control bus - pub ctl_endpoint: NodeAddr, +impl Config { + pub fn get_syncer_servers(&self, network: Network) -> Option { + match network { + Network::Mainnet => self.syncers.as_ref()?.mainnet.clone(), + Network::Testnet => self.syncers.as_ref()?.testnet.clone(), + Network::Local => self.syncers.as_ref()?.local.clone(), + } + } } -#[cfg(feature = "shell")] -impl From for Config { - fn from(opts: Opts) -> Self { +impl Default for Config { + fn default() -> Self { Config { - chain: opts.chain, - msg_endpoint: opts.msg_socket.into(), - ctl_endpoint: opts.ctl_socket.into(), + syncers: Some(SyncersConfig::default()), } } } + +#[derive(Deserialize, Serialize, Debug, Clone)] +#[serde(crate = "serde_crate")] +pub struct SyncersConfig { + /// Mainnet syncer configuration + pub mainnet: Option, + + /// Testnet syncer configuration + pub testnet: Option, + + /// Local syncer configuration + pub local: Option, +} + +#[derive(Deserialize, Serialize, Default, Debug, Clone)] +#[serde(crate = "serde_crate")] +pub struct SyncerServers { + /// Electrum server to use + pub electrum_server: String, + + /// Monero daemon to use + pub monero_daemon: String, + + /// Monero rpc wallet to use + pub monero_rpc_wallet: String, +} + +impl Default for SyncersConfig { + fn default() -> Self { + SyncersConfig { + mainnet: Some(SyncerServers { + electrum_server: FARCASTER_MAINNET_ELECTRUM_SERVER.into(), + monero_daemon: FARCASTER_MAINNET_MONERO_DAEMON.into(), + monero_rpc_wallet: FARCASTER_MAINNET_MONERO_RPC_WALLET.into(), + }), + testnet: Some(SyncerServers { + electrum_server: FARCASTER_TESTNET_ELECTRUM_SERVER.into(), + monero_daemon: FARCASTER_TESTNET_MONERO_DAEMON.into(), + monero_rpc_wallet: FARCASTER_TESTNET_MONERO_RPC_WALLET.into(), + }), + local: None, + } + } +} + +pub fn parse_config(path: &str) -> Result { + if Path::new(path).exists() { + let config_file = path; + debug!("Loading config file at: {}", &config_file); + let mut settings = config::Config::default(); + settings.merge(config::File::with_name(config_file).required(true))?; + settings.try_into::() + } else { + debug!("No configuration file found, generate default config"); + Ok(Config::default()) + } +} diff --git a/src/error.rs b/src/error.rs index fa2a11f82..9360bcd9a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -36,6 +36,11 @@ pub enum Error { /// Wallet node errors: {0} Wallet(String), + + /// Config errors: {0} + #[from(config::ConfigError)] + Config(config::ConfigError), + /// I/O error: {0:?} #[from(io::Error)] Io(IoError), @@ -83,6 +88,7 @@ pub enum Error { /// Syncer #[display(inner)] + #[from(SyncerError)] Syncer(SyncerError), /// BitcoinHashes @@ -94,15 +100,20 @@ pub enum Error { pub enum SyncerError { #[display(inner)] Electrum(electrum_client::Error), + #[display(inner)] NoTxsOnAddress, + #[display(inner)] ScriptAlreadyRegistered, + #[display("syncer creating error")] UnknownNetwork, + #[display(inner)] MoneroRpc(anyhow::Error), - #[display(inner)] + + #[display("Invalid configuration. Missing or malformed")] InvalidConfig, #[display("height did not increment")] NoIncrementToHeight, diff --git a/src/farcasterd/opts.rs b/src/farcasterd/opts.rs index 0611a6be1..5fecf3b0a 100644 --- a/src/farcasterd/opts.rs +++ b/src/farcasterd/opts.rs @@ -12,7 +12,9 @@ // along with this software. // If not, see . -use clap::{AppSettings, Clap}; +use clap::{AppSettings, Clap, ValueHint}; + +pub const FARCASTER_CONFIG: &str = "{data_dir}/farcasterd.toml"; /// Farcaster node management daemon; part of Farcaster Node /// @@ -31,10 +33,22 @@ pub struct Opts { /// command-line args or environment variables #[clap(flatten)] pub shared: crate::opts::Opts, + + /// Path to the configuration file. + #[clap( + short, + long, + global = true, + env = "FARCASTER_CONFIG", + default_value = FARCASTER_CONFIG, + value_hint = ValueHint::FilePath + )] + pub config: String, } impl Opts { pub fn process(&mut self) { self.shared.process(); + self.shared.process_dir(&mut self.config); } } diff --git a/src/farcasterd/runtime.rs b/src/farcasterd/runtime.rs index 77246f27c..b98c0224d 100644 --- a/src/farcasterd/runtime.rs +++ b/src/farcasterd/runtime.rs @@ -24,6 +24,8 @@ use crate::{ Senders, }; use amplify::Wrapper; +use clap::Clap; +use clap::IntoApp; use request::{Commit, Params}; use std::io; use std::net::SocketAddr; @@ -56,9 +58,10 @@ use microservices::rpc::Failure; use farcaster_core::{blockchain::Network, negotiation::PublicOfferId, swap::SwapId}; +use crate::farcasterd::Opts; use crate::rpc::request::{GetKeys, IntoProgressOrFalure, Msg, NodeInfo, OptionDetails}; use crate::rpc::{request, Request, ServiceBus}; -use crate::{Config, Error, LogStyle, Service, ServiceId}; +use crate::{Config, Error, LogStyle, Service, ServiceConfig, ServiceId}; use farcaster_core::{ blockchain::FeePriority, @@ -77,8 +80,13 @@ use farcaster_core::{ use std::str::FromStr; -pub fn run(config: Config, wallet_token: Token) -> Result<(), Error> { - let _walletd = launch("walletd", &["--wallet-token", &wallet_token.to_string()])?; +pub fn run( + service_config: ServiceConfig, + config: Config, + _opts: Opts, + wallet_token: Token, +) -> Result<(), Error> { + let _walletd = launch("walletd", &["--token", &wallet_token.to_string()])?; let runtime = Runtime { identity: ServiceId::Farcasterd, listens: none!(), @@ -99,10 +107,11 @@ pub fn run(config: Config, wallet_token: Token) -> Result<(), Error> { consumed_offers: none!(), progress: none!(), stats: none!(), + config, }; let broker = true; - Service::run(config, runtime, broker) + Service::run(service_config, runtime, broker) } pub struct Runtime { @@ -125,6 +134,7 @@ pub struct Runtime { syncer_clients: HashMap<(Coin, Network), HashSet>, progress: HashMap>, stats: Stats, + config: Config, } struct Stats { @@ -219,14 +229,17 @@ impl Runtime { if !xs.is_empty() { Some(((coin, network), xs)) } else { - let service_id = ServiceId::Syncer(coin.clone(), network.clone()); + let service_id = ServiceId::Syncer(coin, network); info!("Terminating syncer: {:?}", service_id); - if let Ok(_) = senders.send_to( - ServiceBus::Ctl, - identity.clone(), - service_id, - Request::Terminate, - ) { + if senders + .send_to( + ServiceBus::Ctl, + identity.clone(), + service_id, + Request::Terminate, + ) + .is_ok() + { None } else { Some(((coin, network), xs)) @@ -392,10 +405,10 @@ impl Runtime { } } ServiceId::Syncer(coin, network) - if !self.syncer_services.contains_key(&(coin.clone(), *network)) => + if !self.syncer_services.contains_key(&(*coin, *network)) => { self.syncer_services - .insert((coin.clone(), *network), source.clone()); + .insert((*coin, *network), source.clone()); } _ => { // Ignoring the rest of daemon/client types @@ -422,6 +435,7 @@ impl Runtime { Coin::Bitcoin, *network, swapid, + &self.config, )?; syncers_up( &self.syncer_services, @@ -429,6 +443,7 @@ impl Runtime { Coin::Monero, *network, swapid, + &self.config, )?; // FIXME msgs should go to walletd? senders.send_to( @@ -463,6 +478,7 @@ impl Runtime { Coin::Bitcoin, *network, swapid, + &self.config, )?; syncers_up( &self.syncer_services, @@ -470,6 +486,7 @@ impl Runtime { Coin::Monero, *network, swapid, + &self.config, )?; // FIXME msgs should go to walletd? senders.send_to( @@ -553,8 +570,7 @@ impl Runtime { .ok_or(internet2::presentation::Error::InvalidEndpoint)? .into(); - self.consumed_offers - .insert((public_offer.id(), swap_id.clone())); + self.consumed_offers.insert((public_offer.id(), swap_id)); launch_swapd( self, peer, @@ -969,7 +985,7 @@ impl Runtime { &port.to_string(), "--peer-secret-key", &format!("{:x}", sk), - "--wallet-token", + "--token", &self.wallet_token.clone().to_string(), ], )?; @@ -1005,8 +1021,8 @@ impl Runtime { &node_addr.to_string(), "--peer-secret-key", &format!("{:x}", sk), - "--wallet-token", - &format!("{}", self.wallet_token.clone()), + "--token", + &self.wallet_token.clone().to_string(), ], ); @@ -1060,11 +1076,19 @@ fn syncers_up( coin: Coin, network: Network, swap_id: SwapId, + config: &Config, ) -> Result<(), Error> { - let k = (coin.clone(), network); + let k = (coin, network); if !services.contains_key(&k) { - launch("syncerd", &[coin.to_string(), network.to_string()])?; - clients.insert(k.clone(), none!()); + let mut args = vec![ + "--coin".to_string(), + coin.to_string(), + "--network".to_string(), + network.to_string(), + ]; + args.append(&mut syncer_servers_args(config, coin, network)?); + launch("syncerd", args)?; + clients.insert(k, none!()); } if let Some(xs) = clients.get_mut(&k) { xs.insert(swap_id); @@ -1120,10 +1144,31 @@ fn launch_swapd( Ok(msg) } +/// Return the list of needed arguments for a syncer given a config and a network. +/// This function only register the minimal set of URLs needed for the blockchain to work. +fn syncer_servers_args(config: &Config, coin: Coin, net: Network) -> Result, Error> { + match config.get_syncer_servers(net) { + Some(servers) => match coin { + Coin::Bitcoin => Ok(vec![ + "--electrum-server".to_string(), + servers.electrum_server, + ]), + Coin::Monero => Ok(vec![ + "--monero-daemon".to_string(), + servers.monero_daemon, + "--monero-rpc-wallet".to_string(), + servers.monero_rpc_wallet, + ]), + }, + None => Err(SyncerError::InvalidConfig.into()), + } +} + pub fn launch( name: &str, args: impl IntoIterator>, ) -> io::Result { + let app = Opts::into_app(); let mut bin_path = std::env::current_exe().map_err(|err| { error!("Unable to detect binary directory: {}", err); err @@ -1142,9 +1187,47 @@ pub fn launch( let mut cmd = process::Command::new(bin_path); - cmd.args(std::env::args().skip(1)).args(args); + // Forwarded shared options from farcasterd to launched microservices + // Cannot use value_of directly because of default values + let matches = app.get_matches(); + + // Set verbosity to same level + let verbose = matches.occurrences_of("verbose"); + if verbose > 0 { + cmd.args(&[&format!( + "-{}", + (0..verbose).map(|_| "v").collect::() + )]); + } + + if let Some(d) = &matches.value_of("data-dir") { + cmd.args(&["-d", d]); + } + + if let Some(m) = &matches.value_of("msg-socket") { + cmd.args(&["-m", m]); + } + + if let Some(x) = &matches.value_of("ctl-socket") { + cmd.args(&["-x", x]); + } + + // Forward tor proxy argument + let parsed = Opts::parse(); + match &parsed.shared.tor_proxy { + Some(None) => { + cmd.args(&["-T"]); + } + Some(Some(val)) => { + cmd.args(&["-T", &format!("{}", val)]); + } + _ => (), + } + + // Given specialized args in launch + cmd.args(args); - trace!("Executing `{:?}`", cmd); + debug!("Executing `{:?}`", cmd); cmd.spawn().map_err(|err| { error!("Error launching {}: {}", name, err); err diff --git a/src/lib.rs b/src/lib.rs index 8fcacd04f..b2d42900f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,7 +51,7 @@ extern crate serde_with; #[cfg(feature = "cli")] pub mod cli; #[cfg(feature = "_rpc")] -mod config; +pub mod config; pub mod error; #[cfg(feature = "shell")] pub mod opts; @@ -72,7 +72,9 @@ pub mod syncerd; pub mod walletd; #[cfg(feature = "_rpc")] -pub use config::Config; +pub use crate::config::Config; +#[cfg(feature = "_rpc")] +pub use crate::service::ServiceConfig; pub use error::Error; #[cfg(feature = "_rpc")] pub use service::{CtlServer, LogStyle, Senders, Service, ServiceId, TryToServiceId}; diff --git a/src/opts.rs b/src/opts.rs index 615ac6368..049bb769f 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -13,71 +13,53 @@ // If not, see . use clap::{Clap, ValueHint}; -use std::fs; use std::net::SocketAddr; use std::path::PathBuf; +use std::str::FromStr; +use std::{fs, io}; use internet2::PartialNodeAddr; -use lnpbp::chain::Chain; use microservices::shell::LogLevel; #[cfg(any(target_os = "linux"))] -pub const FARCASTER_NODE_DATA_DIR: &str = "~/.farcaster_node"; +pub const FARCASTER_DATA_DIR: &str = "~/.farcaster"; #[cfg(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))] -pub const FARCASTER_NODE_DATA_DIR: &str = "~/.farcaster_node"; +pub const FARCASTER_DATA_DIR: &str = "~/.farcaster"; #[cfg(target_os = "macos")] -pub const FARCASTER_NODE_DATA_DIR: &str = "~/Library/Application Support/FARCASTER Node"; +pub const FARCASTER_DATA_DIR: &str = "~/Library/Application Support/Farcaster"; #[cfg(target_os = "windows")] -pub const FARCASTER_NODE_DATA_DIR: &str = "~\\AppData\\Local\\FARCASTER Node"; +pub const FARCASTER_DATA_DIR: &str = "~\\AppData\\Local\\Farcaster"; #[cfg(target_os = "ios")] -pub const FARCASTER_NODE_DATA_DIR: &str = "~/Documents"; +pub const FARCASTER_DATA_DIR: &str = "~/Documents"; #[cfg(target_os = "android")] -pub const FARCASTER_NODE_DATA_DIR: &str = "."; +pub const FARCASTER_DATA_DIR: &str = "."; -pub const FARCASTER_NODE_MSG_SOCKET_NAME: &str = "lnpz:{data_dir}/msg.rpc?api=esb"; -pub const FARCASTER_NODE_CTL_SOCKET_NAME: &str = "lnpz:{data_dir}/ctl.rpc?api=esb"; +pub const FARCASTER_MSG_SOCKET_NAME: &str = "lnpz:{data_dir}/msg.rpc?api=esb"; +pub const FARCASTER_CTL_SOCKET_NAME: &str = "lnpz:{data_dir}/ctl.rpc?api=esb"; -pub const FARCASTER_NODE_CONFIG: &str = "{data_dir}/farcaster.toml"; - -pub const FARCASTER_NODE_TOR_PROXY: &str = "127.0.0.1:9050"; -pub const FARCASTER_NODE_KEY_FILE: &str = "{data_dir}/key.dat"; - -pub const ELECTRUM_SERVER: &str = "tcp://localhost:50001"; -pub const MONERO_DAEMON: &str = "http://node.monerooutreach.org:18081"; -pub const MONERO_RPC_WALLET: &str = "http://localhost:18083"; +pub const FARCASTER_TOR_PROXY: &str = "127.0.0.1:9050"; +pub const FARCASTER_KEY_FILE: &str = "{data_dir}/key.dat"; /// Shared options used by different binaries #[derive(Clap, Clone, PartialEq, Eq, Debug)] pub struct Opts { /// Data directory path /// - /// Path to the directory that contains FARCASTER Node data, and where ZMQ - /// RPC socket files are located + /// Path to the directory that contains Farcaster Node data, and where ZMQ + /// RPC socket files are located. #[clap( short, long, global = true, - default_value = FARCASTER_NODE_DATA_DIR, - env = "FARCASTER_NODE_DATA_DIR", + default_value = FARCASTER_DATA_DIR, + env = "FARCASTER_DATA_DIR", value_hint = ValueHint::DirPath )] pub data_dir: PathBuf, - /// Path to the configuration file. - /// - /// NB: Command-line options override configuration file values. - #[clap( - short, - long, - global = true, - env = "FARCASTER_NODE_CONFIG", - value_hint = ValueHint::FilePath - )] - pub config: Option, - /// Set verbosity level /// - /// Can be used multiple times to increase verbosity + /// Can be used multiple times to increase verbosity. #[clap(short, long, global = true, parse(from_occurrences))] pub verbose: u8, @@ -92,82 +74,56 @@ pub struct Opts { long, alias = "tor", global = true, - env = "FARCASTER_NODE_TOR_PROXY", + env = "FARCASTER_TOR_PROXY", value_hint = ValueHint::Hostname )] pub tor_proxy: Option>, - /// ZMQ socket name/address to forward all incoming lightning messages + /// ZMQ socket name/address to forward all incoming protocol messages /// - /// Internal interface for transmitting P2P lightning network messages. - /// Defaults to `msg.rpc` file inside `--data-dir` directory, unless - /// `--use-threads` is specified; in that cases uses in-memory - /// communication protocol. + /// Internal interface for transmitting P2P network messages. Defaults + /// to `msg.rpc` file inside `--data-dir` directory. #[clap( short = 'm', long, global = true, - env = "FARCASTER_NODE_MSG_SOCKET", + env = "FARCASTER_MSG_SOCKET", value_hint = ValueHint::FilePath, - default_value = FARCASTER_NODE_MSG_SOCKET_NAME + default_value = FARCASTER_MSG_SOCKET_NAME )] pub msg_socket: PartialNodeAddr, /// ZMQ socket name/address for daemon control interface /// - /// Internal interface for control PRC protocol communications - /// Defaults to `ctl.rpc` file inside `--data-dir` directory, unless - /// `--use-threads` is specified; in that cases uses in-memory - /// communication protocol. + /// Internal interface for control PRC protocol communications. Defaults + /// to `ctl.rpc` file inside `--data-dir` directory. #[clap( short = 'x', long, global = true, - env = "FARCASTER_NODE_CTL_SOCKET", + env = "FARCASTER_CTL_SOCKET", value_hint = ValueHint::FilePath, - default_value = FARCASTER_NODE_CTL_SOCKET_NAME + default_value = FARCASTER_CTL_SOCKET_NAME )] pub ctl_socket: PartialNodeAddr, +} - /// Blockchain to use - #[clap( - short = 'n', - long, - global = true, - alias = "network", - default_value = "testnet", - env = "FARCASTER_NODE_NETWORK" - )] - // TODO: Put it back to `signet` default network once rust-bitcoin will - // release signet support - pub chain: Chain, - - /// Electrum server to use - #[clap( - long, - global = true, - default_value = "tcp://localhost:50001", - env = "ELECTRUM_SERVER" - )] - pub electrum_server: String, +/// Token used in services +#[derive(Clap, Clone, PartialEq, Eq, Debug)] +pub struct TokenString { + /// Token used to authentify calls + #[clap(long, env = "FARCASTER_TOKEN")] + pub token: String, +} - /// Monero daemon to use - #[clap( - long, - global = true, - default_value = "http://node.monerooutreach.org:18081", - env = "MONERO_DAEMON" - )] - pub monero_daemon: String, +impl FromStr for TokenString { + type Err = io::Error; - /// Monero rpc wallet to use - #[clap( - long, - global = true, - default_value = "http://localhost:18083", - env = "MONERO_RPC_WALLET" - )] - pub monero_rpc_wallet: String, + fn from_str(s: &str) -> Result { + Ok(TokenString { + token: s.to_string(), + }) + } } impl Opts { diff --git a/src/peerd/opts.rs b/src/peerd/opts.rs index 522d9346d..d947daa7e 100644 --- a/src/peerd/opts.rs +++ b/src/peerd/opts.rs @@ -13,8 +13,9 @@ // If not, see . use clap::{AppSettings, ArgGroup, Clap, ValueHint}; -use std::{io, net::IpAddr}; +use std::net::IpAddr; +use crate::opts::TokenString; use internet2::{FramingProtocol, LocalNode, RemoteNodeAddr}; use strict_encoding::{StrictDecode, StrictEncode}; @@ -81,9 +82,10 @@ pub struct Opts { #[clap(flatten)] pub peer_key_opts: PeerKeyOpts, - /// WalletToken configuration + /// Token configuration #[clap(flatten)] pub wallet_token: TokenString, + /// These params can be read also from the configuration file, not just /// command-line args or environment variables #[clap(flatten)] @@ -103,23 +105,6 @@ pub struct PeerKeyOpts { pub peer_secret_key: String, } -/// ``WalletToken`` configuration -#[derive(Clap, Clone, PartialEq, Eq, Debug)] -pub struct TokenString { - #[clap(long)] - pub wallet_token: String, -} - -impl FromStr for TokenString { - type Err = io::Error; - - fn from_str(s: &str) -> Result { - Ok(TokenString { - wallet_token: s.to_string(), - }) - } -} - use bitcoin::secp256k1::{rand::thread_rng, SecretKey}; use std::str::FromStr; diff --git a/src/peerd/runtime.rs b/src/peerd/runtime.rs index 8c08c66fa..9f7175163 100644 --- a/src/peerd/runtime.rs +++ b/src/peerd/runtime.rs @@ -30,11 +30,11 @@ use crate::rpc::{ request::{self, Msg, PeerInfo, TakeCommit, Token}, Request, ServiceBus, }; -use crate::{Config, CtlServer, Error, LogStyle, Service, ServiceId}; +use crate::{CtlServer, Error, LogStyle, Service, ServiceConfig, ServiceId}; #[allow(clippy::too_many_arguments)] pub fn run( - config: Config, + config: ServiceConfig, connection: PeerConnection, id: NodeAddr, local_id: PublicKey, diff --git a/src/rpc/client.rs b/src/rpc/client.rs index 9760e41d7..76fbf7588 100644 --- a/src/rpc/client.rs +++ b/src/rpc/client.rs @@ -17,23 +17,22 @@ use std::thread::sleep; use std::time::Duration; use internet2::ZmqType; -use lnpbp::chain::Chain; use microservices::esb; use crate::rpc::request::OptionDetails; use crate::rpc::{Request, ServiceBus}; -use crate::{Config, Error, LogStyle, ServiceId}; +use crate::service::ServiceConfig; +use crate::{Error, LogStyle, ServiceId}; #[repr(C)] pub struct Client { identity: ServiceId, - chain: Chain, response_queue: std::collections::VecDeque, esb: esb::Controller, } impl Client { - pub fn with(config: Config, chain: Chain) -> Result { + pub fn with(config: ServiceConfig) -> Result { debug!("Setting up RPC client..."); let identity = ServiceId::client(); let bus_config = esb::BusConfig::with_locator( @@ -58,7 +57,6 @@ impl Client { Ok(Self { identity, - chain, response_queue: empty!(), esb, }) @@ -68,10 +66,6 @@ impl Client { self.identity.clone() } - pub fn chain(&self) -> Chain { - self.chain.clone() - } - pub fn request(&mut self, daemon: ServiceId, req: Request) -> Result<(), Error> { debug!("Executing {}", req); self.esb.send_to(ServiceBus::Ctl, daemon, req)?; diff --git a/src/service.rs b/src/service.rs index 0f8662ca2..27bd3c452 100644 --- a/src/service.rs +++ b/src/service.rs @@ -28,8 +28,8 @@ use strict_encoding::{StrictDecode, StrictEncode}; use farcaster_core::{blockchain::Network, swap::SwapId}; +use crate::opts::Opts; use crate::rpc::{Request, ServiceBus}; -use crate::Config; use crate::Error; #[derive( @@ -79,6 +79,25 @@ impl FromStr for ClientName { } } +#[derive(Debug, Clone, Hash)] +pub struct ServiceConfig { + /// ZMQ socket for lightning peer network message bus + pub msg_endpoint: NodeAddr, + + /// ZMQ socket for internal service control bus + pub ctl_endpoint: NodeAddr, +} + +#[cfg(feature = "shell")] +impl From for ServiceConfig { + fn from(opts: Opts) -> Self { + ServiceConfig { + msg_endpoint: opts.msg_socket.into(), + ctl_endpoint: opts.ctl_socket.into(), + } + } +} + /// Identifiers of daemons participating in LNP Node #[derive(Clone, PartialEq, Eq, Hash, Debug, Display, From, StrictEncode, StrictDecode)] pub enum ServiceId { @@ -155,13 +174,13 @@ where esb::Error: From, { #[cfg(feature = "node")] - pub fn run(config: Config, runtime: Runtime, broker: bool) -> Result<(), Error> { + pub fn run(config: ServiceConfig, runtime: Runtime, broker: bool) -> Result<(), Error> { let service = Self::with(config, runtime, broker)?; service.run_loop()?; unreachable!() } - fn with(config: Config, runtime: Runtime, broker: bool) -> Result { + fn with(config: ServiceConfig, runtime: Runtime, broker: bool) -> Result { let router = if !broker { Some(ServiceId::router()) } else { @@ -190,12 +209,12 @@ where Ok(Self { esb, broker }) } - pub fn broker(config: Config, runtime: Runtime) -> Result { + pub fn broker(config: ServiceConfig, runtime: Runtime) -> Result { Self::with(config, runtime, true) } #[allow(clippy::self_named_constructors)] - pub fn service(config: Config, runtime: Runtime) -> Result { + pub fn service(config: ServiceConfig, runtime: Runtime) -> Result { Self::with(config, runtime, false) } diff --git a/src/swapd/opts.rs b/src/swapd/opts.rs index 03650b790..80df8065f 100644 --- a/src/swapd/opts.rs +++ b/src/swapd/opts.rs @@ -18,7 +18,7 @@ use farcaster_core::swap::SwapId; use farcaster_core::{negotiation::PublicOffer, role::TradeRole, swap::btcxmr::BtcXmr}; use std::str::FromStr; -/// Lightning peer network channel daemon; part of LNP Node +/// Swap executor daemon; part of Farcaster Node /// /// The daemon is controlled though ZMQ ctl socket (see `ctl-socket` argument /// description) @@ -31,7 +31,7 @@ use std::str::FromStr; setting = AppSettings::ColoredHelp )] pub struct Opts { - /// Channel id + /// Swap id #[clap(parse(try_from_str = SwapId::from_str))] pub swap_id: SwapId, diff --git a/src/swapd/runtime.rs b/src/swapd/runtime.rs index 7a1ecacc6..c54f22741 100644 --- a/src/swapd/runtime.rs +++ b/src/swapd/runtime.rs @@ -33,7 +33,7 @@ use crate::rpc::{ request::{self, Msg}, Request, ServiceBus, }; -use crate::{Config, CtlServer, Error, LogStyle, Senders, Service, ServiceId}; +use crate::{CtlServer, Error, LogStyle, Senders, Service, ServiceConfig, ServiceId}; use bitcoin::{consensus::Encodable, secp256k1}; use bitcoin::{ hashes::{hex::FromHex, sha256, Hash, HashEngine}, @@ -82,9 +82,8 @@ use monero::{cryptonote::hash::keccak_256, PrivateKey, ViewPair}; use request::{Commit, InitSwap, Params, Reveal, TakeCommit, Tx}; pub fn run( - config: Config, + config: ServiceConfig, swap_id: SwapId, - _chain: Chain, public_offer: PublicOffer, local_trade_role: TradeRole, ) -> Result<(), Error> { @@ -527,13 +526,13 @@ impl State { "Wrong state, not updating. Expected BuySig, found {}", &*self ); - return (); + return; } else if self.b_buy_tx_seen() { error!("Buy tx was previously seen, not updating state"); - return (); + return; } match self { - State::Bob(BobState::BuySigB(BuySigB { buy_tx_seen })) if &*buy_tx_seen == &false => { + State::Bob(BobState::BuySigB(BuySigB { buy_tx_seen })) if !(*buy_tx_seen) => { *buy_tx_seen = true } _ => unreachable!("checked state"), diff --git a/src/syncerd/bitcoin_syncer.rs b/src/syncerd/bitcoin_syncer.rs index e8a90c944..b764657da 100644 --- a/src/syncerd/bitcoin_syncer.rs +++ b/src/syncerd/bitcoin_syncer.rs @@ -2,9 +2,9 @@ use crate::internet2::Encrypt; use crate::internet2::TypedEnum; use crate::rpc::request::SyncerdBridgeEvent; use crate::rpc::Request; -use crate::syncerd::opts::Coin; -use crate::syncerd::runtime::SyncerServers; +use crate::syncerd::opts::{Coin, Opts}; use crate::syncerd::runtime::SyncerdTask; +use crate::syncerd::runtime::Synclet; use crate::syncerd::syncer_state::AddressTx; use crate::syncerd::syncer_state::SyncerState; use crate::syncerd::syncer_state::WatchedTransaction; @@ -27,12 +27,12 @@ use electrum_client::Hex32Bytes; use electrum_client::{raw_client::ElectrumSslStream, HeaderNotification}; use electrum_client::{raw_client::RawClient, GetHistoryRes}; use electrum_client::{Client, ElectrumApi}; +use farcaster_core::blockchain::Network; use farcaster_core::consensus; use internet2::zmqsocket::Connection; use internet2::zmqsocket::ZmqType; use internet2::PlainTranscoder; use internet2::ZMQ_CONTEXT; -use lnpbp::chain::Chain; use std::collections::{HashMap, HashSet}; use std::convert::TryInto; use std::io; @@ -54,18 +54,6 @@ use hex; const RETRY_TIMEOUT: u64 = 5; const PING_WAIT: u8 = 2; -pub trait Synclet { - fn run( - &mut self, - rx: Receiver, - tx: zmq::Socket, - syncer_address: Vec, - syncer_servers: SyncerServers, - chain: Chain, - polling: bool, - ); -} - pub struct ElectrumRpc { client: Client, height: u64, @@ -259,7 +247,7 @@ impl ElectrumRpc { }; drop(state_guard); for tx_id in txids.iter() { - let tx_id = bitcoin::Txid::from_slice(&tx_id).unwrap(); + let tx_id = bitcoin::Txid::from_slice(tx_id).unwrap(); // Get the full transaction match self.client.transaction_get(&tx_id) { Ok(tx) => { @@ -537,17 +525,17 @@ async fn run_syncerd_task_receiver( fn address_polling( state: Arc>, - syncer_servers: SyncerServers, + electrum_server: String, polling: bool, ) -> tokio::task::JoinHandle<()> { tokio::task::spawn(async move { loop { - let mut rpc = match ElectrumRpc::new(&syncer_servers.electrum_server, polling) { + let mut rpc = match ElectrumRpc::new(&electrum_server, polling) { Ok(client) => client, Err(err) => { error!( - "failed to spawn electrum rpc client in address polling: {:?}", - err + "failed to spawn electrum rpc client ({}) t in address polling: {:?}", + &electrum_server, err ); // wait a bit before retrying the connection tokio::time::sleep(std::time::Duration::from_secs(RETRY_TIMEOUT)).await; @@ -610,18 +598,18 @@ fn address_polling( fn height_polling( state: Arc>, - syncer_servers: SyncerServers, + electrum_server: String, polling: bool, ) -> tokio::task::JoinHandle<()> { tokio::task::spawn(async move { // outer loop ensures the polling restarts if there is an error loop { - let mut rpc = match ElectrumRpc::new(&syncer_servers.electrum_server, polling) { + let mut rpc = match ElectrumRpc::new(&electrum_server, polling) { Ok(client) => client, Err(err) => { error!( - "failed to spawn electrum rpc client in height polling: {:?}", - err + "failed to spawn electrum rpc client ({}) in height polling: {:?}", + &electrum_server, err ); // wait a bit before retrying the connection tokio::time::sleep(std::time::Duration::from_secs(RETRY_TIMEOUT)).await; @@ -675,18 +663,18 @@ fn height_polling( fn unseen_transaction_polling( state: Arc>, - syncer_servers: SyncerServers, + electrum_server: String, polling: bool, ) -> tokio::task::JoinHandle<()> { tokio::task::spawn(async move { // outer loop ensures the polling restarts if there is an error loop { - let rpc = match ElectrumRpc::new(&syncer_servers.electrum_server, polling) { + let rpc = match ElectrumRpc::new(&electrum_server, polling) { Ok(client) => client, Err(err) => { error!( - "failed to spawn electrum rpc client in transaction polling: {:?}", - err + "failed to spawn electrum rpc client ({}) in transaction polling: {:?}", + &electrum_server, err ); // wait a bit before retrying the connection tokio::time::sleep(std::time::Duration::from_secs(RETRY_TIMEOUT)).await; @@ -716,47 +704,54 @@ impl Synclet for BitcoinSyncer { receive_task_channel: Receiver, tx: zmq::Socket, syncer_address: Vec, - syncer_servers: SyncerServers, - _chain: Chain, + opts: &Opts, + _network: Network, polling: bool, - ) { - std::thread::spawn(move || { - use tokio::runtime::Builder; - let rt = Builder::new_multi_thread() - .worker_threads(2) - .enable_all() - .build() - .unwrap(); - rt.block_on(async { - let (event_tx, event_rx): ( - TokioSender, - TokioReceiver, - ) = tokio::sync::mpsc::channel(120); - let state = Arc::new(Mutex::new(SyncerState::new(event_tx.clone()))); - - run_syncerd_task_receiver( - syncer_servers.electrum_server.clone(), - receive_task_channel, - Arc::clone(&state), - event_tx.clone(), - ) - .await; - run_syncerd_bridge_event_sender(tx, event_rx, syncer_address).await; - - let address_handle = - address_polling(Arc::clone(&state), syncer_servers.clone(), polling); - - let height_handle = - height_polling(Arc::clone(&state), syncer_servers.clone(), polling); - - let unseen_transaction_handle = - unseen_transaction_polling(Arc::clone(&state), syncer_servers.clone(), polling); - - let res = - tokio::try_join!(address_handle, height_handle, unseen_transaction_handle); - debug!("exiting bitcoin synclet run routine with: {:?}", res); + ) -> Result<(), Error> { + if let Some(electrum_server) = &opts.electrum_server { + let electrum_server = electrum_server.clone(); + std::thread::spawn(move || { + use tokio::runtime::Builder; + let rt = Builder::new_multi_thread() + .worker_threads(2) + .enable_all() + .build() + .unwrap(); + rt.block_on(async { + let (event_tx, event_rx): ( + TokioSender, + TokioReceiver, + ) = tokio::sync::mpsc::channel(120); + let state = Arc::new(Mutex::new(SyncerState::new(event_tx.clone()))); + + run_syncerd_task_receiver( + electrum_server.clone(), + receive_task_channel, + Arc::clone(&state), + event_tx.clone(), + ) + .await; + run_syncerd_bridge_event_sender(tx, event_rx, syncer_address).await; + + let address_handle = + address_polling(Arc::clone(&state), electrum_server.clone(), polling); + + let height_handle = + height_polling(Arc::clone(&state), electrum_server.clone(), polling); + + let unseen_transaction_handle = + unseen_transaction_polling(Arc::clone(&state), electrum_server, polling); + + let res = + tokio::try_join!(address_handle, height_handle, unseen_transaction_handle); + debug!("exiting bitcoin synclet run routine with: {:?}", res); + }); }); - }); + Ok(()) + } else { + error!("Missing --electrum-server argument"); + Err(SyncerError::InvalidConfig.into()) + } } } diff --git a/src/syncerd/mod.rs b/src/syncerd/mod.rs index 522de32cd..0b3fc4e7b 100644 --- a/src/syncerd/mod.rs +++ b/src/syncerd/mod.rs @@ -24,5 +24,4 @@ pub mod runtime; #[cfg(feature = "shell")] pub use opts::Opts; pub use runtime::run; -pub use runtime::SyncerServers; pub use types::*; diff --git a/src/syncerd/monero_syncer.rs b/src/syncerd/monero_syncer.rs index df3938b00..00f80a39b 100644 --- a/src/syncerd/monero_syncer.rs +++ b/src/syncerd/monero_syncer.rs @@ -4,20 +4,20 @@ use crate::internet2::Encrypt; use crate::internet2::TypedEnum; use crate::rpc::request::SyncerdBridgeEvent; use crate::rpc::Request; -use crate::syncerd::bitcoin_syncer::Synclet; +use crate::syncerd::opts::Opts; use crate::syncerd::runtime::SyncerdTask; +use crate::syncerd::runtime::Synclet; use crate::syncerd::syncer_state::create_set; use crate::syncerd::syncer_state::AddressTx; use crate::syncerd::syncer_state::SyncerState; use crate::syncerd::types::{AddressAddendum, Boolean, SweepAddressAddendum, Task}; use crate::syncerd::Event; -use crate::syncerd::SyncerServers; use crate::syncerd::TaskTarget; use crate::syncerd::TransactionBroadcasted; use crate::syncerd::XmrAddressAddendum; +use farcaster_core::blockchain::Network; use internet2::zmqsocket::{Connection, ZmqType}; use internet2::PlainTranscoder; -use lnpbp::chain::Chain; use monero::Hash; use monero_rpc::{ GenerateFromKeysArgs, GetBlockHeaderSelector, GetTransfersCategory, GetTransfersSelector, @@ -393,7 +393,7 @@ async fn run_syncerd_task_receiver( fn address_polling( state: Arc>, - syncer_servers: SyncerServers, + syncer_servers: MoneroSyncerServers, network: monero::Network, wallet_mutex: Arc>, ) -> tokio::task::JoinHandle<()> { @@ -437,7 +437,7 @@ fn address_polling( fn height_polling( state: Arc>, - syncer_servers: SyncerServers, + syncer_servers: MoneroSyncerServers, ) -> tokio::task::JoinHandle<()> { tokio::task::spawn(async move { let mut rpc = MoneroRpc::new(syncer_servers.monero_daemon); @@ -522,7 +522,7 @@ fn sweep_polling( fn unseen_transaction_polling( state: Arc>, - syncer_servers: SyncerServers, + syncer_servers: MoneroSyncerServers, ) -> tokio::task::JoinHandle<()> { tokio::task::spawn(async move { let mut rpc = MoneroRpc::new(syncer_servers.monero_daemon); @@ -586,80 +586,97 @@ async fn run_syncerd_bridge_event_sender( }); } +/// Specific Monero configuration +#[derive(Default, Debug, Clone, Eq, PartialEq, Hash)] +pub struct MoneroSyncerServers { + /// Monero daemon to use + pub monero_daemon: String, + + /// Monero rpc wallet to use + pub monero_rpc_wallet: String, +} + impl Synclet for MoneroSyncer { fn run( &mut self, receive_task_channel: Receiver, tx: zmq::Socket, syncer_address: Vec, - syncer_servers: SyncerServers, - chain: Chain, + opts: &Opts, + network: Network, polling: bool, - ) { + ) -> Result<(), Error> { if !polling { - error!("monero syncer only supports polling for now - switching to polling=true"); + warn!("monero syncer only supports polling for now - switching to polling=true"); } - let network = match chain { - Chain::Mainnet | Chain::Regtest(_) => monero::Network::Mainnet, - Chain::Testnet3 => monero::Network::Stagenet, - Chain::Signet => monero::Network::Testnet, - _ => { - error!( - "invalid chain type for monero: {}- switching to mainnet", - chain - ); - monero::Network::Mainnet + let network = network.into(); + if let Some(daemon) = &opts.monero_daemon { + if let Some(rpc_wallet) = &opts.monero_rpc_wallet { + let syncer_servers = MoneroSyncerServers { + monero_daemon: daemon.clone(), + monero_rpc_wallet: rpc_wallet.clone(), + }; + + let _handle = std::thread::spawn(move || { + use tokio::runtime::Builder; + let rt = Builder::new_multi_thread() + .worker_threads(2) + .enable_all() + .build() + .unwrap(); + rt.block_on(async { + let wallet_mutex = Arc::new(Mutex::new( + monero_rpc::RpcClient::new(syncer_servers.monero_rpc_wallet.clone()) + .wallet(), + )); + let (event_tx, event_rx): ( + TokioSender, + TokioReceiver, + ) = tokio::sync::mpsc::channel(120); + let state = Arc::new(Mutex::new(SyncerState::new(event_tx.clone()))); + + run_syncerd_task_receiver( + receive_task_channel, + Arc::clone(&state), + event_tx.clone(), + ) + .await; + run_syncerd_bridge_event_sender(tx, event_rx, syncer_address).await; + + let address_handle = address_polling( + Arc::clone(&state), + syncer_servers.clone(), + network, + Arc::clone(&wallet_mutex), + ); + + // transaction polling is done in the same loop + let height_handle = + height_polling(Arc::clone(&state), syncer_servers.clone()); + + let unseen_transaction_handle = + unseen_transaction_polling(Arc::clone(&state), syncer_servers.clone()); + + let sweep_handle = + sweep_polling(Arc::clone(&state), Arc::clone(&wallet_mutex), network); + + let res = tokio::try_join!( + address_handle, + height_handle, + unseen_transaction_handle, + sweep_handle + ); + debug!("exiting monero synclet run routine with: {:?}", res); + }); + }); + Ok(()) + } else { + error!("Missing --monero-rpc-wallet argument"); + Err(SyncerError::InvalidConfig.into()) } - }; - let _handle = std::thread::spawn(move || { - use tokio::runtime::Builder; - let rt = Builder::new_multi_thread() - .worker_threads(2) - .enable_all() - .build() - .unwrap(); - rt.block_on(async { - let wallet_mutex = Arc::new(Mutex::new( - monero_rpc::RpcClient::new(syncer_servers.monero_rpc_wallet.clone()).wallet(), - )); - let (event_tx, event_rx): ( - TokioSender, - TokioReceiver, - ) = tokio::sync::mpsc::channel(120); - let state = Arc::new(Mutex::new(SyncerState::new(event_tx.clone()))); - - run_syncerd_task_receiver( - receive_task_channel, - Arc::clone(&state), - event_tx.clone(), - ) - .await; - run_syncerd_bridge_event_sender(tx, event_rx, syncer_address).await; - - let address_handle = address_polling( - Arc::clone(&state), - syncer_servers.clone(), - network, - Arc::clone(&wallet_mutex), - ); - - // transaction polling is done in the same loop - let height_handle = height_polling(Arc::clone(&state), syncer_servers.clone()); - - let unseen_transaction_handle = - unseen_transaction_polling(Arc::clone(&state), syncer_servers.clone()); - - let sweep_handle = - sweep_polling(Arc::clone(&state), Arc::clone(&wallet_mutex), network); - - let res = tokio::try_join!( - address_handle, - height_handle, - unseen_transaction_handle, - sweep_handle - ); - debug!("exiting monero synclet run routine with: {:?}", res); - }); - }); + } else { + error!("Missing --monero-daemon argument"); + Err(SyncerError::InvalidConfig.into()) + } } } diff --git a/src/syncerd/opts.rs b/src/syncerd/opts.rs index 55b95ab89..a95f983f6 100644 --- a/src/syncerd/opts.rs +++ b/src/syncerd/opts.rs @@ -13,6 +13,7 @@ // If not, see . use clap::{AppSettings, Clap}; +use farcaster_core::blockchain::Network; use std::str::FromStr; use strict_encoding::{StrictDecode, StrictEncode}; @@ -35,15 +36,35 @@ pub struct Opts { pub shared: crate::opts::Opts, /// Which coin this syncer should target - #[clap(parse(try_from_str = Coin::from_str))] + #[clap(long, parse(try_from_str = Coin::from_str))] pub coin: Coin, - /// Which network this syncer should target - #[clap(parse(try_from_str = farcaster_core::blockchain::Network::from_str))] - pub network: farcaster_core::blockchain::Network, + /// Blockchain networks to use (Mainnet, Testnet, Local) + #[clap( + short, + long, + global = true, + alias = "chain", + default_value = "Testnet", + parse(try_from_str = Network::from_str) + )] + pub network: Network, + + /// Electrum server to use for Bitcoin syncers + #[clap(long)] + pub electrum_server: Option, + + /// Monero daemon to use for Monero syncers + #[clap(long)] + pub monero_daemon: Option, + + /// Monero rpc wallet to use for Monero syncers + #[clap(long)] + pub monero_rpc_wallet: Option, } -#[derive(Clap, Clone, Hash, PartialEq, Eq, Debug, StrictEncode, StrictDecode)] +#[derive(Clap, Display, Copy, Clone, Hash, PartialEq, Eq, Debug, StrictEncode, StrictDecode)] +#[display(Debug)] pub enum Coin { /// Launches a bitcoin syncer Bitcoin, @@ -61,32 +82,15 @@ impl FromStr for Coin { type Err = SyncerCoinError; fn from_str(input: &str) -> Result { match input { - "bitcoin" => Ok(Coin::Bitcoin), - "monero" => Ok(Coin::Monero), + "Bitcoin" | "bitcoin" => Ok(Coin::Bitcoin), + "Monero" | "monero" => Ok(Coin::Monero), _ => Err(SyncerCoinError::InvalidCoin), } } } -impl ToString for Coin { - fn to_string(&self) -> String { - match self { - Coin::Bitcoin => "bitcoin".to_string(), - Coin::Monero => "monero".to_string(), - } - } -} - impl Opts { pub fn process(&mut self) { self.shared.process(); } } - -// fn into(network: &farcaster_core::blockchain::Network) -> monero::Network { -// match network { -// blockchain::Network::Mainnet => monero::Network::Mainnet, -// blockchain::Network::Testnet => monero::Network::Stagenet, -// blockchain::Network::Local => monero::Network::Mainnet, -// } -// } diff --git a/src/syncerd/runtime.rs b/src/syncerd/runtime.rs index 57686c368..3fcb1ede4 100644 --- a/src/syncerd/runtime.rs +++ b/src/syncerd/runtime.rs @@ -13,9 +13,8 @@ // If not, see . use crate::syncerd::bitcoin_syncer::BitcoinSyncer; -use crate::syncerd::bitcoin_syncer::Synclet; use crate::syncerd::monero_syncer::MoneroSyncer; -use crate::syncerd::opts::Coin; +use crate::syncerd::opts::{Coin, Opts}; use amplify::Wrapper; use farcaster_core::blockchain::Network; use std::collections::{HashMap, HashSet}; @@ -35,36 +34,39 @@ use internet2::{ presentation, transport, zmqsocket, NodeAddr, RemoteSocketAddr, TypedEnum, ZmqType, ZMQ_CONTEXT, }; use lnp::{message, Messages, TempChannelId as TempSwapId}; -use lnpbp::chain::Chain; use microservices::esb::{self, Handler}; use microservices::rpc::Failure; use crate::rpc::request::{IntoProgressOrFalure, OptionDetails, SyncerInfo}; use crate::rpc::{request, Request, ServiceBus}; use crate::syncerd::*; -use crate::{Config, Error, LogStyle, Service, ServiceId}; +use crate::{Error, LogStyle, Service, ServiceConfig, ServiceId}; + +pub trait Synclet { + fn run( + &mut self, + rx: Receiver, + tx: zmq::Socket, + syncer_address: Vec, + opts: &Opts, + network: Network, + polling: bool, + ) -> Result<(), Error>; +} pub struct SyncerdTask { pub task: Task, pub source: ServiceId, } -#[derive(Debug, Clone, Hash)] -pub struct SyncerServers { - pub electrum_server: String, - pub monero_daemon: String, - pub monero_rpc_wallet: String, -} +pub fn run(config: ServiceConfig, opts: Opts) -> Result<(), Error> { + let coin = opts.coin; + let network = opts.network; -pub fn run( - config: Config, - coin: Coin, - network: farcaster_core::blockchain::Network, - syncer_servers: SyncerServers, -) -> Result<(), Error> { info!( - "Creating new {} {}", + "Creating new {} ({}) {}", &coin.bright_green_bold(), + &network.bright_white_bold(), "syncer".bright_green_bold() ); let (tx, rx): (Sender, Receiver) = std::sync::mpsc::channel(); @@ -91,10 +93,10 @@ pub fn run( rx, tx_event, runtime.identity().into(), - syncer_servers, - config.chain.clone(), + &opts, + network, polling, - ); + )?; let mut service = Service::service(config, runtime)?; service.add_loopback(rx_event)?; service.run_loop()?; diff --git a/src/walletd/opts.rs b/src/walletd/opts.rs index 9151c2459..ba23cff14 100644 --- a/src/walletd/opts.rs +++ b/src/walletd/opts.rs @@ -12,11 +12,18 @@ // along with this software. // If not, see . -use crate::opts::FARCASTER_NODE_KEY_FILE; +use crate::opts::FARCASTER_KEY_FILE; use clap::{AppSettings, Clap, ValueHint}; use std::path::PathBuf; use std::{fs, io::Read}; +use crate::opts::TokenString; +use bitcoin::secp256k1::{ + rand::{rngs::ThreadRng, thread_rng}, + PublicKey, Secp256k1, SecretKey, +}; +use strict_encoding::{StrictDecode, StrictEncode}; + /// Walletd daemon; part of Farcaster Node #[derive(Clap, Clone, PartialEq, Eq, Debug)] #[clap( @@ -33,7 +40,7 @@ pub struct Opts { /// Walletd token #[clap(flatten)] - pub token: WalletToken, + pub wallet_token: TokenString, /// These params can be read also from the configuration file, not just /// command-line args or environment variables @@ -58,26 +65,13 @@ pub struct KeyOpts { #[clap( short, long, - env = "FARCASTER_NODE_KEY_FILE", - default_value = FARCASTER_NODE_KEY_FILE, + env = "FARCASTER_KEY_FILE", + default_value = FARCASTER_KEY_FILE, value_hint = ValueHint::FilePath )] pub key_file: String, } -#[derive(Clap, Clone, PartialEq, Eq, Debug)] -pub struct WalletToken { - #[clap(short, long, env = "FARCASTER_WALLETD_TOKEN", default_value = "")] - pub wallet_token: String, -} - -use bitcoin::secp256k1::{ - rand::{rngs::ThreadRng, thread_rng}, - PublicKey, Secp256k1, SecretKey, -}; -use strict_encoding; -use strict_encoding::{StrictDecode, StrictEncode}; - #[derive(StrictEncode, StrictDecode, Clone, PartialEq, Eq, Debug)] pub struct Counter(pub u32); impl Counter { diff --git a/src/walletd/runtime.rs b/src/walletd/runtime.rs index 01a1cf627..6aa93e76b 100644 --- a/src/walletd/runtime.rs +++ b/src/walletd/runtime.rs @@ -20,7 +20,7 @@ use crate::{ }, syncerd::SweepXmrAddress, }; -use crate::{Config, CtlServer, Error, Service, ServiceId}; +use crate::{CtlServer, Error, Service, ServiceConfig, ServiceId}; use bitcoin::{ hashes::hex::FromHex, secp256k1::{self, Signature}, @@ -63,7 +63,7 @@ use microservices::esb::{self, Handler}; use request::{LaunchSwap, NodeId}; pub fn run( - config: Config, + config: ServiceConfig, wallet_token: Token, node_secrets: NodeSecrets, node_id: bitcoin::secp256k1::PublicKey, @@ -974,11 +974,11 @@ impl Runtime { bob.generate_parameters(&mut key_manager, &public_offer)?; let funding = create_funding(&mut key_manager, offer.network)?; let funding_addr = funding.get_address()?; - let funding_fee = 150; - let funding_amount = offer.arbitrating_amount.as_sat() + funding_fee; + let funding_fee = bitcoin::Amount::from_sat(150); + let funding_amount = offer.arbitrating_amount + funding_fee; info!( - "Send {} sats to address: {}", - funding_amount.bright_green_bold(), + "Send {} to address: {}", + funding_amount.to_string().bright_green_bold(), funding_addr.addr(), ); info!("Loading {}", "Wallet::Bob".bright_yellow()); diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 3d10b4f11..9f4ae3e1b 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.7" services: bitcoin-core: - image: ghcr.io/farcaster-project/containers/bitcoin-core:latest + image: ghcr.io/farcaster-project/containers/bitcoin-core:0.21.1 environment: NETWORK: regtest RPC_PORT: 18443 @@ -10,15 +10,18 @@ services: - ./data_dir:/data ports: - 18443:18443 + - 18444:18444 electrs: - image: ghcr.io/farcaster-project/containers/electrs:latest + image: ghcr.io/farcaster-project/containers/electrs:0.8.11 command: "/usr/bin/electrs -vv --network regtest --daemon-dir /data --daemon-rpc-addr bitcoin-core:18443 --electrum-rpc-addr 0.0.0.0:50001 --txid-limit 100000" + depends_on: + - "bitcoin-core" volumes: - ./data_dir:/data ports: - 50001:50001 monerod: - image: ghcr.io/farcaster-project/containers/monerod:latest + image: ghcr.io/farcaster-project/containers/monerod:0.17.2.3 environment: NETWORK: regtest MONEROD_RPC_PORT: 18081 @@ -27,15 +30,19 @@ services: ports: - 18081:18081 monero-wallet-rpc-1: - image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:latest + image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:0.17.2.3 environment: MONEROD_ADDRESS: monerod:18081 + depends_on: + - "monerod" ports: - 18083:18083 monero-wallet-rpc-2: - image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:latest + image: ghcr.io/farcaster-project/containers/monero-wallet-rpc:0.17.2.3 environment: MONEROD_ADDRESS: monerod:18081 + depends_on: + - "monerod" ports: - 18084:18083 diff --git a/tests/functional.rs b/tests/functional.rs index 699cc0477..51fdc2c2c 100644 --- a/tests/functional.rs +++ b/tests/functional.rs @@ -1,16 +1,15 @@ use amplify::map; -use bitcoin::BlockHash; use bitcoincore_rpc::{Auth, Client, RpcApi}; +use clap::Clap; use farcaster_node::rpc::Request; use farcaster_node::syncerd::bitcoin_syncer::BitcoinSyncer; -use farcaster_node::syncerd::bitcoin_syncer::Synclet; use farcaster_node::syncerd::monero_syncer::MoneroSyncer; -use farcaster_node::syncerd::opts::Coin; +use farcaster_node::syncerd::opts::{Coin, Opts}; use farcaster_node::syncerd::runtime::SyncerdTask; +use farcaster_node::syncerd::runtime::Synclet; use farcaster_node::syncerd::SweepAddress; use farcaster_node::syncerd::SweepAddressAddendum; use farcaster_node::syncerd::SweepXmrAddress; -use farcaster_node::syncerd::SyncerServers; use farcaster_node::syncerd::TaskTarget; use farcaster_node::syncerd::XmrAddressAddendum; use farcaster_node::ServiceId; @@ -19,7 +18,6 @@ use internet2::Decrypt; use internet2::PlainTranscoder; use internet2::RoutedFrame; use internet2::ZMQ_CONTEXT; -use lnpbp::chain::Chain; use monero::Address; use monero_rpc::GetBlockHeaderSelector; use paste::paste; @@ -27,6 +25,8 @@ use std::collections::HashMap; use std::sync::mpsc::Receiver; use std::sync::mpsc::Sender; +use ntest::timeout; + use bitcoin::hashes::Hash; use internet2::{CreateUnmarshaller, Unmarshall}; use std::str::FromStr; @@ -44,18 +44,23 @@ const SOURCE2: ServiceId = ServiceId::Syncer(Coin::Monero, Network::Local); These tests need to run serialy, otherwise we cannot verify events based on the state of electrum and bitcoin, for that we use `--test-threads=1` when running `cargo test` + +Timeout of 5 min max per test, otherwise test panic. This mitigate test that hangs +because of syncers. */ macro_rules! make_polling_test { ($name:ident) => { paste! { #[test] + #[timeout(300000)] #[ignore] fn [< $name _polling >] () { $name(true); } #[test] + #[timeout(300000)] #[ignore] fn [< $name _no_polling >] () { $name(false); @@ -400,6 +405,7 @@ fn bitcoin_syncer_transaction_test(polling: bool) { let txid_1 = bitcoin_rpc .send_to_address(&address_1, amount, None, None, None, None, None, None) .unwrap(); + std::thread::sleep(duration); tx.send(SyncerdTask { @@ -441,6 +447,9 @@ fn bitcoin_syncer_transaction_test(polling: bool) { let block_hash = bitcoin_rpc.generate_to_address(1, &address_2).unwrap(); let block = bitcoin_rpc.get_block(&block_hash[0]).unwrap(); let address_txid = find_coinbase_transaction_id(block.txdata); + + std::thread::sleep(duration); + tx.send(SyncerdTask { task: Task::WatchTransaction(WatchTransaction { id: 1, @@ -452,8 +461,6 @@ fn bitcoin_syncer_transaction_test(polling: bool) { }) .unwrap(); - std::thread::sleep(duration); - println!("awaiting confirmations"); let message = rx_event.recv_multipart(0).unwrap(); println!("received confirmation"); @@ -585,6 +592,7 @@ We test for the following scenarios in the abort tests: - Submit two WatchTransaction tasks, abort them both and receive both their aborted id's. */ #[test] +#[timeout(300000)] #[ignore] fn bitcoin_syncer_abort_test() { let (tx, rx_event) = create_bitcoin_syncer(true, "abort"); @@ -802,20 +810,24 @@ fn create_bitcoin_syncer( tx_event.connect(&addr).unwrap(); rx_event.bind(&addr).unwrap(); let mut syncer = BitcoinSyncer::new(); - let syncer_servers = SyncerServers { - electrum_server: "tcp://localhost:50001".to_string(), - monero_daemon: "".to_string(), - monero_rpc_wallet: "".to_string(), - }; - let dummy = BlockHash::from_slice(&[0; 32]).unwrap(); - syncer.run( - rx, - tx_event, - SOURCE1.clone().into(), - syncer_servers, - Chain::Regtest(dummy), - polling, - ); + + let opts = Opts::parse_from(vec!["syncerd"].into_iter().chain(vec![ + "--coin", + "Bitcoin", + "--electrum-server", + "tcp://localhost:50001", + ])); + + syncer + .run( + rx, + tx_event, + SOURCE1.clone().into(), + &opts, + Network::Local, + polling, + ) + .expect("Valid bitcoin syncer"); (tx, rx_event) } @@ -865,6 +877,7 @@ We test for the following scenarios in the block height tests: - Mine another block and receive two HeightChanged events */ #[tokio::test] +#[timeout(300000)] #[ignore] async fn monero_syncer_block_height_test() { let (regtest, wallet) = setup_monero().await; @@ -933,6 +946,7 @@ async fn monero_syncer_block_height_test() { } #[tokio::test] +#[timeout(300000)] #[ignore] async fn monero_syncer_sweep_test() { let (regtest, wallet) = setup_monero().await; @@ -1004,6 +1018,7 @@ height */ #[tokio::test] +#[timeout(300000)] #[ignore] async fn monero_syncer_address_test() { let (regtest, wallet) = setup_monero().await; @@ -1187,6 +1202,7 @@ the threshold confs are reached found confirmation event. Then relay and receive further events. */ #[tokio::test] +#[timeout(300000)] #[ignore] async fn monero_syncer_transaction_test() { let (regtest, wallet) = setup_monero().await; @@ -1361,6 +1377,7 @@ We test for the following scenarios in the abort tests: - Submit two WatchTransaction tasks, abort them both and receive both their aborted id's. */ #[tokio::test] +#[timeout(300000)] #[ignore] async fn monero_syncer_abort_test() { let (tx, rx_event) = create_monero_syncer("abort"); @@ -1477,6 +1494,7 @@ async fn monero_syncer_abort_test() { Check that a monero BroadcastTransaction task generates an error */ #[tokio::test] +#[timeout(300000)] #[ignore] async fn monero_syncer_broadcast_tx_test() { let (regtest, wallet) = setup_monero().await; @@ -1527,20 +1545,26 @@ fn create_monero_syncer(socket_name: &str) -> (std::sync::mpsc::Sender = System::new_all() .get_processes() .iter() @@ -116,7 +110,7 @@ fn spawn_swap() { #[cfg(feature = "integration_test")] { - let ps_out = std::process::Command::new("ps") + let ps_out = process::Command::new("ps") .args(&["-e"]) .output() .expect("failed to execute process")