commands: a module for the implementation of the API
This commit is contained in:
parent
4b659bc35a
commit
8309c85e30
37
src/commands/mod.rs
Normal file
37
src/commands/mod.rs
Normal 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,
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
mod bitcoin;
|
||||
mod commands;
|
||||
pub mod config;
|
||||
#[cfg(unix)]
|
||||
mod daemonize;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user