/**
* Output transaction details via HTML code
*
* @param	string	$tx_id
*/
function tx_detail($tx_id)
{
    $raw_tx = getrawtransaction($tx_id);
    if (!isset($raw_tx["txid"])) {
        section_head("Error");
        section_subhead("This transaction is not in the blockchain");
        return;
    }
    section_head("Transaction: " . $raw_tx["txid"]);
    section_subhead("Detailed Description");
    detail_display("TX Version", $raw_tx["version"]);
    detail_display("TX Time", date("F j, Y, H:i:s", $raw_tx["time"]));
    detail_display("Lock Time", $raw_tx["locktime"]);
    detail_display("Confirmations", $raw_tx["confirmations"]);
    detail_display("Block Hash", blockhash_link($raw_tx["blockhash"]));
    //	Florin Coin Feature
    if (isset($raw_tx["tx-comment"]) && $raw_tx["tx-comment"] != "") {
        detail_display("TX Message", htmlspecialchars($raw_tx["tx-comment"]));
    }
    detail_display("HEX Data", $raw_tx["hex"], 50);
    section_head("Transaction Inputs");
    foreach ($raw_tx["vin"] as $key => $txin) {
        section_subhead("Input Transaction " . $key);
        if (isset($txin["coinbase"])) {
            detail_display("Coinbase", $txin["coinbase"]);
            detail_display("Sequence", $txin["sequence"]);
        } else {
            detail_display("TX ID", tx_link($txin["txid"]));
            detail_display("TX Output", $txin["vout"]);
            detail_display("TX Sequence", $txin["sequence"]);
            detail_display("Script Sig (ASM)", $txin["scriptSig"]["asm"], 50);
            detail_display("Script Sig (HEX)", $txin["scriptSig"]["hex"], 50);
        }
    }
    section_head("Transaction Outputs");
    foreach ($raw_tx["vout"] as $key => $txout) {
        section_subhead("Output Transaction " . $key);
        detail_display("TX Value", $txout["value"]);
        detail_display("TX Type", $txout["scriptPubKey"]["type"]);
        if (isset($txout["scriptPubKey"]["reqSigs"])) {
            detail_display("Required Sigs", $txout["scriptPubKey"]["reqSigs"]);
        }
        detail_display("Script Pub Key (ASM)", $txout["scriptPubKey"]["asm"], 50);
        detail_display("Script Pub Key (HEX)", $txout["scriptPubKey"]["hex"], 50);
        if (isset($txout["scriptPubKey"]["addresses"])) {
            foreach ($txout["scriptPubKey"]["addresses"] as $key => $address) {
            }
            detail_display("Address " . $key, $address);
        }
    }
    /* Commented as all the raw info is already presented above
    	section_head ("Raw Transaction Detail");
    	
    	echo "	<textarea name=\"rawtrans\" rows=\"25\" cols=\"80\" style=\"text-align:left;\">\n";
    	print_r ($raw_tx);
    	echo "	\n</textarea><br><br>\n";*/
}
function spectra_tx_parse($txid)
{
    //	Prepare an array for the parsed and calculated data
    $parsed_tx = spectra_tx_new();
    //	Fetch the detailed transaction data from the node
    $tx_verbose = getrawtransaction($txid);
    //	Populate the array with known data
    if (isset($tx_verbose["blockhash"]) && $tx_verbose["blockhash"] != "") {
        $parsed_tx["in_block"] = $tx_verbose["blockhash"];
    }
    if (isset($tx_verbose["txid"]) && $tx_verbose["txid"] != "") {
        $parsed_tx["txid"] = $tx_verbose["txid"];
    }
    if (isset($tx_verbose["version"]) && $tx_verbose["version"] != "") {
        $parsed_tx["version"] = $tx_verbose["version"];
    }
    if (isset($tx_verbose["time"]) && $tx_verbose["time"] != "") {
        $parsed_tx["time"] = $tx_verbose["time"];
    }
    if (isset($tx_verbose["locktime"]) && $tx_verbose["locktime"] != "") {
        $parsed_tx["locktime"] = $tx_verbose["locktime"];
    }
    if (isset($tx_verbose["blocktime"]) && $tx_verbose["blocktime"] != "") {
        $parsed_tx["blocktime"] = $tx_verbose["blocktime"];
    }
    if (isset($tx_verbose["tx-comment"]) && $tx_verbose["tx-comment"] != "") {
        $parsed_tx["tx-comment"] = $tx_verbose["tx-comment"];
    }
    //	These fields are not cached, but they are used to parse the transaction values
    if (isset($tx_verbose["vin"]) && $tx_verbose["vin"] != "") {
        $parsed_tx["vin"] = $tx_verbose["vin"];
    }
    if (isset($tx_verbose["vout"]) && $tx_verbose["vout"] != "") {
        $parsed_tx["vout"] = $tx_verbose["vout"];
    }
    //	Return the parsed tx to the block parser for use in calculating block values
    return $parsed_tx;
}
Example #3
0
<?php

//	Enable the spectra functionality
require_once "lib/spectra_config.php";
//	This code creates the 'raw tx data' view used in the popup
if (isset($_GET["raw"]) && $_GET["raw"] == 1) {
    //	Error handling for missing txid
    if (!isset($_REQUEST["tx"]) || $_REQUEST["tx"] == "") {
        echo "<p> tx parameter (txid) is required </p>\n";
    }
    //	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";
Example #4
0
if ($_REQUEST["method"] == "getblock") {
    if (!isset($_REQUEST["hash"])) {
        spectra_api_response("", 0, "Block Height (&hash=xxxxx) Is Required For Method 'getblock'");
    }
    $requested = getblock($_REQUEST["hash"]);
    if (isset($requested["error"]) && $requested["error"] != "") {
        spectra_api_response("", 0, $requested["error"]["message"]);
    } else {
        spectra_api_response($requested);
    }
}
if ($_REQUEST["method"] == "gettransaction") {
    if (!isset($_REQUEST["txid"])) {
        spectra_api_response("", 0, "Transaction ID (&txid=xxxxx) Is Required For Method 'gettransaction'");
    }
    $requested = getrawtransaction($_REQUEST["txid"]);
    if (isset($requested["error"]) && $requested["error"] != "") {
        spectra_api_response("", 0, $requested["error"]["message"]);
    } else {
        spectra_api_response($requested);
    }
}
/******************************************************************************
	Address API 
******************************************************************************/
if ($_REQUEST["method"] == "isaddress") {
    if (!isset($_REQUEST["address"])) {
        spectra_api_response("", 0, "Address (?address=xxxxx) Is Required For Method 'isaddress'");
    }
    if (spectra_address_exists($_REQUEST["address"])) {
        spectra_api_response("Address Exists");
    // Block height provided
    if (strlen($input) <= 7 && (is_numeric($input) || empty($input))) {
        $block_height = $input;
        if (empty($block_height)) {
            $network_info = getinfo();
            // Default to the latest block
            $block_height = intval($network_info["blocks"]);
        }
        //site_header ("Block Detail Page");
        block_detail($block_height);
    } elseif (strlen($input) == 64 && is_array(getblock($_GET["input"]))) {
        $info = getblock($_GET["input"]);
        //   site_header ("Block Detail Page");
        $block_hash = $_GET["input"];
        block_detail($block_hash, TRUE);
    } elseif (strlen($input) <= 64 && is_array(getrawtransaction($_GET["input"]))) {
        //site_header ("Peercoin Transaction Detail Page");
        tx_detail($_REQUEST["input"]);
    } else {
        //header('Location:index.php');
        $show_detail = false;
        $show_error = true;
        $input_error = "not a block nor a transaction, please try again";
    }
}
//	If there were no request parameters the menu is shown
if (!$show_detail) {
    site_header("Peercoin Block Viewer");
    $network_info = getinfo();
    $difficulty_info = getdifficulty();
    $net_speed = getnetworkhashps();