use {super::*, fee_rate::FeeRate}; #[derive(Debug, Parser)] pub(crate) struct Preview { #[command(flatten)] server: super::server::Server, inscriptions: Vec, } struct KillOnDrop(process::Child); impl Drop for KillOnDrop { fn drop(&mut self) { self.0.kill().unwrap() } } impl Preview { pub(crate) fn run(self) -> SubcommandResult { let tmpdir = TempDir::new()?; let rpc_port = TcpListener::bind("127.0.0.1:0")?.local_addr()?.port(); let bitcoin_data_dir = tmpdir.path().join("bitcoin"); fs::create_dir(&bitcoin_data_dir)?; let _bitcoind = KillOnDrop( Command::new("bitcoind") .arg({ let mut arg = OsString::from("-datadir="); arg.push(&bitcoin_data_dir); arg }) .arg("-regtest") .arg("-txindex") .arg("-listen=0") .arg(format!("-rpcport={rpc_port}")) .spawn() .context("failed to spawn `bitcoind`")?, ); let options = Options { chain_argument: Chain::Regtest,