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
24 changes: 23 additions & 1 deletion src/subcommand/wallet/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pub struct ResumeOutput {
pub(crate) struct Resume {
#[arg(long, help = "Don't broadcast transactions.")]
pub(crate) dry_run: bool,

ldiego08 marked this conversation as resolved.
Show resolved Hide resolved
#[arg(long, help = "Rune commitment to resume.")]
pub(crate) commitment: Option<String>,
ldiego08 marked this conversation as resolved.
Show resolved Hide resolved
}

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

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

if let Some(commitment) = commitment {
ldiego08 marked this conversation as resolved.
Show resolved Hide resolved
let pending_etching = wallet
.pending_etchings()?
.into_iter()
.find(|(_, entry)| entry.commit.txid().to_string() == commitment);

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

pending_etchings.push(pending_etching.unwrap());
} else {
pending_etchings.extend(wallet.pending_etchings()?.into_iter());
}

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