本文整理汇总了PHP中jsonRPCClient::decoderawtransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP jsonRPCClient::decoderawtransaction方法的具体用法?PHP jsonRPCClient::decoderawtransaction怎么用?PHP jsonRPCClient::decoderawtransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonRPCClient
的用法示例。
在下文中一共展示了jsonRPCClient::decoderawtransaction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
$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);
$objJSON = $bitcoin->decoderawtransaction($strRawHex);
示例3: array
$sumpay += $cash["amount"];
$intx[] = array("txid" => $cash["txid"], "vout" => $cash["vout"]);
if ($sumpay > $win + TRANSACTION_FEE) {
break;
}
}
$inadd = array($playeraddress => $win, DELIVER_FUNDS => $sumpay - $win);
$play_log["outcome"] = 1;
$play_log["sumout"] = $win;
}
//end else win
//create output tx
$tl = $ftc->createrawtransaction($intx, $inadd);
//sign tx
$stl = $ftc->signrawtransaction($tl);
//send
if (isset($stl["complete"]) && $stl["complete"] == 1) {
$out = $ftc->sendrawtransaction($stl["hex"]);
$rawout = $ftc->decoderawtransaction($stl["hex"]);
$play_log["txout"] = $rawout['txid'];
//put in the log file for the succesfull plays (wins or looses)
$logname = PLAY_LOG_LOCATION . "play_log" . date("Y-m-d") . ".txt";
$strout = @json_encode($play_log) . "\n";
@file_put_contents($logname, $strout, FILE_APPEND | LOCK_EX);
}
} else {
//the one who use this script should define this
//bet is smaller than minimum or bigger than max amount
//capture the bet or return to the bet address or prform bet with the max amount and return the rest + outcome of the game
}
//end if ($bet >= $min_bet && $bet <= $max_bet )
示例4: 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":
示例5: 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;
}