WalletBit/API/Getnewaddress

From Bitcoin Wiki
Revision as of 15:10, 27 May 2012 by WalletBit (talk | contribs) (Created page with "===Generate new Bitcoin address=== <source lang="php"> $fields = array( 'merchant' => 'owner@example.com', 'label' => 'TEST' ); $fields['encrypted'] = strtoupper(hash('sh...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Generate new Bitcoin address

$fields = array(
  'merchant' => 'owner@example.com',
  'label' => 'TEST'
);
$fields['encrypted'] = strtoupper(hash('sha256', $fields['merchant'] . ':' . $fields['label'] . ':' . 'API Key'));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://walletbit.com/api/getnewaddress');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$response = curl_exec($ch);
curl_close($ch);

If successful $response will contain your new bitcoin address, otherwise empty.