From f15dc93f9155c5950b485719965339ccac2b2156 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Tue, 18 Jun 2019 12:59:18 +0700 Subject: [PATCH] Simplify internal generateKey API --- src/index.js | 2 +- src/key-formats/bip39.js | 4 ++-- src/key-formats/xpub.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index 8ef9690..b56c329 100644 --- a/src/index.js +++ b/src/index.js @@ -60,7 +60,7 @@ class Vain extends Emitter { attempts++; - keyData = generateKey({addressFormat, options, attempts}); + keyData = generateKey({...options, addressFormat, attempts}); address = addressFormat.derive(keyData.publicKey); if (address.startsWith(this.prefix)) { diff --git a/src/key-formats/bip39.js b/src/key-formats/bip39.js index 75acb80..936f23f 100644 --- a/src/key-formats/bip39.js +++ b/src/key-formats/bip39.js @@ -1,8 +1,8 @@ const bip39 = require('bip39'); const bitcoin = require('bitcoinjs-lib'); -const generatebip39Key = ({addressFormat, options}) => { - const mnemonic = bip39.generateMnemonic(options.entropy); +const generatebip39Key = ({addressFormat, entropy}) => { + const mnemonic = bip39.generateMnemonic(entropy); const seed = bip39.mnemonicToSeedSync(mnemonic); const node = bitcoin.bip32.fromSeed(seed); diff --git a/src/key-formats/xpub.js b/src/key-formats/xpub.js index 8175021..06dca39 100644 --- a/src/key-formats/xpub.js +++ b/src/key-formats/xpub.js @@ -1,15 +1,15 @@ const bitcoin = require('bitcoinjs-lib'); -const generateXpubKey = ({options, attempts}) => { +const generateXpubKey = ({attempts, xpub}) => { const change = 0; const index = attempts - 1; const derivationPath = `${change}/${index}`; - const node = bitcoin.bip32.fromBase58(options.xpub); + const node = bitcoin.bip32.fromBase58(xpub); const {publicKey} = node.derivePath(derivationPath); const format = () => ({ - xpub: options.xpub, + xpub, derivationPath });