Exemplo n.º 1
0
 /**
  * Sign the transaction skeleton.
  *
  * @param string[]|string $privateKeys
  * @param string $coinSymbol
  * @return $this
  * @throws BlockCypherSignatureException
  */
 public function sign($privateKeys, $coinSymbol)
 {
     if (is_string($privateKeys)) {
         $privateKeys = array($privateKeys);
     }
     // Create PrivateKey objects from plain hex private keys (public keys compressed)
     $privateKeyCompressedList = PrivateKeyList::fromHexPrivateKeyArray($privateKeys, $coinSymbol, true);
     // Create PrivateKey objects from plain hex private keys (public keys uncompressed)
     // Uncompressed keys are not supported by the API, we use them only to check if user is using them and
     // show a specific exception.
     $privateKeyUncompressedList = PrivateKeyList::fromHexPrivateKeyArray($privateKeys, $coinSymbol, false);
     $this->generateSignatures($privateKeyCompressedList, $privateKeyUncompressedList, $coinSymbol);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider dataProvider
  * @expectedException \InvalidArgumentException
  * @param $address
  */
 public function testFromHexPrivateKeyArrayWithInvalidCoinSymbol($address)
 {
     $hexPrivateKeyArray = array($address['private']);
     $privateKeyList = PrivateKeyList::fromHexPrivateKeyArray($hexPrivateKeyArray, 'INVALID-COIN-SYMBOL', $address['compressed']);
     $this->assertEmpty($privateKeyList->getPrivateKeys());
 }