@bitaccess/coinlib-common
Advanced tools
Comparing version 7.0.0 to 7.0.1
@@ -476,10 +476,14 @@ 'use strict'; | ||
function deriveHDNode(hdKey, derivationPath, network) { | ||
const rootNode = typeof hdKey === 'string' | ||
const baseNode = typeof hdKey === 'string' | ||
? hdKeyToHdNode(hdKey, network) | ||
: hdKey; | ||
const parts = splitDerivationPath(derivationPath).slice(rootNode.depth); | ||
let node = rootNode; | ||
if (parts.length > 0) { | ||
node = rootNode.derivePath(parts.join('/')); | ||
const fullPathParts = splitDerivationPath(derivationPath); | ||
if (baseNode.depth > fullPathParts.length) { | ||
throw new Error(`Cannot deriveHDNode to path ${derivationPath} because hdKey depth (${baseNode.depth}) is already deeper`); | ||
} | ||
const partialPathParts = fullPathParts.slice(baseNode.depth); | ||
let node = baseNode; | ||
if (partialPathParts.length > 0) { | ||
node = baseNode.derivePath(partialPathParts.join('/')); | ||
} | ||
return node; | ||
@@ -486,0 +490,0 @@ } |
@@ -450,10 +450,14 @@ import * as t from 'io-ts'; | ||
function deriveHDNode(hdKey, derivationPath, network) { | ||
const rootNode = typeof hdKey === 'string' | ||
const baseNode = typeof hdKey === 'string' | ||
? hdKeyToHdNode(hdKey, network) | ||
: hdKey; | ||
const parts = splitDerivationPath(derivationPath).slice(rootNode.depth); | ||
let node = rootNode; | ||
if (parts.length > 0) { | ||
node = rootNode.derivePath(parts.join('/')); | ||
const fullPathParts = splitDerivationPath(derivationPath); | ||
if (baseNode.depth > fullPathParts.length) { | ||
throw new Error(`Cannot deriveHDNode to path ${derivationPath} because hdKey depth (${baseNode.depth}) is already deeper`); | ||
} | ||
const partialPathParts = fullPathParts.slice(baseNode.depth); | ||
let node = baseNode; | ||
if (partialPathParts.length > 0) { | ||
node = baseNode.derivePath(partialPathParts.join('/')); | ||
} | ||
return node; | ||
@@ -460,0 +464,0 @@ } |
@@ -469,10 +469,14 @@ (function (global, factory) { | ||
function deriveHDNode(hdKey, derivationPath, network) { | ||
const rootNode = typeof hdKey === 'string' | ||
const baseNode = typeof hdKey === 'string' | ||
? hdKeyToHdNode(hdKey, network) | ||
: hdKey; | ||
const parts = splitDerivationPath(derivationPath).slice(rootNode.depth); | ||
let node = rootNode; | ||
if (parts.length > 0) { | ||
node = rootNode.derivePath(parts.join('/')); | ||
const fullPathParts = splitDerivationPath(derivationPath); | ||
if (baseNode.depth > fullPathParts.length) { | ||
throw new Error(`Cannot deriveHDNode to path ${derivationPath} because hdKey depth (${baseNode.depth}) is already deeper`); | ||
} | ||
const partialPathParts = fullPathParts.slice(baseNode.depth); | ||
let node = baseNode; | ||
if (partialPathParts.length > 0) { | ||
node = baseNode.derivePath(partialPathParts.join('/')); | ||
} | ||
return node; | ||
@@ -479,0 +483,0 @@ } |
@@ -48,10 +48,14 @@ import crypto from 'crypto'; | ||
export function deriveHDNode(hdKey, derivationPath, network) { | ||
const rootNode = typeof hdKey === 'string' | ||
const baseNode = typeof hdKey === 'string' | ||
? hdKeyToHdNode(hdKey, network) | ||
: hdKey; | ||
const parts = splitDerivationPath(derivationPath).slice(rootNode.depth); | ||
let node = rootNode; | ||
if (parts.length > 0) { | ||
node = rootNode.derivePath(parts.join('/')); | ||
const fullPathParts = splitDerivationPath(derivationPath); | ||
if (baseNode.depth > fullPathParts.length) { | ||
throw new Error(`Cannot deriveHDNode to path ${derivationPath} because hdKey depth (${baseNode.depth}) is already deeper`); | ||
} | ||
const partialPathParts = fullPathParts.slice(baseNode.depth); | ||
let node = baseNode; | ||
if (partialPathParts.length > 0) { | ||
node = baseNode.derivePath(partialPathParts.join('/')); | ||
} | ||
return node; | ||
@@ -58,0 +62,0 @@ } |
{ | ||
"name": "@bitaccess/coinlib-common", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "Common module used by coinlib", | ||
@@ -47,3 +47,2 @@ "main": "dist/index.cjs.js", | ||
"@bitaccess/ts-common": "^1.0.2", | ||
"@faast/ts-common": "^0.6.0", | ||
"bip32": "^3.0.1", | ||
@@ -56,3 +55,3 @@ "bip39": "^3.0.4", | ||
}, | ||
"gitHead": "98fed792eebe30aadf3f421f0cf3e720350d6e01" | ||
"gitHead": "c6846f6d5b498ac229506fa46513592928e7452f" | ||
} |
@@ -69,10 +69,16 @@ import crypto from 'crypto' | ||
export function deriveHDNode(hdKey: string | HDNode, derivationPath: string, network?: Bip32Network): HDNode { | ||
const rootNode = typeof hdKey === 'string' | ||
const baseNode = typeof hdKey === 'string' | ||
? hdKeyToHdNode(hdKey, network) | ||
: hdKey | ||
const parts = splitDerivationPath(derivationPath).slice(rootNode.depth) | ||
let node = rootNode | ||
if (parts.length > 0) { | ||
node = rootNode.derivePath(parts.join('/')) | ||
const fullPathParts = splitDerivationPath(derivationPath) | ||
if (baseNode.depth > fullPathParts.length) { | ||
throw new Error( | ||
`Cannot deriveHDNode to path ${derivationPath} because hdKey depth (${baseNode.depth}) is already deeper` | ||
) | ||
} | ||
const partialPathParts = fullPathParts.slice(baseNode.depth) | ||
let node = baseNode | ||
if (partialPathParts.length > 0) { | ||
node = baseNode.derivePath(partialPathParts.join('/')) | ||
} | ||
return node | ||
@@ -79,0 +85,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
352158
7
4524
- Removed@faast/ts-common@^0.6.0
- Removed@faast/ts-common@0.6.3(transitive)