diff --git a/src/subcommand/wallet.rs b/src/subcommand/wallet.rs index 28b51b0806..b555ee0f9c 100644 --- a/src/subcommand/wallet.rs +++ b/src/subcommand/wallet.rs @@ -66,7 +66,7 @@ pub(crate) enum Subcommand { #[command(about = "Restore wallet")] Restore(restore::Restore), #[command(about = "Resume pending etchings")] - Resume, + Resume(resume::Resume), #[command(about = "List wallet satoshis")] Sats(sats::Sats), #[command(about = "Send sat or inscription")] @@ -109,7 +109,7 @@ impl WalletCommand { Subcommand::Mint(mint) => mint.run(wallet), Subcommand::Outputs => outputs::run(wallet), Subcommand::Receive(receive) => receive.run(wallet), - Subcommand::Resume => resume::run(wallet), + Subcommand::Resume(resume) => resume.run(wallet), Subcommand::Sats(sats) => sats.run(wallet), Subcommand::Send(send) => send.run(wallet), Subcommand::Transactions(transactions) => transactions.run(wallet), diff --git a/src/subcommand/wallet/resume.rs b/src/subcommand/wallet/resume.rs index 3f235d0421..7a59df706b 100644 --- a/src/subcommand/wallet/resume.rs +++ b/src/subcommand/wallet/resume.rs @@ -4,28 +4,47 @@ use super::*; pub struct ResumeOutput { pub etchings: Vec, } +#[derive(Debug, Parser)] +pub(crate) struct Resume { + #[arg(long, help = "Don't broadcast transactions.")] + pub(crate) dry_run: bool, +} -pub(crate) fn run(wallet: Wallet) -> SubcommandResult { - let mut etchings = Vec::new(); - loop { - if SHUTTING_DOWN.load(atomic::Ordering::Relaxed) { - break; - } +impl Resume { + pub(crate) fn run(self, wallet: Wallet) -> SubcommandResult { + let mut etchings = Vec::new(); + loop { + if SHUTTING_DOWN.load(atomic::Ordering::Relaxed) { + break; + } - for (rune, entry) in wallet.pending_etchings()? { - if wallet.is_mature(&entry.commit)? { - etchings.push(wallet.send_etching(rune, &entry)?); + for (rune, entry) in wallet.pending_etchings()? { + if self.dry_run { + etchings.push(batch::Output { + reveal_broadcast: false, + ..entry.output.clone() + }); + continue; + }; + + if wallet.is_mature(&entry.commit)? { + etchings.push(wallet.send_etching(rune, &entry)?); + } } - } - if wallet.pending_etchings()?.is_empty() { - break; - } + if wallet.pending_etchings()?.is_empty() { + break; + } + + if self.dry_run { + break; + } - if !wallet.integration_test() { - thread::sleep(Duration::from_secs(5)); + if !wallet.integration_test() { + thread::sleep(Duration::from_secs(5)); + } } - } - Ok(Some(Box::new(ResumeOutput { etchings }) as Box)) + Ok(Some(Box::new(ResumeOutput { etchings }) as Box)) + } }