Skip to content

Commit

Permalink
Clear etching when rune commitment is spent (#3618)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipelincoln authored Apr 19, 2024
1 parent 036ef68 commit e85c325
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/subcommand/wallet/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Resume {
continue;
};

if wallet.is_mature(&entry.commit)? {
if wallet.is_mature(rune, &entry.commit)? {
etchings.push(wallet.send_etching(rune, &entry)?);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl Wallet {
self.settings.integration_test()
}

pub(crate) fn is_mature(&self, commit: &Transaction) -> Result<bool> {
pub(crate) fn is_mature(&self, rune: Rune, commit: &Transaction) -> Result<bool> {
let transaction = self
.bitcoin_client()
.get_transaction(&commit.txid(), Some(true))
Expand All @@ -315,6 +315,7 @@ impl Wallet {
return Ok(true);
}
} else {
self.clear_etching(rune)?;
bail!("rune commitment spent, can't send reveal tx");
}
}
Expand All @@ -340,7 +341,7 @@ impl Wallet {
return Ok(entry.output);
}

if self.is_mature(&entry.commit)? {
if self.is_mature(rune, &entry.commit)? {
break;
}

Expand Down

0 comments on commit e85c325

Please sign in to comment.