/**
  * Provide an electrum mnemonic and derive the master key
  *
  * @param $mnemonic
  * @param ElectrumWordListInterface $wordList
  * @param EcAdapterInterface $ecAdapter
  * @return ElectrumKey
  */
 public static function fromMnemonic($mnemonic, ElectrumWordListInterface $wordList = null, EcAdapterInterface $ecAdapter = null)
 {
     $ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter();
     $mnemonicConverter = MnemonicFactory::electrum($wordList, $ecAdapter);
     $entropy = $mnemonicConverter->mnemonicToEntropy($mnemonic);
     return self::generateMasterKey($entropy, $ecAdapter);
 }
Exemple #2
-2
<?php

require_once "../vendor/autoload.php";
use BitWasp\Bitcoin\Crypto\Random\Random;
use BitWasp\Bitcoin\Mnemonic\MnemonicFactory;
use BitWasp\Bitcoin\Mnemonic\Bip39\Bip39SeedGenerator;
// Generate a mnemonic
$random = new Random();
$entropy = $random->bytes(64);
$bip39 = MnemonicFactory::bip39();
$seedGenerator = new Bip39SeedGenerator($bip39);
$mnemonic = $bip39->entropyToMnemonic($entropy);
// Derive a seed from mnemonic/password
$seed = $seedGenerator->getSeed($mnemonic, 'password');
echo $seed->getHex() . "\n";
$bip32 = \BitWasp\Bitcoin\Key\Deterministic\HierarchicalKeyFactory::fromEntropy($seed);