JoinMarket-Org / joinmarket-clientserver

Bitcoin CoinJoin implementation with incentive structure to convince people to take part
GNU General Public License v3.0
731 stars 179 forks source link

Accessing wallet never connected to Bitcoin Core #676

Closed beardo01 closed 4 years ago

beardo01 commented 4 years ago

Hey there,

I've made a rookie error and deposited coins into a wallet which never connected to Bitcoin Core. I get that this is completely my fault, but would appreciate some help if possible.

What I did I followed the installation instructions listed here for macOS. Everything seemed to run smoothly. I began tinkering with the joinmarket.cfg config and inadvertently set my blockchain_source to no-blockchain. I generated a wallet using the python wallet-tool.py generate command and then listed my addresses using the python wallet-tool.py wallet.jmdat command. I deposited Bitcoin into one of my addresses before realising that I wasn't correctly connecting to Bitcoin Core. When I set the blockchain_source back to bitcoin-rpc I get an error stating Failure of RPC connection to Bitcoin Core. Application cannot continue, shutting down. when attempting to run python joinmarket-qt.py.

What should I do? I'm not entirely sure how I am meant to be connecting to Bitcoin Core and if once I do connect, I'll be able to access my funds deposited to the wallet address listed earlier.

Would I be better off somehow exporting this wallet to another program (or whatever that process is)?

Any advice would be appreciated. Let me know if you have any questions.

Cheers!

undeath commented 4 years ago

Your funds are not lost, only your wallet is lacking connectivity to the bitcoin network to know about deposited funds.

In order to use joinmarket you need a fully synced bitcoind running and configure that bitcoind in your joinmarket.cfg.

beardo01 commented 4 years ago

Your funds are not lost, only your wallet is lacking connectivity to the bitcoin network to know about deposited funds.

In order to use joinmarket you need a fully synced bitcoind running and configure that bitcoind in your joinmarket.cfg.

Hey @undeath, thanks for the quick reply. Your explanation matches what I thought was the case.

If I understand correctly, I'll need to install Bitcoin Core which will generate a bitcoin.conf, synchronise with the full blockchain (320gb ish) and then configure my joinmarket.cfg to connect to the synchronised node? Feel free to correct me if I am wrong.

As a bonus, is there an alternative way rather than synchronising the full blockchain? Would it be easier to install another wallet (like Electrum or something else) and import my existing wallet generated by joinmarket into that?

Thanks a lot!

AdamISZ commented 4 years ago

Yes, there are a couple of ways to access the funds you deposited without using Joinmarket. The seedphrase is BIP39, so you can take that and import it into certain wallets, including Electrum (but note: there are several options in that import process; if you deposited into the first mixdepth, then the account will be /0 which is what Electrum uses by default (Electrum no longer supports multiple accounts), so in that case it would show up there automatically; if you used one of the later mixdepths (1-4) then I believe you can specify the exact HD path during the Electrum import process). The other way is to print out the private key of the address you deposited to; I believe this works with no-blockchain source; I will double check. Look at the options of wallet-tool with python wallet-tool.py --help and note in particular the -H option, although you may not need it.

AdamISZ commented 4 years ago

On the above "double-check":

You need the HD path of the address you deposited to, which you can get again from the display command you already used.

The command is like this:

(jmvenv) user@jmcs$ python wallet-tool.py -H "m/49'/0'/0'/0/0" wallet.jmdat dumpprivkey
User data location: ~/.joinmarket
Enter passphrase to decrypt wallet: 
2020-08-26 13:42:18,892 [WARNING]  No blockchain source available, wallet tools will not show correct balances.
cRqJhu3MGdftCztveJ86x9nHQr6E6sAvR6KJGcjEVJS5CnFwSfJ6

(note: the above is a testnet private key, the mainnet starts with K or L not c.)

beardo01 commented 4 years ago

Cheers @AdamISZ. Unfortunately it looks like since I am running the macOS Big Sur Developer Beta Electrum won't open, however I wanted to add that I do have my full 12 word mnemonic phrase, wallet password and have been able to access the wallet private key via python wallet-tool.py -H "m/49'/0'/4'/0/0" wallet.jmdat dumpprivkey (the key beings with a L).

Additionally, FYI the address that I deposited into was the very first address listed after running python wallet-tool.py wallet.jmdat, which as I understand means that that the mixdepth should be (as you rightly pointed out) 0.

Pardon my ignorance, but with the information I listed above, does that mean that I should be able to recover the wallet on any device (i.e. not my Mac running Big Sur) or do I need to do it on my Mac?

Thanks!

AdamISZ commented 4 years ago

Well, the wallet is one thing, but from what you say, you just deposited funds into an address; and you now have the private key to that address, so you can import or sweep that private key into any number of wallets to access/spend the funds. And that's not platform specific. (also I'm pretty sure you should be able to open Electrum fine on your macOS, I just don't know any details, not being a user).

BIP39 (with the seedphrase) is just easier if you want to use the whole wallet (e.g. if you had multiple utxos, on different addresses).

AdamISZ commented 4 years ago

Oh, I did forget one important point: the importing-private-key thing depends on the deposited wallet supporting p2sh-p2wpkh (that's segwit address starting with '3' which is a common type, but certainly not universal) addresses. If you import into a wallet that thinks it should be native segwit ('bc1..') or non-segwit ('1..'), then of course the funds will not be recognised since they're different addresses.

beardo01 commented 4 years ago

Oh, I did forget one important point: the importing-private-key thing depends on the deposited wallet supporting p2sh-p2wpkh (that's segwit address starting with '3' which is a common type, but certainly not universal) addresses. If you import into a wallet that thinks it should be native segwit ('bc1..') or non-segwit ('1..'), then of course the funds will not be recognised since they're different addresses.

Ahh, I think therein lies the issue. I have imported the address into a seperate wallet using the private key I got earlier, however it looks like the imported address is different (starts with a 1 rather than a 3) than the one that I deposited money to (and is listed when I view the addresses).

I take it I need to find a wallet that supports p2sh-p2wpkh and import the address into that using the private key (bear with me as I learn the correct terminology)?

AdamISZ commented 4 years ago

Yes. The situation is a little frustrating for me, as Bitcoin Core, Electrum and Joinmarket are the three wallets I use or have used the most, and the first two are very widely used indeed, but all are disqualified here. Trezor and Ledger would happily import your bip39 seedphrase, but that's of no interest if you don't have those devices (I think?). As for sweeping/importing private keys in other wallets, I'm not sure on details of various wallets. I think GreenAddress (now Blockstream Green) has an import private key function, but I can't be sure if it works here, I mean you could try it.

BIP39 might be easier just because it's a widely known wallet standard (and indeed the purpose of the standard is exactly to avoid the kind of issue you encountered with importing a raw private key), I don't know which of the two is easier, but you have both available, by design. We created every conceivable possibility for someone to take money out of the wallet.

undeath commented 4 years ago

If I understand correctly, I'll need to install Bitcoin Core which will generate a bitcoin.conf, synchronise with the full blockchain (320gb ish) and then configure my joinmarket.cfg to connect to the synchronised node?

Yes, that's correct.

As a bonus, is there an alternative way rather than synchronising the full blockchain? Would it be easier to install another wallet (like Electrum or something else) and import my existing wallet generated by joinmarket into that?

Unfortunately, there is not. Other wallets like Electrum will send all your addresses to the connected Electrum server, which allows linking them together and allow deanonymizing all your coinjoins (if you are connected to an evil server, but point is: do not trust anyone or anything if you want to ensure privacy). This is of course also the case if you import multiple joinmarket addresses into an Electrum wallet or similar.

beardo01 commented 4 years ago

@undeath @AdamISZ

I'm happy to report that I was able to build Electrum Wallet locally on my machine and run it without the problems that I was experiencing earlier. This let me import the address using the private key and prefixing the private key with the type of wallet p2wpkh-p2sh:privateKey.

Thank you both for your assistance!