diff --git a/src/BlocktrailSDK.php b/src/BlocktrailSDK.php index e42eb85..7960534 100644 --- a/src/BlocktrailSDK.php +++ b/src/BlocktrailSDK.php @@ -557,7 +557,7 @@ public function initWallet($identifier, $password) { $primaryPrivateKey = BIP32::master_key($primarySeed, $this->network, $this->testnet); // create checksum (address) of the primary privatekey to compare to the stored checksum - $checksum2 = $this->createChecksum($primaryPrivateKey); + $checksum2 = self::createChecksum($primaryPrivateKey); if ($checksum2 != $checksum) { throw new WalletChecksumException("Checksum [{$checksum2}] does not match [{$checksum}], most likely due to incorrect password"); } @@ -579,7 +579,7 @@ public function initWallet($identifier, $password) { * @param string $primaryPrivateKey the private key for which we want a checksum * @return bool|string */ - protected function createChecksum($primaryPrivateKey) { + public static function createChecksum($primaryPrivateKey) { return BIP32::key_to_address($primaryPrivateKey[0]); } diff --git a/tests/WalletTest.php b/tests/WalletTest.php index 81ef4d6..a716ab8 100644 --- a/tests/WalletTest.php +++ b/tests/WalletTest.php @@ -132,7 +132,10 @@ protected function _createTestWallet(BlocktrailSDKInterface $client, $identifier $testnet = true; - $result = $client->_createNewWallet($identifier, $primaryPublicKey, $backupPublicKey, $primaryMnemonic, "mkiPAxhzUMo8mAwW3q95q7aNuXt6HzbbUA", 9999); + // create a checksum of our private key which we'll later use to verify we used the right password + $checksum = BlocktrailSDK::createChecksum($primaryPrivateKey); + + $result = $client->_createNewWallet($identifier, $primaryPublicKey, $backupPublicKey, $primaryMnemonic, $checksum, 9999); $blocktrailPublicKeys = $result['blocktrail_public_keys']; $keyIndex = $result['key_index'];