Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Public Address from xPub Key #106

Open
mchalise opened this issue Feb 4, 2020 · 1 comment
Open

Generate Public Address from xPub Key #106

mchalise opened this issue Feb 4, 2020 · 1 comment

Comments

@mchalise
Copy link

mchalise commented Feb 4, 2020

Hi, I am trying to generate a possible public key(receiving address) from xPub key. Currently, I am using this code

var hdkey = require('ethereumjs-wallet/hdkey');

var extPubKey = 'xpub6D4vX5InpWpivgUZixTzYlsuFCpnimEv7UFaxrcTGnBMUtdL3RpdsdekdCkEeGelLUt31N2LCe3TwA8ge5sC9d72HSRYYhgq1DO4yMaQb9g0';

var hdwallet = hdkey.fromExtendedKey(extPubKey);
var wallet = hdwallet.getWallet();
var address = wallet.getAddress();

console.log(`Address: 0x${address.toString('hex')}`);

It's generating a correct address for ETH (Legacy) xPub. But its not working for new xPub keys. Like Jaxx Wallet, Ledger Nano, so on. are using now-a-days.

LEDGER NANO
xpub key:
xpub6BemYiVNp19a1YNegeXbcmYxwzi5ym8dVsHCSR6vHqFcaRxRBUkZ14uqaZSiPLPDA259FzDE5PQHQFKjw4aP4apXSVRdf2y1vZHTM395CbH

correct address:
0x766540cA3EF86A62E6fBb877B26592ce4c907080

Jaxx
xpub key:
xpub6E6BLhWoLSzcTnGYQgVjMdfin8njwC4BPrANqaJxoWpM2ywhqAbDa49mCBJyWGsE57mKGwqUqttHn2dHR7sGnfksY78Q9gy3g4b6q2xxYau

correct address:

0x070dF77fA482A94219687b4f7e33Aca943E36E55
0x08D368bBE00dD5Cc5FDb8864eC559D931440eaA3
0x4106f355CF717815DF3FC7418EB11c9aF66d28a1
0x50D4C33086E8D2Ced61bf54004B81faaA13a8023
0xe222C3BfE9F95f0b3D6C58cFeC312Ec433E74718
0xD662C376996A8F9c65699E718e349E52E4C5D3Be
0x995814B92331949010B2806A09A32EDb1c9C82ba
0x2d67D60eE3D6147A179c93320f82b6c8Ef3856cA
0xa1AEDB4cfECe780d86c9Db36262DC3656faeC6e3
0xdab36F94127D037bBb9113dD414D19a54E9a2082
0x25e3Aa4Fe5307616ce8a323Fc1B4e42071BD5d8E
0x019EF643e607df6B881256fbceeE4E45dAa597f0
0xaA5BA5e8999CE742e5d5BdD837862BC866D18524
0x8b8CB635F84AcF5251AeE90c138831C6b07Fa093
0xf68210D5634f277D0ff7fe52DC00D1C276c76413
0x1dDA13b983142517f261BC82b33F0C2083c6c5B5
0xA315ADd458B63241bc58396785cBa8177D1a4e30
0xB0a578F2D0e9912d4CfEacf964B1b073C943324F
0x40D3385C852656D35B308B3798604D38B1786CCf
0x6Fb2cE37f16D65a246CBD06535c6a4500e65ceDb

can someone help me here? Thanks in advance.

@mchalise
Copy link
Author

mchalise commented Feb 4, 2020

here's Ledger Nano address derivation path

{
  “xpub”: “xpub6BemYiVNp19a1YNegeXbcmYxwzi5ym8dVsHCSR6vHqFcaRxRBUkZ14uqaZSiPLPDA259FzDE5PQHQFKjw4aP4apXSVRdf2y1vZHTM395CbH”,
  “index”: 0,
  “freshAddressPath”: “44'/60'/0'/0/0”,
  “id”: “libcore:1:ethereum:xpub6BemYiVNp19a1YNegeXbcmYxwzi5ym8dVsHCSR6vHqFcaRxRBUkZ14uqaZSiPLPDA259FzDE5PQHQFKjw4aP4apXSVRdf2y1vZHTM395CbH:“,
  “blockHeight”: 9415975
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant