Example #1
0
if ($debug == True) {
    echo "[DEBUG TURNED ON, SHOWING ERRORS!]";
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(-1);
} else {
}
//END DEBUG
session_start();
include "polApi.php";
include_once "config.php";
require_once 'jsonRPCClient.php';
$bitcoin = new jsonRPCClient("http://{$rpcuser}:{$rpcpass}@{$rpcserver}:{$rpcport}/");
//print_r($bitcoin->getinfo());
//echo "\n";
$blockcount = $bitcoin->getblockcount();
$daemonConnections = $bitcoin->getconnectioncount();
$daemonBlockCount = $bitcoin->getblockcount();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LimeCart v0.1</title>
<?php 
echo "<link href=\"style/{$styleSheet}\" rel=\"stylesheet\" type=\"text/css\">";
?>
</head>

<body>
<?php

require_once 'jsonRPCClient.php';
$data = new jsonRPCClient('http://*****:*****@127.0.0.1:8332');
if ($rpctry) {
    try {
        $data->getblockcount();
    } catch (Exception $e) {
        echo "Sorry!  Bitcoin server is down.";
        exit;
    }
}
Example #3
0
// rpcport, rpcallowip and txindex=1 in your protoshares.conf
$rpchost = 'localhost';
$rpcuser = '******';
$rpcpass = '******';
$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":
Example #4
0
<?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
Example #5
0
 /**
  * @return Array - JSON RPC ARRAY
  */
 private static function getBlockCount()
 {
     $wallet = new jsonRPCClient(HOTWALLET, true);
     $return = $wallet->getblockcount();
     return $return;
 }