feat: Orchestration & Controller (#492)

* fix: formatting in stress_test.rs

* refactor: move asb binary into swap-asb

* refactor(swap-asb): remove unused disable_timestamp argument

* fix(monero-sys): Include search path for aarch64-linux-gnu

* fix(swap): notpick formatting in swap.rs

* feat(swap-env): Split up config wizard, add default rendezvous points

* feat(swap-controller, swap-controller-api): Minimal maker shell with just a check-connection command

* fix(monero-rpc-pool): Use new axum route path syntax to prevent runtime panic

* feat(ci): Specify crate when building binaries; build asb-controller

* fix: Add swap-controller, swap-controller-api crates and their dependencies to Cargo.toml

* feat(Dockerfile): Build asb-controller; default to 1.87 rust toolchain

* feat(swap-orchestrator): Compose spec generator

* formatting: nitpicks

* fix: add swap-orchestrator auto generated files to gitginore

* refactoring(swap-orchestrator: Use Into<_> to derive asb::Network and electrs::Network from Bitcoin/Monero network, use defaults

* feat(swap-env): Change default bitcoin_confirmation_target to 1

* feat: Dockerfile for asb-controller, bitcoin-balance and monero-balance controller commands

* formatting: nitpicks

* changelog: default bitcoin finality confirmations change

* feat(ci): Build swap-orchestrator binary

* disable rpc server by default, split rpc-bind into rpc-bind-port and rpc-bind-host

* feat(swap-controller): Add monero-address command to print primary address of internal wallet

* chore: upgrade rustyline to 17.0.0

* changelog: Document CONTROLLER, ORCHESTRATOR and JSON-RPC server

* refactor: Change swap-orchestrator binary to just "orchestrator"

* refactor: let RpcServer::start(...) take port and host seperately

* default electrum servers in config wizard

* formatting

* feat(swap-orchestrator): README

* feat(swap-controller): Add Multiaddresses and ActiveConnections command

Signed-off-by: Binarybaron <binarybaron@protonmail.com>

* refactor(asb/event_loop.rs): Move quote logic and tower service into their own modules

* fix(swap): some unit tests

* feat(swap-controller): redumentary repl command auto complete

* formatting

* feat(swap-orchestrator): Burn Git commit hash into orchestrator binary

* feat(swap-orchestrator): burn git commit hash into binary when building from source

* feat(Dockerfiles): Build with --locked

* feat: derive ports for images from network combination

add some doc into the docker compose file

* small refactorings

* feat(swap-controller): Add get-swaps command

* feat: add more default electrum mainnet nodes

* feat: build asb-controller docker image in ci, move asb Dockerfile into swap-asb

* fix: do not allow pre-built docker images for now

* amend changelog

* remove default monero_daemon_url, default to None (Monero RPC pool)

* unify asb and orchestrator wizard for monero daemon url setup

---------

Signed-off-by: Binarybaron <binarybaron@protonmail.com>
This commit is contained in:
Mohan 2025-08-06 15:33:41 +02:00 committed by GitHub
parent 7c82853050
commit 97a4a31af9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 2979 additions and 704 deletions

View file

@ -0,0 +1,72 @@
mod cli;
mod repl;
use clap::Parser;
use cli::{Cli, Cmd};
use swap_controller_api::AsbApiClient;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
let client = jsonrpsee::http_client::HttpClientBuilder::default().build(&cli.url)?;
match cli.cmd {
None => repl::run(client, dispatch).await?,
Some(cmd) => {
if let Err(e) = dispatch(cmd.clone(), client.clone()).await {
eprintln!("Command failed with error: {e:?}");
}
}
}
Ok(())
}
async fn dispatch(cmd: Cmd, client: impl AsbApiClient) -> anyhow::Result<()> {
match cmd {
Cmd::CheckConnection => {
client.check_connection().await?;
println!("Connected");
}
Cmd::BitcoinBalance => {
let response = client.bitcoin_balance().await?;
println!("Current Bitcoin balance is {} BTC", response.balance);
}
Cmd::MoneroBalance => {
let response = client.monero_balance().await?;
let amount = monero::Amount::from_pico(response.balance);
println!("Current Monero balance is {:.12} XMR", amount.as_xmr());
}
Cmd::MoneroAddress => {
let response = client.monero_address().await?;
println!("The primary Monero address is {}", response.address);
}
Cmd::Multiaddresses => {
let response = client.multiaddresses().await?;
if response.multiaddresses.is_empty() {
println!("No external multiaddresses configured");
} else {
for addr in response.multiaddresses {
println!("{}", addr);
}
}
}
Cmd::ActiveConnections => {
let response = client.active_connections().await?;
println!("Connected to {} peers", response.connections);
}
Cmd::GetSwaps => {
let swaps = client.get_swaps().await?;
if swaps.is_empty() {
println!("No swaps found");
} else {
for swap in swaps {
println!("{}: {}", swap.id, swap.state);
}
}
}
}
Ok(())
}