예제 #1
0
//	Enable the spectra functionality
require_once "lib/spectra_config.php";
//	This code creates the 'raw block data' view used in the popup
if (isset($_GET["raw"]) && $_GET["raw"] == 1) {
    if (!isset($_REQUEST["hash"]) || $_REQUEST["hash"] == "") {
        echo "<p> hash parameter is required for raw data request</p>\n\n";
    }
    $rawblock = getblock($_REQUEST["hash"]);
    echo "<pre>\n" . print_r($rawblock, 1) . "\n</pre>\n";
    exit;
}
//	Verify that a block descriptor was provided and attempt retrieval
if (isset($_REQUEST["height"]) && $_REQUEST["height"] != "") {
    $block = mysqli_getrow($GLOBALS["tables"]["block"], "`height` = '" . $_REQUEST["height"] . "'");
} elseif (isset($_REQUEST["hash"]) && $_REQUEST["hash"] != "") {
    $block = mysqli_getrow($GLOBALS["tables"]["block"], "`hash` = '" . $_REQUEST["hash"] . "'");
} else {
    $message = "<p> \n";
    $message .= "\tYou must provide either a block hash or a block height to use this page. \n";
    $message .= "</p> \n\n";
    spectra_page_error("Missing Block Descriptor", $message);
}
//	Verify that block data was retrieved
if ($block["success"] < 1 || $block["data"] == "") {
    $message = "<p> \n";
    $message .= "\tUnable To Retrieve Specified Block \n";
    $message .= "</p> \n\n";
    $message .= "<p> \n";
    $message .= "\tPlease verify your block hash/height and try again. \n";
    $message .= "</p> \n\n";
    spectra_page_error("Invalid Block Descriptor", $message);
예제 #2
0
}
//	If the hashes don't match, the block chain has had a fork/orphan
//	since the last time the script ran.
if ($data_exp["data"]["hash"] != $hash_node) {
    //	A flag is set to rebuild balances at the end of the script
    system_flag_set("balance_rebuild", 1);
    //	The script will scan back along the chain until it gets a match
    while ($data_exp["data"]["hash"] != $hash_node) {
        //	If the block hashes do not match, we have a fork.
        spectra_log_write(0, "Block Data Mismatch at block" . $height_exp);
        //	The invalid block and it's data are removed from the database
        spectra_orphan_wipe($data_exp["data"]["hash"]);
        //	The explorer block height is decremented
        $height_exp = $height_exp - 1;
        //	The next block is retrieved from the explorer
        $data_exp = mysqli_getrow($GLOBALS["tables"]["block"], "`height` = '" . $height_exp . "'");
        //	The next hash is retrieved from the node
        $hash_node = getblockhash($height_exp);
        //	The while loop will perform the comparison against the new values
    }
    //	The block height of the match found is written to the log
    spectra_log_write(0, "Found sync at block " . $height_exp);
}
/******************************************************************************
	Load New Blocks
******************************************************************************/
//	Block heights are reloaded in case of a resync
$start = spectra_block_height();
$top = getblockcount();
//	If there is not a new block, end the checks
if ($start >= $top) {
예제 #3
0
function spectra_vin_parse($parsed_tx, $vin)
{
    //	An empty vin record is creatd to populate all expected fields
    $vin_parsed = spectra_vin_new();
    //	Add information about the vin location
    $vin_parsed["in_block"] = $parsed_tx["in_block"];
    $vin_parsed["in_tx"] = $parsed_tx["txid"];
    $vin_parsed["time"] = $parsed_tx["time"];
    //	Move in the values from the current vin
    if (isset($vin["coinbase"]) && $vin["coinbase"] != "") {
        //	This is a coinbase transaction
        $vin_parsed["coinbase"] = $vin["coinbase"];
        $vin_parsed["sequence"] = $vin["sequence"];
        //	Calculate the value out
        $val_out = 0;
        foreach ($parsed_tx["vout"] as $spend) {
            $val_out = bcadd($val_out, $spend["value"], 8);
        }
        //	Update the vin with the coinbase value
        $vin_parsed["src_block"] = $parsed_tx["in_block"];
        $vin_parsed["src_tx"] = "Coinbase";
        $vin_parsed["src_vout"] = 0;
        $vin_parsed["src_address"] = "Generated";
        $vin_parsed["src_value"] = $val_out;
    } else {
        //	This is a p2p transaction
        //	Fetch the origin vout
        $vout_orig = mysqli_getrow($GLOBALS["tables"]["vout"], "`in_tx` = '" . $vin["txid"] . "' AND `n` = '" . $vin["vout"] . "'");
        //	Add information from the origin vout
        $vin_parsed["src_block"] = $vout_orig["data"]["in_block"];
        $vin_parsed["src_tx"] = $vout_orig["data"]["in_tx"];
        $vin_parsed["src_vout"] = $vin["vout"];
        $vin_parsed["src_address"] = $vout_orig["data"]["addresses"];
        $vin_parsed["src_value"] = $vout_orig["data"]["value"];
    }
    //	Return expanded vin data
    return $vin_parsed;
}
예제 #4
0
<?php

//	Enable the spectra functionality
require_once "lib/spectra_config.php";
//	Error handling for missing address
if (!isset($_REQUEST["address"]) || $_REQUEST["address"] == "") {
    $message = "<p> \n";
    $message .= "\tYou must provde an address to use this page. \n";
    $message .= "</p> \n\n";
    spectra_page_error("No Address Provided", $message);
}
//	Attempt to fetch the specified address
$address = mysqli_getrow($GLOBALS["tables"]["ledger"], "`address` = '" . $_REQUEST["address"] . "'");
//	Error handling for invalid or unrecognized address
if ($address["success"] < 1 || $address["data"] == "") {
    $message = "<p> \n";
    $message .= "\tInvalid or Unrecognized Address \n";
    $message .= "</p> \n\n";
    $message .= "<p> \n";
    $message .= "\tPlease verify your address and try again. \n";
    $message .= "</p> \n\n";
    spectra_page_error("Invalid Address", $message);
}
//	If there were no error the address details are rendered
spectra_site_head($GLOBALS["currency"]["code"] . " Address Detail");
spectra_address_detail($address["data"]);
spectra_site_foot();
/******************************************************************************
	Developed By Jake Paysnoe - Copyright © 2015 SPEC Development Team
	SPEC Block Explorer is released under the MIT Software License.
	For additional details please read license.txt in this package.
예제 #5
0
파일: tx.php 프로젝트: newmight2015/SPECTRA
    //	Attempt to retrieve the tx from the node
    $rawtx = getrawtransaction($_REQUEST["tx"]);
    //	The response data is formatted and returned to the browser
    echo "<pre>\n" . print_r($rawtx, 1) . "\n</pre>\n";
    //	Exit without rendering the full transaction page
    exit;
}
//	Error handling for a missing txid
if (!isset($_REQUEST["tx"]) || $_REQUEST["tx"] == "") {
    $message = "<p> \n";
    $message .= "\tYou must provide a transaction ID to use this page. \n";
    $message .= "</p> \n\n";
    spectra_page_error("Missing Transaction ID", $message);
}
//	Attempt to retrieve the specified transaction
$tx = mysqli_getrow($GLOBALS["tables"]["tx"], "`txid` = '" . $_REQUEST["tx"] . "'");
//	Error handling for unrecognized transaction
if ($tx["success"] < 1 || $tx["data"] == "") {
    $message = "<p> \n";
    $message .= "\tInvalid or Unrecognized TX ID \n";
    $message .= "</p> \n\n";
    $message .= "<p> \n";
    $message .= "\tPlease verify your TX ID and try again. \n";
    $message .= "</p> \n\n";
    spectra_page_error("Invalid Transaction ID", $message);
}
//	The rest of the code generates the normal tx detail page for the site
spectra_site_head($GLOBALS["currency"]["code"] . " Transaction Detail");
spectra_tx_detail($tx["data"]);
spectra_site_foot();
/******************************************************************************