Browse Source

Test xpub key format

master
Luke Childs 6 years ago
parent
commit
fb21c80a32
  1. 25
      test/vanity-addresses.js

25
test/vanity-addresses.js

@ -17,8 +17,6 @@ const deriveAddress = {
} }
}; };
const keyFormats = ['wif', 'bip39'];
const testCases = [ const testCases = [
{ {
options: { options: {
@ -43,9 +41,22 @@ const testCases = [
} }
]; ];
keyFormats.forEach(keyFormat => { const additionalOptionCombos = [
{
keyFormat: 'wif'
},
{
keyFormat: 'bip39'
},
{
keyFormat: 'xpub',
xpub: 'xpub6EDZZg3os4RaLxfPpnGBb7ajm6ccyjRs3PGZ5jNK31rPnbpyKb7dc87cEPaLEjFYDBGCQT8VMm8q8MVj2tj7HPBu8syxu82cdHLCNaQmT42'
}
];
additionalOptionCombos.forEach(additionalOptions => {
testCases.forEach(({options, expectedPrefix}) => { testCases.forEach(({options, expectedPrefix}) => {
options = {...options, keyFormat}; options = {...options, ...additionalOptions};
test(`Vain generates a valid ${options.keyFormat} ${options.addressFormat} vanity address`, async t => { test(`Vain generates a valid ${options.keyFormat} ${options.addressFormat} vanity address`, async t => {
const vain = new Vain(options); const vain = new Vain(options);
@ -66,6 +77,12 @@ keyFormats.forEach(keyFormat => {
break; break;
} }
case 'xpub': {
const node = bitcoin.bip32.fromBase58(keyData.xpub);
({publicKey} = node.derivePath(keyData.derivationPath));
break;
}
default: default:
} }

Loading…
Cancel
Save