예제 #1
0
<?php

// # Create Wallet
// This sample code demonstrate how you can create a wallet, as documented here at:
// <a href="http://dev.blockcypher.com/#wallet_api">http://dev.blockcypher.com/#wallet_api</a>
//
// API used: POST /v1/btc/main/wallets
require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
    $walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
    $walletName = 'alice';
    // Default wallet name for samples
}
$wallet = new \BlockCypher\Api\Wallet();
$wallet->setName($walletName);
$wallet->setAddresses(array("1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"));
/// For Sample Purposes Only.
$request = clone $wallet;
$walletClient = new \BlockCypher\Client\WalletClient($apiContexts['BTC.main']);
try {
    $output = $walletClient->create($wallet);
} catch (Exception $ex) {
    ResultPrinter::printError("Created Wallet", "Wallet", null, $request, $ex);
    exit(1);
}
ResultPrinter::printResult("Created Wallet", "Wallet", $output->getName(), $request, $output);
return $output;
<?php

// # Remove Addresses from Wallet
//
// This sample code demonstrate how you can removes addresses from a wallet, as documented here at:
// <a href="http://dev.blockcypher.com/#wallets">http://dev.blockcypher.com/#wallets</a>
//
// API used: DELETE /v1/btc/main/wallets/Wallet-Name/addresses?address=13cj1Qtf...gQiRM6j
// In samples we are using CreateWallet.php sample to get the created instance of wallet
// and AddAddressesToWallet to add the address which is going to be removed.
// You have to run that sample before running this one.
require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
    $walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
    $walletName = 'alice';
    // Default wallet name for samples
}
$walletClient = new \BlockCypher\Client\WalletClient($apiContexts['BTC.main']);
/// List of addresses to be removed from the wallet
$addressList = \BlockCypher\Api\AddressList::fromAddressesArray(array("13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"));
try {
    /// Remove addresses from wallet
    $output = $walletClient->removeAddresses($walletName, $addressList);
} catch (Exception $ex) {
    ResultPrinter::printError("Remove Addresses from a Wallet", "Wallet", $walletName, $addressList, $ex);
    exit(1);
}
ResultPrinter::printResult("Remove Addresses from a Wallet", "Wallet", $walletName, $addressList, $output);
return $output;
<?php

// # Generate New Address for a Wallet
//
// This sample code demonstrate how you can generate new addresses and associate them to a wallet,
// as documented here at: <a href="http://dev.blockcypher.com/#wallets">http://dev.blockcypher.com/#wallets</a>
//
// API used: GET /v1/btc/main/wallets/Wallet-Name/addresses/generate
// In samples we are using CreateWallet.php sample to get the created instance of wallet.
// You have to run that sample before running this one or there will be no wallets
require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
    $walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
    $walletName = 'alice';
    // Default wallet name for samples
}
$walletClient = new \BlockCypher\Client\WalletClient($apiContexts['BTC.main']);
try {
    /// Generate address in Wallet
    $output = $walletClient->generateAddress($walletName);
} catch (Exception $ex) {
    ResultPrinter::printError("Add Addresses to a Wallet", "WalletGenerateAddressResponse", $walletName, null, $ex);
    exit(1);
}
ResultPrinter::printResult("Add Addresses to a Wallet", "WalletGenerateAddressResponse", $walletName, null, $output);
return $output;
예제 #4
0
<?php

// # Delete Wallet
//
// This sample code demonstrate how you can delete a wallet, as documented here at:
// <a href="http://dev.blockcypher.com/#wallets">http://dev.blockcypher.com/#wallets</a>
//
// API used: DELETE /v1/btc/main/wallets/Wallet-Name
require __DIR__ . '/../bootstrap.php';
// Delete a new instance of Wallet object.
// First you have to run CreateWallet sample to create "alice" wallet
if (isset($_GET['wallet_name'])) {
    $walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
    $walletName = 'alice';
    // Default wallet name for samples
}
$walletClient = new \BlockCypher\Client\WalletClient($apiContexts['BTC.main']);
try {
    /// Delete the Wallet
    $output = $walletClient->delete($walletName);
} catch (Exception $ex) {
    ResultPrinter::printError("Deleted Wallet", "Wallet", $walletName, null, $ex);
    exit(1);
}
ResultPrinter::printResult("Deleted Wallet", "Wallet", $walletName, null, $output);
return $output;
예제 #5
0
<?php

// # Get Wallet
//
// This sample code demonstrate how you can get a wallet, as documented here at:
// <a href="http://dev.blockcypher.com/#wallets">http://dev.blockcypher.com/#wallets</a>
//
// API used: GET /v1/btc/main/wallets/Wallet-Name
// In samples we are using CreateWallet.php sample to get the created instance of wallet.
// You have to run that sample before running this one or there will be no wallets
require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
    $walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
    $walletName = 'alice';
    // Default wallet name for samples
}
$walletClient = new \BlockCypher\Client\WalletClient($apiContexts['BTC.main']);
try {
    $output = $walletClient->get($walletName);
} catch (Exception $ex) {
    ResultPrinter::printError("Get a Wallet", "Wallet", null, $walletName, $ex);
    exit(1);
}
ResultPrinter::printResult("Get a Wallet", "Wallet", $output->getName(), null, $output);
return $output;
예제 #6
0
<?php

// # Add Addresses to Wallet
//
// This sample code demonstrate how you can add addresses to a wallet, as documented here at:
// <a href="http://dev.blockcypher.com/#wallets">http://dev.blockcypher.com/#wallets</a>
//
// API used: GET /v1/btc/main/wallets/Wallet-Name/addresses
// In samples we are using CreateWallet.php sample to get the created instance of wallet.
// You have to run that sample before running this one or there will be no wallets
require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
    $walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
    $walletName = 'alice';
    // Default wallet name for samples
}
$walletClient = new \BlockCypher\Client\WalletClient($apiContexts['BTC.main']);
$addressList = \BlockCypher\Api\AddressList::fromAddressesArray(array("13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"));
try {
    /// Add addresses to Wallet
    $output = $walletClient->addAddresses($walletName, $addressList);
} catch (Exception $ex) {
    ResultPrinter::printError("Add Addresses to a Wallet", "Wallet", $walletName, $addressList, $ex);
    exit(1);
}
ResultPrinter::printResult("Add Addresses to a Wallet", "Wallet", $walletName, $addressList, $output);
return $output;
예제 #7
0
<?php

// # Get All Wallet Addresses
//
// Use this call to list all the wallet addresses, as documented here at:
// <a href="http://dev.blockcypher.com/#wallets">http://dev.blockcypher.com/#wallets</a>
//
// API used: GET /v1/btc/main/wallets/<Wallet-Name>/addresses?token=<Your-Token>
// In samples we are using CreateWallet.php sample to get the created instance of wallet.
// You have to run that sample before running this one or there will be no wallets
require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
    $walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
    $walletName = 'alice';
    // Default wallet name for samples
}
$walletClient = new \BlockCypher\Client\WalletClient($apiContexts['BTC.main']);
try {
    $output = $walletClient->getWalletAddresses($walletName);
} catch (Exception $ex) {
    ResultPrinter::printError("List all Wallet addresses", "Wallet", $walletName, null, $ex);
    exit(1);
}
ResultPrinter::printResult("List all Wallet addresses", "Wallet", $walletName, null, $output);
return $output;