use crate::jcli_lib::certificate::{write_cert, Error};
use chain_crypto::Blake2b256;
use chain_impl_mockchain::certificate::{Certificate, PoolRetirement};
use chain_time::DurationSeconds;
use clap::Parser;
use std::path::PathBuf;
#[derive(Parser)]
pub struct StakePoolRetirement {
#[clap(long = "pool-id", name = "POOL_ID")]
pool_id: Blake2b256,
#[clap(long = "retirement-time", name = "SECONDS-SINCE-START")]
pub retirement_time: u64,
pub output: Option<PathBuf>,
}
impl StakePoolRetirement {
pub fn exec(self) -> Result<(), Error> {
let pool_retirement = PoolRetirement {
pool_id: self.pool_id.into(),
retirement_time: DurationSeconds::from(self.retirement_time).into(),
};
let cert = Certificate::PoolRetirement(pool_retirement);
write_cert(self.output, cert.into())
}
}