当前位置: 首页>>代码示例>>PHP>>正文


PHP jsonRPCClient::gettransaction方法代码示例

本文整理汇总了PHP中jsonRPCClient::gettransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP jsonRPCClient::gettransaction方法的具体用法?PHP jsonRPCClient::gettransaction怎么用?PHP jsonRPCClient::gettransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jsonRPCClient的用法示例。


在下文中一共展示了jsonRPCClient::gettransaction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: jsonRPCClient

    //call processorder script
    $json_url = $strCallbackURL . "?secret={$strSecret}&transaction_hash={$strTransactionID}&address={$strAddress}&input_address={$strAddress}&userid={$strLabel2}&value={$intAmount}&confirms={$intConfirmations}&server=amsterdam";
    echo "<br>url: {$json_url} <br>";
    $json_data = file_get_contents($json_url);
    echo "data = {$json_data} <br>";
    $json_feed = json_decode($json_data);
    $strCallbackResponse = $json_data;
    echo "strCallbackResponse = {$strCallbackResponse} <br>";
}
$strTransaction = funct_GetandCleanVariables($_GET['txid']);
//$strTransaction = "d3de9c8d5ed75ca9d265f5b4581795d002234246f19dafe4d83b17661a4e3473";
//echo $strTransaction ;
if ($strTransaction) {
    //get transaction info as JSON object, only for local transactions
    $bitcoin = new jsonRPCClient(JSONRPC_CONNECTIONSTRING_CC);
    $trxinfo = $bitcoin->gettransaction($strTransaction);
    $new = "Transaction hash: " . $argv[1] . "\n balance: " . $trxinfo["balance"] . "\n amount: " . $trxinfo["amount"] . "\n confirmations: " . $trxinfo["confirmations"] . "\n blockhash: " . $trxinfo["blockhash"] . "\n blockindex: " . $trxinfo["blockindex"] . "\n blocktime: " . $trxinfo["blocktime"] . "\n txid: " . $trxinfo["txid"] . "\n time: " . $trxinfo["time"] . "\n timereceived: " . $trxinfo["timereceived"] . "\n account: " . $trxinfo["details"][0]["account"] . "\n address: " . $trxinfo["details"][0]["address"] . "\n category: " . $trxinfo["details"][0]["category"] . "\n amount: " . $trxinfo["details"][0]["amount"] . "\n fee: " . $trxinfo["details"][0]["fee"];
    // According to https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list, fee is returned, but it doesn't seem that way here
    echo nl2br($new) . "<br><br><br>";
    //if we want the from address and more detail we can get the raw transaction, decode it, extract the values from Json and get more info
    //Enable txindex=1 in your bitcoin.conf (You'll need to rebuild the database as the transaction index is normally not maintained, start using -reindex to do so), and
    //use the getrawtransaction call to request information about any transaction
    $strRawHex = $bitcoin->getrawtransaction($strTransaction);
    $objJSON = $bitcoin->decoderawtransaction($strRawHex);
    //print_r($objJSON)."<br><br>";
    $trxinfo = $objJSON;
    $json_string = json_encode($objJSON, JSON_PRETTY_PRINT);
    //$trxinfo = json_decode($objJSON);
    //print_r( ($json_string))."<br><br>";
    echo "input 1 txid: " . $trxinfo["vin"][0]["txid"] . "<br>";
    echo "output 1 amt: " . $trxinfo["vout"][0]["value"] . "<br>";
开发者ID:bitcoinbrisbane,项目名称:EzBitcoin-Api-Wallet,代码行数:31,代码来源:test.php

示例2: foreach

 $obj = ["blockchain" => $blockchain, "address" => "N/A", "txs" => []];
 if (isset($_GET['id']) && $_GET['id'] && $_GET['id'] != 'false' && isset($_GET['to']) && $_GET['to'] && $_GET['to'] != 'false') {
     $valid_txs = [];
     $address = $_GET['id'];
     $credit_address = $_GET['to'];
     $obj['address'] = $address;
     $account_name = 'XXX_' . $address;
     $credit_account_name = 'XXX_' . $credit_address;
     $originaL_txs = $bitcoind->listtransactions($credit_account_name, 1000, 0, true);
     if ($originaL_txs && is_array($originaL_txs)) {
         $txs = array_reverse($originaL_txs);
         foreach ($txs as $key => $tx) {
             //$txs[$key]['raw'] = $bitcoind->getrawtransaction($tx['txid'], 1);
             $txs[$key]['tx'] = $bitcoind->getrawtransaction($tx['txid'], 1);
             foreach ($txs[$key]['tx']['vin'] as $input_key => $input) {
                 $txs[$key]['tx']['vin'][$input_key]['tx'] = $bitcoind->gettransaction($input['txid'], true);
                 foreach ($txs[$key]['tx']['vin'][$input_key]['tx']['details'] as $detail_key => $detail) {
                     if (isset($detail['address']) && $detail['address'] == $obj['address']) {
                         if (!isset($valid_txs['TX_' . $tx['time'] . '_' . $tx['txid']])) {
                             $valid_txs['TX_' . $tx['time'] . '_' . $tx['txid']] = $bitcoind->getrawtransaction($tx['txid'], 1);
                             $valid_txs['TX_' . $tx['time'] . '_' . $tx['txid']]['details'] = $detail;
                         }
                     }
                 }
             }
         }
         $txs = [];
         foreach ($valid_txs as $tx) {
             $this_tx = ["txid" => $tx['txid'], "data" => "", "pos" => null, "tot" => count($tx['vout'])];
             foreach ($tx['vout'] as $key => $output) {
                 if ($output['value'] <= 0) {
开发者ID:blockstrap,项目名称:blockstrap.github.io,代码行数:31,代码来源:rpc.php


注:本文中的jsonRPCClient::gettransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。