|
@@ 839-848 (lines=10) @@
|
| 836 |
|
$recoveryEncryptedSecret = null; |
| 837 |
|
$backupSeed = null; |
| 838 |
|
|
| 839 |
|
if (!isset($options['primary_private_key'])) { |
| 840 |
|
if (isset($options['primary_seed'])) { |
| 841 |
|
if (!$options['primary_seed'] instanceof BufferInterface) { |
| 842 |
|
throw new \InvalidArgumentException('Primary Seed should be passed as a Buffer'); |
| 843 |
|
} |
| 844 |
|
$primarySeed = $options['primary_seed']; |
| 845 |
|
} else { |
| 846 |
|
$primarySeed = new Buffer(self::randomBits(256)); |
| 847 |
|
} |
| 848 |
|
} |
| 849 |
|
|
| 850 |
|
if ($storeDataOnServer) { |
| 851 |
|
if (!isset($options['secret'])) { |
|
@@ 872-881 (lines=10) @@
|
| 869 |
|
$recoveryEncryptedSecret = Encryption::encrypt($secret, $recoverySecret, KeyDerivation::DEFAULT_ITERATIONS); |
| 870 |
|
} |
| 871 |
|
|
| 872 |
|
if (!isset($options['backup_public_key'])) { |
| 873 |
|
if (isset($options['backup_seed'])) { |
| 874 |
|
if (!$options['backup_seed'] instanceof Buffer) { |
| 875 |
|
throw new \RuntimeException('Backup seed must be an instance of Buffer'); |
| 876 |
|
} |
| 877 |
|
$backupSeed = $options['backup_seed']; |
| 878 |
|
} else { |
| 879 |
|
$backupSeed = new Buffer(self::randomBits(256)); |
| 880 |
|
} |
| 881 |
|
} |
| 882 |
|
|
| 883 |
|
if (isset($options['primary_private_key'])) { |
| 884 |
|
$options['primary_private_key'] = BlocktrailSDK::normalizeBIP32Key($options['primary_private_key']); |
|
@@ 1150-1157 (lines=8) @@
|
| 1147 |
|
); |
| 1148 |
|
break; |
| 1149 |
|
case Wallet::WALLET_VERSION_V3: |
| 1150 |
|
if (isset($options['encrypted_primary_seed'])) { |
| 1151 |
|
if (!$options['encrypted_primary_seed'] instanceof Buffer) { |
| 1152 |
|
throw new \InvalidArgumentException('Encrypted PrimarySeed must be provided as a Buffer'); |
| 1153 |
|
} |
| 1154 |
|
$encryptedPrimarySeed = $data['encrypted_primary_seed']; |
| 1155 |
|
} else { |
| 1156 |
|
$encryptedPrimarySeed = new Buffer(base64_decode($data['encrypted_primary_seed'])); |
| 1157 |
|
} |
| 1158 |
|
|
| 1159 |
|
if (isset($options['encrypted_secret'])) { |
| 1160 |
|
if (!$options['encrypted_secret'] instanceof Buffer) { |
|
@@ 1159-1167 (lines=9) @@
|
| 1156 |
|
$encryptedPrimarySeed = new Buffer(base64_decode($data['encrypted_primary_seed'])); |
| 1157 |
|
} |
| 1158 |
|
|
| 1159 |
|
if (isset($options['encrypted_secret'])) { |
| 1160 |
|
if (!$options['encrypted_secret'] instanceof Buffer) { |
| 1161 |
|
throw new \InvalidArgumentException('Encrypted secret must be provided as a Buffer'); |
| 1162 |
|
} |
| 1163 |
|
|
| 1164 |
|
$encryptedSecret = $data['encrypted_secret']; |
| 1165 |
|
} else { |
| 1166 |
|
$encryptedSecret = new Buffer(base64_decode($data['encrypted_secret'])); |
| 1167 |
|
} |
| 1168 |
|
|
| 1169 |
|
$wallet = new WalletV3( |
| 1170 |
|
$this, |