您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CScript函数代码示例

51自学网 2021-06-01 20:06:34
  C++
这篇教程C++ CScript函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CScript函数的典型用法代码示例。如果您正苦于以下问题:C++ CScript函数的具体用法?C++ CScript怎么用?C++ CScript使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CScript函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: inputData

voidCAuxPow::initAuxPow (CBlockHeader& header){  /* Set auxpow flag right now, since we take the block hash below.  */  header.SetAuxpowVersion(true);  /* Build a minimal coinbase script input for merge-mining.  */  const uint256 blockHash = header.GetHash ();  valtype inputData(blockHash.begin (), blockHash.end ());  std::reverse (inputData.begin (), inputData.end ());  inputData.push_back (1);  inputData.insert (inputData.end (), 7, 0);  /* Fake a parent-block coinbase with just the required input     script and no outputs.  */  CMutableTransaction coinbase;  coinbase.vin.resize (1);  coinbase.vin[0].prevout.SetNull ();  coinbase.vin[0].scriptSig = (CScript () << inputData);  assert (coinbase.vout.empty ());  CTransactionRef coinbaseRef = MakeTransactionRef (coinbase);  /* Build a fake parent block with the coinbase.  */  CBlock parent;  parent.nVersion = 1;  parent.vtx.resize (1);  parent.vtx[0] = coinbaseRef;  parent.hashMerkleRoot = BlockMerkleRoot (parent);  /* Construct the auxpow object.  */  header.SetAuxpow (new CAuxPow (coinbaseRef));  assert (header.auxpow->vChainMerkleBranch.empty ());  header.auxpow->nChainIndex = 0;  assert (header.auxpow->vMerkleBranch.empty ());  header.auxpow->nIndex = 0;  header.auxpow->parentBlock = parent;}
开发者ID:8bitcoder,项目名称:myriadcoin,代码行数:37,


示例2: 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 = "RevolverCoin: Bitcoin Price Hits Six-Month High Amid 5% Surge - Coindesk 27.05";    const CScript genesisOutputScript = CScript() << ParseHex("04e6b3ff62fe1e27e35cabd879eac29e39b45811d061851f790453fc5109c5218bc2a5925a4d2496a38b07a9f531ec037a6207d0f370c1fc41cddd81d202e44203") << OP_CHECKSIG;    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);}
开发者ID:RevolverCoin,项目名称:revolvercoin,代码行数:17,


示例3: TestPackageSelection

// Test suite for ancestor feerate transaction selection.// Implemented as an additional function, rather than a separate test case,// to allow reusing the blockchain created in CreateNewBlock_validity.// Note that this test assumes blockprioritysize is 0.void TestPackageSelection(const CChainParams& chainparams, CScript scriptPubKey, std::vector<CTransaction *>& txFirst){    // Test the ancestor feerate transaction selection.    TestMemPoolEntryHelper entry;    // Test that a medium fee transaction will be selected after a higher fee    // rate package with a low fee rate parent.    CMutableTransaction tx;    tx.vin.resize(1);    tx.vin[0].scriptSig = CScript() << OP_1;    tx.vin[0].prevout.hash = txFirst[0]->GetHash();    tx.vin[0].prevout.n = 0;    tx.vout.resize(1);    tx.vout[0].nValue = 5000000000LL - 1000;    // This tx has a low fee: 1000 satoshis    uint256 hashParentTx = tx.GetHash(); // save this txid for later use    mempool.addUnchecked(hashParentTx, entry.Fee(1000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));    // This tx has a medium fee: 10000 satoshis    tx.vin[0].prevout.hash = txFirst[1]->GetHash();    tx.vout[0].nValue = 5000000000LL - 10000;    uint256 hashMediumFeeTx = tx.GetHash();    mempool.addUnchecked(hashMediumFeeTx, entry.Fee(10000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));    // This tx has a high fee, but depends on the first transaction    tx.vin[0].prevout.hash = hashParentTx;    tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 50k satoshi fee    uint256 hashHighFeeTx = tx.GetHash();    mempool.addUnchecked(hashHighFeeTx, entry.Fee(50000).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));    CBlockTemplate *pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey);    BOOST_CHECK(pblocktemplate->block.vtx[1].GetHash() == hashParentTx);    BOOST_CHECK(pblocktemplate->block.vtx[2].GetHash() == hashHighFeeTx);    BOOST_CHECK(pblocktemplate->block.vtx[3].GetHash() == hashMediumFeeTx);    // Test that a package below the min relay fee doesn't get included    tx.vin[0].prevout.hash = hashHighFeeTx;    tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 0 fee    uint256 hashFreeTx = tx.GetHash();    mempool.addUnchecked(hashFreeTx, entry.Fee(0).FromTx(tx));    size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);    // Calculate a fee on child transaction that will put the package just    // below the min relay fee (assuming 1 child tx of the same size).    CAmount feeToUse = minRelayTxFee.GetFee(2*freeTxSize) - 1;    tx.vin[0].prevout.hash = hashFreeTx;    tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse;    uint256 hashLowFeeTx = tx.GetHash();    mempool.addUnchecked(hashLowFeeTx, entry.Fee(feeToUse).FromTx(tx));    pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey);    // Verify that the free tx and the low fee tx didn't get selected    for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {        BOOST_CHECK(pblocktemplate->block.vtx[i].GetHash() != hashFreeTx);        BOOST_CHECK(pblocktemplate->block.vtx[i].GetHash() != hashLowFeeTx);    }    // Test that packages above the min relay fee do get included, even if one    // of the transactions is below the min relay fee    // Remove the low fee transaction and replace with a higher fee transaction    std::list<CTransaction> dummy;    mempool.removeRecursive(tx, dummy);    tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee    hashLowFeeTx = tx.GetHash();    mempool.addUnchecked(hashLowFeeTx, entry.Fee(feeToUse+2).FromTx(tx));    pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey);    BOOST_CHECK(pblocktemplate->block.vtx[4].GetHash() == hashFreeTx);    BOOST_CHECK(pblocktemplate->block.vtx[5].GetHash() == hashLowFeeTx);    // Test that transaction selection properly updates ancestor fee    // calculations as ancestor transactions get included in a block.    // Add a 0-fee transaction that has 2 outputs.    tx.vin[0].prevout.hash = txFirst[2]->GetHash();    tx.vout.resize(2);    tx.vout[0].nValue = 5000000000LL - 100000000;    tx.vout[1].nValue = 100000000; // 1BTC output    uint256 hashFreeTx2 = tx.GetHash();    mempool.addUnchecked(hashFreeTx2, entry.Fee(0).SpendsCoinbase(true).FromTx(tx));    // This tx can't be mined by itself    tx.vin[0].prevout.hash = hashFreeTx2;    tx.vout.resize(1);    feeToUse = minRelayTxFee.GetFee(freeTxSize);    tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;    uint256 hashLowFeeTx2 = tx.GetHash();    mempool.addUnchecked(hashLowFeeTx2, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));    pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey);    // Verify that this tx isn't selected.    for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {        BOOST_CHECK(pblocktemplate->block.vtx[i].GetHash() != hashFreeTx2);        BOOST_CHECK(pblocktemplate->block.vtx[i].GetHash() != hashLowFeeTx2);    }    // This tx will be mineable, and should cause hashLowFeeTx2 to be selected    // as well.//.........这里部分代码省略.........
开发者ID:APCLab,项目名称:bitcoin,代码行数:101,


示例4: CMainParams

    CMainParams() {        // The message start string is designed to be unlikely to occur in normal data.        pchMessageStart[0] = 0x04;        pchMessageStart[1] = 0x05;        pchMessageStart[2] = 0x05;        pchMessageStart[3] = 0x04;        nDefaultPort = 25536;        nRPCPort = 25537;        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 = "Scotcoin!";        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    = 1392946703;        genesis.nBits    = 0x1e0fffff;        genesis.nNonce   = 168193;                //// 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("0x0000020b9d4db902554e1131eee9d0a016e201215b2fd6e7279e4321f99a3e15"));        assert(genesis.hashMerkleRoot == uint256("0xa887ab6f2204b79e5af2878efc78e5da804013f94f4e23cb73239b6abbf95ce4"));        vSeeds.push_back(CDNSSeedData("someaddress.com or IP addy", "someaddress.com"));        base58Prefixes[PUBKEY_ADDRESS] = 63;        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);        }    }
开发者ID:Roverok,项目名称:scotcoin,代码行数:66,


示例5: Solver

bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet){    // Templates    static std::multimap<txnouttype, CScript> mTemplates;    if (mTemplates.empty())    {        // Standard tx, sender provides pubkey, receiver adds signature        mTemplates.insert(std::make_pair(TX_PUBKEY, CScript() << OP_PUBKEY << OP_CHECKSIG));        // Bitcoin address tx, sender provides hash of pubkey, receiver provides signature and pubkey        mTemplates.insert(std::make_pair(TX_PUBKEYHASH, CScript() << OP_DUP << OP_HASH160 << OP_PUBKEYHASH << OP_EQUALVERIFY << OP_CHECKSIG));        // Sender provides N pubkeys, receivers provides M signatures        mTemplates.insert(std::make_pair(TX_MULTISIG, CScript() << OP_SMALLINTEGER << OP_PUBKEYS << OP_SMALLINTEGER << OP_CHECKMULTISIG));    }    vSolutionsRet.clear();    // If we have a name script, strip the prefix    const CNameScript nameOp(scriptPubKey);    const CScript& script1 = nameOp.getAddress();    // Shortcut for pay-to-script-hash, which are more constrained than the other types:    // it is always OP_HASH160 20 [20 byte hash] OP_EQUAL    if (script1.IsPayToScriptHash(false))    {        typeRet = TX_SCRIPTHASH;        std::vector<unsigned char> hashBytes(script1.begin()+2, script1.begin()+22);        vSolutionsRet.push_back(hashBytes);        return true;    }    int witnessversion;    std::vector<unsigned char> witnessprogram;    if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {        if (witnessversion == 0 && witnessprogram.size() == 20) {            typeRet = TX_WITNESS_V0_KEYHASH;            vSolutionsRet.push_back(witnessprogram);            return true;        }        if (witnessversion == 0 && witnessprogram.size() == 32) {            typeRet = TX_WITNESS_V0_SCRIPTHASH;            vSolutionsRet.push_back(witnessprogram);            return true;        }        if (witnessversion != 0) {            typeRet = TX_WITNESS_UNKNOWN;            vSolutionsRet.push_back(std::vector<unsigned char>{(unsigned char)witnessversion});            vSolutionsRet.push_back(std::move(witnessprogram));            return true;        }        return false;    }    // Provably prunable, data-carrying output    //    // So long as script passes the IsUnspendable() test and all but the first    // byte passes the IsPushOnly() test we don't care what exactly is in the    // script.    if (scriptPubKey.size() >= 1 && scriptPubKey[0] == OP_RETURN && scriptPubKey.IsPushOnly(scriptPubKey.begin()+1)) {        typeRet = TX_NULL_DATA;        return true;    }    // Scan templates    for (const std::pair<txnouttype, CScript>& tplate : mTemplates)    {        const CScript& script2 = tplate.second;        vSolutionsRet.clear();        opcodetype opcode1, opcode2;        std::vector<unsigned char> vch1, vch2;        // Compare        CScript::const_iterator pc1 = script1.begin();        CScript::const_iterator pc2 = script2.begin();        while (true)        {            if (pc1 == script1.end() && pc2 == script2.end())            {                // Found a match                typeRet = tplate.first;                if (typeRet == TX_MULTISIG)                {                    // Additional checks for TX_MULTISIG:                    unsigned char m = vSolutionsRet.front()[0];                    unsigned char n = vSolutionsRet.back()[0];                    if (m < 1 || n < 1 || m > n || vSolutionsRet.size()-2 != n)                        return false;                }                return true;            }            if (!script1.GetOp(pc1, opcode1, vch1))                break;            if (!script2.GetOp(pc2, opcode2, vch2))                break;            // Template matching opcodes:            if (opcode2 == OP_PUBKEYS)            {//.........这里部分代码省略.........
开发者ID:randy-waterhouse,项目名称:namecoin-core,代码行数:101,


示例6: BOOST_FIXTURE_TEST_CASE

BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup){    // Test that passing CheckInputs with one set of script flags doesn't imply    // that we would pass again with a different set of flags.    {        LOCK(cs_main);        InitScriptExecutionCache();    }    CScript p2pk_scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;    CScript p2sh_scriptPubKey = GetScriptForDestination(CScriptID(p2pk_scriptPubKey));    CScript p2pkh_scriptPubKey = GetScriptForDestination(coinbaseKey.GetPubKey().GetID());    CScript p2wpkh_scriptPubKey = GetScriptForWitness(p2pkh_scriptPubKey);    CBasicKeyStore keystore;    keystore.AddKey(coinbaseKey);    keystore.AddCScript(p2pk_scriptPubKey);    // flags to test: SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, SCRIPT_VERIFY_CHECKSEQUENCE_VERIFY, SCRIPT_VERIFY_NULLDUMMY, uncompressed pubkey thing    // Create 2 outputs that match the three scripts above, spending the first    // coinbase tx.    CMutableTransaction spend_tx;    spend_tx.nVersion = 1;    spend_tx.vin.resize(1);    spend_tx.vin[0].prevout.hash = m_coinbase_txns[0]->GetHash();    spend_tx.vin[0].prevout.n = 0;    spend_tx.vout.resize(4);    spend_tx.vout[0].nValue = 11*CENT;    spend_tx.vout[0].scriptPubKey = p2sh_scriptPubKey;    spend_tx.vout[1].nValue = 11*CENT;    spend_tx.vout[1].scriptPubKey = p2wpkh_scriptPubKey;    spend_tx.vout[2].nValue = 11*CENT;    spend_tx.vout[2].scriptPubKey = CScript() << OP_CHECKLOCKTIMEVERIFY << OP_DROP << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;    spend_tx.vout[3].nValue = 11*CENT;    spend_tx.vout[3].scriptPubKey = CScript() << OP_CHECKSEQUENCEVERIFY << OP_DROP << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;    // Sign, with a non-DER signature    {        std::vector<unsigned char> vchSig;        uint256 hash = SignatureHash(p2pk_scriptPubKey, spend_tx, 0, SIGHASH_ALL, 0, SigVersion::BASE);        BOOST_CHECK(coinbaseKey.Sign(hash, vchSig));        vchSig.push_back((unsigned char) 0); // padding byte makes this non-DER        vchSig.push_back((unsigned char)SIGHASH_ALL);        spend_tx.vin[0].scriptSig << vchSig;    }    // Test that invalidity under a set of flags doesn't preclude validity    // under other (eg consensus) flags.    // spend_tx is invalid according to DERSIG    {        LOCK(cs_main);        CValidationState state;        PrecomputedTransactionData ptd_spend_tx(spend_tx);        BOOST_CHECK(!CheckInputs(spend_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true, true, ptd_spend_tx, nullptr));        // If we call again asking for scriptchecks (as happens in        // ConnectBlock), we should add a script check object for this -- we're        // not caching invalidity (if that changes, delete this test case).        std::vector<CScriptCheck> scriptchecks;        BOOST_CHECK(CheckInputs(spend_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true, true, ptd_spend_tx, &scriptchecks));        BOOST_CHECK_EQUAL(scriptchecks.size(), 1U);        // Test that CheckInputs returns true iff DERSIG-enforcing flags are        // not present.  Don't add these checks to the cache, so that we can        // test later that block validation works fine in the absence of cached        // successes.        ValidateCheckInputsForAllFlags(spend_tx, SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_LOW_S | SCRIPT_VERIFY_STRICTENC, false);    }    // And if we produce a block with this tx, it should be valid (DERSIG not    // enabled yet), even though there's no cache entry.    CBlock block;    block = CreateAndProcessBlock({spend_tx}, p2pk_scriptPubKey);    BOOST_CHECK(chainActive.Tip()->GetBlockHash() == block.GetHash());    BOOST_CHECK(pcoinsTip->GetBestBlock() == block.GetHash());    LOCK(cs_main);    // Test P2SH: construct a transaction that is valid without P2SH, and    // then test validity with P2SH.    {        CMutableTransaction invalid_under_p2sh_tx;        invalid_under_p2sh_tx.nVersion = 1;        invalid_under_p2sh_tx.vin.resize(1);        invalid_under_p2sh_tx.vin[0].prevout.hash = spend_tx.GetHash();        invalid_under_p2sh_tx.vin[0].prevout.n = 0;        invalid_under_p2sh_tx.vout.resize(1);        invalid_under_p2sh_tx.vout[0].nValue = 11*CENT;        invalid_under_p2sh_tx.vout[0].scriptPubKey = p2pk_scriptPubKey;        std::vector<unsigned char> vchSig2(p2pk_scriptPubKey.begin(), p2pk_scriptPubKey.end());        invalid_under_p2sh_tx.vin[0].scriptSig << vchSig2;        ValidateCheckInputsForAllFlags(invalid_under_p2sh_tx, SCRIPT_VERIFY_P2SH, true);    }//.........这里部分代码省略.........
开发者ID:Crypto2,项目名称:omnicore,代码行数:101,


示例7: Solver

/** * Return public keys or hashes from scriptPubKey, for 'standard' transaction types. */bool Solver(const CScript& scriptPubKeyIn, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet){    // Templates    static std::multimap<txnouttype, CScript> mTemplates;    if (mTemplates.empty())    {        // Standard tx, sender provides pubkey, receiver adds signature        mTemplates.insert(std::make_pair(TX_PUBKEY, CScript() << OP_PUBKEY << OP_CHECKSIG));        // Syscoin address tx, sender provides hash of pubkey, receiver provides signature and pubkey        mTemplates.insert(std::make_pair(TX_PUBKEYHASH, CScript() << OP_DUP << OP_HASH160 << OP_PUBKEYHASH << OP_EQUALVERIFY << OP_CHECKSIG));        // Sender provides N pubkeys, receivers provides M signatures        mTemplates.insert(std::make_pair(TX_MULTISIG, CScript() << OP_SMALLINTEGER << OP_PUBKEYS << OP_SMALLINTEGER << OP_CHECKMULTISIG));    }	// SYSCOIN check to see if this is a syscoin service transaction, if so get the scriptPubKey by extracting service specific script information	CScript scriptPubKey;	CScript scriptPubKeyOut;	if (RemoveSyscoinScript(scriptPubKeyIn, scriptPubKeyOut))		scriptPubKey = scriptPubKeyOut;	else		scriptPubKey = scriptPubKeyIn;    vSolutionsRet.clear();    // Shortcut for pay-to-script-hash, which are more constrained than the other types:    // it is always OP_HASH160 20 [20 byte hash] OP_EQUAL    if (scriptPubKey.IsPayToScriptHash())    {        typeRet = TX_SCRIPTHASH;        std::vector<unsigned char> hashBytes(scriptPubKey.begin()+2, scriptPubKey.begin()+22);        vSolutionsRet.push_back(hashBytes);        return true;    }    // Provably prunable, data-carrying output    //    // So long as script passes the IsUnspendable() test and all but the first    // byte passes the IsPushOnly() test we don't care what exactly is in the    // script.    if (scriptPubKey.size() >= 1 && scriptPubKey[0] == OP_RETURN && scriptPubKey.IsPushOnly(scriptPubKey.begin()+1)) {        typeRet = TX_NULL_DATA;        return true;    }    // Scan templates    const CScript& script1 = scriptPubKey;    BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates)    {        const CScript& script2 = tplate.second;        vSolutionsRet.clear();        opcodetype opcode1, opcode2;        std::vector<unsigned char> vch1, vch2;        // Compare        CScript::const_iterator pc1 = script1.begin();        CScript::const_iterator pc2 = script2.begin();        while (true)        {            if (pc1 == script1.end() && pc2 == script2.end())            {                // Found a match                typeRet = tplate.first;                if (typeRet == TX_MULTISIG)                {                    // Additional checks for TX_MULTISIG:                    unsigned char m = vSolutionsRet.front()[0];                    unsigned char n = vSolutionsRet.back()[0];                    if (m < 1 || n < 1 || m > n || vSolutionsRet.size()-2 != n)                        return false;                }                return true;            }            if (!script1.GetOp(pc1, opcode1, vch1))                break;            if (!script2.GetOp(pc2, opcode2, vch2))                break;            // Template matching opcodes:            if (opcode2 == OP_PUBKEYS)            {                while (vch1.size() >= 33 && vch1.size() <= 65)                {                    vSolutionsRet.push_back(vch1);                    if (!script1.GetOp(pc1, opcode1, vch1))                        break;                }                if (!script2.GetOp(pc2, opcode2, vch2))                    break;                // Normal situation is to fall through                // to other if/else statements            }            if (opcode2 == OP_PUBKEY)            {                if (vch1.size() < 33 || vch1.size() > 65)//.........这里部分代码省略.........
开发者ID:syscoin,项目名称:syscoin2,代码行数:101,


示例8: CMainParams

    CMainParams() {        // The message start string is designed to be unlikely to occur in normal data.        pchMessageStart[0] = 0xaf;        pchMessageStart[1] = 0x45;        pchMessageStart[2] = 0x76;        pchMessageStart[3] = 0xee;        vAlertPubKey = ParseHex("04a82e43bebee0af77bb6d4f830c5b2095b7479a480e91bbbf3547fb261c5e6d1be2c27e3c57503f501480f5027371ec62b2be1b6f00fc746e4b3777259e7f6a78");        nDefaultPort = 10888;        nRPCPort = 10889;        bnProofOfWorkLimit[ALGO_SHA256D] = CBigNum(~uint256(0) >> 20);        bnProofOfWorkLimit[ALGO_SCRYPT]  = CBigNum(~uint256(0) >> 20);        bnProofOfWorkLimit[ALGO_GROESTL] = CBigNum(~uint256(0) >> 20);        bnProofOfWorkLimit[ALGO_SKEIN]   = CBigNum(~uint256(0) >> 20);        bnProofOfWorkLimit[ALGO_QUBIT]   = CBigNum(~uint256(0) >> 20);        nSubsidyHalvingInterval = 80640 * 12;        // 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 = "2014-02-23 FT - G20 aims to add $2tn to global economy";        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 = 1000 * COIN;        txNew.vout[0].scriptPubKey = CScript() << ParseHex("04e941763c7750969e751bee1ffbe96a651a0feb131db046546c219ea40bff40b95077dc9ba1c05af991588772d8daabbda57386c068fb9bc7477c5e28702d5eb9") << OP_CHECKSIG;        genesis.vtx.push_back(txNew);        genesis.hashPrevBlock = 0;        genesis.hashMerkleRoot = genesis.BuildMerkleTree();        genesis.nVersion = BLOCK_VERSION_DEFAULT;        genesis.nTime    = 1393164995;        genesis.nBits    = 0x1e0fffff;        genesis.nNonce   = 2092903596;                //// debug print        hashGenesisBlock = genesis.GetHash();        //while (hashGenesisBlock > bnProofOfWorkLimit[ALGO_SHA256D].getuint256()){        //    if (++genesis.nNonce==0) break;        //    hashGenesisBlock = genesis.GetHash();        //}        //printf("MAIN: %s/n", hashGenesisBlock.ToString().c_str());        //printf("%s/n", genesis.hashMerkleRoot.ToString().c_str());        //printf("%x/n", bnProofOfWorkLimit[ALGO_SHA256D].GetCompact());        //genesis.print();                assert(hashGenesisBlock == uint256("0x00000ffde4c020b5938441a0ea3d314bf619eff0b38f32f78f7583cffa1ea485"));        assert(genesis.hashMerkleRoot == uint256("0x3f75db3c18e92f46c21530dc1222e1fddf4ccebbf88e289a6c9dc787fd6469da"));        vSeeds.push_back(CDNSSeedData("seed1.myriadcoin.org", "seed1.myriadcoin.org"));        vSeeds.push_back(CDNSSeedData("seed2.myriadcoin.org", "seed2.myriadcoin.org"));        vSeeds.push_back(CDNSSeedData("seed3.myriadcoin.org", "seed3.myriadcoin.org"));        vSeeds.push_back(CDNSSeedData("seed4.myriadcoin.org", "seed4.myriadcoin.org"));        base58Prefixes[PUBKEY_ADDRESS] = 50;        base58Prefixes[SCRIPT_ADDRESS] = 9;        base58Prefixes[SECRET_KEY] = 178;        // 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);        }    }
开发者ID:Brokencoin,项目名称:selectioncoin,代码行数:72,


示例9: SignatureHashOld

// Old script.cpp SignatureHash functionuint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType){    static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));    if (nIn >= txTo.vin.size())    {        printf("ERROR: SignatureHash(): nIn=%d out of range/n", nIn);        return one;    }    CMutableTransaction txTmp(txTo);    // In case concatenating two scripts ends up with two codeseparators,    // or an extra one at the end, this prevents all those possible incompatibilities.    scriptCode.FindAndDelete(CScript(OP_CODESEPARATOR));    // Blank out other inputs' signatures    for (unsigned int i = 0; i < txTmp.vin.size(); i++)        txTmp.vin[i].scriptSig = CScript();    txTmp.vin[nIn].scriptSig = scriptCode;    // Blank out some of the outputs    if ((nHashType & 0x1f) == SIGHASH_NONE)    {        // Wildcard payee        txTmp.vout.clear();        // Let the others update at will        for (unsigned int i = 0; i < txTmp.vin.size(); i++)            if (i != nIn)                txTmp.vin[i].nSequence = 0;    }    else if ((nHashType & 0x1f) == SIGHASH_SINGLE)    {        // Only lock-in the txout payee at same index as txin        unsigned int nOut = nIn;        if (nOut >= txTmp.vout.size())        {            printf("ERROR: SignatureHash(): nOut=%d out of range/n", nOut);            return one;        }        txTmp.vout.resize(nOut+1);        for (unsigned int i = 0; i < nOut; i++)            txTmp.vout[i].SetNull();        // Let the others update at will        for (unsigned int i = 0; i < txTmp.vin.size(); i++)            if (i != nIn)                txTmp.vin[i].nSequence = 0;    }    // Blank out other inputs completely, not recommended for open transactions    if (nHashType & SIGHASH_ANYONECANPAY)    {        txTmp.vin[0] = txTmp.vin[nIn];        txTmp.vin.resize(1);    }    // Serialize and hash    CHashWriter ss(SER_GETHASH, SERIALIZE_TRANSACTION_NO_WITNESS);    ss << txTmp << nHashType;    return ss.GetHash();}
开发者ID:8bitcoder,项目名称:myriadcoin,代码行数:62,


示例10: 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=00000ffd590b14, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=e0028e, nTime=1390095618, nBits=1e0ffff0, nNonce=28917698, vtx=1) *   CTransaction(hash=e0028e, ver=1, vin.size=1, vout.size=1, nLockTime=0) *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d01044c5957697265642030392f4a616e2f3230313420546865204772616e64204578706572696d656e7420476f6573204c6976653a204f76657273746f636b2e636f6d204973204e6f7720416363657074696e6720426974636f696e73) *     CTxOut(nValue=50.00000000, scriptPubKey=0xA9037BAC7050C479B121CF) *   vMerkleTree: e0028e */static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward){    const char* pszTimestamp = "The history of Bangkok dates at least back to the early 15th century";    const CScript genesisOutputScript = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);}
开发者ID:prapun77,项目名称:monoeci,代码行数:17,


示例11: CMainParams

    CMainParams() {        // The message start string is designed to be unlikely to occur in normal data.        pchMessageStart[0] = 0x1a;        pchMessageStart[1] = 0x2b;        pchMessageStart[2] = 0x3c;        pchMessageStart[3] = 0x4e;        vAlertPubKey = ParseHex("045337216002ca6a71d63edf062895417610a723d453e722bf4728996c58661cdac3d4dec5cecd449b9086e9602b35cc726a9e0163e1a4d40f521fbdaebb674658");        nDefaultPort = 7921;        nRPCPort = 7920;        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);        nSubsidyHalvingInterval = 80640;        // Build the genesis block. Note that the output of the genesis coinbase cannot        // be spent as it did not originally exist in the database.                //00000e1b77bd39ddb4b76f58a766ba0f40653977d3d9a20ded261a28b51074df		//f592dac23841d61ab7b74c5f13e73e7db5e176fae4aa8b37048af74ce9d46005		//1e0fffff		//CBlock(hash=00000e1b77bd39ddb4b76f58a766ba0f40653977d3d9a20ded261a28b51074df, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=f592dac23841d61ab7b74c5f13e73e7db5e176fae4aa8b37048af74ce9d46005, nTime=1388822738, nBits=1e0fffff, nNonce=238626, vtx=1)  		//CTransaction(hash=f592dac238, ver=1, vin.size=1, vout.size=1, nLockTime=0)    	//CTxIn(COutPoint(0000000000, 4294967295), coinbase 04ffff001d010408312d342d32303134)    	//CTxOut(nValue=1000.00000000, scriptPubKey=04678afdb0fe5548271967f1a67130)  		//vMerkleTree: f592dac23841d61ab7b74c5f13e73e7db5e176fae4aa8b37048af74ce9d46005               const char* pszTimestamp = "1-4-2014";        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 = 1000 * 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    = 1388874174;        genesis.nBits    = 0x1e0fffff;        genesis.nNonce   = 758274;                //// debug print        hashGenesisBlock = genesis.GetHash();        //comment out        //while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){        //    if (++genesis.nNonce==0) break;        //    hashGenesisBlock = genesis.GetHash();        //}		//comment out        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("0x00000887c81496d79ff7d6467a25cc6a52d9ed457e787c8b9a6bca4e5441b012"));        assert(genesis.hashMerkleRoot == uint256("0xf592dac23841d61ab7b74c5f13e73e7db5e176fae4aa8b37048af74ce9d46005"));        //vSeeds.push_back(CDNSSeedData("192.168.1.112", "192.168.1.112"));        //vSeeds.push_back(CDNSSeedData("", ""));        //vSeeds.push_back(CDNSSeedData("", ""));        //vSeeds.push_back(CDNSSeedData("", ""));        //vSeeds.push_back(CDNSSeedData("", ""));        //vSeeds.push_back(CDNSSeedData("", ""));        //vSeeds.push_back(CDNSSeedData("", ""));        //vSeeds.push_back(CDNSSeedData("", ""));        //vSeeds.push_back(CDNSSeedData("", ""));        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);        }    }
开发者ID:clonecoin,项目名称:clonecoin,代码行数:87,


示例12: foreach

WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipient> &recipients, const CCoinControl *coinControl){    qint64 total = 0;    QSet<QString> setAddress;    QString hex;    if(recipients.empty())    {        return OK;    }    // Pre-check input data for validity    foreach(const SendCoinsRecipient &rcp, recipients)    {        if(!validateAddress(rcp.address))        {            return InvalidAddress;        }        setAddress.insert(rcp.address);        if(rcp.amount <= 0)        {            return InvalidAmount;        }        total += rcp.amount;    }    if(recipients.size() > setAddress.size())    {        return DuplicateAddress;    }    int64_t nBalance = 0;    std::vector<COutput> vCoins;    wallet->AvailableCoins(vCoins, true, coinControl);    BOOST_FOREACH(const COutput& out, vCoins)        nBalance += out.tx->vout[out.i].nValue;    if(total > nBalance)    {        return AmountExceedsBalance;    }    if((total + nTransactionFee) > nBalance)    {        return SendCoinsReturn(AmountWithFeeExceedsBalance, nTransactionFee);    }    {        LOCK2(cs_main, wallet->cs_wallet);        // Sendmany        std::vector<std::pair<CScript, int64_t> > vecSend;        std::string sNarr;        foreach(const SendCoinsRecipient &rcp, recipients)        {            CScript scriptPubKey;            scriptPubKey.SetDestination(CBitcoinAddress(rcp.address.toStdString()).Get());            vecSend.push_back(make_pair(scriptPubKey, rcp.amount));            sNarr = rcp.reference.toStdString();            if (sNarr.length() > 0)            {               if (sNarr.length() > 50)               {                   printf("Reference is too long./n");                   return ReferenceTooLong;               };               std::vector<uint8_t> vNarr(sNarr.c_str(), sNarr.c_str() + sNarr.length());               CScript scriptN = CScript() << OP_RETURN << vNarr;               vecSend.push_back(make_pair(scriptN, 0));            }        }        CWalletTx wtx;        if (sNarr.length() > 0) {            wtx.mapValue["reference"] = sNarr;        }        CReserveKey keyChange(wallet);        int64_t nFeeRequired = 0;        bool fCreated = wallet->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, coinControl);        if(!fCreated)        {            if((total + nFeeRequired) > nBalance) // FIXME: could cause collisions in the future            {                return SendCoinsReturn(AmountWithFeeExceedsBalance, nFeeRequired);            }            return TransactionCreationFailed;        }        if(!uiInterface.ThreadSafeAskFee(nFeeRequired, tr("Sending...").toStdString()))        {            return Aborted;        }        if(!wallet->CommitTransaction(wtx, keyChange))//.........这里部分代码省略.........
开发者ID:microcoinsource,项目名称:microCoin_V3.0,代码行数:101,


示例13: CMainParams

    CMainParams() {        // 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 4-byte int at any alignment.            pchMessageStart[0] = 0xc7;            pchMessageStart[1] = 0xa1;            pchMessageStart[2] = 0xf6;            pchMessageStart[3] = 0xc9; //chimark            vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");            nDefaultPort = 58778;            nRPCPort = 58777;            bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);            nSubsidyHalvingInterval = 770000;            // 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 = "Dec 2013 light speed X-day";        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    = 1389429187;        genesis.nBits    = 0x1e0fffff; //chimark        genesis.nNonce   = 1030111;        hashGenesisBlock = genesis.GetHash();        //// debug print        //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("0x00000a8f9572e068cffbdb30c23f698e659e1e2e13e51cfcb8114fa5df38ffee"));        assert(genesis.hashMerkleRoot == uint256("0x91c7edee50dd32d8544412f4cef06f8812723eefe8fec24fd3e66d92f83b1b9e"));        vSeeds.push_back(CDNSSeedData("chicoin.sipa.be", "seed.chicoin.sipa.be"));        vSeeds.push_back(CDNSSeedData("bluematt.me", "dnsseed.bluematt.me"));        vSeeds.push_back(CDNSSeedData("dashjr.org", "dnsseed.chicoin.dashjr.org"));        vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org"));        base58Prefixes[PUBKEY_ADDRESS] = 27;        base58Prefixes[SCRIPT_ADDRESS] = 29;        base58Prefixes[SECRET_KEY] =     127;        // 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);        }    }
开发者ID:DeepCoin,项目名称:chicoin,代码行数:73,


示例14: CMainParams

    CMainParams() {        // The message start string is designed to be unlikely to occur in normal data.        pchMessageStart[0] = 0x03;        pchMessageStart[1] = 0xd5;        pchMessageStart[2] = 0xb5;        pchMessageStart[3] = 0x03;        nDefaultPort = 65534;        nRPCPort = 65535;        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 = "San Francisco plaza evacuated after suspicious package is found";        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("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;        genesis.vtx.push_back(txNew);        genesis.hashPrevBlock = 0;        genesis.hashMerkleRoot = genesis.BuildMerkleTree();        genesis.nVersion = 1;        genesis.nTime    = 1375548986;        genesis.nBits    = 0x1e0fffff;        genesis.nNonce   = 1211565;                //// 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("0x000004c2fc5fffb810dccc197d603690099a68305232e552d96ccbe8e2c52b75"));        assert(genesis.hashMerkleRoot == uint256("0x36a192e90f70131a884fe541a1e8a5643a28ba4cb24cbb2924bd0ee483f7f484"));        vSeeds.push_back(CDNSSeedData("andarazoroflove.org", "andarazoroflove.org"));        vSeeds.push_back(CDNSSeedData("rockchain.info", "rockchain.info"));        base58Prefixes[PUBKEY_ADDRESS] = 130;        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);        }    }
开发者ID:DeepCoin,项目名称:Unobtanium,代码行数:66,


示例15: MempoolEviction

// Right now this is only testing eviction performance in an extremely small// mempool. Code needs to be written to generate a much wider variety of// unique transactions for a more meaningful performance measurement.static void MempoolEviction(benchmark::State& state){    CMutableTransaction tx1 = CMutableTransaction();    tx1.vin.resize(1);    tx1.vin[0].scriptSig = CScript() << OP_1;    tx1.vout.resize(1);    tx1.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL;    tx1.vout[0].nValue = 10 * COIN;    CMutableTransaction tx2 = CMutableTransaction();    tx2.vin.resize(1);    tx2.vin[0].scriptSig = CScript() << OP_2;    tx2.vout.resize(1);    tx2.vout[0].scriptPubKey = CScript() << OP_2 << OP_EQUAL;    tx2.vout[0].nValue = 10 * COIN;    CMutableTransaction tx3 = CMutableTransaction();    tx3.vin.resize(1);    tx3.vin[0].prevout = COutPoint(tx2.GetHash(), 0);    tx3.vin[0].scriptSig = CScript() << OP_2;    tx3.vout.resize(1);    tx3.vout[0].scriptPubKey = CScript() << OP_3 << OP_EQUAL;    tx3.vout[0].nValue = 10 * COIN;    CMutableTransaction tx4 = CMutableTransaction();    tx4.vin.resize(2);    tx4.vin[0].prevout.SetNull();    tx4.vin[0].scriptSig = CScript() << OP_4;    tx4.vin[1].prevout.SetNull();    tx4.vin[1].scriptSig = CScript() << OP_4;    tx4.vout.resize(2);    tx4.vout[0].scriptPubKey = CScript() << OP_4 << OP_EQUAL;    tx4.vout[0].nValue = 10 * COIN;    tx4.vout[1].scriptPubKey = CScript() << OP_4 << OP_EQUAL;    tx4.vout[1].nValue = 10 * COIN;    CMutableTransaction tx5 = CMutableTransaction();    tx5.vin.resize(2);    tx5.vin[0].prevout = COutPoint(tx4.GetHash(), 0);    tx5.vin[0].scriptSig = CScript() << OP_4;    tx5.vin[1].prevout.SetNull();    tx5.vin[1].scriptSig = CScript() << OP_5;    tx5.vout.resize(2);    tx5.vout[0].scriptPubKey = CScript() << OP_5 << OP_EQUAL;    tx5.vout[0].nValue = 10 * COIN;    tx5.vout[1].scriptPubKey = CScript() << OP_5 << OP_EQUAL;    tx5.vout[1].nValue = 10 * COIN;    CMutableTransaction tx6 = CMutableTransaction();    tx6.vin.resize(2);    tx6.vin[0].prevout = COutPoint(tx4.GetHash(), 1);    tx6.vin[0].scriptSig = CScript() << OP_4;    tx6.vin[1].prevout.SetNull();    tx6.vin[1].scriptSig = CScript() << OP_6;    tx6.vout.resize(2);    tx6.vout[0].scriptPubKey = CScript() << OP_6 << OP_EQUAL;    tx6.vout[0].nValue = 10 * COIN;    tx6.vout[1].scriptPubKey = CScript() << OP_6 << OP_EQUAL;    tx6.vout[1].nValue = 10 * COIN;    CMutableTransaction tx7 = CMutableTransaction();    tx7.vin.resize(2);    tx7.vin[0].prevout = COutPoint(tx5.GetHash(), 0);    tx7.vin[0].scriptSig = CScript() << OP_5;    tx7.vin[1].prevout = COutPoint(tx6.GetHash(), 0);    tx7.vin[1].scriptSig = CScript() << OP_6;    tx7.vout.resize(2);    tx7.vout[0].scriptPubKey = CScript() << OP_7 << OP_EQUAL;    tx7.vout[0].nValue = 10 * COIN;    tx7.vout[1].scriptPubKey = CScript() << OP_7 << OP_EQUAL;    tx7.vout[1].nValue = 10 * COIN;    CTxMemPool pool(CFeeRate(1000));    while (state.KeepRunning()) {        AddTx(tx1, 10000LL, pool);        AddTx(tx2, 5000LL, pool);        AddTx(tx3, 20000LL, pool);        AddTx(tx4, 7000LL, pool);        AddTx(tx5, 1000LL, pool);        AddTx(tx6, 1100LL, pool);        AddTx(tx7, 9000LL, pool);        pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4);        pool.TrimToSize(GetVirtualTransactionSize(tx1));    }}
开发者ID:13971643458,项目名称:qtum,代码行数:89,


示例16: CMainParams

    CMainParams() {        // The message start string is designed to be unlikely to occur in normal data.        pchMessageStart[0] = 0xa5;        pchMessageStart[1] = 0xc0;        pchMessageStart[2] = 0x79;        pchMessageStart[3] = 0x55;        vAlertPubKey = ParseHex("000000000007840aaf100de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");        nDefaultPort = 32333;        nRPCPort = 32332;        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 32);        nSubsidyHalvingInterval = 126000; // 1 year        // 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 = "CNN 23/10/2013 Scientists find gold growing on trees in Australia";        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 = 50 * 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    = 1382532797;        genesis.nBits    = 0x1d00ffff;        genesis.nNonce   = 704106316;                //// 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("0x000000008ef7da946aa3f4dd81b240c6bdedac0dc038cb04e7cf8e60f37d9281"));        assert(genesis.hashMerkleRoot == uint256("0xd25dbe3a2852926fc2ec6591a95983bbcde80c449f30ced37fd657361073fa96"));         vSeeds.push_back(CDNSSeedData("seed1.betacoin.org", "seed1.betacoin.org"));        vSeeds.push_back(CDNSSeedData("seed2.betacoin.org", "seed2.betacoin.org"));         vSeeds.push_back(CDNSSeedData("seed3.betacoin.org", "seed3.betacoin.org"));          vSeeds.push_back(CDNSSeedData("seed4.betacoin.org", "seed4.betacoin.org"));        vSeeds.push_back(CDNSSeedData("seed5.betacoin.org", "seed5.betacoin.org"));         vSeeds.push_back(CDNSSeedData("seed6.betacoin.org", "seed6.betacoin.org"));        base58Prefixes[PUBKEY_ADDRESS] = 25;        base58Prefixes[SCRIPT_ADDRESS] = 11;        base58Prefixes[SECRET_KEY] = 143;        // 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);        }    }
开发者ID:AUSTRALIANBITCOINS,项目名称:betacoin,代码行数:72,


示例17: GetTimeMicros

std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, bool fMineWitnessTx){    int64_t nTimeStart = GetTimeMicros();    resetBlock();    pblocktemplate.reset(new CBlockTemplate());    if(!pblocktemplate.get())        return nullptr;    pblock = &pblocktemplate->block; // pointer for convenience    // Add dummy coinbase tx as first transaction    pblock->vtx.emplace_back();    pblocktemplate->vTxFees.push_back(-1); // updated at end    pblocktemplate->vTxSigOpsCost.push_back(-1); // updated at end    LOCK2(cs_main, mempool.cs);    CBlockIndex* pindexPrev = chainActive.Tip();    assert(pindexPrev != nullptr);    nHeight = pindexPrev->nHeight + 1;    pblock->nVersion = ComputeBlockVersion(pindexPrev, chainparams.GetConsensus());    // -regtest only: allow overriding block.nVersion with    // -blockversion=N to test forking scenarios    if (chainparams.MineBlocksOnDemand())        pblock->nVersion = gArgs.GetArg("-blockversion", pblock->nVersion);    pblock->nTime = GetAdjustedTime();    const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();    nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST)                       ? nMedianTimePast                       : pblock->GetBlockTime();    // Decide whether to include witness transactions    // This is only needed in case the witness softfork activation is reverted    // (which would require a very deep reorganization) or when    // -promiscuousmempoolflags is used.    // TODO: replace this with a call to main to assess validity of a mempool    // transaction (which in most cases can be a no-op).    fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus()) && fMineWitnessTx;    int nPackagesSelected = 0;    int nDescendantsUpdated = 0;    addPackageTxs(nPackagesSelected, nDescendantsUpdated);    int64_t nTime1 = GetTimeMicros();    nLastBlockTx = nBlockTx;    nLastBlockWeight = nBlockWeight;    // Create coinbase transaction.    CMutableTransaction coinbaseTx;    coinbaseTx.vin.resize(1);    coinbaseTx.vin[0].prevout.SetNull();    coinbaseTx.vout.resize(1);    coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn;    coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());    coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;    pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));    pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus());    pblocktemplate->vTxFees[0] = -nFees;    LogPrintf("CreateNewBlock(): block weight: %u txs: %u fees: %ld sigops %d/n", GetBlockWeight(*pblock), nBlockTx, nFees, nBlockSigOpsCost);    // Fill in header    pblock->hashPrevBlock  = pindexPrev->GetBlockHash();    UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);    pblock->nBits          = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());    pblock->nNonce         = 0;    pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);    CValidationState state;    if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) {        throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state)));    }    int64_t nTime2 = GetTimeMicros();    LogPrint(BCLog::BENCH, "CreateNewBlock() packages: %.2fms (%d packages, %d updated descendants), validity: %.2fms (total %.2fms)/n", 0.001 * (nTime1 - nTimeStart), nPackagesSelected, nDescendantsUpdated, 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart));    return std::move(pblocktemplate);}
开发者ID:admxjx,项目名称:bitcoin,代码行数:83,


示例18: CMainParams

    CMainParams() {        // The message start string is designed to be unlikely to occur in normal data.        pchMessageStart[0] = 0xf7;        pchMessageStart[1] = 0x26;        pchMessageStart[2] = 0xa1;        pchMessageStart[3] = 0xbf;        vAlertPubKey = ParseHex("04e41db2a8b8dc3981f819d46060875ce483bf303613b108e673d7bb636f7786bd0458e2ced6e8b337be32d024562f3e69776412b55a7210396ad7a9944812b445");        nDefaultPort = 48481;        nRPCPort = 48480;        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);        nSubsidyHalvingInterval = 262800;        // 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 = "Tone Abbet Does it again";        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 = COIN / 10000;        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    = 1403852000;        genesis.nBits    = 0x1e0fffff;        genesis.nNonce   = 1376737;                //// 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();        /*if (false && (genesis.GetHash() != hashGenesisBlock)) {        // This will figure out a valid hash and Nonce if you're        // creating a different genesis block:            uint256 hashTarget = CBigNum().SetCompact(genesis.nBits).getuint256();            while (genesis.GetHash() > hashTarget)               {                   ++genesis.nNonce;                   if (genesis.nNonce == 0)                   {                       printf("NONCE WRAPPED, incrementing time");                       ++genesis.nTime;                   }               }        }        //// debug print        genesis.print();        printf("genesis.GetHash() == %s/n", genesis.GetHash().ToString().c_str());        printf("genesis.hashMerkleRoot == %s/n", genesis.hashMerkleRoot.ToString().c_str());        printf("genesis.nTime = %u /n", genesis.nTime);        printf("genesis.nNonce = %u /n", genesis.nNonce);              */        assert(hashGenesisBlock == uint256("0x00000dffc654ad0a8d9055536135b69d71dcd878d901508fc9381bde67bf0645"));        assert(genesis.hashMerkleRoot == uint256("0x94076775c950c86d89bc2225c87bcb4e29621b57d5e9b430d7fa190078b0e980"));        vSeeds.push_back(CDNSSeedData("162.248.4.167", "162.248.4.167"));        vSeeds.push_back(CDNSSeedData("seed2.whirlcoin.org", "seed2.whirlcoin.org"));        vSeeds.push_back(CDNSSeedData("seed3.whirlcoin.org", "seed3.whirlcoin.org"));        vSeeds.push_back(CDNSSeedData("whirlcoin.zapto.org", "whirlcoin.zapto.org"));        vSeeds.push_back(CDNSSeedData("whirlcoin.no-ip.org", "whirlcoin.no-ip.org"));        vSeeds.push_back(CDNSSeedData("whirlcoin.strangled.net", "whirlcoin.strangled.net"));        vSeeds.push_back(CDNSSeedData("whirlcoin.ignorelist.com", "whirlcoin.ignorelist.com"));        base58Prefixes[PUBKEY_ADDRESS] = 73;        base58Prefixes[SCRIPT_ADDRESS] = 12;        base58Prefixes[SECRET_KEY] = 226;        // 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);        }    }
开发者ID:nuggetbram,项目名称:whirlcoin,代码行数:94,


示例19: BOOST_FIXTURE_TEST_CASE

BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup){    // Make sure skipping validation of transactions that were    // validated going into the memory pool does not allow    // double-spends in blocks to pass validation when they should not.    CScript scriptPubKey = CScript() <<  ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;    // Create a double-spend of mature coinbase txn:    std::vector<CMutableTransaction> spends;    spends.resize(2);    for (int i = 0; i < 2; i++)    {        spends[i].nVersion = 1;        spends[i].vin.resize(1);        spends[i].vin[0].prevout.hash = m_coinbase_txns[0]->GetHash();        spends[i].vin[0].prevout.n = 0;        spends[i].vout.resize(1);        spends[i].vout[0].nValue = 11*CENT;        spends[i].vout[0].scriptPubKey = scriptPubKey;        // Sign:        std::vector<unsigned char> vchSig;        uint256 hash = SignatureHash(scriptPubKey, spends[i], 0, SIGHASH_ALL, 0, SigVersion::BASE);        BOOST_CHECK(coinbaseKey.Sign(hash, vchSig));        vchSig.push_back((unsigned char)SIGHASH_ALL);        spends[i].vin[0].scriptSig << vchSig;    }    CBlock block;    // Test 1: block with both of those transactions should be rejected.    block = CreateAndProcessBlock(spends, scriptPubKey);    {        LOCK(cs_main);        BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash());    }    // Test 2: ... and should be rejected if spend1 is in the memory pool    BOOST_CHECK(ToMemPool(spends[0]));    block = CreateAndProcessBlock(spends, scriptPubKey);    {        LOCK(cs_main);        BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash());    }    mempool.clear();    // Test 3: ... and should be rejected if spend2 is in the memory pool    BOOST_CHECK(ToMemPool(spends[1]));    block = CreateAndProcessBlock(spends, scriptPubKey);    {        LOCK(cs_main);        BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash());    }    mempool.clear();    // Final sanity test: first spend in mempool, second in block, that's OK:    std::vector<CMutableTransaction> oneSpend;    oneSpend.push_back(spends[0]);    BOOST_CHECK(ToMemPool(spends[1]));    block = CreateAndProcessBlock(oneSpend, scriptPubKey);    {        LOCK(cs_main);        BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() == block.GetHash());    }    // spends[1] should have been removed from the mempool when the    // block with spends[0] is accepted:    BOOST_CHECK_EQUAL(mempool.size(), 0U);}
开发者ID:sudosurootdev,项目名称:bitcoin,代码行数:69,


示例20: GetScriptForRawPubKey

CScript GetScriptForRawPubKey(const CPubKey& pubKey){    return CScript() << std::vector<unsigned char>(pubKey.begin(), pubKey.end()) << OP_CHECKSIG;}
开发者ID:randy-waterhouse,项目名称:namecoin-core,代码行数:4,


示例21: getblocktemplate

//.........这里部分代码省略.........        if (!IsRPCRunning())            throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Shutting down");        // TODO: Maybe recheck connections/IBD and (if something wrong) send an expires-immediately template to stop miners?    }    const struct VBDeploymentInfo& segwit_info = VersionBitsDeploymentInfo[Consensus::DEPLOYMENT_SEGWIT];    // If the caller is indicating segwit support, then allow CreateNewBlock()    // to select witness transactions, after segwit activates (otherwise    // don't).    bool fSupportsSegwit = setClientRules.find(segwit_info.name) != setClientRules.end();    // Update block    static CBlockIndex* pindexPrev;    static int64_t nStart;    static std::unique_ptr<CBlockTemplate> pblocktemplate;    // Cache whether the last invocation was with segwit support, to avoid returning    // a segwit-block to a non-segwit caller.    static bool fLastTemplateSupportsSegwit = true;    if (pindexPrev != chainActive.Tip() ||        (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 5) ||        fLastTemplateSupportsSegwit != fSupportsSegwit)    {        // Clear pindexPrev so future calls make a new block, despite any failures from here on        pindexPrev = nullptr;        // Store the pindexBest used before CreateNewBlock, to avoid races        nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();        CBlockIndex* pindexPrevNew = chainActive.Tip();        nStart = GetTime();        fLastTemplateSupportsSegwit = fSupportsSegwit;        // Create new block        CScript scriptDummy = CScript() << OP_TRUE;        pblocktemplate = BlockAssembler(Params()).CreateNewBlock(scriptDummy, fSupportsSegwit);        if (!pblocktemplate)            throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");        // Need to update only after we know CreateNewBlock succeeded        pindexPrev = pindexPrevNew;    }    assert(pindexPrev);    CBlock* pblock = &pblocktemplate->block; // pointer for convenience    const Consensus::Params& consensusParams = Params().GetConsensus();    // Update nTime    UpdateTime(pblock, consensusParams, pindexPrev);    pblock->nNonce = 0;    // NOTE: If at some point we support pre-segwit miners post-segwit-activation, this needs to take segwit support into consideration    const bool fPreSegWit = (ThresholdState::ACTIVE != VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_SEGWIT, versionbitscache));    UniValue aCaps(UniValue::VARR); aCaps.push_back("proposal");    UniValue transactions(UniValue::VARR);    std::map<uint256, int64_t> setTxIndex;    int i = 0;    for (const auto& it : pblock->vtx) {        const CTransaction& tx = *it;        uint256 txHash = tx.GetHash();        setTxIndex[txHash] = i++;        if (tx.IsCoinBase())            continue;        UniValue entry(UniValue::VOBJ);
开发者ID:GlobalBoost,项目名称:GlobalBoost,代码行数:67,


示例22: CreateGenesisBlock

static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward){    const char* pszTimestamp = "NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56";    const CScript genesisOutputScript = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);}
开发者ID:FeatherCoin,项目名称:Feathercoin,代码行数:6,


示例23: CMainParams

    CMainParams() {        // The message start string is designed to be unlikely to occur in normal data.        printf("main params/n");        pchMessageStart[0] = 0x09;        pchMessageStart[1] = 0x08;        pchMessageStart[2] = 0x2c;        pchMessageStart[3] = 0xab;        nDefaultPort = 46110;        nRPCPort = 46111;        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 = "The Times 5-6-14 30 rebels die in battle to retake Slovyansk";        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    = 1399374629;        genesis.nBits    = 0x1e0fffff;        genesis.nNonce   = 1141676;                //// 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("0x00000303a4dc1ffd6b7bf5419ac44798d089eb788aa2e521a42b6f20810b2438"));        assert(genesis.hashMerkleRoot == uint256("0x8c5a7bbd33316019cfbf75a6ec78c02ab7ff2529abc36dd31e3b3aaa193c9e82"));        //vSeeds.push_back(CDNSSeedData("someaddress.com or IP addy", "someaddress.com"));        base58Prefixes[PUBKEY_ADDRESS] = 73; //W        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);        }    }
开发者ID:WorldWideCoin,项目名称:wwcoin,代码行数:68,


示例24: CScript

CScript* CScriptManager::AddScript(tstring sName){    m_aScripts[sName] = CScript();    return &m_aScripts[sName];}
开发者ID:BSVino,项目名称:Digitanks,代码行数:5,


示例25: 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=167230846, vtx=1) *   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0) *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d01043f5468652054696d65732031382f4a616e2f323031382042696c6c696f6e616972652042756666657474207374696c6c2064656e79696e6720426974636f696e) *     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 14/Mar/2018 Stephen Hawking dies aged 76";    const CScript genesisOutputScript = CScript() << ParseHex("04908afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);}
开发者ID:Airche,项目名称:wificoin,代码行数:17,


示例26: CMainParams

    CMainParams() {        // The message start string is designed to be unlikely to occur in normal data.        pchMessageStart[0] = 0xb6;        pchMessageStart[1] = 0xb6;        pchMessageStart[2] = 0xb6;        pchMessageStart[3] = 0xb6;        nDefaultPort = 48327;        nRPCPort = 48328;        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 = "Nadecoin";        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    = 1300000000;        genesis.nBits    = 0x1e0fffff;        genesis.nNonce   = 0;                //// 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("0x5c85b50a51b3437abdf0ed22d984278d4f95e60650966ecc179e84d7d1a1a271"));        assert(genesis.hashMerkleRoot == uint256("0xc3ab53bcf6c4174ab22abec6923320e6f2af142fc3ec9c6c6f36065db7d02940"));        vSeeds.push_back(CDNSSeedData("google.org", "google.org"));        base58Prefixes[PUBKEY_ADDRESS] = 36;        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);        }    }
开发者ID:excellentsloth,项目名称:Nadecoin,代码行数:66,


示例27: CMainParams

    CMainParams() {        // The message start string is designed to be unlikely to occur in normal data.        pchMessageStart[0] = 0x0A;        pchMessageStart[1] = 0x05;        pchMessageStart[2] = 0x03;        pchMessageStart[3] = 0x0C;        nDefaultPort = 10240;        nRPCPort = 10241;        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);        nSubsidyHalvingInterval = 102400;        // 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 = "ImperialCoin's Reign Has Started!";        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    = 1393638000;        genesis.nBits    = 0x1e0fffff;        genesis.nNonce   = 0;                //// 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("0x"));        assert(genesis.hashMerkleRoot == uint256("0x"));        vSeeds.push_back(CDNSSeedData("68.232.180.111", "68.232.180.111"));        base58Prefixes[PUBKEY_ADDRESS] = 1;        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);        }    }
开发者ID:ImperialCoin,项目名称:ImperialCoin,代码行数:66,


示例28: IsInitialBlockDownload

//// Bootup the masternode, look for a 10000 PEPE input and register on the network//void CActiveMasternode::ManageStatus(){    std::string errorMessage;    if (fDebug) LogPrintf("CActiveMasternode::ManageStatus() - Begin/n");    if(!fMasterNode) return;    //need correct adjusted time to send ping    bool fIsInitialDownload = IsInitialBlockDownload();    if(fIsInitialDownload) {        status = MASTERNODE_SYNC_IN_PROCESS;        LogPrintf("CActiveMasternode::ManageStatus() - Sync in progress. Must wait until sync is complete to start masternode./n");        return;    }    if(status == MASTERNODE_INPUT_TOO_NEW || status == MASTERNODE_NOT_CAPABLE || status == MASTERNODE_SYNC_IN_PROCESS){        status = MASTERNODE_NOT_PROCESSED;    }    if(status == MASTERNODE_NOT_PROCESSED) {        if(strMasterNodeAddr.empty()) {            if(!GetLocal(service)) {                notCapableReason = "Can't detect external address. Please use the masternodeaddr configuration option.";                status = MASTERNODE_NOT_CAPABLE;                LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s/n", notCapableReason.c_str());                return;            }        } else {        	service = CService(strMasterNodeAddr, true);        }        LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'/n", service.ToString().c_str());            if(!ConnectNode((CAddress)service, service.ToString().c_str())){                notCapableReason = "Could not connect to " + service.ToString();                status = MASTERNODE_NOT_CAPABLE;                LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s/n", notCapableReason.c_str());                return;            }        if(pwalletMain->IsLocked()){            notCapableReason = "Wallet is locked.";            status = MASTERNODE_NOT_CAPABLE;            LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s/n", notCapableReason.c_str());            return;        }        // Set defaults        status = MASTERNODE_NOT_CAPABLE;        notCapableReason = "Unknown. Check debug.log for more information./n";        // Choose coins to use        CPubKey pubKeyCollateralAddress;        CKey keyCollateralAddress;        if(GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) {            if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){                notCapableReason = "Input must have least " + boost::lexical_cast<string>(MASTERNODE_MIN_CONFIRMATIONS) +                        " confirmations - " + boost::lexical_cast<string>(GetInputAge(vin)) + " confirmations";                LogPrintf("CActiveMasternode::ManageStatus() - %s/n", notCapableReason.c_str());                status = MASTERNODE_INPUT_TOO_NEW;                return;            }            LogPrintf("CActiveMasternode::ManageStatus() - Is capable master node!/n");            status = MASTERNODE_IS_CAPABLE;            notCapableReason = "";            pwalletMain->LockCoin(vin.prevout);            // send to all nodes            CPubKey pubKeyMasternode;            CKey keyMasternode;            if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode))            {            	LogPrintf("ActiveMasternode::Dseep() - Error upon calling SetKey: %s/n", errorMessage.c_str());            	return;            }            /* donations are not supported in pepecoin.conf */            CScript donationAddress = CScript();            int donationPercentage = 0;            if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, donationAddress, donationPercentage, errorMessage)) {                LogPrintf("CActiveMasternode::ManageStatus() - Error on Register: %s/n", errorMessage.c_str());            }            return;        } else {            notCapableReason = "Could not find suitable coins!";        	LogPrintf("CActiveMasternode::ManageStatus() - Could not find suitable coins!/n");//.........这里部分代码省略.........
开发者ID:bobfeldbauer,项目名称:pepecoin-core,代码行数:101,



注:本文中的CScript函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CService函数代码示例
C++ CS_LOCALS函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。