Exemplo n.º 1
0
 /**
  * Fund an address with faucet.
  * The faucet endpoint is only available on BlockCypher’s Test Blockchain and Bitcoin Testnet3
  *
  * @param string $address Address to fund
  * @param int $amount
  * @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 FaucetResponse
  */
 public function fundAddress($address, $amount, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($address, 'address');
     NumericValidator::validate($amount, 'amount');
     $faucet = new Faucet();
     $faucet->setAddress($address);
     $faucet->setAmount($amount);
     return $this->turnOn($faucet, $apiContext, $restCall);
 }
Exemplo n.º 2
0
 /**
  * Obtain the information about the adoption of upgrade features on a blockchain.
  *
  * @param string $featureName
  * @param array $params Parameters. Options: txstart, and limit
  * @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 string
  */
 public function getFeature($featureName, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($featureName, 'featureName');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = "";
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $json = $this->executeCall("{$chainUrlPrefix}/feature/{$featureName}?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     return $json;
 }
Exemplo n.º 3
0
 /**
  * Obtain the TXConfidence resource for the given identifier.
  *
  * @deprecated since version 1.2.1 Use TXClient.
  * @param string $txhash
  * @param array $params Parameters
  * @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 TXConfidence
  */
 public static function get($txhash, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($txhash, 'txhash');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = "";
     $chainUrlPrefix = self::getChainUrlPrefix($apiContext);
     $json = self::executeCall("{$chainUrlPrefix}/txs/{$txhash}/confidence" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new TXConfidence();
     $ret->fromJson($json);
     return $ret;
 }
Exemplo n.º 4
0
 /**
  * Obtain the Block resource for the given identifier (hash or height).
  *
  * @param string $hashOrHeight
  * @param array $params Parameters. Options: txstart, and limit
  * @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 Block
  */
 public function get($hashOrHeight, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($hashOrHeight, 'hashOrHeight');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array('txstart' => 1, 'limit' => 1);
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = "";
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $json = $this->executeCall("{$chainUrlPrefix}/blocks/{$hashOrHeight}?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new Block();
     $ret->fromJson($json);
     return $ret;
 }
Exemplo n.º 5
0
 /**
  * Obtain the Address resource for the given identifier.
  *
  * @deprecated since version 1.2. Use AddressClient.
  * @param string $address
  * @param array $params Parameters. Options: unspentOnly, and before
  * @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 Address
  */
 public static function get($address, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($address, 'address');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array('unspentOnly' => 1, 'before' => 1);
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = "";
     $chainUrlPrefix = self::getChainUrlPrefix($apiContext);
     $json = self::executeCall("{$chainUrlPrefix}/addrs/{$address}?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new Address();
     $ret->fromJson($json);
     return $ret;
 }
Exemplo n.º 6
0
 /**
  * Obtain the WebHook resource for the given identifier.
  *
  * @deprecated since version 1.2. Use WebHookClient.
  * @param string $webHookId
  * @param array $params Parameters.
  * @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 WebHook
  */
 public static function get($webHookId, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($webHookId, 'webHookId');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = "";
     $chainUrlPrefix = self::getChainUrlPrefix($apiContext);
     $json = self::executeCall("{$chainUrlPrefix}/hooks/{$webHookId}?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new WebHook();
     $ret->fromJson($json);
     return $ret;
 }
Exemplo n.º 7
0
 /**
  * Get all addresses in a given wallet.
  *
  * @deprecated since version 1.2. Use HDWalletClient.
  * @param string $walletName
  * @param array $params Parameters.
  * @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 HDWallet
  */
 public static function getOnlyAddresses($walletName, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($walletName, 'walletName');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = "";
     $chainUrlPrefix = self::getChainUrlPrefix($apiContext);
     $json = self::executeCall("{$chainUrlPrefix}/wallets/hd/{$walletName}/addresses?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new AddressList();
     $ret->fromJson($json);
     return $ret;
 }
Exemplo n.º 8
0
 /**
  * Obtain the Blockchain resource for the given identifier.
  *
  * @param string $name
  * @param array $params Parameters
  * @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 Blockchain
  */
 public function get($name, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($name, 'name');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     if (strpos($name, '.') === FALSE) {
         throw new \InvalidArgumentException("Invalid chain name {$name}. FORMAT: COIN.chain e.g. BTC.main");
     }
     $payLoad = "";
     if ($apiContext === null) {
         $apiContext = $this->getApiContext();
     }
     $version = $apiContext->getVersion();
     list($coin, $chain) = explode(".", $name);
     $coin = strtolower($coin);
     $json = $this->executeCall("/{$version}/{$coin}/{$chain}" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new Blockchain();
     $ret->fromJson($json);
     return $ret;
 }
Exemplo n.º 9
0
 /**
  * Remove Addresses to the Wallet. Addresses will no longer be associated with the wallet.
  *
  * @deprecated since version 1.2. Use WalletClient.
  * @param AddressList $addressList
  * @param array $params Parameters
  * @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 Wallet
  */
 public function removeAddresses($addressList, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($addressList, 'addressList');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     // DEPRECATED: Using DELETE Body
     //$payLoad = $addressList->toJSON();
     $payLoad = '';
     // Using 'address' url parameter
     if (!isset($params['address'])) {
         $params['address'] = implode(';', $addressList->getAddresses());
     } else {
         $params['address'] .= ';' . implode(';', $addressList->getAddresses());
     }
     $chainUrlPrefix = self::getChainUrlPrefix($apiContext);
     $json = self::executeCall("{$chainUrlPrefix}/wallets/{$this->name}/addresses?" . http_build_query($params), "DELETE", $payLoad, null, $apiContext, $restCall);
     $this->fromJson($json);
     return $this;
 }
Exemplo n.º 10
0
 /**
  *
  * @dataProvider invalidProvider
  * @expectedException \InvalidArgumentException
  */
 public function testInvalidDataValidate($input)
 {
     $this->assertTrue(ArgumentValidator::validate($input, "Name"));
 }
Exemplo n.º 11
0
 /**
  * Deletes the PaymentForward identified by webhook_id for the application associated with access token.
  *
  * @param string $paymentForwardId
  * @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 bool
  */
 public function delete($paymentForwardId, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($paymentForwardId, 'paymentForwardId');
     $payLoad = "";
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $this->executeCall("{$chainUrlPrefix}/payments/{$paymentForwardId}", "DELETE", $payLoad, null, $apiContext, $restCall);
     return true;
 }
Exemplo n.º 12
0
 /**
  * Obtain the AddressBalance resource for the given address.
  *
  * @param string $address
  * @param array $params Parameters
  * @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 AddressBalance
  */
 public function getBalance($address, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($address, 'address');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array('omitWalletAddresses' => 1);
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = "";
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $json = $this->executeCall("{$chainUrlPrefix}/addrs/{$address}/balance" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new AddressBalance();
     $ret->fromJson($json);
     return $ret;
 }
Exemplo n.º 13
0
 /**
  * Push the raw transaction to the network.
  *
  * @deprecated since version 1.2. Use TXClient.
  * @param string $hexRawTx
  * @param array $params Parameters. Options: instart, outstart and limit
  * @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 TX
  */
 public static function push($hexRawTx, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($hexRawTx, 'hexRawTx');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $txHex = new TXHex();
     $txHex->setTx($hexRawTx);
     $payLoad = $txHex->toJSON();
     $chainUrlPrefix = self::getChainUrlPrefix($apiContext);
     $json = self::executeCall("{$chainUrlPrefix}/txs/push?" . http_build_query($params), "POST", $payLoad, null, $apiContext, $restCall);
     $ret = new TX();
     $ret->fromJson($json);
     return $ret;
 }
Exemplo n.º 14
0
 /**
  * Get all addresses in a given wallet.
  *
  * @param string $walletName
  * @param array $params Parameters.
  * @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 AddressList
  */
 public function getWalletAddresses($walletName, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($walletName, 'walletName');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array('used' => 1, 'zerobalance' => 1);
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = "";
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $json = $this->executeCall("{$chainUrlPrefix}/wallets/hd/{$walletName}/addresses?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     $addressList = new AddressList();
     $addressList->fromJson($json);
     return $addressList;
 }