bitpay / copay-recovery

A simple client-side app to recover funds from all current and past Copay backups.
https://bitpay.github.io/copay-recovery/
55 stars 59 forks source link

recovering BCH #89

Open gabrielbazan7 opened 6 years ago

gabrielbazan7 commented 6 years ago

morrisonbrett:

I'm having the same issue. My older, Derivation Strategy BIP45 wallet had BTC in it pre-fork, and I'm not seeing anything in the recovery tool. Wallet ID: 4b3133503ee52b85

morrisonbrett commented 6 years ago

@gabrielbazan7 responding to your comment: https://github.com/bitpay/copay-recovery/issues/86#issuecomment-343915793.

Running with Chrome Console output now... Will post results.

morrisonbrett commented 6 years ago

Nothing in the console output.

image

gabrielbazan7 commented 6 years ago

Could you download the project and make some tests ? Try deleting lines 313 to 326 in src -> app -> services -> recovery.service.ts . This ones:

  if (wallet.publicKeyRing) {
      let hdPublicKey;
      let derivedItemsArray = [].concat(derivedItems);
      let path = derivedItemsArray[0].path;
      let n = parseInt(_.last(path.split('/')).toString());
      derivedPublicKeys = [];
      wallet.publicKeyRing.forEach((item) => {
        if (wallet.derivationStrategy == 'BIP45')
          hdPublicKey = new self.bitcore.HDPublicKey(item.xPubKey).deriveChild(2147483647).deriveChild(n).deriveChild(index);
        if (wallet.derivationStrategy == 'BIP44')
          hdPublicKey = new self.bitcore.HDPublicKey(item.xPubKey).deriveChild(n).deriveChild(index);
        derivedPublicKeys.push(hdPublicKey.publicKey);
      });
    } 
morrisonbrett commented 6 years ago

Just tried. Ran npm install and ng serve and I'm getting this fatal error in the browser:

index.js:12 Uncaught Error: More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.
    at Object.webpackJsonp.../../../../bitcore-mnemonic/node_modules/bitcore-lib/index.js.bitcore.versionGuard (index.js:12)
    at Object.<anonymous> (index.js:15)
    at Object.../../../../bitcore-mnemonic/node_modules/bitcore-lib/index.js (index.js:69)
    at __webpack_require__ (bootstrap 9fad9ceb3f0c1250614e:54)
    at Object.<anonymous> (mnemonic.js:3)
    at Object.../../../../bitcore-mnemonic/lib/mnemonic.js (mnemonic.js:297)
    at __webpack_require__ (bootstrap 9fad9ceb3f0c1250614e:54)
    at Object.../../../../bitcore-mnemonic/index.js (index.js:1)
    at __webpack_require__ (bootstrap 9fad9ceb3f0c1250614e:54)
    at Object.../../../../../src/app/services/recovery.service.ts (app.module.ts:21)
gabrielbazan7 commented 6 years ago

Sorry about that. Modify this package.json dependencies: "bitcore-mnemonic": "1.2.5" "bitcore-lib": "0.14.0" Remove the ^. Then remove node_modules and run npm i again. Then follow the README to fix the Crypto issue.

morrisonbrett commented 6 years ago

Got it. That fixed the runtime.

morrisonbrett commented 6 years ago

OK. Just ran the tool locally with lines 313 to 326 removed. Same result. 0 BCH. :-(

gabrielbazan7 commented 6 years ago

Did the tool find any active address if you set BTC instead of BCH?

morrisonbrett commented 6 years ago

Not sure how to answer that. I left the address gap to 20 (default). And I see 'Inactive Address Streak' increment during the run. I don't see console / browser output showing if I have any 'active address'.

JDonadio commented 6 years ago

@morrisonbrett ensure to select all levels if you are using Chrome.

copay_-_copay_bitcoin_wallet

gabrielbazan7 commented 6 years ago

Try to modify line 80 in src -> app -> services -> recovery.service.ts. Remove payload.addressType and leave P2SH only.

gabrielbazan7 commented 6 years ago

That is an old file backup? if the answer is yes. Could you try importing in Copay, and exporting again for new file backup?

morrisonbrett commented 6 years ago

@JDonadio yes it's all levels.

morrisonbrett commented 6 years ago

@gabrielbazan7 The wallet is in CoPay. I've tried both a backup I have from 01/2017 and from a few days ago.

gabrielbazan7 commented 6 years ago

Try the first option, modify that line and try again.

morrisonbrett commented 6 years ago

Tried modifying that line, and I got a CORS error.

morrisonbrett commented 6 years ago

OK. I installed a CORS chrome extension and it's running now with line 82 modified. Console is "active addresses" on BTC, but then error for the address.

gabrielbazan7 commented 6 years ago

It seems that insight is down... Sorry.. I will tell you when it starts working again.

gabrielbazan7 commented 6 years ago

BCH hardfork is happening right now... so, we have to wait for insight update. But, try with BTC instead of BCH, tell me if you find active addresses

morrisonbrett commented 6 years ago

I'm not seeing any active addresses in the Console.

gabrielbazan7 commented 6 years ago

With the line I told you modified ?

morrisonbrett commented 6 years ago

Yes, with that line modified. None.

morrisonbrett commented 6 years ago

Please tell me this isn't hopeless. I've been using CoPay exclusively since January. The coins were in my CoPay wallet pre-fork. Not seeing the address has me worried.

gabrielbazan7 commented 6 years ago

Let's try to fix the problem together tomorrow.

morrisonbrett commented 6 years ago

Thx. We can share screens if that helps.

gabrielbazan7 commented 6 years ago

Sure !

gabrielbazan7 commented 6 years ago

I send you an email

morrisonbrett commented 6 years ago

Replied

morrisonbrett commented 6 years ago

How's it looking?

gabrielbazan7 commented 6 years ago

I could find some BCH. But not all... your backup file seems to be corrupt. I modified the line I told you. No more changes to the code, only this:

Try to modify line 80 in src -> app -> services -> recovery.service.ts. Remove payload.addressType and leave P2SH only.

the credentials object should be :

var credential = {
      walletId: payload.walletId,
      copayerId: payload.copayerId,
      publicKeyRing: payload.publicKeyRing,
      xPriv: xPriv,
      derivationStrategy: "BIP45",
      addressType: "P2SH",
      m: m,
      n: n,
      network: network,
      coin: coin,
      from: "backup",
    }; 

finding 6.21433319 BCH from H6muxFAM1MYx1f3zVQ8j2dZH11CaKWYrc6, HC4psyg1eFmrnqwVnUYXccE1buXbxuvqtB and H9rTadZF2kWBpG3SARt57N6ERKrUkdrcV3.

Let me investigate further. You are right that this address belongs to your wallet and have balance: HFwJ6e1X54bzWZ4ZpHGSoNBt9SFkFt2g8i

It's ok if you want to move that 6.21433319 BCH balance to a new BCH wallet.

morrisonbrett commented 6 years ago

Would it help if we did a screen share?

gabrielbazan7 commented 6 years ago

No for the moment. Thanks.

morrisonbrett commented 6 years ago

Those addresses that start with H. They're not showing up on Blocktrail.

gabrielbazan7 commented 6 years ago

Try using https://bch-insight.bitpay.com/. Blocktrail do not support the new addresses convention for BCH. https://support.bitpay.com/hc/en-us/articles/115004671663-BitPay-s-Adopted-Conventions-for-Bitcoin-Cash-Addresses-URIs-and-Payment-Requests

JDonadio commented 6 years ago

If you want to use another block-explorer you should translate it using the address translator tool

morrisonbrett commented 6 years ago

Looking at this, how did it get to 0 balance? I've never moved BCH. It says it was 'mined' on 08/04 and then is moved out of there.

morrisonbrett commented 6 years ago

After running the tool, I see I can transfer the BCH. Should I go for it? And then we can try and recover the rest?

gabrielbazan7 commented 6 years ago

Yes. I'm closer to make it work.

morrisonbrett commented 6 years ago

OK. It's on its way to my new Copay[BCH] wallet!

morrisonbrett commented 6 years ago

"Closer to make it work". Fingers crossed @gabrielbazan7. Thank you!

Noticed the BCH network is slowwwww. It's still an unconfirmed transaction.

gabrielbazan7 commented 6 years ago

Sorry, we still having problems with our backend. I will let you know when the tool start working fine again.

gabrielbazan7 commented 6 years ago

I just send a PR with fix. I was able to find your BCH :) !! Could you try now ? Do a pull of master branch. And remember to do this :

Try to modify line 80 in src -> app -> services -> recovery.service.ts. Remove payload.addressType and leave P2SH only.
morrisonbrett commented 6 years ago

YOU FOUND IT??!!! I'm a little confused. Didn't I already do this? Also, I don't see your PR fixing this. Should I just pull master from your repo and run that version?

Also - I submitted a PR too for some cosmetic fixes.

gabrielbazan7 commented 6 years ago

Yes! It's already on master.

morrisonbrett commented 6 years ago

OK - with latest master and that line commented out - I SEE THE RIGHT BALANCE PRE-FORK!!!

Yes!!!!

I increased the BCH transaction fee to 0.005 (around $6 at today's price), and I'm re-running. Maybe that will make the transaction confirm much sooner than the default of 0.0001. Because my attempt to move coins yesterday is still unconfirmed. Not trying to "double spend" here. Hopefully this higher-fee one goes through and the other one will get rejected.

morrisonbrett commented 6 years ago

OK. Just tried to send to my new Copay BCH wallet. I got this: Could not build tx: TypeError: Address has mismatched network type..

Should I run this through your address translator? Why isn't the Copay wallet generating the native address?

gabrielbazan7 commented 6 years ago

Yes, use the address translator. Translate the address that Copay wallet is given to you and use that one on the tool.

morrisonbrett commented 6 years ago

I'm now getting: Please enter a valid address.

Also, is it OK / smart that I increased the fee?

gabrielbazan7 commented 6 years ago

Let me test it.

smart that I increased the fee? 

^ that's ok.

morrisonbrett commented 6 years ago

I tried just now using the Bitcoin.com wallet, which I noticed is similar to Copay / Bitpay. That receiving address didn't work either.