commands: a module for the implementation of the API

This commit is contained in:
Antoine Poinsot 2022-07-30 12:49:26 +02:00
parent 4b659bc35a
commit 8309c85e30
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
2 changed files with 38 additions and 0 deletions

37
src/commands/mod.rs Normal file
View File

@ -0,0 +1,37 @@
//! # Minisafe commands
//!
//! External interface to the Minisafe daemon.
use crate::{DaemonControl, VERSION};
use miniscript::{bitcoin, descriptor};
impl DaemonControl {
/// Get information about the current state of the daemon
pub fn get_info(&self) -> GetInfoResult {
GetInfoResult {
version: VERSION.to_string(),
network: self.config.bitcoind_config.network,
blockheight: self.bitcoin.chain_tip().height,
sync: self.bitcoin.sync_progress(),
descriptors: GetInfoDescriptors {
main: self.config.main_descriptor.clone(),
},
}
}
}
#[derive(Debug, Clone)]
pub struct GetInfoDescriptors {
pub main: descriptor::Descriptor<descriptor::DescriptorPublicKey>,
}
/// Information about the daemon
#[derive(Debug, Clone)]
pub struct GetInfoResult {
pub version: String,
pub network: bitcoin::Network,
pub blockheight: i32,
pub sync: f64,
pub descriptors: GetInfoDescriptors,
}

View File

@ -1,4 +1,5 @@
mod bitcoin;
mod commands;
pub mod config;
#[cfg(unix)]
mod daemonize;