(node, path)
| 62 | return { IL: I.slice(0, 32), IR: I.slice(32) }; |
| 63 | } |
| 64 | function derivePath(node, path) { |
| 65 | const components = path.split("/"); |
| 66 | (0, index_js_4.assertArgument)(components.length > 0, "invalid path", "path", path); |
| 67 | if (components[0] === "m") { |
| 68 | (0, index_js_4.assertArgument)(node.depth === 0, `cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${node.depth}`, "path", path); |
| 69 | components.shift(); |
| 70 | } |
| 71 | let result = node; |
| 72 | for (let i = 0; i < components.length; i++) { |
| 73 | const component = components[i]; |
| 74 | if (component.match(/^[0-9]+'$/)) { |
| 75 | const index = parseInt(component.substring(0, component.length - 1)); |
| 76 | (0, index_js_4.assertArgument)(index < HardenedBit, "invalid path index", `path[${i}]`, component); |
| 77 | result = result.deriveChild(HardenedBit + index); |
| 78 | } |
| 79 | else if (component.match(/^[0-9]+$/)) { |
| 80 | const index = parseInt(component); |
| 81 | (0, index_js_4.assertArgument)(index < HardenedBit, "invalid path index", `path[${i}]`, component); |
| 82 | result = result.deriveChild(index); |
| 83 | } |
| 84 | else { |
| 85 | (0, index_js_4.assertArgument)(false, "invalid path component", `path[${i}]`, component); |
| 86 | } |
| 87 | } |
| 88 | return result; |
| 89 | } |
| 90 | /** |
| 91 | * An **HDNodeWallet** is a [[Signer]] backed by the private key derived |
| 92 | * from an HD Node using the [[link-bip-32]] stantard. |
no test coverage detected