Esempio n. 1
0
//============================================================
// <T>解析16进制字符串。</T>
//
// @param pSource 来源
// @param length 长度
// @return 内容
//============================================================
TUint8 RUint8::ParseHexNvl(TCharC* pSource, TInt length){
   if(NULL != pSource){
      return ParseHex(pSource, length);
   }
   return 0;
}
Esempio n. 2
0
void MultisigDialog::on_signTransactionButton_clicked()
{
    ui->signedTransaction->clear();

    if(!model)
        return;

    CWallet *wallet = model->getWallet();

    // Decode the raw transaction
    std::vector<unsigned char> txData(ParseHex(ui->transaction->text().toStdString()));
    CDataStream ss(txData, SER_NETWORK, PROTOCOL_VERSION);
    CTransaction tx;
    try
    {
        ss >> tx;
    }
    catch(std::exception &e)
    {
        (void)e;
        return;
    }
    CTransaction mergedTx(tx);

    // Fetch previous transactions (inputs)
    std::map<COutPoint, CScript> mapPrevOut;
    for(unsigned int i = 0; i < mergedTx.vin.size(); i++)
    {
        CTransaction tempTx;
        MapPrevTx mapPrevTx;
        CTxDB txdb("r");
        std::map<uint256, CTxIndex> unused;
        bool fInvalid;

        tempTx.vin.push_back(mergedTx.vin[i]);
        tempTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid);

        BOOST_FOREACH(const CTxIn& txin, tempTx.vin)
        {
            const uint256& prevHash = txin.prevout.hash;
            if(mapPrevTx.count(prevHash) && mapPrevTx[prevHash].second.vout.size() > txin.prevout.n)
                mapPrevOut[txin.prevout] = mapPrevTx[prevHash].second.vout[txin.prevout.n].scriptPubKey;
        }
    }

    // Add the redeem scripts to the wallet keystore
    for(int i = 0; i < ui->inputs->count(); i++)
    {
        MultisigInputEntry *entry = qobject_cast<MultisigInputEntry *>(ui->inputs->itemAt(i)->widget());
        if(entry)
        {
            QString redeemScriptStr = entry->getRedeemScript();
            if(redeemScriptStr.size() > 0)
            {
                std::vector<unsigned char> scriptData(ParseHex(redeemScriptStr.toStdString()));
                CScript redeemScript(scriptData.begin(), scriptData.end());
                wallet->AddCScript(redeemScript);
            }
        }
    }

    WalletModel::UnlockContext ctx(model->requestUnlock());
    if(!ctx.isValid())
        return;

    // Sign what we can
    bool fComplete = true;
    for(unsigned int i = 0; i < mergedTx.vin.size(); i++)
    {
        CTxIn& txin = mergedTx.vin[i];
        if(mapPrevOut.count(txin.prevout) == 0)
        {
            fComplete = false;
            continue;
        }
        const CScript& prevPubKey = mapPrevOut[txin.prevout];

        txin.scriptSig.clear();
        SignSignature(*wallet, prevPubKey, mergedTx, i, SIGHASH_ALL);
        txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, tx.vin[i].scriptSig);
        if(!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, true, 0))
        {
            fComplete = false;
        }
    }

    CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
    ssTx << mergedTx;
    ui->signedTransaction->setText(HexStr(ssTx.begin(), ssTx.end()).c_str());

    if(fComplete)
    {
        ui->statusLabel->setText(tr("Transaction signature is complete"));
        ui->sendTransactionButton->setEnabled(true);
    }
    else
    {
        ui->statusLabel->setText(tr("Transaction is NOT completely signed"));
        ui->sendTransactionButton->setEnabled(false);
    }
}
void TestHMACSHA512(const std::string &hexkey, const std::string &hexin, const std::string &hexout) {
    std::vector<unsigned char> key = ParseHex(hexkey);
    TestVector(CHMAC_SHA512(&key[0], key.size()), ParseHex(hexin), ParseHex(hexout));
}
Esempio n. 4
0
    CMainParams() {
        strNetworkID = "main";
        consensus.nMajorityEnforceBlockUpgrade = 750;
        consensus.nMajorityRejectBlockOutdated = 950;
        consensus.nMajorityWindow = 1000;
        consensus.BIP34Height = 227931;
        consensus.BIP34Hash = uint256S("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
        consensus.powLimit = uint256S("0x00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20;
        consensus.nPowTargetTimespan = 6 * 60 * 60; // 6h retarget
        consensus.nPowTargetSpacing = 1 * 60; // 1 minute
        consensus.fPowAllowMinDifficultyBlocks = false;
        consensus.fPowNoRetargeting = false;
		consensus.nAuxpowChainId = 0x1000;
        /** 
         * The message start string is designed to be unlikely to occur in normal data.
         * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
         * a large 32-bit integer with any alignment.
         */
        pchMessageStart[0] = 0xf9;
        pchMessageStart[1] = 0xbe;
        pchMessageStart[2] = 0xb4;
        pchMessageStart[3] = 0xd9;
        vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
        nDefaultPort = 8369;
		// SYSCOIN todo fix for now
		nMaxTipAge = 0x7fffffff;
        //nMaxTipAge = 24 * 60 * 60;
        nPruneAfterHeight = 100000;

        genesis = CreateGenesisBlock(1450473723, 5258726, 0x1e0ffff0, 1, 2.5 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("0x0000072d66e51ab87de265765cc8bdd2d229a4307c672a1b3d5af692519cf765"));
        assert(genesis.hashMerkleRoot == uint256S("0x5215c5a2af9b63f2550b635eb2b354bb13645fd8fa31275394eb161944303065"));
        vSeeds.push_back(CDNSSeedData("seed1.syscoin.org", "seed1.syscoin.org"));
        vSeeds.push_back(CDNSSeedData("seed2.syscoin.org", "seed2.syscoin.org"));
        vSeeds.push_back(CDNSSeedData("seed3.syscoin.org", "seed3.syscoin.org"));
        vSeeds.push_back(CDNSSeedData("seed4.syscoin.org", "seed4.syscoin.org"));

		// SYSCOIN/BITCOIN key prefixes
        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
        base58Prefixes[SECRET_KEY]     = std::vector<unsigned char>(1,128);

		base58Prefixes[PUBKEY_ADDRESS_SYS] = std::vector<unsigned char>(1,63);
		base58Prefixes[SECRET_KEY_SYS] = std::vector<unsigned char>(1,191);

        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();

        //vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
		//vFixedSeeds.clear();
        fMiningRequiresPeers = true;
        fDefaultConsistencyChecks = false;
        fRequireStandard = true;
        fMineBlocksOnDemand = false;
        fTestnetToBeDeprecatedFieldRPC = false;

       /* checkpointData = (CCheckpointData) {
            boost::assign::map_list_of
            ( 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
            ( 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))
            ( 74000, uint256S("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"))
            (105000, uint256S("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"))
            (134444, uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"))
            (168000, uint256S("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763"))
            (193000, uint256S("0x000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317"))
            (210000, uint256S("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e"))
            (216116, uint256S("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e"))
            (225430, uint256S("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932"))
            (250000, uint256S("0x000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214"))
            (279000, uint256S("0x0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40"))
            (295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983")),
            1397080064, // * UNIX timestamp of last checkpoint block
            36544669,   // * total number of transactions between genesis and last checkpoint
                        //   (the tx=... number in the SetBestChain debug.log lines)
            60000.0     // * estimated number of transactions per day after checkpoint
        };*/
    }
Esempio n. 5
0
/**
 * Build the genesis block. Note that the output of its generation
 * transaction cannot be spent since it did not originally exist in the
 * database.
 *
 * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
 *   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
 *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
 *     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
 *   vMerkleTree: 4a5e1e
 */
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
    const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
Esempio n. 6
0
bool CImportExportHex::ImportHexFile(_TCHAR* filePath, CPICkitFunctions* picFuncs)
{
	bool ret = true;
	FILE *hexfile;
	errno_t err;

	picFuncs->ResetBuffers();

	if ((err = _tfopen_s(&hexfile, filePath, "rt")) == 0)
	{	
        int bytesPerWord = picFuncs->DevFile.Families[picFuncs->ActiveFamily].ProgMemHexBytes;
        int eeMemBytes = picFuncs->DevFile.Families[picFuncs->ActiveFamily].EEMemHexBytes;
        unsigned int eeAddr = picFuncs->DevFile.PartsList[picFuncs->ActivePart].EEAddr;
        int progMemSizeBytes = (int)picFuncs->DevFile.PartsList[picFuncs->ActivePart].ProgramMem * bytesPerWord;
        int segmentAddress = 0;
        bool configRead = false;
        bool lineExceedsFlash = true;
        bool fileExceedsFlash = false;
        int userIDs = picFuncs->DevFile.PartsList[picFuncs->ActivePart].UserIDWords;
        unsigned int userIDAddr = picFuncs->DevFile.PartsList[picFuncs->ActivePart].UserIDAddr;
        if (userIDAddr == 0)
        {
            userIDAddr = 0xFFFFFFFF;
        }
        int userIDMemBytes = picFuncs->DevFile.Families[picFuncs->ActiveFamily].UserIDHexBytes;
        // need to set config words to memory blank.
        int configWords = picFuncs->DevFile.PartsList[picFuncs->ActivePart].ConfigWords;
        for (int cw = 0; cw < configWords; cw++)
        {
            picFuncs->DeviceBuffers->ConfigWords[cw] = picFuncs->DevFile.Families[picFuncs->ActiveFamily].BlankValue;
        }
		int cfgBytesPerWord = bytesPerWord;
		unsigned int programMemStart = 0;
		unsigned int bootMemStart = 0;
		unsigned int bootMemSize = picFuncs->DevFile.PartsList[picFuncs->ActivePart].BootFlash;
		if (picFuncs->FamilyIsPIC32())
        { // PIC32
            programMemStart = K_P32_PROGRAM_FLASH_START_ADDR;
            bootMemStart = K_P32_BOOT_FLASH_START_ADDR;
            progMemSizeBytes -= (int)bootMemSize * bytesPerWord;
            progMemSizeBytes += (int)programMemStart;
            cfgBytesPerWord = 2;
        }
        unsigned int bootMemEnd = bootMemStart + (bootMemSize * (unsigned int)bytesPerWord);   
        int bootArrayStart = (int)(picFuncs->DevFile.PartsList[picFuncs->ActivePart].ProgramMem - bootMemSize);

		_TCHAR fileLine[MAX_LINE_LEN] ="";
		while (!feof(hexfile))
		{
		   if (_fgetts(fileLine, MAX_LINE_LEN, hexfile) == NULL)
		   {
			   printf("\n Error reading hex file.\n");
			   	if (hexfile != NULL)
					fclose(hexfile);
				return false;
		   }
           if ((fileLine[0] == ':') && (_tcslen(fileLine) >= 11))
            { // skip line if not hex line entry,or not minimum length ":BBAAAATTCC"
                int byteCount = ParseHex(&fileLine[1], 2);
				int fileAddress = segmentAddress + ParseHex(&fileLine[3], 4);
				int recordType = ParseHex(&fileLine[7], 2);

                if (recordType == 0)
                { // Data Record}
                    if ((int)_tcslen(fileLine) >= (11+ (2* byteCount)))
                    { // skip if line isn't long enough for bytecount.                    

                        for (int lineByte = 0; lineByte < byteCount; lineByte++)
						{
                            int byteAddress = fileAddress + lineByte;
                            // compute array address from hex file address # bytes per memory location
                            int arrayAddress = (byteAddress - (int)programMemStart) / bytesPerWord;
                            // compute byte position withing memory word
                            int bytePosition = byteAddress % bytesPerWord;
                            // get the byte value from hex file
                            unsigned int wordByte = 0xFFFFFF00 | ParseHex(&fileLine[9 + (2 * lineByte)], 2); 
                            // shift the byte into its proper position in the word.
                            for (int shift = 0; shift < bytePosition; shift++)
							{ // shift byte into proper position
                                wordByte <<= 8;
                                wordByte |= 0xFF; // shift in ones.
                            }

                           lineExceedsFlash = true; // if not in any memory section, then error

                            // program memory section --------------------------------------------------
                            if ((byteAddress < progMemSizeBytes) && (byteAddress >= (int)programMemStart))
                            { 
                                picFuncs->DeviceBuffers->ProgramMemory[arrayAddress] &= wordByte; // add byte.
                                lineExceedsFlash = false;
                                //NOTE: program memory locations containing config words may get modified
                                // by the config section below that applies the config masks.
                            }

                            // boot memory section --------------------------------------------------
                            if ((bootMemSize > 0) && (byteAddress >= (int)bootMemStart) && (byteAddress < (int)bootMemEnd))
                            {              
                                arrayAddress = (int)(bootArrayStart + ((byteAddress - bootMemStart) / bytesPerWord));
                                picFuncs->DeviceBuffers->ProgramMemory[arrayAddress] &= wordByte; // add byte.
                                lineExceedsFlash = false;
                                //NOTE: program memory locations containing config words may get modified
                                // by the config section below that applies the config masks.
                            }  
                            
                            // EE data section ---------------------------------------------------------
                            if ((byteAddress >= (int)eeAddr) && (eeAddr > 0) && ((int)picFuncs->DevFile.PartsList[picFuncs->ActivePart].EEMem > 0))
                            {
                                int eeAddress = (int)(byteAddress - eeAddr) / eeMemBytes;
                                if (eeAddress < picFuncs->DevFile.PartsList[picFuncs->ActivePart].EEMem)
                                {
                                    lineExceedsFlash = false;
                                    if (eeMemBytes == bytesPerWord)
                                    { // same # hex bytes per EE location as ProgMem location
                                        picFuncs->DeviceBuffers->EEPromMemory[eeAddress] &= wordByte; // add byte.    
                                    }
                                    else
                                    {  // PIC18F/J
                                        int eeshift = (bytePosition / eeMemBytes) * eeMemBytes;
                                        for (int reshift = 0; reshift < eeshift; reshift++)
                                        { // shift byte into proper position
                                            wordByte >>= 8;
                                        }
                                        picFuncs->DeviceBuffers->EEPromMemory[eeAddress] &= wordByte; // add byte. 
                                    }
                                }
                            }
                            // Some 18F parts without EEPROM have hex files created with blank EEPROM by MPLAB
                            else if ((byteAddress >= (int)eeAddr) && (eeAddr > 0) && ((int)picFuncs->DevFile.PartsList[picFuncs->ActivePart].EEMem == 0))
                            {
                                lineExceedsFlash = false; // don't give too-large file error.
                            }
                            // Config words section ----------------------------------------------------
                            if ((byteAddress >= (int)picFuncs->DevFile.PartsList[picFuncs->ActivePart].ConfigAddr)
                                    && (configWords > 0))
                            {
                                int configNum = (byteAddress - ((int)picFuncs->DevFile.PartsList[picFuncs->ActivePart].ConfigAddr)) / cfgBytesPerWord;
                                if ((cfgBytesPerWord != bytesPerWord) && (bytePosition > 1))
                                { // PIC32
                                    wordByte = (wordByte >> 16) & picFuncs->DevFile.Families[picFuncs->ActiveFamily].BlankValue;
                                }
                                if (configNum < picFuncs->DevFile.PartsList[picFuncs->ActivePart].ConfigWords)
                                {
                                    lineExceedsFlash = false;
                                    configRead = true;
                                    picFuncs->DeviceBuffers->ConfigWords[configNum] &= 
                                        (wordByte & picFuncs->DevFile.PartsList[picFuncs->ActivePart].ConfigMasks[configNum]);
                                    if (byteAddress < progMemSizeBytes)
                                    { // also mask off the word if in program memory.
                                        picFuncs->DeviceBuffers->ProgramMemory[arrayAddress] &= 
                                            (wordByte & picFuncs->DevFile.PartsList[picFuncs->ActivePart].ConfigMasks[configNum]); // add byte.
										if (picFuncs->DevFile.Families[picFuncs->ActiveFamily].BlankValue == 0xFFFF)
										{// PIC18J
											picFuncs->DeviceBuffers->ProgramMemory[arrayAddress] |= 0xF000; // set upper nibble
										}
										else
										{// PIC24FJ is currently only other case of config in program mem
											picFuncs->DeviceBuffers->ProgramMemory[arrayAddress] |= (0xFF0000);
											picFuncs->DeviceBuffers->ProgramMemory[arrayAddress] |= 
												(picFuncs->DevFile.PartsList[picFuncs->ActivePart].ConfigBlank[configNum] &
												~ picFuncs->DevFile.PartsList[picFuncs->ActivePart].ConfigMasks[configNum]);
										}
                                    }
                                }                                    
                                
                            } 
Esempio n. 7
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0xf8;
        pchMessageStart[1] = 0xb5;
        pchMessageStart[2] = 0x03;
        pchMessageStart[3] = 0xdf;
        vAlertPubKey = ParseHex("04f09702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
        nDefaultPort = 12835;
        nRPCPort = 12832;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 950000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.

        const char* pszTimestamp = "February 5, 2014: The Black Hills are not for sale - 1868 Is The LAW!";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 5000 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1390747675;
        genesis.nBits    = 0x1e0ffff0;
        genesis.nNonce   = 2091390249;

        //// debug print
        hashGenesisBlock = genesis.GetHash();
        //while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
        //   if (++genesis.nNonce==0) break;
        //    hashGenesisBlock = genesis.GetHash();
        //}

        //printf("%s\n", hashGenesisBlock.ToString().c_str());
        //printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        //printf("%x\n", bnProofOfWorkLimit.GetCompact());
        //genesis.print();


        assert(hashGenesisBlock == uint256("0x00000c7c73d8ce604178dae13f0fc6ec0be3275614366d44b1b4b5c6e238c60c"));
        assert(genesis.hashMerkleRoot == uint256("0x62d496378e5834989dd9594cfc168dbb76f84a39bbda18286cddc7d1d1589f4f"));

        vSeeds.push_back(CDNSSeedData("node.Maza.org", "node.Maza.org"));
        vSeeds.push_back(CDNSSeedData("node.Maza.cf", "node.Maza.cf"));
        vSeeds.push_back(CDNSSeedData("Maza.no-ip.org", "Maza.no-ip.org"));

        base58Prefixes[PUBKEY_ADDRESS] = 50;
        base58Prefixes[SCRIPT_ADDRESS] = 9;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time'
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Esempio n. 8
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0xfd;
        pchMessageStart[1] = 0xa4;
        pchMessageStart[2] = 0xdc;
        pchMessageStart[3] = 0x6c;
        vAlertPubKey = ParseHex("04d1832d7d0c59634d67d3023379403014c2878d0c2372d175219063a48fa06e6d429e09f36d3196ec544c2cfdd12d6fe510a399595f75ebb6da238eb5f70f2072");
        nDefaultPort = 12340;
        nRPCPort = 12341;

        bnProofOfWorkLimit[ALGO_SHA256D] = CBigNum(~uint256(0) >> 20); // 1.00000000
        bnProofOfWorkLimit[ALGO_SCRYPT]  = CBigNum(~uint256(0) >> 20);
        bnProofOfWorkLimit[ALGO_GROESTL] = CBigNum(~uint256(0) >> 20); // 0.00195311
        bnProofOfWorkLimit[ALGO_SKEIN]   = CBigNum(~uint256(0) >> 20); // 0.00195311
        bnProofOfWorkLimit[ALGO_QUBIT]   = CBigNum(~uint256(0) >> 20); // 0.00097655

        // Build the genesis block.
        const char* pszTimestamp = "Visir 10. oktober 2008 Gjaldeyrishoft sett a Islendinga";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("04a5814813115273a109cff99907ba4a05d951873dae7acb6c973d0c9e7c88911a3dbc9aa600deac241b91707e7b4ffb30ad91c8e56e695a1ddf318592988afe0a") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1390598806;
        genesis.nBits    = Params().ProofOfWorkLimit(ALGO_SCRYPT).GetCompact();
        //genesis.nBits = 0x1e0fffff;
        genesis.nNonce   = 538548;

        hashGenesisBlock = genesis.GetHash();

        assert(hashGenesisBlock == uint256("0x2a8e100939494904af825b488596ddd536b3a96226ad02e0f7ab7ae472b27a8e"));
        assert(genesis.hashMerkleRoot == uint256("0x8957e5e8d2f0e90c42e739ec62fcc5dd21064852da64b6528ebd46567f222169"));

        vSeeds.push_back(CDNSSeedData("luxembourgh", "s1.auroraseed.net"));
        vSeeds.push_back(CDNSSeedData("united-states-west", "aurseed1.criptoe.com"));
        vSeeds.push_back(CDNSSeedData("united-states-east", "s1.auroraseed.com"));
        vSeeds.push_back(CDNSSeedData("iceland", "s1.auroraseed.org"));
        vSeeds.push_back(CDNSSeedData("the-netherlands", "s1.auroraseed.eu"));
        vSeeds.push_back(CDNSSeedData("electrum2", "electrum2.aurorcoin.is"));
        vSeeds.push_back(CDNSSeedData("electrum3", "electrum3.auroracoin.is"));
        vSeeds.push_back(CDNSSeedData("electrum4", "electrum4.auroracoin.is"));

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,23);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
        base58Prefixes[SECRET_KEY]     = std::vector<unsigned char>(1,176);
        base58Prefixes[SECRET_KEY_OLD] = std::vector<unsigned char>(1,151);
        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            const int64_t nOneWeek = 7*24*60*60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
            vFixedSeeds.push_back(addr);
        }
    }
Esempio n. 9
0
void ThreadSendAlert()
{
    if (!mapArgs.count("-sendalert") && !mapArgs.count("-printalert"))
        return;

    MilliSleep(60*1000); // Wait a minute so we get connected

    //
    // Alerts are relayed around the network until nRelayUntil, flood
    // filling to every node.
    // After the relay time is past, new nodes are told about alerts
    // when they connect to peers, until either nExpiration or
    // the alert is cancelled by a newer alert.
    // Nodes never save alerts to disk, they are in-memory-only.
    //
    CAlert alert;
    alert.nRelayUntil   = GetTime() + 15 * 60;
    alert.nExpiration   = GetTime() + 365 * 60 * 60;
    alert.nID           = 1000;  // use https://github.com/zcash/zcash/wiki/specification#assigned-numbers to keep track of alert IDs
    alert.nCancel       = 0;   // cancels previous messages up to this ID number

    // These versions are protocol versions
    // 170002 : 1.0.0
    alert.nMinVer       = 170002;
    alert.nMaxVer       = 170002;

    //
    // main.cpp: 
    //  1000 for Misc warnings like out of disk space and clock is wrong
    //  2000 for longer invalid proof-of-work chain 
    //  Higher numbers mean higher priority
    //  4000 or higher will put the RPC into safe mode
    alert.nPriority     = 5000;
    alert.strComment    = "";
    alert.strStatusBar  = "URGENT: Upgrade required: see https://z.cash";
    alert.strRPCError   = "URGENT: Upgrade required: see https://z.cash";

    // Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done:
    // alert.setSubVer.insert(std::string("/MagicBean:0.7.2/"));

    // Sign
    const CChainParams& chainparams = Params();
    std::string networkID = chainparams.NetworkIDString();
    bool fIsTestNet = networkID.compare("test") == 0;
    std::vector<unsigned char> vchTmp(ParseHex(fIsTestNet ? pszTestNetPrivKey : pszPrivKey));
    CPrivKey vchPrivKey(vchTmp.begin(), vchTmp.end());

    CDataStream sMsg(SER_NETWORK, CLIENT_VERSION);
    sMsg << *(CUnsignedAlert*)&alert;
    alert.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());
    CKey key;
    if (!key.SetPrivKey(vchPrivKey, false))
    {
        printf("ThreadSendAlert() : key.SetPrivKey failed\n");
        return;
    }
    if (!key.Sign(Hash(alert.vchMsg.begin(), alert.vchMsg.end()), alert.vchSig))
    {
        printf("ThreadSendAlert() : key.Sign failed\n");
        return;
    }

    // Test
    CDataStream sBuffer(SER_NETWORK, CLIENT_VERSION);
    sBuffer << alert;
    CAlert alert2;
    sBuffer >> alert2;
    if (!alert2.CheckSignature(chainparams.AlertKey()))
    {
        printf("ThreadSendAlert() : CheckSignature failed\n");
        return;
    }
    assert(alert2.vchMsg == alert.vchMsg);
    assert(alert2.vchSig == alert.vchSig);
    alert.SetNull();
    printf("\nThreadSendAlert:\n");
    printf("hash=%s\n", alert2.GetHash().ToString().c_str());
    printf("%s\n", alert2.ToString().c_str());
    printf("vchMsg=%s\n", HexStr(alert2.vchMsg).c_str());
    printf("vchSig=%s\n", HexStr(alert2.vchSig).c_str());

    // Confirm
    if (!mapArgs.count("-sendalert"))
        return;
    while (vNodes.size() < 1 && !ShutdownRequested())
        MilliSleep(500);
    if (ShutdownRequested())
        return;

    // Send
    printf("ThreadSendAlert() : Sending alert\n");
    int nSent = 0;
    {
        LOCK(cs_vNodes);
        BOOST_FOREACH(CNode* pnode, vNodes)
        {
            if (alert2.RelayTo(pnode))
            {
                printf("ThreadSendAlert() : Sent alert to %s\n", pnode->addr.ToString().c_str());
                nSent++;
            }
        }
    }
    printf("ThreadSendAlert() : Alert sent to %d nodes\n", nSent);
}
Esempio n. 10
0
    CTestNetParams() {
        strNetworkID = "test";
        consensus.nSubsidyHalvingInterval = 210000;
        consensus.nMajorityEnforceBlockUpgrade = 51;
        consensus.nMajorityRejectBlockOutdated = 75;
        consensus.nMajorityWindow = 100;
        consensus.BIP34Height = 21111;
        consensus.BIP34Hash = uint256S("0x0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8");
        consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
        consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
        consensus.nPowTargetSpacing = 10 * 60;
        consensus.fPowAllowMinDifficultyBlocks = true;
        consensus.fPowNoRetargeting = false;
        consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
        consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
        consensus.vDeployments[Consensus::BIP113].bitmask = 1;
        consensus.vDeployments[Consensus::BIP113].nTimeout = 1;
        consensus.vDeployments[Consensus::BIP113].nStartTime = 1; 

        pchMessageStart[0] = 0x0b;
        pchMessageStart[1] = 0x11;
        pchMessageStart[2] = 0x09;
        pchMessageStart[3] = 0x07;
        vAlertPubKey = ParseHex("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a");
        nDefaultPort = 18333;
        nMaxTipAge = 0x7fffffff;
        nPruneAfterHeight = 1000;

        genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"));
        assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));

        vFixedSeeds.clear();
        vSeeds.clear();
        vSeeds.push_back(CDNSSeedData("alexykot.me", "testnet-seed.alexykot.me"));
        vSeeds.push_back(CDNSSeedData("bitcoin.petertodd.org", "testnet-seed.bitcoin.petertodd.org"));
        vSeeds.push_back(CDNSSeedData("bluematt.me", "testnet-seed.bluematt.me"));
        vSeeds.push_back(CDNSSeedData("bitcoin.schildbach.de", "testnet-seed.bitcoin.schildbach.de"));

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();

        vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));

        fMiningRequiresPeers = true;
        fDefaultConsistencyChecks = false;
        fRequireStandard = false;
        fMineBlocksOnDemand = false;
        fTestnetToBeDeprecatedFieldRPC = true;

        checkpointData = (CCheckpointData) {
            boost::assign::map_list_of
            ( 546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")),
            1337966069,
            1488,
            300
        };

    }
Esempio n. 11
0
    CMainParams() {
        strNetworkID = "main";
        consensus.nSubsidyHalvingInterval = 210000;
        consensus.nMajorityEnforceBlockUpgrade = 750;
        consensus.nMajorityRejectBlockOutdated = 950;
        consensus.nMajorityWindow = 1000;
        consensus.BIP34Height = 227931;
        consensus.BIP34Hash = uint256S("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
        consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
        consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
        consensus.nPowTargetSpacing = 10 * 60;
        consensus.fPowAllowMinDifficultyBlocks = false;
        consensus.fPowNoRetargeting = false;
        consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
        consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
        consensus.vDeployments[Consensus::BIP113].bitmask = 1;
        consensus.vDeployments[Consensus::BIP113].nTimeout = 1;
        consensus.vDeployments[Consensus::BIP113].nStartTime = 1; 

        /** 
         * The message start string is designed to be unlikely to occur in normal data.
         * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
         * a large 32-bit integer with any alignment.
         */
        pchMessageStart[0] = 0xf9;
        pchMessageStart[1] = 0xbe;
        pchMessageStart[2] = 0xb4;
        pchMessageStart[3] = 0xd9;
        vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
        nDefaultPort = 8333;
        nMaxTipAge = 24 * 60 * 60;
        nPruneAfterHeight = 100000;

        genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
        assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));

        vSeeds.push_back(CDNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be")); // Pieter Wuille
        vSeeds.push_back(CDNSSeedData("bluematt.me", "dnsseed.bluematt.me")); // Matt Corallo
        vSeeds.push_back(CDNSSeedData("dashjr.org", "dnsseed.bitcoin.dashjr.org")); // Luke Dashjr
        vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com")); // Christian Decker
        vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org")); // Jeff Garzik
        vSeeds.push_back(CDNSSeedData("bitcoin.jonasschnelli.ch", "seed.bitcoin.jonasschnelli.ch")); // Jonas Schnelli

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,128);
        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();

        vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));

        fMiningRequiresPeers = true;
        fDefaultConsistencyChecks = false;
        fRequireStandard = true;
        fMineBlocksOnDemand = false;
        fTestnetToBeDeprecatedFieldRPC = false;

        checkpointData = (CCheckpointData) {
            boost::assign::map_list_of
            ( 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
            ( 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))
            ( 74000, uint256S("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"))
            (105000, uint256S("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"))
            (134444, uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"))
            (168000, uint256S("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763"))
            (193000, uint256S("0x000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317"))
            (210000, uint256S("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e"))
            (216116, uint256S("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e"))
            (225430, uint256S("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932"))
            (250000, uint256S("0x000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214"))
            (279000, uint256S("0x0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40"))
            (295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983")),
            1397080064, // * UNIX timestamp of last checkpoint block
            36544669,   // * total number of transactions between genesis and last checkpoint
                        //   (the tx=... number in the SetBestChain debug.log lines)
            60000.0     // * estimated number of transactions per day after checkpoint
        };
    }
Esempio n. 12
0
static void TestHMACSHA256(const std::string &hexkey, const std::string &hexin, const std::string &hexout) {
    std::vector<unsigned char> key = ParseHex(hexkey);
    TestVector(CHMAC_SHA256(key.data(), key.size()), ParseHex(hexin), ParseHex(hexout));
}
Esempio n. 13
0
/************************************************************************
** Function: ProcessUsgDetail
**
** Purpose: Read a  detail usage record from usage file.
**
** returns:	SUCCESS - no errors, or "soft" (minor) error.  SUCCESS
**		          means that the record will be saved in either
**		          CDR_DATA or CDR_DATA_WORK.
**		FAILURE - serious parsing error. return FAILURE implies
**		          "hard" error.  Such records will be written to
**		          the bad image file.
**		          Note that records with hard errors will be
**		          written to bad image file as is.  This means
**		          error codes are NOT saved.  This is why we
**		          return immediately for FAILURE case.
**
** General idea is that missing data will be considered a "soft" error
** where as non-numeric data in a numeric field will be considered a
** hard error.
*************************************************************************
*/
int ProcessUsgDetail(CDR_DATA_STRUCT *cdr_data,
        RECORD_TYPE_STRUCT *rec_type,
        int  minimize,
        int  *checksum1,
        int  *checksum2,
        int  *checksum3)
{
   char *ptr;
   char tmpstr[1024];
   char gstrScratch1[1024];
   int  pos;	/* floating pointer into cdr_data->usg_rec */

   /* for time field, we need to convert to the usage time zone if
   ** it is provided. But sometime we do not have timezone in usage
   ** file, in this case we will convert to default timezone?
   ** To convert time, we need to wait after the whole usage record
   ** has been processed, then do conversion if necessary
   */

   short trans_dt_type = -1; /* -1 means not supplied in usg file,no op */
   short second_dt_type = -1;/* -1 means not supplied in usg file,no op */
   short rate_dt_type = -1;  /* -1 means not supplied in usg file,no op */
   short new_timezone = FALSE; /* to indicate whether there is a timezone
                               ** in the usage record 
                               */
   char usage_tz[szUnixTZ+1+3];
   char unix_tz[szUnixTZ+1];
   short size;     /* size of input field */
   tiny isdst;     /* ignored */

   int  i;
   int  j;

   pos = 0;
   ptr = gstrScratch1;

   if(mpsIsLogLevelHigh())
   {
      sprintf(tmpstr, "\nProcessing Record Type \'%s\'",
         rec_type->record_type);
      emit(ERRLOC,MPS_GENERIC_INFORM,tmpstr);
      sprintf(tmpstr, "===================================");
      emit(ERRLOC,MPS_GENERIC_INFORM,tmpstr);
      sprintf(tmpstr, "%-20.20s   %-20.20s   %-12.12s %-5.5s %-15.12s",
         "Field Name From", "Field Name To","Field Type", "Size","Field Value");
      emit(ERRLOC,MPS_GENERIC_INFORM,tmpstr);
      sprintf(tmpstr,
         "===============        ===============        ============ ===== ===========");
      emit(ERRLOC,MPS_GENERIC_INFORM,tmpstr);
   }

   for(i = rec_type->from_pos; i <= rec_type->to_pos; i++)
   {
      size = gsField_Mapping[i].field_from_size;
      /* Skip over some fields if in minimize / non-debug mode */
      if ( minimize && !mpsIsLogLevelHigh() )
      {
         switch(gsField_Mapping[i].field_to_id)
         {
         case to_type_id_usg:
         case to_point_origin:
         case to_point_target:
         case to_trans_dt:
         case to_timezone:
         case to_external_id:
         case to_external_id_type:
         case to_home_carrier_sid_bid:
         case to_num_tax_details:
            break;

         default:
            pos += size;
            continue;
         }
      }

      switch(gsField_Mapping[i].field_from_type)
      {
      case binary:
         j = ParseHex((char *)cdr_data->usg_rec+pos, (int) size);
         pos += size;
         if(mpsIsLogLevelHigh())
         {
            sprintf(tmpstr, 
               "%-20.20s   %-20.20s   %-12.12s %-6d%-12d",
               gsField_Mapping[i].field_from_name,
               gsField_Mapping[i].field_to_name,
               "(binary)",
               size,
               j);
            emit(ERRLOC,MPS_GENERIC_INFORM,tmpstr);
         }
         break;
      default:
         if((gsField_Mapping[i].field_to_id == to_annotation)   ||
            (gsField_Mapping[i].field_to_id == to_customer_tag) ||
            (gsField_Mapping[i].field_to_id == to_roaming_detail))
         {
            extract_field_no_strip(&ptr, (char *)cdr_data->usg_rec, &pos, (int) size);
         } else {
            extract_field(&ptr, (char *)cdr_data->usg_rec, &pos, (int) size);
         }
         if(mpsIsLogLevelHigh())
         {
            sprintf(tmpstr, 
               "%-20.20s   %-20.20s   %-12.12s %-6d%-s",
               gsField_Mapping[i].field_from_name,
               gsField_Mapping[i].field_to_name,
               "(a/n str)",
               size,
               ptr);
            emit(ERRLOC,MPS_GENERIC_INFORM,tmpstr);
         }
         break;
      } 
      if(gsField_Mapping[i].is_ignored)
      {
         continue;
      }
      if(gsField_Mapping[i].is_required && ptr[0] == '\0' &&
         gsField_Mapping[i].field_from_type != binary)
      {
         emit(ERRLOC,CAP_FIELD_MISSING_X,gsField_Mapping[i].field_from_name);
         set_cdr_error_code(cdr_data, CAP_FIELD_MISSING); 
         sprintf(tmpstr, "%d,Field: \"%s\"",
            CAP_FIELD_MISSING,gsField_Mapping[i].field_to_name);

         emit(ERRLOC,MPS_GEN_ERROR,tmpstr );
         set_mps_error_struct(tmpstr,""); 
      }

      /* if we need to convert from string to a numeric field *
      ** we need to check no digital char and overflow        */
      if(gsField_Mapping[i].field_to_type != to_string)
      {
         if(gsField_Mapping[i].field_from_type != binary)
         {
            if(numeric_string(ptr))
            {
               if(gsField_Mapping[i].field_to_type == to_numeric)
               {
               }
               else
               {
                  if(convert_to_number(ptr,&j, 
                     (short) gsField_Mapping[i].field_to_type) == FAILURE)
                  {
                     /* conversion caused overflow */
                     j = 0;
                     set_cdr_error_code(cdr_data, CAP_VALUE_OVERFLOW);
                     sprintf(tmpstr,
                        "%d,convert \"%s\" to \"%s\" caused overflow",
                        CAP_VALUE_OVERFLOW,
                        ptr,
                        gsField_Mapping[i].field_to_name);
                     set_mps_error_struct(tmpstr,"");
                  }
               }
            }
            else
            {
               /* some non-numeric characters for numeric field */
               j = 0;
               set_cdr_error_code(cdr_data, CAP_BAD_NUM_FIELD);
               sprintf(tmpstr,
                  "%d,Field value: \"%s\"",
                  CAP_BAD_NUM_FIELD,
                  ptr);
               emit(ERRLOC,CAP_BAD_NUM_FIELD );
               sprintf(tmpstr, "%-20.20s: \"%s\"",
                  gsField_Mapping[i].field_from_name,gstrScratch1);
               emit(ERRLOC,MPS_GEN_ERROR,tmpstr );
               set_mps_error_struct(tmpstr,""); 
            }
         }
         else
         {
            /* when we get a binary field, we need to check overflow
            ** since we may get the int and try to convert to a tiny */
            if(check_overflow(j, (short) gsField_Mapping[i].field_to_type) == FAILURE)
            {
               j = 0;
               /* conversion caused overflow */
               set_cdr_error_code(cdr_data, CAP_VALUE_OVERFLOW);
               sprintf(tmpstr,
                  "%d,convert %d to \"%s\" caused overflow",
                  CAP_VALUE_OVERFLOW,
                  j,
                  gsField_Mapping[i].field_to_name);
               emit(ERRLOC,MPS_GEN_ERROR,tmpstr );
               set_mps_error_struct(tmpstr,"");
            }
         } 
      } 

      switch(gsField_Mapping[i].field_to_id)
      {
      case to_ext_tracking_id:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->ext_tracking_id, ptr, szExtTrackingId);
            cdr_data->ext_tracking_id[szExtTrackingId] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->ext_tracking_id, tmpstr,szExtTrackingId);
            cdr_data->ext_tracking_id[szExtTrackingId] = '\0';
         }
         break;
      case to_trans_id:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->trans_id, ptr, szTransID);
            cdr_data->trans_id[szTransID] = '\0';
         }
         else
         {
            sprintf(cdr_data->trans_id,"%d",j);
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->trans_id, tmpstr, szTransID);
            cdr_data->trans_id[szTransID] = '\0';
         }
         break;
      case to_element_id:
         cdr_data->element_id = j;
         break;
      case to_type_id_usg:
         cdr_data->type_id_usg = j;
         cdr_data->orig_type_id_usg = j;
         break;
      case to_rate_class:
         cdr_data->rate_class = j;
         break;
      case to_bill_class:
         cdr_data->bill_class = j;
         break;
      case to_num_tax_details:
         cdr_data->num_tax_details = j;
         break;
      case to_provider_id:
         cdr_data->provider_id = j;
         break;
      case to_provider_class:
         cdr_data->provider_class = j;
         break;
      case to_jurisdiction:
         cdr_data->jurisdiction = j;
         break;
      case to_rate_currency_code:
         cdr_data->rate_currency_code = j;
         break;
      case to_emf_create_date:
         break;
      case to_point_origin:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->point_origin, ptr, szUsagePoint);
            cdr_data->point_origin[szUsagePoint] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->point_origin, tmpstr, szUsagePoint);
            cdr_data->point_origin[szUsagePoint] = '\0';
         }
         break;
      case to_country_dial_code_origin:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->country_dial_code_origin, ptr, 
               szDialCode);
            cdr_data->country_dial_code_origin[szDialCode] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->country_dial_code_origin, tmpstr, szDialCode);
            cdr_data->country_dial_code_origin[szDialCode] = '\0';
         }
         break;
      case to_point_tax_code_origin:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->point_tax_code_origin, ptr, szTaxCode);
            cdr_data->point_tax_code_origin[szTaxCode] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->point_tax_code_origin, tmpstr, szTaxCode);
            cdr_data->point_tax_code_origin[szTaxCode] = '\0';
         }
         break;
      case to_point_tax_code_type_origin:
         cdr_data->point_tax_code_type_origin = j;
         break;
      case to_point_target:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->point_target, ptr, szUsagePoint);
            cdr_data->point_target[szUsagePoint] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->point_target, tmpstr, szUsagePoint);
            cdr_data->point_target[szUsagePoint] = '\0';
         }
         break;
      case to_point_tax_code_target:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->point_tax_code_target, ptr, szTaxCode);
            cdr_data->point_tax_code_target[szTaxCode] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->point_tax_code_target, tmpstr, szTaxCode);
            cdr_data->point_tax_code_target[szTaxCode] = '\0';
         }
         break;
      case to_point_tax_code_type_target:
         cdr_data->point_tax_code_type_target = j;
         break;
      case to_trans_dt:
         /* if time comes in as unix time save it in the trans_time field
         ** and do conversion later by using a timezone 
         */
         if(gsField_Mapping[i].field_to_type == to_int)
            cdr_data->trans_time = j;
         else
         {
            /* if time comes in as char string save the string and convert
            ** to YYYYMMDD HH:MM:SS according the input format
            */
            if(convert_date_string(cdr_data->trans_dt, gstrScratch1,
               gsField_Mapping[i].date_format_type) == FAILURE)
            {
               emit(ERRLOC, MPS_BAD_FIELD, "trans_dt", cdr_data->trans_dt);
               set_cdr_error_code(cdr_data, CAP_BAD_PRIMTIME);
               sprintf(tmpstr,
                  "%d,%s: \"%s\"",
                  CAP_BAD_PRIMTIME,gsField_Mapping[i].field_to_name,
                  cdr_data->trans_dt);
               emit(ERRLOC, MPS_GEN_ERROR, tmpstr );
               set_mps_error_struct(tmpstr,"");
               break;
            }
         }
         trans_dt_type = gsField_Mapping[i].field_to_type;
         break;
      case to_second_dt:
         /* if time comes in as unix time save it in the trans_time field
         ** and do conversion later by using a timezone 
         */
         if(gsField_Mapping[i].field_to_type == to_int)
            cdr_data->second_time = j;
         else
         {
            /* if time comes in as char string save the string and convert
            ** to YYYYMMDD HH:MM:SS according the input format later 
            */
            if(convert_date_string(cdr_data->second_dt, gstrScratch1,
               gsField_Mapping[i].date_format_type) == FAILURE)
            {
               emit(ERRLOC, MPS_BAD_FIELD,"second_dt",cdr_data->second_dt);
               set_cdr_error_code(cdr_data, CAP_BAD_SECONDTIME);
               sprintf(tmpstr,
                  "%d,%s: \"%s\"",
                  CAP_BAD_SECONDTIME,
                  gsField_Mapping[i].field_to_name,
                  cdr_data->second_dt);

               emit(ERRLOC, MPS_GEN_ERROR, tmpstr );
               set_mps_error_struct(tmpstr,"");
               break;
            }
         }
         second_dt_type = gsField_Mapping[i].field_to_type;
         break;
      case to_timezone:
         cdr_data->timezone = j;
         new_timezone = TRUE;
         break;
      case to_primary_units:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->primary_units), j);
         }
         else
         {
            arb_numeric_from_string(&(cdr_data->primary_units), ptr);
            if ( arb_numeric_to_int( &(cdr_data->primary_units), &j) == FAILURE)
            {
               j = cdr_data->primary_units.low;
            }
         }
         *checksum1 += j;
         break;
      case to_primary_type:
         cdr_data->primary_type = j;
         break;
      case to_second_units:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->second_units), j);
         }
         else
         {
            arb_numeric_from_string(&(cdr_data->second_units), ptr);
            if ( arb_numeric_to_int( &(cdr_data->second_units), &j) == FAILURE)
            {
               j = cdr_data->second_units.low;
            }
         }
         *checksum2 += j;
         break;
      case to_second_type:
         cdr_data->second_type = j;
         break;
      case to_third_units:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->third_units), j);
         }
         else
         {
            arb_numeric_from_string(&(cdr_data->third_units), ptr);
            if ( arb_numeric_to_int( &(cdr_data->third_units), &j) == FAILURE)
            {
               j = cdr_data->third_units.low;
            }
         }
         *checksum3 += j;
         break;
      case to_third_type:
         cdr_data->third_type = j;
         break;
      case to_federal_tax:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->federal_tax), j);
         }
         else
         {
            arb_numeric_from_string(&(cdr_data->federal_tax), ptr);
         }
         break;
      case to_state_tax:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->state_tax), j);
         }
         else
         {
            arb_numeric_from_string(&(cdr_data->state_tax), ptr);
         }
         break;
      case to_county_tax:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->county_tax), j);
         }
         else
         {
            arb_numeric_from_string(&(cdr_data->county_tax), ptr);
         }
         break;
      case to_city_tax:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->city_tax), j);
         }
         else
         {
            arb_numeric_from_string(&(cdr_data->city_tax), ptr);
         }
         break;
      case to_other_tax:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->other_tax), j);
         }
         else
         {
            arb_numeric_from_string(&(cdr_data->other_tax), ptr);
         }
         break;
      case to_units_currency_code:
         cdr_data->units_currency_code = j;
         break;
      case to_annotation:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->annotation, ptr, size);
            cdr_data->annotation[size] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->annotation, tmpstr, size);
            cdr_data->annotation[size] = '\0';
         }
         break;
      case to_customer_tag:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->customer_tag, ptr, szCustomerTag);
            cdr_data->customer_tag[szCustomerTag] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->customer_tag, tmpstr, szCustomerTag);
            cdr_data->customer_tag[szCustomerTag] = '\0';
         }
         break;
      case to_geocode:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->geocode, ptr, szTaxCode);
            cdr_data->geocode[szTaxCode] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->geocode, tmpstr, szTaxCode);
            cdr_data->geocode[szTaxCode] = '\0';
         }
         break;
      case to_roaming_detail:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->roaming_detail, ptr, size);
            cdr_data->roaming_detail[size] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->roaming_detail, tmpstr, size);
            cdr_data->roaming_detail[size] = '\0';
         }
         break;	    
      case to_rated_units:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->rated_units), j);
         }
         else
            arb_numeric_from_string(&(cdr_data->rated_units), ptr);
         break;
      case to_total_amt:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->total_amt), j);
         }
         else
            arb_numeric_from_string(&(cdr_data->total_amt), ptr);
         break;
      case to_base_amt:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->base_amt), j);
         }
         else
            arb_numeric_from_string(&(cdr_data->base_amt), ptr);

         break;
      case to_unrounded_amount:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->unrounded_amount), j);
         }
         else
            arb_numeric_from_string(&(cdr_data->unrounded_amount), ptr);
         break;
      case to_foreign_amount:
         if(gsField_Mapping[i].field_from_type == binary)
         {
            arb_numeric_from_int(&(cdr_data->foreign_amount), j);
         }
         else
            arb_numeric_from_string(&(cdr_data->foreign_amount), ptr);
         break;
      case to_rate_period:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->rate_period, ptr, szRatePeriod);
            cdr_data->rate_period[szRatePeriod] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->rate_period, tmpstr, szRatePeriod);
            cdr_data->rate_period[szRatePeriod] = '\0';
         }
         break;
      case to_rate_dt:
         /* if time comes in as unix time save it in the trans_time field
         ** and do conversion later by using a timezone 
         */
         if(gsField_Mapping[i].field_to_type == to_int)
            cdr_data->rate_time = j;
         else
         {
            if(convert_date_string(cdr_data->rate_dt, gstrScratch1,
               gsField_Mapping[i].date_format_type) == FAILURE)
            { 
               emit(ERRLOC, MPS_BAD_FIELD,"rate_dt",cdr_data->rate_dt);
               set_cdr_error_code(cdr_data, CAP_BAD_RATETIME);
               sprintf(tmpstr,
                  "%d,%s: \"%s\"",
                  CAP_BAD_RATETIME,
                  gsField_Mapping[i].field_to_name,
                  cdr_data->rate_dt);
               emit(ERRLOC, MPS_GEN_ERROR, tmpstr );
               set_mps_error_struct(tmpstr,"");
               break;
            }
         }
         rate_dt_type = gsField_Mapping[i].field_to_type;
         break;
      case to_no_bill:
         cdr_data->no_bill = j;
         break;
      case to_comp_status:
         cdr_data->comp_status = j;
         break;
      case to_cdr_status:
         cdr_data->cdr_status = j;
         break;
      case to_external_id:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->external_id, ptr, size);
            cdr_data->external_id[size] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->external_id, tmpstr, size);
            cdr_data->external_id[size] = '\0';
         }
         break;
      case to_external_id_type:
         cdr_data->external_id_type = j;
         break;
      case to_account_no:
         cdr_data->account_no = j;
         break;
      case to_kp_subscr_no:
         cdr_data->kp_subscr_no = j;
         break;
      case to_kp_subscr_no_resets:
         cdr_data->kp_subscr_no_resets = j;
         break;
      case to_kp_server_id:
         cdr_data->kp_server_id = j;
         break;
      case to_ccard_account:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->miu_ccard_account, ptr, szCCardAcct);
            cdr_data->miu_ccard_account[szCCardAcct] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->miu_ccard_account, tmpstr, szCCardAcct);
            cdr_data->miu_ccard_account[szCCardAcct] = '\0';
         }
         break;
      case to_ccard_carrier_code:
         cdr_data->miu_ccard_carrier_code = j;
         break;
      case to_ccard_ownr_fname:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->miu_ccard_ownr_fname, ptr, szCCardOwnr);
            cdr_data->miu_ccard_ownr_fname[szCCardOwnr] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->miu_ccard_ownr_fname, tmpstr, szCCardOwnr);
            cdr_data->miu_ccard_ownr_fname[szCCardOwnr] = '\0';
         }
         break;
      case to_ccard_ownr_lname:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->miu_ccard_ownr_lname, ptr, szCCardOwnr);
            cdr_data->miu_ccard_ownr_lname[szCCardOwnr] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->miu_ccard_ownr_lname, tmpstr, szCCardOwnr);
            cdr_data->miu_ccard_ownr_lname[szCCardOwnr] = '\0';
         }
         break;
      case to_ccard_expire:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->miu_ccard_expire, ptr, szCCardExpire);
            cdr_data->miu_ccard_expire[szCCardExpire] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->miu_ccard_expire, tmpstr, szCCardExpire);
            cdr_data->miu_ccard_expire[szCCardExpire] = '\0';
         }
         break;
      case to_ccard_carrier:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->miu_ccard_carrier, ptr, szCCCarrier);
            cdr_data->miu_ccard_carrier[szCCCarrier] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->miu_ccard_carrier, tmpstr, szCCCarrier);
            cdr_data->miu_ccard_carrier[szCCCarrier] = '\0';
         }
         break;
      case to_free_flag:
         cdr_data->free_flag = j;
         break;
      case to_home_carrier_sid_bid:
         cdr_data->home_carrier_sid_bid = j;
         break;
      case to_open_item_id:
         cdr_data->open_item_id = j;
         break;
      case to_cell_name_origin:
         if(gsField_Mapping[i].field_from_type != binary)
         {
            strncpy(cdr_data->cell_name_origin, ptr, szCellName);
            cdr_data->cell_name_origin[szCellName] = '\0';
         }
         else
         {
            sprintf(tmpstr,"%d",j);
            strncpy(cdr_data->cell_name_origin, tmpstr, szCellName);
            cdr_data->cell_name_origin[szCellName] = '\0';
         }
         break;
     }
   }

   if(new_timezone)
   {
      if(timezone_lookup(cdr_data->timezone,unix_tz,&isdst) != SUCCESS)
      {
         emit(ERRLOC, CAP_BAD_USG_TIMEZONE, cdr_data->timezone);
         set_cdr_error_code(cdr_data, CAP_BAD_TIMEZONE);
         sprintf(tmpstr,"%d,Timezone:%d",CAP_BAD_TIMEZONE,cdr_data->timezone);
         emit(ERRLOC, MPS_GEN_ERROR, tmpstr );
         set_mps_error_struct(tmpstr,"");
         return(SUCCESS);
      }
      /* if we get a unix time do conversion 
      ** from int to arbor/bp date format */

      if(trans_dt_type == to_int || second_dt_type == to_int || 
         rate_dt_type == to_int)
      {
         if(mpsGetGuideTZ() == TIMEZONE_NOT_USED) 
         {
            /* convert to input usage record's timezone
            ** (already saved in cdr_data)
            */
            strcpy(usage_tz, unix_tz);
         }
         else
         {
            /* Use guiding timezone instead.
            ** NOTE: in this case, the timezone from the usage record
            **       IS DISCARDED !!
            */
            strcpy(usage_tz, mpsGetGuideTZstr());
            cdr_data->timezone = mpsGetGuideTZ();  /* int version of mpsGetGuideTZstr() */
         }

         /* ----------------------------------------------------
         ** Convert trans_dt & second_dt to appropriate timezone
         ** since we are converting a unix time_t, the "from_tz" arg
         ** of convert_timezone (arg 3) is not used.
         */

         if(trans_dt_type == to_int)
         {
            if(convert_timezone(cdr_data->trans_time, cdr_data->trans_dt, "GMT0", usage_tz)
               == FAILURE)
            {
               emit(ERRLOC, CAP_BAD_USG_TIMEZONE, cdr_data->timezone);
               set_cdr_error_code(cdr_data, CAP_BAD_TIMEZONE);
               sprintf(tmpstr,
                  "%d,Timezone:%d",
                  CAP_BAD_TIMEZONE,cdr_data->timezone);
               emit(ERRLOC, MPS_GEN_ERROR, tmpstr );
               set_mps_error_struct(tmpstr,"");
               return(SUCCESS);
            }
         }
         if(second_dt_type == to_int)
         {
            if(convert_timezone(cdr_data->second_time, cdr_data->second_dt, "GMT0", usage_tz)
               == FAILURE)
            {
               emit(ERRLOC, CAP_BAD_USG_TIMEZONE, cdr_data->timezone);
               set_cdr_error_code(cdr_data, CAP_BAD_TIMEZONE);
               sprintf(tmpstr,
                  "%d,Timezone:%d",
                  CAP_BAD_TIMEZONE,cdr_data->timezone);
               emit(ERRLOC, MPS_GEN_ERROR, tmpstr );
               set_mps_error_struct(tmpstr,"");
               return(SUCCESS);
            }
         }
         if(rate_dt_type == to_int)
         {
            if(convert_timezone(cdr_data->rate_time, cdr_data->rate_dt, "GMT0", usage_tz)
               == FAILURE)
            {
               emit(ERRLOC, CAP_BAD_USG_TIMEZONE, cdr_data->timezone);
               set_cdr_error_code(cdr_data, CAP_BAD_TIMEZONE);
               sprintf(tmpstr,
                  "%d,Timezone:%d",
                  CAP_BAD_TIMEZONE,cdr_data->timezone);
               emit(ERRLOC, MPS_GEN_ERROR, tmpstr );
               set_mps_error_struct(tmpstr,"");
               return(SUCCESS);
            }
         }
      }
   }
   else
   {
      /* no timezone provided, get the default time zone later */
      if(trans_dt_type == to_int || second_dt_type == to_int ||
         rate_dt_type == to_int)
      {
         if(mpsGetGuideTZ() == TIMEZONE_NOT_USED)
         {
            /* no default set, do not know what to convert to, hard error */
            emit(ERRLOC,CAP_NO_TIMEZONE);
            sprintf(tmpstr,
               "%d,No timezone",
               CAP_NO_TIMEZONE);
            emit(ERRLOC,MPS_GEN_ERROR, tmpstr );
            set_mps_error_struct(tmpstr,"");
            return(SUCCESS);
         }
         else
         {
            /* Use guiding timezone */
            strcpy(usage_tz, mpsGetGuideTZstr());
            cdr_data->timezone = mpsGetGuideTZ();  /* int version of mpsGetGuideTZstr() */

            /* ----------------------------------------------------
            ** Convert trans_dt & second_dt to appropriate timezone
            */

            if(trans_dt_type == to_int)
            {
               if(convert_timezone(cdr_data->trans_time, cdr_data->trans_dt,
                  "GMT0", usage_tz) == FAILURE)
               {
                  emit(ERRLOC, CAP_BAD_USG_TIMEZONE, cdr_data->timezone);
                  set_cdr_error_code(cdr_data, CAP_BAD_TIMEZONE);
                  sprintf(tmpstr,
                     "%d,Timezone:%d",
                     CAP_BAD_TIMEZONE,cdr_data->timezone);
                  emit(ERRLOC,MPS_GEN_ERROR, tmpstr );
                  set_mps_error_struct(tmpstr,"");
                  return(SUCCESS);
               }
            }
            if(second_dt_type == to_int)
            {
               if(convert_timezone(cdr_data->second_time, cdr_data->second_dt,
                  "GMT0", usage_tz) == FAILURE)
               {
                  emit(ERRLOC, CAP_BAD_USG_TIMEZONE, cdr_data->timezone);
                  set_cdr_error_code(cdr_data, CAP_BAD_TIMEZONE);
                  sprintf(tmpstr,
                     "%d,Timezone:%d",
                     CAP_BAD_TIMEZONE,cdr_data->timezone);
                  emit(ERRLOC,MPS_GEN_ERROR, tmpstr );
                  set_mps_error_struct(tmpstr,"");
                  return(SUCCESS);
               }
            }
            if(rate_dt_type == to_int)
            {
               if(convert_timezone(cdr_data->rate_time, cdr_data->rate_dt,
                  "GMT0", usage_tz) == FAILURE)
               {
                  emit(ERRLOC, CAP_BAD_USG_TIMEZONE, cdr_data->timezone);
                  set_cdr_error_code(cdr_data, CAP_BAD_TIMEZONE);
                  sprintf(tmpstr,
                     "%d,Timezone:%d",
                     CAP_BAD_TIMEZONE,cdr_data->timezone);
                  emit(ERRLOC,MPS_GEN_ERROR, tmpstr );
                  set_mps_error_struct(tmpstr,"");
                  return(SUCCESS);
               }
            }
         }
      }
   }
   return(SUCCESS);

} /* ProcessUsgDetail() */
Esempio n. 14
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x02;
        pchMessageStart[1] = 0x03;
        pchMessageStart[2] = 0x04;
        pchMessageStart[3] = 0x05;
        nDefaultPort = 25535;
        nRPCPort = 25536;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 86400;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.
  
        const char* pszTimestamp = "Lumberjacks and Maple Trees in the Great White North";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1390857400;
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 102200;
        
        //// debug print
        hashGenesisBlock = genesis.GetHash();
        while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
            if (++genesis.nNonce==0) break;
            hashGenesisBlock = genesis.GetHash();
        }

        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();
        
        
        assert(hashGenesisBlock == uint256("0x00000567bbebf0cde56b9d36d3476eb1ea5c5060a45006e3523e5eaab5e5e212"));
        assert(genesis.hashMerkleRoot == uint256("0xb929ecd9c646676b88098ad7a1031e0ab2baf390901083e3f22292b26d8c50b4"));

        vSeeds.push_back(CDNSSeedData("andarazoroflove.org", "andarazoroflove.org"));


        base58Prefixes[PUBKEY_ADDRESS] = 28;
        base58Prefixes[SCRIPT_ADDRESS] = 28;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time' 
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Esempio n. 15
0
    CMainParams() {
        strNetworkID = "main";
        consensus.nSubsidyHalvingInterval = 210000;
        consensus.nMajorityEnforceBlockUpgrade = 750;
        consensus.nMajorityRejectBlockOutdated = 950;
        consensus.nMajorityWindow = 1000;
        consensus.BIP34Height = 1;
        consensus.BIP34Hash = uint256S("0x00000000bea1b41eb016f9c39e02d36294d435222ce03576919123aee697c2ff");
        consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
        consensus.nPowTargetTimespan = 18000; // two weeks
        consensus.nPowTargetSpacing =  60;
        consensus.fPowAllowMinDifficultyBlocks = false;
        consensus.fPowNoRetargeting = false;
        /** 
         * The message start string is designed to be unlikely to occur in normal data.
         * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
         * a large 32-bit integer with any alignment.
         */
        pchMessageStart[0] = 0xf9;
        pchMessageStart[1] = 0xbe;
        pchMessageStart[2] = 0xb4;
        pchMessageStart[3] = 0xd9;
        vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
        nDefaultPort = 12333;
        nPruneAfterHeight = 100000;

        genesis = CreateGenesisBlock(1448621995, 2826399945, 0x1d00ffff, 1, COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("0x0000000066247638c1b022cb6f224c2600e6ad8d3d1bb48e869bb7a153f3be1d"));
        assert(genesis.hashMerkleRoot == uint256S("0x15f722118330cdc1d1f2c5446e052605cd8c18e2b42eba1de1b884bc28a8bfed"));

        vSeeds.push_back(CDNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be")); // Pieter Wuille
        vSeeds.push_back(CDNSSeedData("bluematt.me", "dnsseed.bluematt.me")); // Matt Corallo
        vSeeds.push_back(CDNSSeedData("dashjr.org", "dnsseed.bitcoin.dashjr.org")); // Luke Dashjr
        vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com")); // Christian Decker
        vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org")); // Jeff Garzik
        vSeeds.push_back(CDNSSeedData("bitcoin.jonasschnelli.ch", "seed.bitcoin.jonasschnelli.ch")); // Jonas Schnelli

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,128);
        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();

        vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));

        fMiningRequiresPeers = true;
        fDefaultConsistencyChecks = false;
        fRequireStandard = true;
        fMineBlocksOnDemand = false;
        fTestnetToBeDeprecatedFieldRPC = false;

        checkpointData = (CCheckpointData) {
            boost::assign::map_list_of
            ( 111, uint256S("0x000000008830ab01db79a1645e6f2a2756879e9574c172f66dad4f83e59d6cd8"))
            ( 333, uint256S("0x00000000d0f0ca8c98aa09337443cc9b4c5e074fd354168f2333c319fbb53d51")),
            1450518141, // * UNIX timestamp of last checkpoint block
            337,   // * total number of transactions between genesis and last checkpoint
                        //   (the tx=... number in the SetBestChain debug.log lines)
            60000.0     // * estimated number of transactions per day after checkpoint
        };
    }
Esempio n. 16
0
vector<unsigned char> ParseHex(const string& str)
{
    return ParseHex(str.c_str());
}
Esempio n. 17
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x09;
        pchMessageStart[1] = 0x04;
        pchMessageStart[2] = 0x04;
        pchMessageStart[3] = 0x05;
        nDefaultPort = 7777;
        nRPCPort = 7070;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 250000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.

        const char* pszTimestamp = "Pump dump sell buy hold but when you hear the thunder be ready bc it will be showtimeee";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1387754247;
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 416023;

        //// debug print
        hashGenesisBlock = genesis.GetHash();
        while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
            if (++genesis.nNonce==0) break;
            hashGenesisBlock = genesis.GetHash();
        }

        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();


        assert(hashGenesisBlock == uint256("0x00000a26ae3a3e42c19266cdcb6c1705c644f6e12eff14ed69384ae9415f555d"));
        assert(genesis.hashMerkleRoot == uint256("0xcbe518469ca4a98504a704913d2e3b4c0a131c8734a21aa8e56f879071e5c3fc"));

        vSeeds.push_back(CDNSSeedData("70.193.4.56", "70.193.4.56"));


        base58Prefixes[PUBKEY_ADDRESS] = 127;
        base58Prefixes[SCRIPT_ADDRESS] = 30;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time'
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Esempio n. 18
0
    CTestNetParams() {
        strNetworkID = "test";
        consensus.nSubsidyHalvingInterval = 210000;
        consensus.nMajorityEnforceBlockUpgrade = 51;
        consensus.nMajorityRejectBlockOutdated = 75;
        consensus.nMajorityWindow = 100;
        consensus.powLimit = uint256S("0000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
        consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
        consensus.nPowTargetSpacing = 10 * 60;
        consensus.fPowAllowMinDifficultyBlocks = true;
        consensus.nMinDifficultySince = 1394838000; // 15 Mar 2014
        consensus.fPowNoRetargeting = false;

        consensus.nAuxpowStartHeight = 0;
        consensus.nAuxpowChainId = 0x0001;
        consensus.fStrictChainId = false;
        consensus.nLegacyBlocksBefore = -1;

        consensus.rules.reset(new Consensus::TestNetConsensus());

        pchMessageStart[0] = 0xfa;
        pchMessageStart[1] = 0xbf;
        pchMessageStart[2] = 0xb5;
        pchMessageStart[3] = 0xfe;
        vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
        nDefaultPort = 18334;
        nMaxTipAge = 0x7fffffff;
        nPruneAfterHeight = 1000;

        genesis = CreateTestnetGenesisBlock(1296688602, 0x16ec0bff, 0x1d07fff8, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008"));
        assert(genesis.hashMerkleRoot == uint256S("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));

        vFixedSeeds.clear();
        vSeeds.clear();
        vSeeds.push_back(CDNSSeedData("webbtc.com", "dnsseed.test.namecoin.webbtc.com"));

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
        /* FIXME: Update these below.  */
        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();

        /* FIXME: fixed seeds?  */
        //vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));

        fMiningRequiresPeers = true;
        fDefaultConsistencyChecks = false;
        fRequireStandard = false;
        fMineBlocksOnDemand = false;
        fTestnetToBeDeprecatedFieldRPC = true;

        checkpointData = (CCheckpointData) {
            boost::assign::map_list_of
            (  2016, uint256S("00000000b9e4132e1a803114bc88df3e49184a3c794c01a6eac334f12f4ccadb"))
            (  4032, uint256S("00000003fbc13a48b8de5c8742044c84b800edeabff8b39f7f23ac572c6d80ce"))
            (  8064, uint256S("f594a75db40244bc7baa808a695f796ba81cae5bb48fa920e367cdd31dbfb0e3"))
            ( 10080, uint256S("398d44a1a6e58dce3f7463217f677c2532e42a83696dcc5d4d97329c00a10891"))
            ( 12096, uint256S("22c9278493cda563565fc2a4250eff48bd68ed40cb5fb30029ca08ea6120ddab"))
            ( 14112, uint256S("83bade3e3d88845eb52de90311a8017b1cdf725b15d19bc89c47a568f7b4e08c"))
            ( 16128, uint256S("f456354835623f733bb928ed77d97ae06b96ad6c40aba63f51f94f06e905effc"))
            ( 18144, uint256S("c0ec570117822ca3c76abd1d10449b283d8ad39c64290d6abafe2bed23917886"))
            ( 34715, uint256S("0000000580cf4342f869e278d94d7e67d2ac8cae4a411082e0fd518a8091ebf2"))
            ( 48384, uint256S("00000001d528af69dce584f882e3bdb36127104988607b726591cc5e62287922"))
            ( 60480, uint256S("d3af823c32e890ca589dd4277aa4d27b8cd290396b7e0eeeee5121481fd43ca5")),
            1407617760,
            93107,
            230
        };

        assert(mapHistoricBugs.empty());
    }
Esempio n. 19
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x55;
        pchMessageStart[1] = 0x42;
        pchMessageStart[2] = 0x4B;
        pchMessageStart[3] = 0x45;
        nDefaultPort = 11066;
        nRPCPort = 11067;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 100000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.
  
        const char* pszTimestamp = "Viking Era";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 0.001 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1400630400; //nTime
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 2016973;
        
        hashGenesisBlock = genesis.GetHash();
        // while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
        //     if (++genesis.nNonce==0) break;
        //     hashGenesisBlock = genesis.GetHash();
        //}


        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();
        
        
        assert(hashGenesisBlock == uint256("0x00000c07c30a4f74683e64ed156668e3f8d2e71bb4efcdcc44c248708d1cabf2"));
        assert(genesis.hashMerkleRoot == uint256("0xb8b26c88ea01ea6cbbd9fd39158f1e6cae130cc2cd5950b78727d83aa71c056d"));

        vSeeds.push_back(CDNSSeedData("198.46.134.15", "192.3.10.93"));
		vSeeds.push_back(CDNSSeedData("95.85.46.218", "81.11.246.44"));
        vSeeds.push_back(CDNSSeedData("108.61.10.90", "192.241.199.243"));
   

        base58Prefixes[PUBKEY_ADDRESS] = 70;
        base58Prefixes[SCRIPT_ADDRESS] = 132;
        base58Prefixes[SECRET_KEY] = 86;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time' 
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Esempio n. 20
0
    CMainParams() {
        strNetworkID = "main";
        consensus.nSubsidyHalvingInterval = 210000;
        consensus.nMajorityEnforceBlockUpgrade = 750;
        consensus.nMajorityRejectBlockOutdated = 950;
        consensus.nMajorityWindow = 1000;
        consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
        consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
        consensus.nPowTargetSpacing = 10 * 60;
        consensus.fPowAllowMinDifficultyBlocks = false;
        consensus.fPowNoRetargeting = false;

        consensus.nAuxpowChainId = 0x0001;
        consensus.nAuxpowStartHeight = 19200;
        consensus.fStrictChainId = true;
        consensus.nLegacyBlocksBefore = 19200;

        consensus.rules.reset(new Consensus::MainNetConsensus());

        /** 
         * The message start string is designed to be unlikely to occur in normal data.
         * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
         * a large 32-bit integer with any alignment.
         */
        pchMessageStart[0] = 0xf9;
        pchMessageStart[1] = 0xbe;
        pchMessageStart[2] = 0xb4;
        pchMessageStart[3] = 0xfe;
        vAlertPubKey = ParseHex("04ba207043c1575208f08ea6ac27ed2aedd4f84e70b874db129acb08e6109a3bbb7c479ae22565973ebf0ac0391514511a22cb9345bdb772be20cfbd38be578b0c");
        nDefaultPort = 8334;
        nMaxTipAge = 24 * 60 * 60;
        nPruneAfterHeight = 100000;

        genesis = CreateGenesisBlock(1303000001, 0xa21ea192u, 0x1c007fff, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("0x000000000062b72c5e2ceb45fbc8587e807c155b0da735e6483dfba2f0a9c770"));
        assert(genesis.hashMerkleRoot == uint256S("0x41c62dbd9068c89a449525e3cd5ac61b20ece28c3c38b3f35b2161f0e6d3cb0d"));

        vSeeds.push_back(CDNSSeedData("digi-masters.com", "namecoindnsseed.digi-masters.com"));
        vSeeds.push_back(CDNSSeedData("digi-masters.uk", "namecoindnsseed.digi-masters.uk"));
        vSeeds.push_back(CDNSSeedData("domob.eu", "seed.namecoin.domob.eu"));
        vSeeds.push_back(CDNSSeedData("quisquis.de", "nmc.seed.quisquis.de"));
        vSeeds.push_back(CDNSSeedData("webbtc.com", "dnsseed.namecoin.webbtc.com"));

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,52);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,13);
        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,180);
        /* FIXME: Update these below.  */
        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();

        /* FIXME: fixed seeds?  */
        //vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));

        fMiningRequiresPeers = true;
        fDefaultConsistencyChecks = false;
        fRequireStandard = true;
        fMineBlocksOnDemand = false;
        fTestnetToBeDeprecatedFieldRPC = false;

        checkpointData = (CCheckpointData) {
            boost::assign::map_list_of
            (  2016, uint256S("0000000000660bad0d9fbde55ba7ee14ddf766ed5f527e3fbca523ac11460b92"))
            (  4032, uint256S("0000000000493b5696ad482deb79da835fe2385304b841beef1938655ddbc411"))
            (  6048, uint256S("000000000027939a2e1d8bb63f36c47da858e56d570f143e67e85068943470c9"))
            (  8064, uint256S("000000000003a01f708da7396e54d081701ea406ed163e519589717d8b7c95a5"))
            ( 10080, uint256S("00000000000fed3899f818b2228b4f01b9a0a7eeee907abd172852df71c64b06"))
            ( 12096, uint256S("0000000000006c06988ff361f124314f9f4bb45b6997d90a7ee4cedf434c670f"))
            ( 14112, uint256S("00000000000045d95e0588c47c17d593c7b5cb4fb1e56213d1b3843c1773df2b"))
            ( 16128, uint256S("000000000001d9964f9483f9096cf9d6c6c2886ed1e5dec95ad2aeec3ce72fa9"))
            ( 18940, uint256S("00000000000087f7fc0c8085217503ba86f796fa4984f7e5a08b6c4c12906c05"))
            ( 30240, uint256S("e1c8c862ff342358384d4c22fa6ea5f669f3e1cdcf34111f8017371c3c0be1da"))
            ( 57000, uint256S("aa3ec60168a0200799e362e2b572ee01f3c3852030d07d036e0aa884ec61f203"))
            (112896, uint256S("73f880e78a04dd6a31efc8abf7ca5db4e262c4ae130d559730d6ccb8808095bf"))
            (182000, uint256S("d47b4a8fd282f635d66ce34ebbeb26ffd64c35b41f286646598abfd813cba6d9"))
            (193000, uint256S("3b85e70ba7f5433049cfbcf0ae35ed869496dbedcd1c0fafadb0284ec81d7b58")),
            1409050213, // * UNIX timestamp of last checkpoint block
            1441814,    // * total number of transactions between genesis and last checkpoint
                        //   (the tx=... number in the SetBestChain debug.log lines)
            1635.0      // * estimated number of transactions per day after checkpoint
        };

        /* See also doc/NamecoinBugs.txt for more explanation on the
           historical bugs added below.  */

        /* These transactions have name outputs but a non-Namecoin tx version.
           They contain NAME_NEWs, which are fine, and also NAME_FIRSTUPDATE.
           The latter are not interpreted by namecoind, thus also ignore
           them for us here.  */
        addBug(98423, "bff3ed6873e5698b97bf0c28c29302b59588590b747787c7d1ef32decdabe0d1", BUG_FULLY_IGNORE);
        addBug(98424, "e9b211007e5cac471769212ca0f47bb066b81966a8e541d44acf0f8a1bd24976", BUG_FULLY_IGNORE);
        addBug(98425, "8aa2b0fc7d1033de28e0192526765a72e9df0c635f7305bdc57cb451ed01a4ca", BUG_FULLY_IGNORE);

        /* These are non-Namecoin tx that contain just NAME_NEWs.  Those were
           handled with a special rule previously, but now they are fully
           disallowed and we handle the few exceptions here.  It is fine to
           "ignore" them, as their outputs need no special Namecoin handling
           before they are reused in a NAME_FIRSTUPDATE.  */
        addBug(98318, "0ae5e958ff05ad8e273222656d98d076097def6d36f781a627c584b859f4727b", BUG_FULLY_IGNORE);
        addBug(98321, "aca8ce46da1bbb9bb8e563880efcd9d6dd18342c446d6f0e3d4b964a990d1c27", BUG_FULLY_IGNORE);
        addBug(98424, "c29b0d9d478411462a8ac29946bf6fdeca358a77b4be15cd921567eb66852180", BUG_FULLY_IGNORE);
        addBug(98425, "221719b360f0c83fa5b1c26fb6b67c5e74e4e7c6aa3dce55025da6759f5f7060", BUG_FULLY_IGNORE);
        addBug(193518, "597370b632efb35d5ed554c634c7af44affa6066f2a87a88046532d4057b46f8", BUG_FULLY_IGNORE);
        addBug(195605, "0bb8c7807a9756aefe62c271770b313b31dee73151f515b1ac2066c50eaeeb91", BUG_FULLY_IGNORE);
        addBug(195639, "3181930765b970fc43cd31d53fc6fc1da9439a28257d9067c3b5912d23eab01c", BUG_FULLY_IGNORE);
        addBug(195639, "e815e7d774937d96a4b265ed4866b7e3dc8d9f2acb8563402e216aba6edd1e9e", BUG_FULLY_IGNORE);
        addBug(195639, "cdfe6eda068e09fe760a70bec201feb041b8c660d0e98cbc05c8aa4106eae6ab", BUG_FULLY_IGNORE);
        addBug(195641, "1e29e937b2a9e1f18af500371b8714157cf5ac7c95461913e08ce402de64ae75", BUG_FULLY_IGNORE);
        addBug(195648, "d44ed6c0fac251931465f9123ada8459ec954cc6c7b648a56c9326ff7b13f552", BUG_FULLY_IGNORE);
        addBug(197711, "dd77aea50a189935d0ef36a04856805cd74600a53193c539eb90c1e1c0f9ecac", BUG_FULLY_IGNORE);
        addBug(204151, "f31875dfaf94bd3a93cfbed0e22d405d1f2e49b4d0750cb13812adc5e57f1e47", BUG_FULLY_IGNORE);

        /* This transaction has both a NAME_NEW and a NAME_FIRSTUPDATE as
           inputs.  This was accepted due to the "argument concatenation" bug.
           It is fine to accept it as valid and just process the NAME_UPDATE
           output that builds on the NAME_FIRSTUPDATE input.  (NAME_NEW has no
           special side-effect in applying anyway.)  */
        addBug(99381, "774d4c446cecfc40b1c02fdc5a13be6d2007233f9d91daefab6b3c2e70042f05", BUG_FULLY_APPLY);

        /* These were libcoin's name stealing bugs.  */
        addBug(139872, "2f034f2499c136a2c5a922ca4be65c1292815c753bbb100a2a26d5ad532c3919", BUG_IN_UTXO);
        addBug(139936, "c3e76d5384139228221cce60250397d1b87adf7366086bc8d6b5e6eee03c55c7", BUG_FULLY_IGNORE);
    }
Esempio n. 21
0
/*
===============
VM_LoadSymbols
===============
*/
void VM_LoadSymbols( vm_t *vm ) {
	int		len;
	char	*mapfile, *text_p, *token;
	char	name[MAX_QPATH];
	char	symbols[MAX_QPATH];
	vmSymbol_t	**prev, *sym;
	int		count;
	int		value;
	int		chars;
	int		segment;
	int		numInstructions;

	// don't load symbols if not developer
	if ( !com_developer->integer ) {
		return;
	}

	COM_StripExtension(vm->name, name, sizeof(name));
	Com_sprintf( symbols, sizeof( symbols ), "vm/%s.map", name );
	len = FS_ReadFile( symbols, (void **)&mapfile );
	if ( !mapfile ) {
		Com_Printf( "Couldn't load symbol file: %s\n", symbols );
		return;
	}

	numInstructions = vm->instructionPointersLength >> 2;

	// parse the symbols
	text_p = mapfile;
	prev = &vm->symbols;
	count = 0;

	while ( 1 ) {
		token = COM_Parse( &text_p );
		if ( !token[0] ) {
			break;
		}
		segment = ParseHex( token );
		if ( segment ) {
			COM_Parse( &text_p );
			COM_Parse( &text_p );
			continue;		// only load code segment values
		}

		token = COM_Parse( &text_p );
		if ( !token[0] ) {
			Com_Printf( "WARNING: incomplete line at end of file\n" );
			break;
		}
		value = ParseHex( token );

		token = COM_Parse( &text_p );
		if ( !token[0] ) {
			Com_Printf( "WARNING: incomplete line at end of file\n" );
			break;
		}
		chars = strlen( token );
		sym = Hunk_Alloc( sizeof( *sym ) + chars, h_high );
		*prev = sym;
		prev = &sym->next;
		sym->next = NULL;

		// convert value from an instruction number to a code offset
		if ( value >= 0 && value < numInstructions ) {
			value = vm->instructionPointers[value];
		}

		sym->symValue = value;
		Q_strncpyz( sym->symName, token, chars + 1 );

		count++;
	}

	vm->numSymbols = count;
	Com_Printf( "%i symbols parsed from %s\n", count, symbols );
	FS_FreeFile( mapfile );
}
Esempio n. 22
0
CScript ParseScript(const std::string& s)
{
    CScript result;

    static std::map<std::string, opcodetype> mapOpNames;

    if (mapOpNames.empty())
    {
        for (unsigned int op = 0; op <= MAX_OPCODE; op++)
        {
            // Allow OP_RESERVED to get into mapOpNames
            if (op < OP_NOP && op != OP_RESERVED)
                continue;

            const char* name = GetOpName((opcodetype)op);
            if (strcmp(name, "OP_UNKNOWN") == 0)
                continue;
            std::string strName(name);
            mapOpNames[strName] = (opcodetype)op;
            // Convenience: OP_ADD and just ADD are both recognized:
            boost::algorithm::replace_first(strName, "OP_", "");
            mapOpNames[strName] = (opcodetype)op;
        }
    }

    std::vector<std::string> words;
    boost::algorithm::split(words, s, boost::algorithm::is_any_of(" \t\n"), boost::algorithm::token_compress_on);

    for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w)
    {
        if (w->empty())
        {
            // Empty string, ignore. (boost::split given '' will return one word)
        }
        else if (all(*w, boost::algorithm::is_digit()) ||
            (boost::algorithm::starts_with(*w, "-") && all(std::string(w->begin()+1, w->end()), boost::algorithm::is_digit())))
        {
            // Number
            int64_t n = atoi64(*w);
            result << n;
        }
        else if (boost::algorithm::starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(std::string(w->begin()+2, w->end())))
        {
            // Raw hex data, inserted NOT pushed onto stack:
            std::vector<unsigned char> raw = ParseHex(std::string(w->begin()+2, w->end()));
            result.insert(result.end(), raw.begin(), raw.end());
        }
        else if (w->size() >= 2 && boost::algorithm::starts_with(*w, "'") && boost::algorithm::ends_with(*w, "'"))
        {
            // Single-quoted string, pushed as data. NOTE: this is poor-man's
            // parsing, spaces/tabs/newlines in single-quoted strings won't work.
            std::vector<unsigned char> value(w->begin()+1, w->end()-1);
            result << value;
        }
        else if (mapOpNames.count(*w))
        {
            // opcode, e.g. OP_ADD or ADD:
            result << mapOpNames[*w];
        }
        else
        {
            throw std::runtime_error("script parse error");
        }
    }

    return result;
}
Esempio n. 23
0
    CTestNetParams() {
        strNetworkID = "test";
        consensus.nMajorityEnforceBlockUpgrade = 51;
        consensus.nMajorityRejectBlockOutdated = 75;
        consensus.nMajorityWindow = 100;
        consensus.BIP34Height = 21111;
        consensus.BIP34Hash = uint256S("0x0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8");
        consensus.powLimit = uint256S("0x00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20;
        consensus.nPowTargetTimespan = 6 * 60 * 60; // 6h retarget
        consensus.nPowTargetSpacing = 1 * 60; // 1 minute
        consensus.fPowAllowMinDifficultyBlocks = true;
        consensus.fPowNoRetargeting = false;
		consensus.nAuxpowChainId = 0x1000;

        pchMessageStart[0] = 0x0b;
        pchMessageStart[1] = 0x11;
        pchMessageStart[2] = 0x09;
        pchMessageStart[3] = 0x07;
        vAlertPubKey = ParseHex("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a");
        nDefaultPort = 18369;
        nMaxTipAge = 0x7fffffff;
        nPruneAfterHeight = 1000;

        genesis = CreateGenesisBlock(1450470135, 3161522, 0x1e0ffff0, 1, 2.5 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("0x000008113f038c81fcccb06fba03ac17f9dac9a38f659555e17e6b8252f6ec4b"));
        assert(genesis.hashMerkleRoot == uint256S("0x5215c5a2af9b63f2550b635eb2b354bb13645fd8fa31275394eb161944303065"));

        vFixedSeeds.clear();
        vSeeds.clear();
        /*vSeeds.push_back(CDNSSeedData("alexykot.me", "testnet-seed.alexykot.me"));
        vSeeds.push_back(CDNSSeedData("syscoin.petertodd.org", "testnet-seed.syscoin.petertodd.org"));
        vSeeds.push_back(CDNSSeedData("bluematt.me", "testnet-seed.bluematt.me"));
        vSeeds.push_back(CDNSSeedData("syscoin.schildbach.de", "testnet-seed.syscoin.schildbach.de"));*/

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);

        base58Prefixes[PUBKEY_ADDRESS_SYS] = std::vector<unsigned char>(1,65);
        base58Prefixes[SECRET_KEY_SYS] =     std::vector<unsigned char>(1,193);

        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();

        vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));

        fMiningRequiresPeers = true;
        fDefaultConsistencyChecks = false;
        fRequireStandard = false;
        fMineBlocksOnDemand = false;
        fTestnetToBeDeprecatedFieldRPC = true;

        /*checkpointData = (CCheckpointData) {
            boost::assign::map_list_of
            ( 546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")),
            1337966069,
            1488,
            300
        };*/

    }
Esempio n. 24
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x66;
        pchMessageStart[1] = 0x66;
        pchMessageStart[2] = 0x66;
        pchMessageStart[3] = 0x66;
        nDefaultPort = 24242;
        nRPCPort = 24243;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 35040000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.
  
        const char* pszTimestamp = "Release the Kraken - www.krakencoin.com";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNewvout1nValue = 5;
        txNewvout2nValue = 450000 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1394270601;
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 943874;
        
        //// debug print
        hashGenesisBlock = genesis.GetHash();
        //while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
          //  if (++genesis.nNonce==0) break;
            //hashGenesisBlock = genesis.GetHash();
        //}

        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();
        
        
        assert(hashGenesisBlock == uint256("0x00000e9d058285796d9d49c3110a98c9367d25b7ab82cab06088f29ff4160b2a"));
        assert(genesis.hashMerkleRoot == uint256("0x67cf79c130dc3b7f3a164ffde6d4ff3b30fb3847e649e5ab8c889cbcba8db40d"));

        vSeeds.push_back(CDNSSeedData("162.243.90.199", "162.243.90.199"));


        base58Prefixes[PUBKEY_ADDRESS] = 45;
        base58Prefixes[SCRIPT_ADDRESS] = 30;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time' 
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Esempio n. 25
0
void MultisigDialog::on_transaction_textChanged()
{
    while(ui->inputs->count())
        delete ui->inputs->takeAt(0)->widget();
    while(ui->outputs->count())
        delete ui->outputs->takeAt(0)->widget();

    if(ui->transaction->text().size() > 0)
        ui->signTransactionButton->setEnabled(true);
    else
        ui->signTransactionButton->setEnabled(false);

    // Decode the raw transaction
    std::vector<unsigned char> txData(ParseHex(ui->transaction->text().toStdString()));
    CDataStream ss(txData, SER_NETWORK, PROTOCOL_VERSION);
    CTransaction tx;
    try
    {
        ss >> tx;
    }
    catch(std::exception &e)
    {
        (void)e;
        return;
    }

    // Fill input list
    int index = -1;
    BOOST_FOREACH(const CTxIn& txin, tx.vin)
    {
        uint256 prevoutHash = txin.prevout.hash;
        addInput();
        index++;
        MultisigInputEntry *entry = qobject_cast<MultisigInputEntry *>(ui->inputs->itemAt(index)->widget());
        if(entry)
        {
            entry->setTransactionId(QString(prevoutHash.GetHex().c_str()));
            entry->setTransactionOutputIndex(txin.prevout.n);
        }
    }

    // Fill output list
    index = -1;
    BOOST_FOREACH(const CTxOut& txout, tx.vout)
    {
        CScript scriptPubKey = txout.scriptPubKey;
        CTxDestination addr;
        ExtractDestination(scriptPubKey, addr);
        CBitcoinAddress address(addr);
        SendCoinsRecipient recipient;
        recipient.address = QString(address.ToString().c_str());
        recipient.amount = txout.nValue;
        addOutput();
        index++;
        SendCoinsEntry *entry = qobject_cast<SendCoinsEntry *>(ui->outputs->itemAt(index)->widget());
        if(entry)
        {
            entry->setValue(recipient);
        }
    }

    updateRemoveEnabled();
}
Esempio n. 26
0
void MultisigDialog::on_transaction_textChanged()
{
    ui->fee->setStyleSheet("");
    ui->statusLabel->setText("");

    while(ui->inputs->count())
        delete ui->inputs->takeAt(0)->widget();
    while(ui->outputs->count())
        delete ui->outputs->takeAt(0)->widget();

    if(ui->transaction->text().size() > 0)
        ui->signTransactionButton->setEnabled(true);
    else
        ui->signTransactionButton->setEnabled(false);

    // Decode the raw transaction
    std::vector<unsigned char> txData(ParseHex(ui->transaction->text().toStdString()));
    CDataStream ss(txData, SER_NETWORK, PROTOCOL_VERSION);
    CTransaction tx;
    try
    {
        ss >> tx;
    }
    catch(std::exception &e)
    {
        return;
    }

    // Fill input list
    int index = -1;
    BOOST_FOREACH(const CTxIn& txin, tx.vin)
    {
        uint256 prevoutHash = txin.prevout.hash;
        addInput();
        index++;
        MultisigInputEntry *entry = qobject_cast<MultisigInputEntry *>(ui->inputs->itemAt(index)->widget());
        if(entry)
        {
            entry->setTransactionId(QString(prevoutHash.GetHex().c_str()));
            entry->setTransactionOutputIndex(txin.prevout.n);
        }
    }

    // Fill output list
    index = -1;
    BOOST_FOREACH(const CTxOut& txout, tx.vout)
    {
        CScript scriptPubKey = txout.scriptPubKey;
        CTxDestination addr;
        ExtractDestination(scriptPubKey, addr);
        CBitcoinAddress address(addr);
        SendCoinsRecipient recipient;
        recipient.address = QString(address.ToString().c_str());
        recipient.amount = txout.nValue;
        addOutput();
        index++;
        SendCoinsEntry *entry = qobject_cast<SendCoinsEntry *>(ui->outputs->itemAt(index)->widget());
        if(entry)
        {
            entry->setValue(recipient);
        }
    }

    updateRemoveEnabled();

    // Check the fee
    int64_t transactionSize = ui->transaction->text().size() / 2;
    if(transactionSize == 0)
        return;
    transactionSize += ui->inputs->count() * 73; // Future ECDSA signatures in DER format
    int64_t fee = (int64_t ) (ui->fee->text().toDouble() * COIN);
    int64_t minFee = MIN_TX_FEE * (1 + (int64_t) transactionSize / 1000);
    if(fee < minFee)
    {
        ui->fee->setStyleSheet("color:red;");
        ui->statusLabel->setText(tr("The transaction fee might be too small."));
    }
    else if(fee > minFee)
    {
        ui->fee->setStyleSheet("color:red;");
        ui->statusLabel->setText(tr("The transaction fee might be too big. Don't forget to add an output for the change address."));
    }
}
Esempio n. 27
0
void TestRIPEMD160(const std::string &in, const std::string &hexout) { TestVector(CRIPEMD160(), in, ParseHex(hexout));}
Esempio n. 28
0
/**
 * Build the genesis block. Note that the output of its generation
 * transaction cannot be spent since it did not originally exist in the
 * database.
 *
 * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
 *   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
 *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
 *     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
 *   vMerkleTree: 4a5e1e
 */
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    const char* pszTimestamp = "27/11/2015 Putin: Oil that Turkey buys from terrorists is mixed with Russian blood";
    const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
Esempio n. 29
0
static void TestSHA1(const std::string &in, const std::string &hexout) { TestVector(CSHA1(), in, ParseHex(hexout));}
Esempio n. 30
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x05;
        pchMessageStart[1] = 0x05;
        pchMessageStart[2] = 0xb5;
        pchMessageStart[3] = 0x05;
        nDefaultPort = 5530;
        nRPCPort = 5531;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 100000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.
  
        const char* pszTimestamp = "vcoin sn";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1431517588;
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 1486592;
        
        //// debug print
        hashGenesisBlock = genesis.GetHash();
        while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
            if (++genesis.nNonce==0) break;
            hashGenesisBlock = genesis.GetHash();
        }

        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();
        
        
        assert(hashGenesisBlock == uint256("0x00000b7e804f0de87e7752550ff04d7686a4599509897feefd7f03904eb45633"));
        assert(genesis.hashMerkleRoot == uint256("0x1576ef41775095b26a8f8f2bb65b693ec12230608a425aa84ee462381cae00e6"));

        vSeeds.push_back(CDNSSeedData("1", "108.61.10.90"));
        vSeeds.push_back(CDNSSeedData("2", "185.92.222.31"));


        base58Prefixes[PUBKEY_ADDRESS] = 70;
        base58Prefixes[SCRIPT_ADDRESS] = 30;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time' 
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }