Exemple #1
0
 /**
  * Create a new TX.
  *
  * @param TX $tx
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return TXSkeleton
  */
 public function create(TX $tx, $apiContext = null, $restCall = null)
 {
     // TODO: change signature. Add $params = array() after TX $tx
     //ArgumentGetParamsValidator::validate($params, 'params');
     //$allowedParams = array(
     //    'includeToSignTx' => 1,
     //);
     //$params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = $tx->toJSON();
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $json = $this->executeCall("{$chainUrlPrefix}/txs/new", "POST", $payLoad, null, $apiContext, $restCall);
     $txSkeleton = new TXSkeleton();
     $txSkeleton->fromJson($json);
     return $txSkeleton;
 }
Exemple #2
0
 /**
  * Create a new TX.
  *
  * @param TX $tx
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return TXSkeleton
  */
 public function create(TX $tx, $apiContext = null, $restCall = null)
 {
     $payLoad = $tx->toJSON();
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $json = $this->executeCall("{$chainUrlPrefix}/txs/new", "POST", $payLoad, null, $apiContext, $restCall);
     $txSkeleton = new TXSkeleton();
     $txSkeleton->fromJson($json);
     return $txSkeleton;
 }
Exemple #3
0
 public function testMultipleEmptyArrayConversion()
 {
     /** @noinspection SpellCheckingInspection */
     $json = '{"block_hash":"0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328","inputs":[{"related_resources":[{},{}]}]}';
     $transaction = new TX($json);
     $result = $transaction->toJSON();
     $this->assertContains('"related_resources":[{},{}]', $result);
     $this->assertNotNull($result);
 }