/** * Derive a path in the tree of available addresses. * * @param string $path * @return MultisigHD */ public function derivePath($path) { return $this->deriveFromList($this->sequences->decodePath($path)); }
/** * Decodes a BIP32 path into actual 32bit sequence numbers and derives the child key * * @param string $path * @return HierarchicalKey * @throws \Exception */ public function derivePath($path) { $sequences = new HierarchicalKeySequence($this->ecAdapter->getMath()); return $this->deriveFromList($sequences->decodePath($path)); }
/** * Decodes a BIP32 path into it's actual 32bit sequence numbers: ie, m/0/1'/2/3' -> m/0/2147483649/2/2147483651 * * @param string $path * @return string */ public function decodePath($path) { $pathPieces = explode("/", $path); if (strlen($path) == 0 || count($pathPieces) == 0) { throw new \InvalidArgumentException('Invalid path passed to decodePath()'); } $newPath = array(); $helper = new HierarchicalKeySequence($this->ecAdapter->getMath()); foreach ($pathPieces as $c => $sequence) { $newPath[] = $helper->fromNode($sequence); } $path = implode("/", $newPath); return $path; }
/** * Derive each HK child and produce a new MultisigHD object * * @param int|string $sequence * @return MultisigHD */ public function deriveChild($sequence) { return new self($this->m, $this->path . "/" . $this->sequences->getNode($sequence), array_map(function (HierarchicalKey $hk) use($sequence) { return $hk->deriveChild($sequence); }, $this->keys), $this->sequences, $this->sort); }