Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --rune flag to resume command to enable resuming a specific etching #3679

Merged
merged 10 commits into from
May 17, 2024
23 changes: 22 additions & 1 deletion src/subcommand/wallet/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub struct ResumeOutput {
pub(crate) struct Resume {
#[arg(long, help = "Don't broadcast transactions.")]
pub(crate) dry_run: bool,
#[arg(long, value_name = "PENDING•RUNE", help = "Rune to resume (spaced).")]
ldiego08 marked this conversation as resolved.
Show resolved Hide resolved
pub(crate) rune: Option<SpacedRune>,
}

impl Resume {
Expand All @@ -18,7 +20,26 @@ impl Resume {
break;
}

for (rune, entry) in wallet.pending_etchings()? {
let mut pending_etchings = Vec::new();
let spaced_rune = self.rune.clone();

if let Some(spaced_rune) = spaced_rune {
ldiego08 marked this conversation as resolved.
Show resolved Hide resolved
let pending_etching = wallet
.pending_etchings()?
.into_iter()
.find(|(rune, _)| *rune == spaced_rune.rune);
ldiego08 marked this conversation as resolved.
Show resolved Hide resolved

ensure!(
pending_etching.is_some(),
"rune `{spaced_rune}` does not correspond to any pending etching."
);

pending_etchings.push(pending_etching.unwrap());
} else {
pending_etchings.extend(wallet.pending_etchings()?);
}
ldiego08 marked this conversation as resolved.
Show resolved Hide resolved

for (rune, entry) in pending_etchings {
if self.dry_run {
etchings.push(batch::Output {
reveal_broadcast: false,
Expand Down
Loading