bitpay / php-bitpay-client

PHP implementation for the BitPay cryptographically secure RESTful API
MIT License
165 stars 149 forks source link

Uncaught Exception: The private key must be in hex format. #275

Closed huturen closed 6 years ago

huturen commented 6 years ago

php version: PHP 7.1.3 bitpay/php-client: 2.2.20

This example below is not working. https://github.com/bitpay/php-bitpay-client/blob/v2.2.20/examples/GetTokens.php

$bitpay = new \Bitpay\Bitpay(
    array(
        'bitpay' => array(
            'network'     => 'testnet', // testnet or livenet, default is livenet
            'public_key'  => '/tmp/bitpay.pub', //see tutorial/001.php and 002.php
            'private_key' => '/tmp/bitpay.pri',
            'key_storage' => 'Bitpay\Storage\EncryptedFilesystemStorage',
            'key_storage_password' => 'xxNxx'
        )
    )
);
/**
 * Create the client that will be used to send requests to BitPay's API
 */
$client = $bitpay->get('client');
$tokens = $client->getTokens();
PHP Fatal error:  Uncaught Exception: The private key must be in hex format. in /home/hu/web/btcwallet/bitpay/vendor/bitpay/php-client/src/Bitpay/PrivateKey.php:127
Stack trace:
#0 /home/hu/web/btcwallet/bitpay/vendor/bitpay/php-client/src/Bitpay/Client/Client.php(663): Bitpay\PrivateKey->sign('https://test.bi...')
#1 /home/hu/web/btcwallet/bitpay/vendor/bitpay/php-client/src/Bitpay/Client/Client.php(489): Bitpay\Client\Client->addSignatureHeader(Object(Bitpay\Client\Request))
#2 /home/hu/web/btcwallet/bitpay/test.php(36): Bitpay\Client\Client->getTokens()
#3 {main}
  thrown in /home/hu/web/btcwallet/bitpay/vendor/bitpay/php-client/src/Bitpay/PrivateKey.php on line 127
huturen commented 6 years ago

it's a duplicated issue, it was resolved at: https://github.com/bitpay/php-bitpay-client/issues/188