/** * @expectedException PHPUnit_Framework_Error_Notice */ public function testsSanitizeWithNotAllowedParams() { $params = array('paramNotAllowed' => 'param1Value'); $allowedParams = array('param1' => 'param1Value'); $validationLevel = 'strict'; ArgumentGetParamsValidator::sanitize($params, $allowedParams, $validationLevel); }
/** * Obtain all WebHook resources for the provided token. * * @param array $params Parameters. Options: token * @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 function getAll($params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array('token' => 1); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall("{$chainUrlPrefix}/hooks?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall); return WebHook::getList($json); }
/** * Allow to embed small pieces of data on the blockchain. * * @param NullData $nullData * @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 NullData */ public function create(NullData $nullData, $params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = $nullData->toJSON(); $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall("{$chainUrlPrefix}/txs/data?" . http_build_query($params), "POST", $payLoad, null, $apiContext, $restCall); $nullData->fromJson($json); return $nullData; }
/** * 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; }
/** * Obtain multiple TransactionConfidences resources for the given identifiers. * * @deprecated since version 1.2.1 Use TXClient. * @param string[] $array * @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 getMultiple($array, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($array, 'array'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $txhashList = implode(";", $array); $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall("{$chainUrlPrefix}/txs/{$txhashList}/confidence" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall); return TXConfidence::getList($json); }
/** * Obtain multiple Block resources for the given identifiers (hash or height). * * @param string[] $array * @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 getMultiple($array, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($array, 'array'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array('txstart' => 1, 'limit' => 1); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $blockList = implode(";", $array); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall("{$chainUrlPrefix}/blocks/{$blockList}?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall); return Block::getList($json); }
/** * Obtain multiple FullAddress resources for the given identifiers. * * @deprecated since version 1.2. Use AddressClient. * @param string[] $array * @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 FullAddress[] */ public static function getMultiple($array, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($array, 'array'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array('unspentOnly' => 1, 'before' => 1); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $addressList = implode(";", $array); $payLoad = ""; $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall("{$chainUrlPrefix}/addrs/{$addressList}/full?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall); return FullAddress::getList($json); }
/** * 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; }
/** * A new address is generated similar to Address Generation and associated it with the given wallet. * * @deprecated since version 1.2. Use WalletClient. * @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 WalletGenerateAddressResponse */ public function generateAddress($params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall("{$chainUrlPrefix}/wallets/{$this->name}/addresses/generate?" . http_build_query($params), "POST", $payLoad, null, $apiContext, $restCall); $ret = new WalletGenerateAddressResponse(); $ret->fromJson($json); return $ret; }
/** * Obtain multiple AddressBalances resources for the given identifiers. * * @param string[] $array * @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 getMultipleBalances($array, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($array, 'array'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array('omitWalletAddresses' => 1); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $addressList = implode(";", $array); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall("{$chainUrlPrefix}/addrs/{$addressList}/balance" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall); return AddressBalance::getList($json); }
/** * 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; }
/** * This endpoint allows you to derive a new address (or multiple addresses) associated with the $NAME HD Wallet. * If successful, it will return an HDWallet but only with the newly derived address(es) represented in * its chains field to limit the data transmitted; for the full address list after derivation, * you can follow up this API call with the Get Wallet Addresses Endpoint. * * @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 Partial */ public function deriveAddress($walletName, $params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array('count' => 1, 'subchain_index' => 1); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall("{$chainUrlPrefix}/wallets/hd/{$walletName}/addresses/derive?" . http_build_query($params), "POST", $payLoad, null, $apiContext, $restCall); $ret = new HDWallet(); $ret->fromJson($json); return $ret; }