require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
$walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
$walletName = 'bob';
}
try {
$wallet = \BlockCypher\Api\HDWallet::get($walletName, array(), $apiContexts['BTC.main']);
$params = array(
'subchain_index' => 1,
);
$output = $wallet->generateAddress($params, $apiContexts['BTC.main']);
} catch (Exception $ex) {
ResultPrinter::printError("Generate Address in a HDWallet", "HDWalletGenerateAddressResponse", $walletName, null, $ex);
exit(1);
}
ResultPrinter::printResult("Generate Address in a HDWallet", "HDWalletGenerateAddressResponse", $walletName, null, $output);
return $output;
Generate New Address in a HD Wallet
This sample code demonstrate how you can generate new addresses in a hd wallet, as documented here at docs
API used: GET /v1/btc/main/wallets/hd/Wallet-Name/addresses/generate