Пример #1
0
 /**
  * Obtain the Wallet resource for the given identifier.
  *
  * @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 get($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}?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new HDWallet();
     $ret->fromJson($json);
     return $ret;
 }
Пример #2
0
 /**
  * @dataProvider mockProvider
  * @param HDWallet $obj
  * @param $mockApiContext
  */
 public function testDelete($obj, $mockApiContext)
 {
     $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock();
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(true));
     /** @noinspection PhpParamsInspection */
     $result = $obj->delete(array(), $mockApiContext, $mockBlockCypherRestCall);
     $this->assertNotNull($result);
 }
Пример #3
0
<?php

// Run on console:
// php -f .\sample\wallet-api\CreateHDWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Api\HDWallet;
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\HDWalletClient;
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'));
$wallet = new HDWallet();
$wallet->setName('bob');
$wallet->setExtendedPublicKey('xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8');
$wallet->setSubchainIndexes(array(1, 3));
/// For Sample Purposes Only.
$request = clone $wallet;
$walletClient = new HDWalletClient($apiContext);
$createdWallet = $walletClient->create($wallet);
ResultPrinter::printResult("Created HDWallet", "HDWallet", $createdWallet->getName(), $request, $createdWallet);
Пример #4
0
 /**
  * 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;
 }
Пример #5
0
 /**
  * Create a new HDWallet.
  *
  * @param HDWallet $hdWallet
  * @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 function create(HDWallet $hdWallet, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = $hdWallet->toJSON();
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $json = $this->executeCall("{$chainUrlPrefix}/wallets/hd?" . http_build_query($params), "POST", $payLoad, null, $apiContext, $restCall);
     $returnedHDWallet = new HDWallet();
     $returnedHDWallet->fromJson($json);
     return $returnedHDWallet;
 }