require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
$walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
$walletName = 'alice';
}
try {
$wallet = \BlockCypher\Api\Wallet::get($walletName, array(), $apiContexts['BTC.main']);
$output = $wallet->generateAddress(array(), $apiContexts['BTC.main']);
} 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;
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: http://dev.blockcypher.com/#wallets
API used: GET /v1/btc/main/wallets/Wallet-Name/addresses/generate