aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2013-08-25 18:49:25 -0700
committerJeff Garzik <jgarzik@bitpay.com>2013-08-25 18:49:25 -0700
commitbb7d0fc12fcfbb2a91e39cb49f2a0873344dbae0 (patch)
tree78ce02c824847489b87d7a76261f0b187c3f620e /src/miner.cpp
parentb62dc051aa44ee73e24b49dd9337de2434b89710 (diff)
parentf1dbed9233fb138026c646db0ac34e83ae2114f1 (diff)
downloadbitcoin-bb7d0fc12fcfbb2a91e39cb49f2a0873344dbae0.tar.xz
Merge pull request #2928 from jgarzik/cnb-txout
CreateNewBlock / getblocktemplate cleaning
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index e50c0b576d..3ecf1609e1 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -141,7 +141,7 @@ public:
}
};
-CBlockTemplate* CreateNewBlock(CReserveKey& reservekey)
+CBlockTemplate* CreateNewBlock(const 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;