本文整理汇总了C++中ParseHex函数的典型用法代码示例。如果您正苦于以下问题:C++ ParseHex函数的具体用法?C++ ParseHex怎么用?C++ ParseHex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ParseHex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseHex
//============================================================
// <T>解析16进制字符串。</T>
//
// @param pSource 来源
// @param length 长度
// @return 内容
//============================================================
TUint8 RUint8::ParseHexNvl(TCharC* pSource, TInt length){
if(NULL != pSource){
return ParseHex(pSource, length);
}
return 0;
}
示例2: txData
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);
}
//.........这里部分代码省略.........
示例3: TestHMACSHA512
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));
}
示例4: CMainParams
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
};*/
}
示例5: CreateGenesisBlock
/**
* 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);
}
示例6: while
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;
//.........这里部分代码省略.........
示例7: CMainParams
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);
}
}
示例8: CMainParams
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);
}
}
示例9: ThreadSendAlert
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++;
//.........这里部分代码省略.........
示例10: CTestNetParams
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
};
}
示例11: CMainParams
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
};
}
示例12: TestHMACSHA256
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));
}
示例13: ProcessUsgDetail
//.........这里部分代码省略.........
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);
示例14: CMainParams
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);
}
}
示例15: CMainParams
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
};
}