forked from bisq-network/bisq-musig
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmusigd.rs
More file actions
50 lines (41 loc) · 1.69 KB
/
musigd.rs
File metadata and controls
50 lines (41 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use std::error::Error;
use std::sync::Arc;
use bmp_tracing::tracing::info;
use clap::Parser;
use rpc::bmp_service::BmpServiceImpl;
use rpc::bmp_wallet_service::BmpWalletServiceImpl;
use rpc::pb::bmp_protocol::bmp_protocol_service_server::BmpProtocolServiceServer;
use rpc::pb::bmp_wallet::wallet_server::WalletServer as BmpWalletServer;
use rpc::server::{MusigImpl, MusigServer, WalletImpl, WalletServer};
use rpc::wallet::WalletServiceImpl;
use testenv::TestEnv;
use tonic::transport::Server;
#[derive(Debug, Parser)]
#[command(version, about, long_about = None)]
#[expect(clippy::doc_markdown, reason = "doc comments are used verbatim by Clap and not intended to be markdown")]
struct Cli {
/// The port of the MuSig daemon
#[arg(short, long, default_value_t = 50051)]
port: u16,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let cli: Cli = Cli::parse();
bmp_tracing::init("info");
let testenv = TestEnv::new()?;
let addr = format!("127.0.0.1:{}", cli.port).parse()?;
let musig = MusigImpl::default();
let wallet = WalletImpl { wallet_service: Arc::new(WalletServiceImpl::create_with_rpc_params(testenv.bitcoin_core_rpc_client()?)) };
wallet.wallet_service.clone().spawn_connection();
let bmp_protocol_impl = BmpServiceImpl::default();
let bmp_wallet_service = BmpWalletServiceImpl::default();
info!(port = cli.port, "Starting gRPC server.");
Server::builder()
.add_service(MusigServer::new(musig))
.add_service(WalletServer::new(wallet))
.add_service(BmpProtocolServiceServer::new(bmp_protocol_impl))
.add_service(BmpWalletServer::new(bmp_wallet_service))
.serve(addr)
.await?;
Ok(())
}