ordinals / ord

👁‍🗨 Rare and exotic sats
https://ordinals.com
Creative Commons Zero v1.0 Universal
3.84k stars 1.37k forks source link

error: wallet "ord" contains unexpected output descriptors, and does not appear to be an `ord` wallet, create a new wallet with `ord wallet create` #2719

Closed KKimos closed 8 months ago

KKimos commented 10 months ago

Whenever I perform operations on the wallet (deleting, creating, using bitcoin-cli to create a wallet), I encounter this problem.

KKimos commented 10 months ago

This issue needs to be fixed as soon as possible, as it greatly affects the user experience.

siyangyuandegit commented 10 months ago

me too

raphjaph commented 10 months ago

ord requires a specific kind of Bitcoin Core wallet, if you create one not using ord wallet create it will not work. Do not create a wallet with bitcoin-cli if you want to use it with ord.

What happens when you create a wallet with ord wallet create?

0pcom commented 10 months ago

I followed the documentation exactly, as far as I can tell. The wallet is created but I can't receive or do other operations on the wallet because of the error in the title of this issue.

[0pcom@linux ord-0.13.1]$ sudo rm -rf /var/lib/bitcoind/wallets/ord
[0pcom@linux ord-0.13.1]$ ./ord wallet create
{
  "mnemonic": "plug fatal spy carpet dust live auction gossip story odor banner fan",
  "passphrase": ""
}
[0pcom@host ord-0.13.1]$ ./ord wallet receive
error: wallet "ord" contains unexpected output descriptors, and does not appear to be an `ord` wallet, create a new wallet with `ord wallet create`

The logging from bitcoind shows that the cookie authentication worked and the wallet was created

023-12-20T19:16:50Z Using SQLite Version 3.43.1
2023-12-20T19:16:50Z Using wallet /var/lib/bitcoind/wallets/ord
2023-12-20T19:16:50Z init message: Loading wallet\u2026
2023-12-20T19:16:50Z [ord] Wallet file version = 10500, last client version = 250000
2023-12-20T19:16:50Z [ord] Keys: 0 plaintext, 0 encrypted, 0 w/ metadata, 0 total. Unknown wallet records: 0
2023-12-20T19:16:50Z [ord] Setting minversion to 169900
2023-12-20T19:16:50Z [ord] Wallet completed loading in              62ms
2023-12-20T19:16:50Z [ord] setKeyPool.size() = 0
2023-12-20T19:16:50Z [ord] mapWallet.size() = 0
2023-12-20T19:16:50Z [ord] m_address_book.size() = 0
2023-12-20T19:16:50Z [ord] Setting spkMan to active: id = 89773e84c2d268490254eb901e2f7ba9dfe75e554fa9c6f327824464deee27f1, type = bech32m, internal = false
2023-12-20T19:16:50Z [ord] RescanFromTime: Rescanning last 16 blocks
2023-12-20T19:16:50Z [ord] Rescan started from block 00000000000000000003e9e6ad8e08d9a0cca2a19e64077b393686ed85bf7999... (slow variant inspecting all blocks)
2023-12-20T19:16:50Z [ord] Scanning current mempool transactions.
2023-12-20T19:16:51Z [ord] Rescan completed in             723ms
2023-12-20T19:16:51Z [ord] Setting spkMan to active: id = 5676cbc02c76501f17c278c8e6406454ea9170016e279bd4e7e7088ff18a06c5, type = bech32m, internal = true
2023-12-20T19:16:51Z [ord] RescanFromTime: Rescanning last 16 blocks
2023-12-20T19:16:51Z [ord] Rescan started from block 00000000000000000003e9e6ad8e08d9a0cca2a19e64077b393686ed85bf7999... (slow variant inspecting all blocks)
2023-12-20T19:16:51Z [ord] Scanning current mempool transactions.
2023-12-20T19:16:52Z [ord] Rescan completed in             772ms

either the documentation is wrong or this is a bug.

tested on archlinux with bitcoin-daemon 25.0-3

tested with version 0.13.1, 0.13.0, 0.12.3, 0.9.0.. same result

raphjaph commented 10 months ago

Ok, after some debugging I think I know what's going on here.

You seemed to have already created an ord wallet before and loaded it into Bitcoin Core. Then while Bitcoin Core was still running you deleted the wallet from disk. Then you created a wallet with the same name but the existing wallet was still in memory. The wallet.dat file didn't exist so Bitcoin didn't complain that you are creating a wallet that already exists, but it still had the old wallet in memory. It then proceeded to write both wallet descriptors to the wallet.dat file (the new one and the one that was still in memory).

We have a check for a specific kind and number of descriptors, since this now was different than what we expect the wallet to have our code errored. It's good that there was this error or otherwise the wallet would have done unexpected things.

The task for me is now to figure out how to prevent creating a wallet even if it is deleted from disk but still in memory.

If your wallet didn't have any BTC or inscriptions I recommend stopping Bitcoin Core, deleting (or to be safe moving) the ord directory inside the wallets directory. Then restart bitcoind and try creating a new wallet with ord wallet create. Alternatively you can create a named wallet with ord --wallet my_wallet_name wallet create. If you do this you will always have to pass in the wallet name: ord --wallet my_wallet_name wallet receive

0pcom commented 10 months ago

Thanks for your reply, however I only ever deleted the wallet from the disk in the first place because of this error.

in the second place, being able to delete a wallet from memory directly with, say ord wallet delete or documentation reflecting how to do so properly would help others.

mainly the issue i have is bitcoin-cli is not authenticating to the .cookie as ord wallet command does.

Will try your suggestions @raphjaph, sincere thanks.

raphjaph commented 8 months ago

3048 we just merged this which allows to dump the wallet descriptor and restore from one. This might help you. It's not in a release version yet but will probably release something next week.

raphjaph commented 8 months ago

The way to recover the wallet would be to do:

bitcoin-cli -rpcwallet=<WALLET_NAMME> listdescriptors true > descriptor.json

and then load a new ord wallet from that descriptor

cat descriptor.json | ord wallet --name <NEW_WALLET_NAME> restore --descriptor
gmart7t2 commented 6 months ago

being able to delete a wallet from memory directly with, say ord wallet delete or documentation reflecting how to do so properly would help others

bitcoin-cli unloadwallet ord

Cardoso-CHM commented 6 months ago

Hi guys, @gmart7t2 @raphjaph I'm struggling to understand this whole wallet recovering thing, and I would like to understand this clearly to pass the correct information to around 200 people...

Goal

I aim to recover an existing wallet (created at unisat/xverse/...) into the cli to execute the commands.

What I've Tried

I accomplish so using the command in an unsafe way:

ord.exe --bitcoin-data-dir D:/btc/data --data-dir D:/btc/ord/data --cookie-file D:/btc/data/.cookie wallet restore --from mnemonic
[then I typed the 12 secret words here separated by space and finished with a "Ctrl + z" command and "enter" (using Windows 11 here...)]

Is there a way to put the 12 secret words in a file and load that file so the words won't be in the prompt history?

I tried to use a .txt file with the words separated by space for example: "word1 word2 word3 word4 ... word12"

And then I tried to execute the following command:

cat secret.txt | ord.exe --bitcoin-data-dir D:/btc/data --data-dir D:/btc/ord/data --cookie-file D:/btc/data/.cookie wallet restore --from descriptor

Which gave the output:

error: expected value at line 1 column 1

Questions

  1. How can I recover an existing btc wallet using the 12 secret words to execute the cli commands?
  2. How can I set a password to be requested every time i try to run an inscription/mint... command, like when we type the password to access our hot wallet at the browsers?

Thanks for your time and attention, success to everybody!