|
@@ 827-836 (lines=10) @@
|
| 824 |
|
$recoveryEncryptedSecret = null; |
| 825 |
|
$backupSeed = null; |
| 826 |
|
|
| 827 |
|
if (!isset($options['primary_private_key'])) { |
| 828 |
|
if (isset($options['primary_seed'])) { |
| 829 |
|
if (!$options['primary_seed'] instanceof BufferInterface) { |
| 830 |
|
throw new \InvalidArgumentException('Primary Seed should be passed as a Buffer'); |
| 831 |
|
} |
| 832 |
|
$primarySeed = $options['primary_seed']; |
| 833 |
|
} else { |
| 834 |
|
$primarySeed = new Buffer(self::randomBits(256)); |
| 835 |
|
} |
| 836 |
|
} |
| 837 |
|
|
| 838 |
|
if ($storeDataOnServer) { |
| 839 |
|
if (!isset($options['secret'])) { |
|
@@ 860-869 (lines=10) @@
|
| 857 |
|
$recoveryEncryptedSecret = Encryption::encrypt($secret, $recoverySecret); |
| 858 |
|
} |
| 859 |
|
|
| 860 |
|
if (!isset($options['backup_public_key'])) { |
| 861 |
|
if (isset($options['backup_seed'])) { |
| 862 |
|
if (!$options['backup_seed'] instanceof Buffer) { |
| 863 |
|
throw new \RuntimeException('Backup seed must be an instance of Buffer'); |
| 864 |
|
} |
| 865 |
|
$backupSeed = $options['backup_seed']; |
| 866 |
|
} else { |
| 867 |
|
$backupSeed = new Buffer(self::randomBits(256)); |
| 868 |
|
} |
| 869 |
|
} |
| 870 |
|
|
| 871 |
|
if (isset($options['primary_private_key'])) { |
| 872 |
|
$options['primary_private_key'] = BlocktrailSDK::normalizeBIP32Key($options['primary_private_key']); |
|
@@ 1112-1119 (lines=8) @@
|
| 1109 |
|
); |
| 1110 |
|
break; |
| 1111 |
|
case Wallet::WALLET_VERSION_V3: |
| 1112 |
|
if (isset($options['encrypted_primary_seed'])) { |
| 1113 |
|
if (!$options['encrypted_primary_seed'] instanceof Buffer) { |
| 1114 |
|
throw new \InvalidArgumentException('Encrypted PrimarySeed must be provided as a Buffer'); |
| 1115 |
|
} |
| 1116 |
|
$encryptedPrimarySeed = $data['encrypted_primary_seed']; |
| 1117 |
|
} else { |
| 1118 |
|
$encryptedPrimarySeed = new Buffer(base64_decode($data['encrypted_primary_seed'])); |
| 1119 |
|
} |
| 1120 |
|
|
| 1121 |
|
if (isset($options['encrypted_secret'])) { |
| 1122 |
|
if (!$options['encrypted_secret'] instanceof Buffer) { |
|
@@ 1121-1129 (lines=9) @@
|
| 1118 |
|
$encryptedPrimarySeed = new Buffer(base64_decode($data['encrypted_primary_seed'])); |
| 1119 |
|
} |
| 1120 |
|
|
| 1121 |
|
if (isset($options['encrypted_secret'])) { |
| 1122 |
|
if (!$options['encrypted_secret'] instanceof Buffer) { |
| 1123 |
|
throw new \InvalidArgumentException('Encrypted secret must be provided as a Buffer'); |
| 1124 |
|
} |
| 1125 |
|
|
| 1126 |
|
$encryptedSecret = $data['encrypted_secret']; |
| 1127 |
|
} else { |
| 1128 |
|
$encryptedSecret = new Buffer(base64_decode($data['encrypted_secret'])); |
| 1129 |
|
} |
| 1130 |
|
|
| 1131 |
|
$wallet = new WalletV3( |
| 1132 |
|
$this, |