本文整理汇总了PHP中jsonRPCClient::getrawtransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP jsonRPCClient::getrawtransaction方法的具体用法?PHP jsonRPCClient::getrawtransaction怎么用?PHP jsonRPCClient::getrawtransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonRPCClient
的用法示例。
在下文中一共展示了jsonRPCClient::getrawtransaction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transactionLookup
public static function transactionLookup($tx)
{
$wallet = new jsonRPCClient(HOTWALLET, true);
$getRawTransaction = $wallet->getrawtransaction($tx);
$decodeRawTransaction = $wallet->decoderawtransaction($getRawTransaction);
$return['rawtransaction'] = $getRawTransaction;
$return['transaction'] = $decodeRawTransaction;
return $return;
}
示例2: jsonRPCClient
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>";
echo "output 1 address: " . $trxinfo["vout"][0]["scriptPubKey"]["addresses"][0] . "<br>";
echo "output 2 amt: " . $trxinfo["vout"][1]["value"] . "<br>";
echo "output 2 address: " . $trxinfo["vout"][1]["scriptPubKey"]["addresses"][0] . "<br>";
echo "<br>";
//get info for input transaction
$strTXID_input = $trxinfo["vin"][0]["txid"];
$strRawHex = $bitcoin->getrawtransaction($strTXID_input);
示例3: die
mysql_select_db(DATABASE) or die(mysql_error() . " " . mysql_errno());
//include json_rpc client
include_once JSON_RPC_CLIENT;
//connect to the wallet
$ftc = new jsonRPCClient('http://' . RPC_USER . ':' . RPC_PASS . '@' . RPC_HOST . ':' . RPC_PORT . '/');
$blockcount = $ftc->getblockcount();
while (true) {
sleep(5);
$txx = array();
//scan last x=50 blocks for incomming but not processes transaction
$transactions = $ftc->listsinceblock($ftc->getblockhash($blockcount - 50));
if (is_array($transactions["transactions"]) && sizeof($transactions["transactions"]) > 0) {
foreach ($transactions["transactions"] as $t) {
if (array_key_exists($t["address"], $game_addresses) && $t["category"] == "receive") {
//prevent transaction malleability
$rawtx = $ftc->getrawtransaction($t["txid"], 1);
$tprocessed = "";
if (is_array($rawtx)) {
foreach ($rawtx["vin"] as $tinput) {
$tprocessed .= $tinput["txid"] . $tinput["vout"];
}
} else {
die("grrr");
}
$tprocessed = md5($tprocessed);
//end prevent transaction malleability
//$sql = "select * from processed where txid = '".$t["txid"]."'";
$sql = "select * from processed where txid = '" . $tprocessed . "'";
$rez = mysql_query($sql);
if (mysql_num_rows($rez) == 0) {
//async call the game with the tx id
示例4: die
//connect to the DB
mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error() . " " . mysql_errno());
mysql_select_db(DATABASE) or die(mysql_error() . " " . mysql_errno());
//include json_rpc client
include_once JSON_RPC_CLIENT;
//connect to the wallet
$ftc = new jsonRPCClient('http://' . RPC_USER . ':' . RPC_PASS . '@' . RPC_HOST . ':' . RPC_PORT . '/');
//set up min and max bets for this game
$max_bet = 0.5;
$min_bet = 0.1;
//code start
$play_log = array();
$play_log["txin"] = $stx;
$play_log["oddaddress"] = $odd_address;
$play_log["odd"] = $odd;
$transactiondetails = $ftc->getrawtransaction($stx, 1);
$vintxid = $transactiondetails['vin'][0]['txid'];
$vinvout = $transactiondetails['vin'][0]['vout'];
$k = 0;
$kvin = 0;
$bet = '';
foreach ($transactiondetails["vout"] as $td) {
if ($td["scriptPubKey"]["addresses"][0] == $odd_address) {
$bet = $td["value"];
$vinscriptpubkey = $td["scriptPubKey"]["hex"];
$kvin = $k;
break;
}
$k++;
}
$play_log["bet"] = $bet;
示例5: foreach
if ($debug && $bitcoind && $loaded) {
$raw = $bitcoind->getinfo();
}
}
if ($call == 'address') {
$obj = ["address" => false, "blockchain" => $blockchain, "hash" => "N/A", "tx_count" => 0, "received" => 0, "balance" => 0, "raw" => []];
if (isset($_GET['id']) && $_GET['id']) {
$address = $_GET['id'];
$obj['address'] = $address;
$account_name = 'XXX_' . $address;
$balance = $bitcoind->getbalance($account_name, 1, true);
$received = $bitcoind->getreceivedbyaccount($account_name, 1);
$address = $bitcoind->validateaddress($obj['address']);
$txs = $bitcoind->listtransactions($account_name, 100, 0, true);
foreach ($txs as $tx_key => $tx) {
$raw_tx = $bitcoind->getrawtransaction($tx['txid'], 1);
foreach ($raw_tx['vout'] as $output) {
if ($output['scriptPubKey']['addresses'][0] == $_GET['id']) {
$asm = explode(' ', $output['scriptPubKey']['asm']);
foreach ($asm as $op) {
if (substr($op, 0, 2) != 'OP') {
$obj['hash'] = $op;
}
}
}
}
}
if ($balance) {
$obj['balance'] = intval($balance * 100000000);
}
if ($received) {
示例6: mysqli
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $database);
if ($mysqli->connect_errno) {
throw new Exception("database connection error");
}
$r = $mysqli->query("select max(block_num) from outputs", MYSQLI_USE_RESULT);
$w = $r->fetch_assoc();
$last_block_in_db = $w["max(block_num)"] + 0;
$r->close();
$pts = new jsonRPCClient("http://" . $rpcuser . ":" . $rpcpass . "@" . $rpchost . ":" . $rpcport);
$blocknum = $pts->getblockcount();
if ($last_block_in_db < $blocknum) {
for ($i = $last_block_in_db + 1; $i <= $blocknum; $i++) {
echo "block " . $i . "\n";
$block = $pts->getblock($pts->getblockhash($i));
foreach ($block["tx"] as $txid) {
$tx = $pts->decoderawtransaction($pts->getrawtransaction($txid));
foreach ($tx["vin"] as $tx_in) {
if (!array_key_exists("coinbase", $tx_in)) {
$mysqli->query("delete from outputs where transaction_hash='" . $tx_in["txid"] . "' and sequence=" . $tx_in["vout"] . ";");
}
}
foreach ($tx["vout"] as $tx_out) {
$scripttype = $tx_out["scriptPubKey"]["type"];
switch ($scripttype) {
case "pubkeyhash":
case "pubkey":
case "scripthash":
$mysqli->query("insert into outputs (block_num, block_hash, transaction_hash, sequence, address, balance) values (" . $i . ", '" . $block["hash"] . "', '" . $txid . "', " . $tx_out["n"] . ", '" . $tx_out["scriptPubKey"]["addresses"][0] . "', " . $tx_out["value"] . ")");
break;
case "nonstandard":
case "multisig":
示例7: processTransactions
/**
* @param $transactions - ARRAY DATA
* @return mixed
*/
private static function processTransactions($transactions)
{
$totalValue = 0;
$transactionCount = 0;
foreach ($transactions as $tx) {
$transactionCount++;
$wallet = new jsonRPCClient(HOTWALLET, true);
$getRawTransaction = $wallet->getrawtransaction($tx);
$decodeRawTransaction = $wallet->decoderawtransaction($getRawTransaction);
$vin = self::processVin($decodeRawTransaction);
$vout = self::processVout($decodeRawTransaction);
$result = self::processTX($decodeRawTransaction);
$totalValue = bcadd($vout['valueTotal'], $totalValue, 6);
}
$return['totalValue'] = $totalValue;
$return['transactionCount'] = $transactionCount;
return $return;
}