如何在Ubuntu Server上使用php和Electrum钱包检查是否进行了BTC交易?

时间:2018-08-15 17:28:03

标签: php curl bitcoin ubuntu-server

我一直在找几个小时的代码示例...

我有这个功能:

    function retrCmd($mtname, $prms = '')
{
    $ch = curl_init();
    $result = null;

    curl_setopt($ch, CURLOPT_URL, $GLOBALS['btcwserver']);
    curl_setopt($ch, CURLOPT_USERPWD, $GLOBALS['btcwupasswd']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "{ \"id\": 0, \"method\": \"" . $mtname . "\", \"params\":[" . $prms . "] }");

    $headers = array();
    $headers[] = "Content-Type: application/x-www-form-urlencoded";
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    try {
        $result = curl_exec($ch);
        if (curl_errno($ch)) {echo 'Error:' . curl_error($ch);exit;}
        curl_close($ch);
    } catch (Exception $e) {
        echo ('No good! My code is stupid');
    }
    return $result;
}

效果很好。

For testing, I did this:
$result = retrCmd("createnewaddress");
$result = json_decode($result, 1);
echo "Deposit Address: " . $result['result'] . '<br/>';

一切都很好!

但是我如何检查是否有人将btc发送到该地址?在任何确认之前。

0 个答案:

没有答案