comit-network / xmr-btc-swap

Bitcoin–Monero Cross-chain Atomic Swap
GNU General Public License v3.0
655 stars 83 forks source link

Error: Unable to create Monero wallet (Cannot create wallet. Already exists.) #971

Open elibroftw opened 2 years ago

elibroftw commented 2 years ago

Describe the bug

First, there's no easy way to rerun the interactive configuration. I deleted the config file to trigger it. Therefore, I'm not sure if this error is because I ran asb start a second time or because I deleted the config file. Someone else can figure out the race condition.

C:\Users\maste\Downloads\commit-xmr-btc-swap>asb start
2022-03-06T14:00:26.6810483-05:00  INFO Initialized tracing level=debug
2022-03-06T14:00:26.6813241-05:00  INFO Running initial setup for mainnet

✔ Enter data directory for asb or hit return to use default · C:\Users\maste\AppData\Roaming\xmr-btc-swap\data\asb\mainnet
✔ How fast should your Bitcoin transactions be confirmed? Your transaction fee will be calculated based on this target. Hit return to use default · 3
? Enter multiaddresses (comma separated) on which asb should list for peer-to-peer communications or hit return to use default (/ip4/0.0.0.0/tcp/9939,/ip4/0.0.0.0/tcp/9940/ws) ✔ Enter multiaddresses (comma separated) on which asb should list for peer-to-peer communications or hit return to use default · /ip4/0.0.0.0/tcp/9939,/ip4/0.0.0.0/tcp/9940/ws
✔ Enter Electrum RPC URL or hit return to use default · ssl://blockstream.info:700
✔ Enter Monero Wallet RPC URL or hit enter to use default · http://127.0.0.1:18083/json_rpc
✔ Enter Tor control port or hit enter to use default. If Tor is not running on your machine, no hidden service will be created. · 9051
✔ Enter Tor socks5 port or hit enter to use default · 9050
✔ Enter minimum Bitcoin amount you are willing to accept per swap or hit enter to use default. · 0.0002
✔ Enter maximum Bitcoin amount you are willing to accept per swap or hit enter to use default. · 0.003
✔ Enter spread (in percent; value between 0.x and 1.0) to be used on top of the market rate or hit enter to use default. · 0.1
✔ Do you want to advertise your ASB instance with a rendezvous node? Enter an empty string if not. ·

2022-03-06T14:00:44.9631898-05:00  INFO Initial setup complete, config file created path=C:\Users\maste\AppData\Roaming\xmr-btc-swap\config\asb\mainnet\config.toml
2022-03-06T14:00:44.9634152-05:00  INFO Reading config file path=C:\Users\maste\AppData\Roaming\xmr-btc-swap\config\asb\mainnet\config.toml
2022-03-06T14:00:44.9642837-05:00 DEBUG Using existing sqlite database.
2022-03-06T14:00:44.9666124-05:00 DEBUG Reading in seed from C:\Users\maste\AppData\Roaming\xmr-btc-swap\data\asb\mainnet\seed.pem
2022-03-06T14:00:44.966721-05:00 DEBUG Opening Bitcoin wallet
2022-03-06T14:00:45.3360098-05:00 DEBUG Opening Monero wallet
Error: Unable to create Monero wallet, please ensure that the monero-wallet-rpc is available

Caused by:
    0: JSON-RPC request failed with code -21: Cannot create wallet. Already exists.
    1: JSON-RPC request failed with code -21: Cannot create wallet. Already exists.

C:\Users\maste\Downloads\commit-xmr-btc-swap>

Lost/trapped Funds Yes or No

Debug logs Please post your debug logs. You find them in: Linux: /home//.local/share/xmr-btc-swap/logs OSX: /Users//Library/ApplicationSupport/xmr-btc-swap/logs

Platform (please complete the following information):

binarybaron commented 2 years ago

Probably related to https://github.com/comit-network/xmr-btc-swap/issues/835

elibroftw commented 2 years ago

I don't think so

binarybaron commented 2 years ago

Can you do a ps | grep monero-wallet-rpc before starting the asb a second time?

elibroftw commented 2 years ago

I can barely do anything useful if https://github.com/comit-network/xmr-btc-swap/issues/970 is stopping me from entering an RPC port. 🤦‍♂️

elibroftw commented 2 years ago

The monero-wallet-rpc will run because it is manually run by me. The ASB does not spawn a monero-wallet-rpc. The bug is that the asb thinks the wallet does not exist even though it does so it tries to create a wallet and that fails!

binarybaron commented 2 years ago

Please watch your language. All active contributors are unpaid volunteers. No one owes you anything.

elibroftw commented 2 years ago

I digress. I'll leave this here https://github.com/comit-network/xmr-btc-swap/blob/master/swap/src/monero/wallet.rs#L31 if someone wants to read my mind (i.e. put a print statement here to see if the software can't open the wallet). Is it possible the ASB forgets to close the wallet when it exits? Therefore the running instance of the wallet-rpc still has the wallet opened? If so, then why doesn't the ASB account for that scenario. Or why doesn't it just spawn the RPC itself rather than requiring the user to do it for them?

binarybaron commented 2 years ago

Yeah, you're right. This is probably what's happening here. Is it fixed by restarting the rpc?

elibroftw commented 2 years ago

Yes it works if I restart the RPC