/**
  * @param $hashOrHeight
  * @param $coinSymbol
  * @param $token
  * @return Block
  */
 public function getBlock($hashOrHeight, $coinSymbol, $token)
 {
     $apiContext = $this->apiContextFactory->getApiContext($coinSymbol, $token);
     $blockClient = new BlockClient($apiContext);
     $block = $blockClient->get($hashOrHeight);
     return $block;
 }
예제 #2
0
<?php

// Run on console:
// php -f .\sample\block-api\BlockHeightEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\BlockClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$blockClient = new BlockClient($apiContext);
$params = array('txstart' => 1, 'limit' => 1);
$block = $blockClient->get('293000', $params);
ResultPrinter::printResult("Get Block With Paging", "Block", $block->getHash(), null, $block);
예제 #3
0
 /**
  * @dataProvider mockProviderGetParamsValidation
  * @param BlockClient $obj
  * @param PHPUnit_Framework_MockObject_MockObject|ApiContext $mockApiContext
  * @param PHPUnit_Framework_MockObject_MockObject|BlockCypherRestCall $mockBlockCypherRestCall
  * @param $params
  * @expectedException \InvalidArgumentException
  */
 public function testGetParamsValidationForParams($obj, $mockApiContext, $mockBlockCypherRestCall, $params)
 {
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(BlockchainTest::getJson()));
     $obj->get(BlockchainTest::getObject()->getName(), $params, $mockApiContext, $mockBlockCypherRestCall);
 }
예제 #4
0
<?php

// Run on console:
// php -f .\sample\block-api\BlockHashEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\BlockClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$blockClient = new BlockClient($apiContext);
$block = $blockClient->get('0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412');
ResultPrinter::printResult("Get Block", "Block", $block->getHash(), null, $block);
예제 #5
0
 /**
  * @dataProvider mockProviderGetParamsValidation
  * @param BlockClient $obj
  * @param PHPUnit_Framework_MockObject_MockObject|ApiContext $mockApiContext
  * @param PHPUnit_Framework_MockObject_MockObject|BlockCypherRestCall $mockBlockCypherRestCall
  * @param $params
  * @expectedException \InvalidArgumentException
  */
 public function testGetMultipleParamsValidationForParams($obj, $mockApiContext, $mockBlockCypherRestCall, $params)
 {
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue('[' . BlockTest::getJson() . ']'));
     $blockList = array(BlockTest::getObject()->getHeight());
     $obj->get($blockList, $params, $mockApiContext, $mockBlockCypherRestCall);
 }