merchant/*/sendmany - 向多个地址支付
使用merchant/$guid/sendmany
调用从钱包向多个外部地址支付。
API调用
GET merchant/$guid/sendmany
URI参数:
- $guid:要使用的钱包的唯一标识符
查询参数:
- password:钱包的密码
- second_password:钱包的第二密码,如果启动双重加密的话
- recipients:收款信息对象,键为收款地址,值为发送金额
- from:指定发送地址,可选
- fee:手续费,可选,单位:satoshi
API返回值
返回支付处理信息,主要字段如下:
- message:支付处理信息
- tx_hash:支付交易哈希
示例代码
使用curl调用merchant/$guid/sendmany
的示例代码如下:
curl http://localhost:3000/merchant/$guid/sendmany?password=1234567890&recipients=%7B%221JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh%22:%20100000000,%2212Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT%22:%201500000000,%221dice6YgEVBf88erBFra9BHf6ZMoyvG88%22:%20200000000%7D
上面的recipients查询参数的值,是如下对象经过url编码后的值:
{
"1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh": 100000000,
"12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT": 1500000000,
"1dice6YgEVBf88erBFra9BHf6ZMoyvG88": 200000000
}
上述调用的返回值如下:
{
"message" : "Sent To Multiple Recipients" ,
"tx_hash" : "f322d01ad784e5deeb25464a5781c3b20971c1863679ca506e702e3e33c18e9c"
}
PHP示例代码如下:
<?
$guid="GUID_HERE";
$firstpassword="PASSWORD_HERE";
$secondpassword="PASSWORD_HERE";
$amounta = "10000000";
$amountb = "400000";
$addressa = "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq";
$addressb = "1ExD2je6UNxL5oSu6iPUhn9Ta7UrN8bjBy";
$recipients = urlencode('{
"'.$addressa.'": '.$amounta.',
"'.$addressb.'": '.$amountb.'
}');
$json_url = "http://localhost:3000/merchant/$guid/sendmany?password=$firstpassword&second_password=$secondpassword&recipients=$recipients";
$json_data = file_get_contents($json_url);
$json_feed = json_decode($json_data);
$message = $json_feed->message;
$txid = $json_feed->tx_hash;