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

"ord wallet mint" spent my immature etch commitment #3436

Closed
gmart7t2 opened this issue Apr 1, 2024 · 4 comments
Closed

"ord wallet mint" spent my immature etch commitment #3436

gmart7t2 opened this issue Apr 1, 2024 · 4 comments

Comments

@gmart7t2
Copy link
Contributor

gmart7t2 commented Apr 1, 2024

I made a new etching:
https://mempool.space/signet/tx/54b6bf9922956bed66c1d4f45b5e53c2ece2288da92d4b92b6e2bc1d2d690f93
It confirmed in block 189442.

I hit control-C while waiting for it to mature, to test that I could resume it later.

While waiting for it to mature, I minted some other tokens:
https://mempool.space/signet/tx/b380a138389006893fac084b7377a5e4e4f3847f50be80523e41fe126f8e65d3

The mint tx spent my commitment! The mint confirmed in block 189446, while the commitment was 4 blocks deep.

When I went back to resume the etching, I saw:
"Waiting for rune commitment 54b6bf9922956bed66c1d4f45b5e53c2ece2288da92d4b92b6e2bc1d2d690f93 to mature…"
even though by now the commitment was 11 blocks deep.

Checking the wait loop I see that the .get_tx_out(&commit.txid(), ...) call is returning None, because the output is no longer unspent.

We should:

  • avoid spending commitment utxos except by revealing them
  • detect and complain when commitment utxos have been spent, rather than entering an infinite loop
@gmart7t2
Copy link
Contributor Author

gmart7t2 commented Apr 6, 2024

When you etch a rune, the commit tx output is in the wallet for 6 blocks until it is spend by the reveal tx. During that time it shows up as a cardinal and is available for spending by other etchings, mints, inscriptions, etc.

The following change ignores these "commit tx recovery key" utxos so they won't be accidentally spent:

diff --git a/src/wallet.rs b/src/wallet.rs
index b1ff75f0..a6683631 100644
--- a/src/wallet.rs
+++ b/src/wallet.rs
@@ -245,6 +245,7 @@ impl Wallet {
       bitcoin_client
         .list_unspent(None, None, None, None, None)?
         .into_iter()
+        .filter(|utxo| utxo.label != Some("commit tx recovery key".to_string()))
         .map(|utxo| {
           let outpoint = OutPoint::new(utxo.txid, utxo.vout);
           let txout = TxOut {

@raphjaph
Copy link
Collaborator

raphjaph commented Apr 8, 2024

Thanks for the report!

I have a PR open that fixes the loop thing and errors if commitment is spent.

I think the most straightforward solution would be to lock the commitment output. The reveal can still spend it but it won't be picked in transaction construction.

@raphjaph
Copy link
Collaborator

raphjaph commented Apr 8, 2024

#3480

@raphjaph raphjaph added this to Tracker Apr 15, 2024
@raphjaph raphjaph moved this to To Do in Tracker Apr 15, 2024
@raphjaph
Copy link
Collaborator

We now lock the commitment output: #3504

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants