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


PHP jsonRPCClient::getblockhash方法代码示例

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


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

示例1: get_block_info

function get_block_info($block){
	require_once('/var/www/midas/root/private/class/jsonRPCClient.php');
	$darkcoin = new jsonRPCClient('http://xxxx:yyyy@127.0.0.1:9998/');
	$hash_block = $darkcoin->getblockhash(intval($block));
	
	$info_block = $darkcoin->getblock($hash_block);
	$tx = $info_block["tx"][0];
	$diff = round($info_block["difficulty"]);
	$last_block = $block_id = $info_block["height"];
	$block_time = $info_block["time"];
	return $info_block;
}
开发者ID:Karasur,项目名称:dashpay.org.ru,代码行数:12,代码来源:func.php

示例2: mysqli

$rpchost = 'localhost';
$rpcuser = 'protosharesrpc';
$rpcpass = 'superdupersecretphrase';
$rpcport = '3838';
////////////////////////////////////////////////////////////////////////////////
$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();
$blocknum = $w["max(block_num)"] + 0;
$r->close();
$r = $mysqli->query("select sum(balance) from outputs", MYSQLI_USE_RESULT);
$w = $r->fetch_assoc();
$moneysupply = $w["sum(balance)"] + 0;
$r->close();
$pts = new jsonRPCClient("http://" . $rpcuser . ":" . $rpcpass . "@" . $rpchost . ":" . $rpcport);
$blockhash = $pts->getblockhash($blocknum);
$blockinfo = $pts->getblock($blockhash);
$blocktime = $blockinfo['time'];
echo "{\"blocknum\":" . $blocknum . ",\"blocktime\":" . $blocktime . ",\"moneysupply\":" . $moneysupply . ",\"balances\":\n";
echo "    {\n";
$r = $mysqli->query("select * from outputs group by address order by balance desc", MYSQLI_USE_RESULT);
while ($w = $r->fetch_assoc()) {
    echo "        \"" . $w['address'] . "\":" . $w['balance'] . ",\n";
}
echo "    }\n";
echo "}";
$r->close();
////////////////////////////////////////////////////////////////////////////////
开发者ID:amtjre,项目名称:pts-unspent,代码行数:31,代码来源:update-jsonapi.php

示例3: die

<?php

error_reporting(E_ALL);
include_once '/var/www/swork/dice/pr/inc/conf.php';
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 . '/');
$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
开发者ID:newmight2015,项目名称:dicestart,代码行数:31,代码来源:go.php

示例4: foreach

         if ($unspents) {
             if (is_array($unspents) && count($unspents) > 0) {
                 $balance = 0;
                 foreach (array_reverse($unspents) as $tx) {
                     $balance = $balance + intval($tx['amount'] * 100000000);
                 }
                 $obj['balance'] = $balance;
             }
         }
     }
 } else {
     if ($call == 'block') {
         $obj = ["blockchain" => $blockchain, "height" => "N/A", "hash" => "N/A", "prev" => "N/A", "next" => "N/A", "tx_count" => 0, "time" => "N/A"];
         if (isset($_GET['id']) && $_GET['id']) {
             $height = intval($_GET['id']);
             $block_hash = $bitcoind->getblockhash($height);
             $block = $bitcoind->getblock($block_hash);
             $obj['raw'] = $block;
             if ($block_hash) {
                 $obj['height'] = $height;
                 $obj['hash'] = $block_hash;
             }
             if ($block) {
                 if (isset($block['previousblockhash']) && $block['previousblockhash']) {
                     $obj['prev'] = $block['previousblockhash'];
                 }
                 if (isset($block['nextblockhash']) && $block['nextblockhash']) {
                     $obj['next'] = $block['nextblockhash'];
                 }
                 if (isset($block['tx']) && is_array($block['tx'])) {
                     $obj['tx_count'] = count($block['tx']);
开发者ID:blockstrap,项目名称:blockstrap.github.io,代码行数:31,代码来源:rpc.php

示例5: mysqli

$rpcport = '3838';
////////////////////////////////////////////////////////////////////////////////
$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;
开发者ID:amtjre,项目名称:pts-unspent,代码行数:31,代码来源:update-database.php

示例6: copyBlockToDB

 /**
  * @param $blockID - Block ID to process
  * @return mixed
  * @throws \RedBeanPHP\RedException
  */
 private static function copyBlockToDB($blockID)
 {
     $wallet = new jsonRPCClient(HOTWALLET, true);
     $getBlockHash = $wallet->getblockhash($blockID);
     $getBlock = $wallet->getblock($getBlockHash);
     //$return['getBlockHash'] = $getBlockHash;
     //$return['getBlock']     = $getBlock;
     $findOne = R::findOne('blocks', 'height = ?', [$blockID]);
     if (!$findOne) {
         $dispense = R::dispense('blocks');
         foreach ($getBlock as $key => $value) {
             if ($key == "tx") {
                 $dispense->{$key} = json_encode($value);
                 $processTX = self::processTransactions($value);
                 $dispense->totalvalue = $processTX['totalValue'];
                 $dispense->transactioncount = $processTX['transactionCount'];
             } else {
                 $dispense->{$key} = $value;
             }
         }
         R::store($dispense);
     }
     //$return['processTX'] = $processTX;
     $return['data'] = "Processed";
     return $return;
 }
开发者ID:newmight2015,项目名称:BlockExplorer,代码行数:31,代码来源:run.php


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