I'm currently using v2 of Blockchain.info's API and am wanting to utilise "Send Many Transaction" and am having some issues.
I have 1 wallet with many addresses, I am trying to send 2 transactions within 1 payment, their API documentation is still from v1 and is missing the '&from' from their api example, and have spent more time than I'd like to admit to get this working.
this is from there website:
http://localhost:3000/merchant/$guid/sendmany?password=$main_password&second_password=$second_password&recipients=$recipients&fee=$fee
$main_password Your Main Blockchain wallet password
$second_password Your second Blockchain Wallet password if double encryption is enabled.
$recipients Is a JSON Object using Bitcoin Addresses as keys and the amounts to send as values (See below).
$from Send from a specific Bitcoin Address (Optional)
$fee Transaction fee value in satoshi (Must be greater than default fee) (Optional)
$note A public note to include with the transaction -- can only be attached to transactions where all outputs are greater than 0.005 BTC.(Optional)
The result I get is:
failed to open stream:HTTP request failed!
Fatal error:Maximum execution time of 120 seconds exceeded
I now the url is wrong but can anyone please help advise me what it is specifically.
So far this is what I have
// Sending addresses
$Address1 = 'Address1';
$Address2 = 'Address2';
//Amount coming from
$From = 'Address3';
//Amounts being sent in satoshi
$Amount1 = 100000; // 0.001 of a btc
$Amount2 = 100000;
$recipients = urlencode(' {
"'.$Address1.'": '.$Amount1.',
"'.$Address2.'": '.$Amount2.'
}');
$Guid = 'MY_GUID';
$Password = 'MY_PASSWORD';
$url = 'http://localhost:3000/merchant/'.$Guid.'/sendmany?password='.$Password.'&from='.$From.'&recipients='.$recipients.'';
// I've also tried to remove $data and put '&api_code=MY_API_CODE' after
// $recipients as this also works for other api calls for v2
$data = array('api_code' => 'MY_API_CODE');
$result = sendAmounts($url, $data);
function sendAmounts($url, $data) {
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST', // Also tried GET
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}
Thank you in advance.