| @@ 525-531 (lines=7) @@ | ||
| 522 | throw new \InvalidArgumentException("Can't store Primary Mnemonic on server without a passphrase"); |
|
| 523 | } |
|
| 524 | ||
| 525 | if ($primaryPrivateKey) { |
|
| 526 | if (is_string($primaryPrivateKey)) { |
|
| 527 | $primaryPrivateKey = [$primaryPrivateKey, "m"]; |
|
| 528 | } |
|
| 529 | } else { |
|
| 530 | $primaryPrivateKey = BIP32::master_key(BIP39::mnemonicToSeedHex($primaryMnemonic, $password), 'bitcoin', $this->testnet); |
|
| 531 | } |
|
| 532 | ||
| 533 | if (!$storePrimaryMnemonic) { |
|
| 534 | $primaryMnemonic = false; |
|
| @@ 554-560 (lines=7) @@ | ||
| 551 | $backupPublicKey = $options['backup_public_key']; |
|
| 552 | } |
|
| 553 | ||
| 554 | if ($backupPublicKey) { |
|
| 555 | if (is_string($backupPublicKey)) { |
|
| 556 | $backupPublicKey = [$backupPublicKey, "m"]; |
|
| 557 | } |
|
| 558 | } else { |
|
| 559 | $backupPublicKey = BIP32::extended_private_to_public(BIP32::master_key(BIP39::mnemonicToSeedHex($backupMnemonic, ""), 'bitcoin', $this->testnet)); |
|
| 560 | } |
|
| 561 | ||
| 562 | // create a checksum of our private key which we'll later use to verify we used the right password |
|
| 563 | $checksum = BIP32::key_to_address($primaryPrivateKey[0]); |
|
| @@ 216-225 (lines=10) @@ | ||
| 213 | throw new \InvalidArgumentException("Can't init wallet with Primary Mnemonic without a passphrase"); |
|
| 214 | } |
|
| 215 | ||
| 216 | if ($primaryPrivateKey) { |
|
| 217 | if (is_string($primaryPrivateKey)) { |
|
| 218 | $primaryPrivateKey = [$primaryPrivateKey, "m"]; |
|
| 219 | } |
|
| 220 | } else { |
|
| 221 | // convert the mnemonic to a seed using BIP39 standard |
|
| 222 | $primarySeed = BIP39::mnemonicToSeedHex($primaryMnemonic, $password); |
|
| 223 | // create BIP32 private key from the seed |
|
| 224 | $primaryPrivateKey = BIP32::master_key($primarySeed, $this->network, $this->testnet); |
|
| 225 | } |
|
| 226 | ||
| 227 | $this->primaryPrivateKey = BIP32Key::create($primaryPrivateKey); |
|
| 228 | ||