Ejemplo n.º 1
0
    // Called exactly like startInput, but with a much richer context
    virtual void edge(
        uint64_t      value,                // Number of satoshis coming in on this input from upstream transaction
        const uint8_t *upTXHash,            // sha256 of upstream transaction
        uint64_t      outputIndex,          // Index of output in upstream transaction
        const uint8_t *outputScript,        // Raw script (challenge to spender) carried by output in upstream transaction
        uint64_t      outputScriptSize,     // Byte size of script carried by output in upstream transaction
        const uint8_t *downTXHash,          // sha256 of current (downstream) transaction
        uint64_t      inputIndex,           // Index of input in downstream transaction
        const uint8_t *inputScript,         // Raw script (answer to challenge) carried by input in downstream transaction
        uint64_t      inputScriptSize       // Byte size of script carried by input in downstream transaction
    )
    {
        printf(
            "%svalue = %" PRIu64 " # %.08f\n",
            spaces,
            value,
            satoshisToNormaForm(value)
        );

        printf(
            "%ssourceTXOutputIndex = %d\n",
            spaces,
            (int)outputIndex
        );

        printf(
            "%ssourceTXHash = '",
            spaces
        );
        showHex(upTXHash);
        printf("'\n");
    }
Ejemplo n.º 2
0
    // Called when an output has been fully parsed
    virtual void endOutput(
        const uint8_t *p,                   // Pointer to TX output raw data
        uint64_t      value,                // Number of satoshis on this output
        const uint8_t *txHash,              // sha256 of the current transaction
        uint64_t      outputIndex,          // Index of this output in the current transaction
        const uint8_t *outputScript,        // Raw script (challenge to would-be spender) carried by this output
        uint64_t      outputScriptSize      // Byte size of raw script
    )
    {
        printf(
            "%svalue = %" PRIu64 " # %.08f\n",
            spaces,
            value,
            satoshisToNormaForm(value)
        );

        printf("%sscript = '\n", spaces);
        showScript(outputScript, outputScriptSize, 0, (const char *)spaces);
        printf("%s'\n", spaces);

        showScriptInfo(outputScript, outputScriptSize, spaces);

        pop();
        printf("%s}\n", spaces);
        ++outputId;
    }
Ejemplo n.º 3
0
    virtual void edge(
        uint64_t      value,
        const uint8_t *upTXHash,
        uint64_t      outputIndex,
        const uint8_t *outputScript,
        uint64_t      outputScriptSize,
        const uint8_t *downTXHash,
        uint64_t      inputIndex,
        const uint8_t *inputScript,
        uint64_t      inputScriptSize
    ) {
        if(dump) {
            uint8_t buf[1 + 2*kSHA256ByteSize];
            toHex(buf, upTXHash);
            printf("        outputIndex = %" PRIu64 "\n", outputIndex);
            printf("        value = %.8f\n", satoshisToNormaForm(value));
            printf("        upTXHash = %s\n\n", buf);
            printf("        # challenge answer script, bytes=%" PRIu64 " (on downstream input) =\n", inputScriptSize);
            showScript(inputScript, inputScriptSize, 0, "        ");
            printf("                           ||\n");
            printf("                           VV\n");
            printf("        # challenge script, bytes=%" PRIu64 " (on upstream output)=\n", outputScriptSize);
            showScript(outputScript, outputScriptSize, 0, "        ");
            showScriptInfo(outputScript, outputScriptSize, (const uint8_t *)"        ");
            valueIn += value;

        }
    }
Ejemplo n.º 4
0
    virtual void startInput(
        const uint8_t *p
    ) {
        if(dump) {
            printf(
                "    input[%" PRIu64 "] = {\n\n",
                nbInputs++
            );

            static uint256_t gNullHash;
            LOAD(uint256_t, upTXHash, p);
            LOAD(uint32_t, upOutputIndex, p);
            LOAD_VARINT(inputScriptSize, p);
            showScript(p, inputScriptSize, 0, "        ");

            isGenTX = (0==memcmp(gNullHash.v, upTXHash.v, sizeof(gNullHash)));
            if(isGenTX) {
                uint64_t reward = getBaseReward(currBlock);
                printf("        generation transaction\n");
                printf("        based on block height, reward = %.8f\n", satoshisToNormaForm(reward));
                printf("        hex dump of coinbase follows:\n\n");
                canonicalHexDump(p, inputScriptSize, "        ");
                valueIn += reward;
            }
        }
    }
Ejemplo n.º 5
0
 virtual void endTX(
     const uint8_t *p
 ) {
     if(dump) {
         LOAD(uint32_t, lockTime, p);
         printf("    nbInputs = %" PRIu64 "\n", (uint64_t)nbInputs);
         printf("   nbOutputs = %" PRIu64 "\n", (uint64_t)nbOutputs);
         printf("    byteSize = %" PRIu64 "\n", (uint64_t)(p - txStart));
         printf("    lockTime = %" PRIu32 "\n", (uint32_t)lockTime);
         printf("     valueIn =  %.2f\n", satoshisToNormaForm(valueIn));
         printf("    valueOut =  %.2f\n", satoshisToNormaForm(valueOut));
         if(!isGenTX) {
             printf("        fees =  %.2f\n", satoshisToNormaForm(valueIn-valueOut));
         }
         printf("}\n");
         ++nbDumped;
     }
     isDone = (nbDumped==txMap.size());
 }
Ejemplo n.º 6
0
    virtual void wrapup()
    {
        printf("\n");
        #define P(x) (pr128(x).c_str())
            printf("    nbMaps = %s\n", P(nbMaps));
            printf("    nbBlocks = %s\n", P(nbBlocks));
            printf("    nbValidBlocks = %s\n", P(nbValidBlocks));
            printf("    nbOrphanedBlocks in maps = %s\n", P(nbBlocks - nbValidBlocks));
            printf("\n");

            printf("    nbInputs = %s\n", P(nbInputs));
            printf("    nbOutputs = %s\n", P(nbOutputs));
            printf("    nbTransactions = %s\n", P(nbTransactions));
            printf("    volume = %.2f (%s satoshis)\n", satoshisToNormaForm(volume), P(volume)); 
            printf("\n");

            printf("    avg tx per block = %.2f\n", (double)nbTransactions / (double)nbValidBlocks);
            printf("    avg inputs per tx = %.2f\n", (double)nbInputs / (double)nbTransactions);
            printf("    avg outputs per tx = %.2f\n", (double)nbOutputs / (double)nbTransactions);
            printf("    avg output value = %.2f\n", satoshisToNormaForm(volume/(double)nbOutputs));
            printf("\n");
        #undef P
    }
Ejemplo n.º 7
0
    // Called when a TX input is encountered
    virtual void startInput(
        const uint8_t *p
    ) {
        printf(
            "%sinput%d = {\n",
            spaces,
            (int)inputId
        );
        push();

        static uint256_t gNullHash;
        LOAD(uint256_t, upTXHash, p);
        LOAD(uint32_t, upOutputIndex, p);
        LOAD_VARINT(inputScriptSize, p);

        printf("%sscript = '\n", spaces);
            pop();
                showScript(p, inputScriptSize, 0, (const char *)spaces);
            push();
        printf("%s'\n", spaces);

        p += inputScriptSize;
        LOAD(uint32_t, sequence, p);
        printf("%snsequence = %" PRIu32 "\n",spaces, sequence);

        isCoinBase = (0==memcmp(gNullHash.v, upTXHash.v, sizeof(gNullHash)));
        if(isCoinBase) {
            uint64_t value = getBaseReward(currBlock);
            printf("%sisCoinBase = true\n", spaces);
            printf(
                "%svalue = %" PRIu64 " # %.08f\n",
                spaces,
                value,
                satoshisToNormaForm(value)
            );
            printf("%scoinBase = '\n", spaces);
            push();
                canonicalHexDump(
                    p,
                    inputScriptSize,
                    (const char *)spaces
                );
            pop();
            printf("%s'\n", spaces);
        }
    }
Ejemplo n.º 8
0
 virtual void endOutput(
     const uint8_t *p,                   // Pointer to TX output raw data
     uint64_t      value,                // Number of satoshis on this output
     const uint8_t *txHash,              // sha256 of the current transaction
     uint64_t      outputIndex,          // Index of this output in the current transaction
     const uint8_t *outputScript,        // Raw script (challenge to would-be spender) carried by this output
     uint64_t      outputScriptSize      // Byte size of raw script
 ) {
     if(dump) {
         printf("        value = %.8f\n", satoshisToNormaForm(value));
         printf("        challenge script, bytes=%" PRIu64 " :\n", outputScriptSize);
         showScript(outputScript, outputScriptSize, 0, "        ");
         showScriptInfo(outputScript, outputScriptSize, (const uint8_t *)"        ");
         printf("    }\n\n");
         valueOut += value;
     }
 }