mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
CreateNewBlock() now takes scriptPubKey argument,
rather than a key. CreateNewBlockWithKey() helper is added to restore existing functionality, making this an equivalent-transformation change.
This commit is contained in:
@@ -141,7 +141,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
CBlockTemplate* CreateNewBlock(CReserveKey& reservekey)
|
||||
CBlockTemplate* CreateNewBlock(CScript& scriptPubKeyIn)
|
||||
{
|
||||
// Create new block
|
||||
auto_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
||||
@@ -154,10 +154,7 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey)
|
||||
txNew.vin.resize(1);
|
||||
txNew.vin[0].prevout.SetNull();
|
||||
txNew.vout.resize(1);
|
||||
CPubKey pubkey;
|
||||
if (!reservekey.GetReservedKey(pubkey))
|
||||
return NULL;
|
||||
txNew.vout[0].scriptPubKey << pubkey << OP_CHECKSIG;
|
||||
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
||||
|
||||
// Add our coinbase tx as first transaction
|
||||
pblock->vtx.push_back(txNew);
|
||||
@@ -383,6 +380,15 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey)
|
||||
return pblocktemplate.release();
|
||||
}
|
||||
|
||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
|
||||
{
|
||||
CPubKey pubkey;
|
||||
if (!reservekey.GetReservedKey(pubkey))
|
||||
return NULL;
|
||||
|
||||
CScript scriptPubKey = CScript() << pubkey << OP_CHECKSIG;
|
||||
return CreateNewBlock(scriptPubKey);
|
||||
}
|
||||
|
||||
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
|
||||
{
|
||||
@@ -510,7 +516,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
unsigned int nTransactionsUpdatedLast = nTransactionsUpdated;
|
||||
CBlockIndex* pindexPrev = pindexBest;
|
||||
|
||||
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(reservekey));
|
||||
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
|
||||
if (!pblocktemplate.get())
|
||||
return;
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
|
||||
Reference in New Issue
Block a user