Commit b6335772 authored by kenshin-samourai's avatar kenshin-samourai
Browse files

fix derivation of payment code fom a seed for testnet

parent bbd7fe54
...@@ -26,9 +26,11 @@ class PaymentCode { ...@@ -26,9 +26,11 @@ class PaymentCode {
} }
static fromSeed(bSeed, id, network) { static fromSeed(bSeed, id, network) {
var reserved = Buffer.alloc(13, 0); network = network || networks.bitcoin;
const reserved = Buffer.alloc(13, 0);
const root = fromSeed(bSeed); const root = fromSeed(bSeed);
const root_bip47 = root.derivePath(`m/47'/0'/${id}'`); const coinType = (network.pubKeyHash == networks.bitcoin.pubKeyHash) ? '0' : '1';
const root_bip47 = root.derivePath(`m/47'/${coinType}'/${id}'`);
let pc = Buffer.from('0100', 'hex'); // version + options let pc = Buffer.from('0100', 'hex'); // version + options
pc = Buffer.concat([pc, root_bip47.publicKey]); pc = Buffer.concat([pc, root_bip47.publicKey]);
......
...@@ -83,6 +83,7 @@ describe('payment-code', function() { ...@@ -83,6 +83,7 @@ describe('payment-code', function() {
const pc_b58 = pc.toBase58(); const pc_b58 = pc.toBase58();
assert(pc_b58 == PC_2.pcBase58); assert(pc_b58 == PC_2.pcBase58);
} catch(e) { } catch(e) {
console.log(e)
assert(false); assert(false);
} }
}); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment