Пример #1
0
 public function testConfigAbleToPersistAndLoadKeys()
 {
     $root = vfsStream::setup($this->temp_path_root);
     $bitpay = new \Bitpay\Bitpay(array('bitpay' => array('network' => 'testnet', 'private_key' => vfsStream::url($this->temp_path_pri), 'public_key' => vfsStream::url($this->temp_path_pub))));
     $pri = new \Bitpay\PrivateKey(vfsStream::url($this->temp_path_pri));
     $pri->generate();
     $pub = new \Bitpay\PublicKey(vfsStream::url($this->temp_path_pub));
     $pub->setPrivateKey($pri)->generate();
     /**
      * Save keys to the filesystem
      */
     $storage = $bitpay->get('key_storage');
     $storage->persist($pri);
     $storage->persist($pub);
     /**
      * This will load the keys, if you have not already persisted them, than
      * this WILL throw an Exception since this will load the keys from the
      * storage class
      */
     $pri = $bitpay->get('private_key');
     $pub = $bitpay->get('public_key');
 }
Пример #2
0
 */
$pairingCode = 'YCBrKpr';
$tokenString = 'realtokengoeshere';
$privateKeyPath = '/tmp/bitpay.pri';
$publicKeyPath = '/tmp/bitpay.pub';
$keyStoragePassword = '******';
/*** end options ***/
/**
 * The Bitpay class takes care of all the dependency injection for
 * you while at the same time allowing you to easily configure based on
 * environment variables or other configuration system you have.
 *
 * For a list of options you can pass in please see the Bitpay\Config\Configuration
 * class. You will find a list of options and the default and valid values.
 */
$bitpay = new \Bitpay\Bitpay(array('bitpay' => array('network' => 'testnet', 'public_key' => $publicKeyPath, 'private_key' => $privateKeyPath, 'key_storage_password' => $keyStoragePassword)));
echo 'Bitpay class initialized.' . PHP_EOL;
/**
* If you have not already generated and persisted you keys, please uncomment
* this code. This should only be ran once. Once you have generated your key
* pairs, keep you keys in a secure location. If you regenerate your keys, you
* will need to repair and get a new token.
*
$privateKey = \Bitpay\PrivateKey::create($privateKeyPath)->generate();
$publicKey  = \Bitpay\PublicKey::create($publicKeyPath)->setPrivateKey($privateKey)->generate();
$bitpay->get('key_manager')->persist($privateKey);
$bitpay->get('key_manager')->persist($publicKey);
echo 'Public and Private keys have been generated and persisted.'.PHP_EOL;
//exit(0); // exit in case you just wanted to generate keys
*/
/**