Beispiel #1
0
void HexView::paint(QPainter *painter)
{
    int left = 0;
    int firstRow =  getRowForY( viewport_.y() )  - 1;
    int lastRow =  getRowForY( viewport_.y() + viewport_.height() )  + 1;

    if (firstRow <  0) firstRow = 0;
    if (lastRow >  rowCount() ) lastRow = rowCount();

    painter->setFont(QFont("Courier"));
    qDebug() << "contentlength=" << contentLength()  << " firstrow=" << firstRow << " lastRow=" << lastRow << " viewport="  << viewport_;

    if (showGuidelines_)    {
        QPen backpen(QColor(255,0,0));
        painter->setPen(backpen);
        //painter->drawRect(viewport_);
    }

    if (showOffsets()) {
        paintOffsets(painter,left,firstRow,lastRow);
    }

    if (showHex()) {
        paintHex(painter,left,firstRow,lastRow);
    }

    if (showAscii()) {
        paintAscii(painter,left,firstRow,lastRow);
    }

}
Beispiel #2
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");
    }
Beispiel #3
0
    virtual void startTX(
        const uint8_t *p,
        const uint8_t *hash
    )
    {
        txStart = p;
        nbInputs = 0;
        nbOutputs = 0;
        dump = (txMap.end()!=txMap.find(hash));

        if(dump) {

            struct tm gmTime;
            time_t blockTime = bTime;
            gmtime_r(&blockTime, &gmTime);

            char timeBuf[256];
            asctime_r(&gmTime, timeBuf);

            size_t sz =strlen(timeBuf);
            if(0<sz) timeBuf[sz-1] = 0;

            LOAD(uint32_t, version, p);

            printf("TX = {\n\n");
            printf("    version = %" PRIu32 "\n", version);
            printf("    minted in block = %" PRIu64 "\n", currBlock-1);
            printf("    mint time = %" PRIu64 " (%s GMT)\n", bTime, timeBuf);
            printf("    txHash = ");
            showHex(hash);
            printf("\n\n");
        }
    }
Beispiel #4
0
    virtual void wrapup()
    {
        info("done\n");

        info("sorting by balance ...");

            CompareAddr compare;
            auto e = allAddrs.end();
            auto s = allAddrs.begin();
            std::sort(s, e, compare);

        info("done\n");

        uint64_t nbRestricts = (uint64_t)restrictMap.size();
        if(0==nbRestricts) info("dumping all balances ...");
        else               info("dumping balances for %" PRIu64 " addresses ...", nbRestricts);

        uint64_t i = 0;
        uint64_t nonZeroCnt = 0;
        while(likely(s<e)) {

            Addr *addr = *(s++);
            if(0!=nbRestricts) {
                auto r = restrictMap.find(addr->hash.v);
                if(restrictMap.end()==r) continue;
            }

            printf("%24.8f ", (1e-8)*addr->sum);
            showHex(addr->hash.v, kRIPEMD160ByteSize, false);
            if(0<addr->sum) ++nonZeroCnt;

            if(i<5000 || 0!=nbRestricts) {
                uint8_t buf[64];
                hash160ToAddr(buf, addr->hash.v);
                printf(" %s", buf);
            }

            struct tm gmTime;
            time_t last = addr->lastTouched;
            gmtime_r(&last, &gmTime);

            char timeBuf[256];
            asctime_r(&gmTime, timeBuf);

            size_t sz =strlen(timeBuf);
            if(0<sz) timeBuf[sz-1] = 0;

            printf(" %s\n", timeBuf);
            ++i;
        }
        info("done\n");

        info("found %" PRIu64 " addresses with non zero balance", nonZeroCnt);
        info("found %" PRIu64 " addresses in total", (uint64_t)allAddrs.size());
        info("shown:%" PRIu64 " addresses", (uint64_t)i);
    }
Beispiel #5
0
void HexView::recalcWidth()
{
    int sizeOfOffsets = (2 + offsetLen()) * asciiSpacer();
    int spacers = 0;
    if (showOffsets()) {
        spacers += spacer() + sizeOfOffsets;
    }
    if (showHex()) {
        spacers += spacer() + (bytesPerRow() * hexSpacer());
    }
    if (showAscii()) {
        spacers += bytesPerRow() * asciiSpacer();
    }
    setContentWidth( spacers );

}
Beispiel #6
0
    virtual void endTX(
        const uint8_t *p
    )
    {
        auto i = srcTxMap.find(txHash);
        bool isSrcTX = (srcTxMap.end() != i);

        Number taint = 0;
             if(unlikely(isSrcTX))    taint = 1;
        else if(txTotal>0 && 0<txBad) taintMap[txHash] = taint = txBad/txTotal;

        if(threshold<taint) {
            printNumber(taint);
            showHex(txHash);
            putchar('\n');
        }
    }
Beispiel #7
0
    // Called when a new TX is encountered
    virtual void startTX(
        const uint8_t *p,
        const uint8_t *hash
    ) {

        printf(
            "%stx%d = {\n",
            spaces,
            txIdInBlock
        );
        push();

        #if defined(CLAM)
            auto pBis = p;
            LOAD(uint32_t, nVersion, pBis);
            txVersion = nVersion;
        #endif

        printf("%stxHash = '", spaces);
        showHex(hash);
        printf("'\n");
    }
Beispiel #8
0
    // Called when a new block is encountered
    virtual void startBlock(
        const Block *b,
        uint64_t    chainSize
    ) {
        txIdInBlock = 0;
        currBlock = b->height;

        printf(
            "%sblock%d = {\n",
            spaces,
            (int)(-1+b->height)
        );
        push();

        printf(
            "%ssize = %" PRIu64 "\n",
            spaces,
            b->chunk->getSize()
        );

        printf(
            "%soffset = %" PRIu64 "\n",
            spaces,
            b->chunk->getOffset()
        );

        printf(
            "%smap = '%s'\n",
            spaces,
            b->chunk->getMap()->name.c_str()
        );

        printf("%sblockHash = '", spaces);
        showHex(b->hash);
        printf("'\n");
    }
Beispiel #9
0
void showNunchukData( WiiNunchuk &wiiClassy )
{

		displayAt(0,0,"x: ");
		showHex(wiiClassy.x());

		displayAt(1,0,"y: ");
		showHex(wiiClassy.y());

		displayAt(0,6,"Xa:");
		showHex(wiiClassy.xacc());

		displayAt(0,11,",Ya:");
		showHex(wiiClassy.yacc());

		displayAt(1,6,"Za:");
		showHex(wiiClassy.zacc());

		setPosition(1,12);
		showHex(wiiClassy.z());

		setPosition(1,15);
		showHex(wiiClassy.c());
}
Beispiel #10
0
    void move(
        const uint8_t *script,
        uint64_t      scriptSize,
        const uint8_t *txHash,
        uint64_t       value,
        bool           add,
        const uint8_t *downTXHash = 0
    )
    {
        uint8_t addrType[3];
        uint160_t pubKeyHash;
        int type = solveOutputScript(pubKeyHash.v, script, scriptSize, addrType);
        if(unlikely(type<0)) return;

        bool match = (addrMap.end() != addrMap.find(pubKeyHash.v));
        if(unlikely(match)) {

            int64_t newSum = sum + value*(add ? 1 : -1);

            if(csv) {
                printf("%6" PRIu64 ", \"", bTime/86400 + 25569);
                showHex(pubKeyHash.v, kRIPEMD160ByteSize, false);
                printf("\", \"");
                showHex(downTXHash ? downTXHash : txHash);
                printf(
                    "\",%17.08f,%17.08f\n",
                    (add ? 1e-8 : -1e-8)*value,
                    newSum*1e-8
                );
            } else {

                struct tm gmTime;
                time_t blockTime = bTime;
                gmtime_r(&blockTime, &gmTime);

                char timeBuf[256];
                asctime_r(&gmTime, timeBuf);

                size_t sz =strlen(timeBuf);
                if(0<sz) timeBuf[sz-1] = 0;

                printf("    %s    ", timeBuf);
                showHex(pubKeyHash.v, kRIPEMD160ByteSize, false);

                printf("    ");
                showHex(downTXHash ? downTXHash : txHash);

                printf(
                    " %24.08f %c %24.08f = %24.08f\n",
                    sum*1e-8,
                    add ? '+' : '-',
                    value*1e-8,
                    newSum*1e-8
                );
            }

            (add ? adds : subs) += value;
            sum = newSum;
            ++nbTX;
        }
    }
Beispiel #11
0
    virtual void wrapup()
    {
        info("done\n");

        info("sorting by balance ...");

            CompareAddr compare;
            auto e = allAddrs.end();
            auto s = allAddrs.begin();
            std::sort(s, e, compare);

        info("done\n");

        uint64_t nbRestricts = (uint64_t)restrictMap.size();
        if(0==nbRestricts) info("dumping all balances ...");
        else               info("dumping balances for %" PRIu64 " addresses ...", nbRestricts);

        printf(
            "---------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"
            "                 Balance                                  Hash160                             Base58   nbIn lastTimeIn                 nbOut lastTimeOut\n"
            "---------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"
        );

        int64_t i = 0;
        int64_t nonZeroCnt = 0;
        while(likely(s<e)) {

            if(0<=limit && limit<=i)
                break;

            Addr *addr = *(s++);
            if(0!=nbRestricts) {
                auto r = restrictMap.find(addr->hash.v);
                if(restrictMap.end()==r) continue;
            }

            printf("%24.8f ", (1e-6)*addr->sum);
            showHex(addr->hash.v, kRIPEMD160ByteSize, false);
            if(0<addr->sum) ++nonZeroCnt;

            if(i<showAddr || 0!=nbRestricts) {
                uint8_t buf[64];
                hash160ToAddr(buf, addr->hash.v);
                printf(" %s", buf);
            } else {
                printf(" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            }

            char timeBuf[256];
            gmTime(timeBuf, addr->lastIn);
            printf(" %6" PRIu64 " %s ", addr->nbIn, timeBuf);

            gmTime(timeBuf, addr->lastOut);
            printf(" %6" PRIu64 " %s\n", addr->nbOut, timeBuf);

            if(detailed) {
                auto e = addr->outputVec->end();
                auto s = addr->outputVec->begin();
                while(s!=e) {
                    printf("    %24.8f ", 1e-6*s->value);
                    gmTime(timeBuf, s->time);
                    showHex(s->upTXHash);
                    printf("%4" PRIu64 " %s", s->outputIndex, timeBuf);
                    if(s->downTXHash) {
                        printf(" -> %4" PRIu64 " ", s->inputIndex);
                        showHex(s->upTXHash);
                    }
                    printf("\n");
                    ++s;
                }
                printf("\n");
            }

            ++i;
        }

        info("done\n");
        info("found %" PRIu64 " addresses with non zero balance", nonZeroCnt);
        info("found %" PRIu64 " addresses in total", (uint64_t)allAddrs.size());
        info("shown:%" PRIu64 " addresses", (uint64_t)i);
        printf("\n");
        exit(0);
    }