litecore-archive / litecore-lib

A pure and powerful JavaScript Litecoin library
https://litecore.io/
Other
72 stars 85 forks source link

HDPrivateKey derivation: version argument is not a buffer #5

Open Burtonium opened 7 years ago

Burtonium commented 7 years ago

The following code fails:

const HDPrivateKey = require('litecore-lib').HDPrivateKey;
const privKey = 'xprv...';

var parent = new HDPrivateKey(privKey);
var child_0_1_2h = parent.derive(0).derive(1).derive(2, true);
var copy_of_child_0_1_2h = parent.derive("m/0/1/2'");
assert(child_0_1_2h.xprivkey === copy_of_child_0_1_2h);

Giving me this error:

AssertionError: version argument is not a buffer at checkBuffer (/home/burton/depositor/node_modules/litecore-lib/lib/hdprivatekey.js:523:5) at Function.HDPrivateKey._validateBufferArguments (/home/burton/depositor/node_modules/litecore-lib/lib/hdprivatekey.js:529:3) at HDPrivateKey._buildFromBuffers (/home/burton/depositor/node_modules/litecore-lib/lib/hdprivatekey.js:461:16) at HDPrivateKey._buildFromObject (/home/burton/depositor/node_modules/litecore-lib/lib/hdprivatekey.js:376:15) at new HDPrivateKey (/home/burton/depositor/node_modules/litecore-lib/lib/hdprivatekey.js:61:10) at Object.<anonymous> (/home/burton/depositor/index.js:5:14) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12)

Any work arounds for this?

manhnc-dev commented 6 years ago

Did you solve this issue?

ultragtx commented 6 years ago

The master and segwit branch are using old base58 prefixes, you can use branch v5.0 https://github.com/litecoin-project/litecore-lib/tree/v5.0 (not published to npm yet)

Or modify xpubkey xprivkey in lib/networks.js back to 0x0488b21e and 0x0488ade4.

visionsofparadise commented 3 years ago

i published the branch to npm as 'litecore-lib-v5' since this repo seems dead

mastashake08 commented 3 years ago

litecore-lib-v5

Yo you are a life save literally!

red-name commented 3 years ago

litecore-lib-v5

You saved me! xpub and xprv works great!

losh11 commented 3 years ago

Please do not use this in production. BitPay is soon releasing a significantly updated version of this repo as part of the Bitcore stack with LTC support. This repo will be archived very soon.

On Thu, 20 May 2021 at 01:26, red-name @.***> wrote:

litecore-lib-v5

You saved me! xpub and xprv works great!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/litecoin-project/litecore-lib/issues/5#issuecomment-844587652, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAT43OTCGQS6QESKBCQRIRLTORJMXANCNFSM4DSAHRHQ .