From e85c3258f4bf2801d3d77cce7f397387810e4ccf Mon Sep 17 00:00:00 2001 From: Felipe Lincoln Date: Fri, 19 Apr 2024 16:36:52 -0300 Subject: [PATCH] Clear etching when rune commitment is spent (#3618) --- src/subcommand/wallet/resume.rs | 2 +- src/wallet.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/subcommand/wallet/resume.rs b/src/subcommand/wallet/resume.rs index 7a59df706b..3cea3f0fa4 100644 --- a/src/subcommand/wallet/resume.rs +++ b/src/subcommand/wallet/resume.rs @@ -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)?); } } diff --git a/src/wallet.rs b/src/wallet.rs index 9b066d68cc..5a4f7b9411 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -296,7 +296,7 @@ impl Wallet { self.settings.integration_test() } - pub(crate) fn is_mature(&self, commit: &Transaction) -> Result { + pub(crate) fn is_mature(&self, rune: Rune, commit: &Transaction) -> Result { let transaction = self .bitcoin_client() .get_transaction(&commit.txid(), Some(true)) @@ -315,6 +315,7 @@ impl Wallet { return Ok(true); } } else { + self.clear_etching(rune)?; bail!("rune commitment spent, can't send reveal tx"); } } @@ -340,7 +341,7 @@ impl Wallet { return Ok(entry.output); } - if self.is_mature(&entry.commit)? { + if self.is_mature(rune, &entry.commit)? { break; }