bitpay / wallet

Bitpay Wallet (formerly Copay) is a secure Bitcoin and other crypto currencies wallet platform for both desktop and mobile devices.
http://bitpay.com/wallet
MIT License
3.78k stars 1.74k forks source link

"Key already associated" when creating wallet #5722

Closed NicSil closed 6 years ago

NicSil commented 7 years ago

At this point, Coplay iPad App has NO more wallets

import again the same seed but with m/44'/0'/0'/0/0

got error "Key already associated"

Associated with what!! does it remember my keys somewhere? This would be very bad.

https://github.com/bitpay/copay/issues/4899 https://github.com/bitpay/bitcore-wallet-service/issues/592

isocolsky commented 7 years ago

Just to clarify:

import BIP 39 seed with m/44'/0'/0'

Do you really mean creating a new wallet specifying the seed?

Delete it because it was an error

What do you mean by this? What kind of error? Were you expecting funds based on that seed+path but found 0 balance?

NicSil commented 7 years ago
the error was using m/44'/0'/0' and I wanted m/44'/0'/0'/0/0

On 06/03/2017 17:08, Ivan Socolsky
  wrote:

  Just to clarify:

    import BIP 39 seed with m/44'/0'/0'

  Do you really mean creating a new wallet specifying the seed?

    Delete it because it was an error

  What do you mean by this? What kind of error? Were you
    expecting funds based on that seed+path but found 0 balance?
  —
    You are receiving this because you authored the thread.
    Reply to this email directly, view
      it on GitHub, or mute
      the thread.

  {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/bitpay/copay","title":"bitpay/copay","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/bitpay/copay"}},"updates":{"snippets":[{"icon":"PERSON","message":"@isocolsky in #5722: Just to clarify:\r\n\r\n\u003e import BIP 39 seed with m/44'/0'/0'\r\n\r\nDo you really mean creating a new wallet specifying the seed?\r\n\r\n\r\n\u003e Delete it because it was an error\r\n\r\nWhat do you mean by this? What kind of error? Were you expecting funds based on that seed+path but found 0 balance?"}],"action":{"name":"View Issue","url":"https://github.com/bitpay/copay/issues/5722#issuecomment-284442692"}}}
dabura667 commented 7 years ago

m/44'/0'/0' is BIP44

Adding two zeroes will make your first address be m/44'/0'/0'/0/0/0/0

Copay is asking for your xPub path, not your first address path

NicSil commented 7 years ago
Ok, may be that's not the point.

Let's be more simple:
I do:

add wallet /create new wallet / advanced options/recovery phrase
and add a 12 words seed.
I get the error "Key already associated with an existing wallet".
But there is NO other wallet in the App (iPad)
I already created the wallet with the same seed and deleted it
  (whatever the reason was).
Hope that helps!

Nicolas.

On 06/03/2017 23:58, Dabura667 wrote:

  m/44'/0'/0' is BIP44
  Adding two zeroes will make your first address be
    m/44'/0'/0'/0/0/0/0
  Copay is asking for your xPub path, not your first address path
  —
    You are receiving this because you authored the thread.
    Reply to this email directly, view
      it on GitHub, or mute
      the thread.

  {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/bitpay/copay","title":"bitpay/copay","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/bitpay/copay"}},"updates":{"snippets":[{"icon":"PERSON","message":"@dabura667 in #5722: m/44'/0'/0' is BIP44\r\n\r\nAdding two zeroes will make your first address be m/44'/0'/0'/0/0/0/0\r\n\r\nCopay is asking for your xPub path, not your first address path"}],"action":{"name":"View Issue","url":"https://github.com/bitpay/copay/issues/5722#issuecomment-284562474"}}}
NicSil commented 7 years ago
Here is the code I use to create a wallet:
var Mnemonic = require('bitcore-mnemonic'); //
  https://bitcore.io/api/mnemonic/
  var bitcore =
  require('./node_modules/bitcore-mnemonic/node_modules/bitcore-lib');
  // https://github.com/bitpay/bitcore-lib

/*
  Returns a struct {seed, adress} where seed is a BIP29 mnemonic and
  adress is the first bitcoin address of the corresponding wallet.
  If no parameter, a new seed is created.
  */
  exports.createWallet = function(seed) {
      var seed = new Mnemonic(seed);
      var hdPrivateKey = seed.toHDPrivateKey(); //
  https://bitcore.io/api/lib/hd-keys
      
      var derived = hdPrivateKey.derive("m/44'/0'/0'/0/0");
      var privateKey = derived.privateKey;
  //console.log("privateKey:" + privateKey);
      var address = privateKey.toAddress();
      console.log('address:', ""+address);
      /*
      var derived = hdPrivateKey.deriveChild("m/44'/0'/0'/0/0"); 
      var privateKey = derived.privateKey;
  //console.log("privateKey:" + privateKey);
      var address = privateKey.toAddress();
      
      console.log('addressChild:', address);
      */
      
      
      
      var derived = hdPrivateKey.derive("m/44'/0'/0'/0/1"); //

https://www.reddit.com/r/Bitcoin/comments/2srxr2/what_is_the_difference_between_bip_32_and_bip_44/     var privateKey = derived.privateKey; //console.log("privateKey:" + privateKey);     var address2 = privateKey.toAddress();         var derived = hdPrivateKey.derive("m/44'/0'/0'/0/2"); // https://www.reddit.com/r/Bitcoin/comments/2srxr2/what_is_the_difference_between_bip_32_and_bip_44/     var privateKey = derived.privateKey; //console.log("privateKey:" + privateKey);     var address3 = privateKey.toAddress();             return {         seed: seed         ,address: address         ,address2: address2         ,address3: address3     }; }

On 06/03/2017 23:58, Dabura667 wrote:

  m/44'/0'/0' is BIP44
  Adding two zeroes will make your first address be
    m/44'/0'/0'/0/0/0/0
  Copay is asking for your xPub path, not your first address path
  —
    You are receiving this because you authored the thread.
    Reply to this email directly, view
      it on GitHub, or mute
      the thread.

  {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/bitpay/copay","title":"bitpay/copay","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/bitpay/copay"}},"updates":{"snippets":[{"icon":"PERSON","message":"@dabura667 in #5722: m/44'/0'/0' is BIP44\r\n\r\nAdding two zeroes will make your first address be m/44'/0'/0'/0/0/0/0\r\n\r\nCopay is asking for your xPub path, not your first address path"}],"action":{"name":"View Issue","url":"https://github.com/bitpay/copay/issues/5722#issuecomment-284562474"}}}
NicSil commented 7 years ago

any progress?

isocolsky commented 7 years ago

The xpub still exists in the server (the xpriv was removed from your device). Try Add Wallet -> Import instead.

Edit: reading the whole thread again I realize this may not be the answer you are looking for. But as @dabura667 said, you only need to provide the path to the xpub which is m/44'/0'/0'. I don't understand why you consider this to be an error. Could you please clarify why you are trying to derive using a different path?

virl commented 6 years ago

Same error when trying to add wallet after deleting it.

JDonadio commented 6 years ago

Because you are trying to create instead of import the wallet.

virl commented 6 years ago

And what’s the difference between creating and importing?

dabura667 commented 6 years ago

Create = “I want to create a metadata structure on Bitpay’s BWS server. In doing this I may choose a random key or specify my own.”

Import = “I want to import the metadata structure from Bitpay’s BWS server. In order to do this I must provide the proper credentials for that metadata, which is derived by the private seed, so I must specify a seed that has already been created before using create wallet.”

If you use “create” on a wallet that BWS already has metadata for, BWS will respond with “you can’t create. Its metadata already exists on our servers.” And you get an error.

“Create” and “Import” wallet is not talking about your private seed. It is talking about the “wallet metadata construct” that exists on BWS databases.

tl;dr use import

virl commented 6 years ago

Creating metadata on BWS server is irrelevant to user experience.

“Create wallet” should only generate new keypair.

“Import wallet” should accept existing seed phrase.

BWS metadata should be created as needed in background without errors if it did not exist.

NicSil commented 6 years ago

That's why I use Mycellium, I don't want "a structure on server".

virl commented 6 years ago

@NicSil Mycelium works in the same way, as I understand.

modood commented 4 years ago

+1 for this, I'm in exactly same situaction described above and I'm not able to import my wallet even if i have already removed the app and reinstall it.