From 52a3d2635c417c8e2398d9d4853db938171d406b Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Sat, 14 Jan 2012 18:51:52 -0500 Subject: [PATCH 1/2] Separated COINBASE_FLAGS out into main.h and made RPC getmemorypool return it --- src/bitcoinrpc.cpp | 2 ++ src/main.cpp | 7 +------ src/main.h | 6 ++++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index db595cbf..50375dd9 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1871,6 +1871,7 @@ Value getmemorypool(const Array& params, bool fHelp) " \"previousblockhash\" : hash of current highest block\n" " \"transactions\" : contents of non-coinbase transactions that should be included in the next block\n" " \"coinbasevalue\" : maximum allowable input to coinbase transaction, including the generation award and transaction fees\n" + " \"coinbaseflags\" : data that should be included in coinbase so support for new features can be judged\n" " \"time\" : timestamp appropriate for next block\n" " \"bits\" : compressed target of next block\n" "If [data] is specified, tries to solve the block and returns true if it was successful."); @@ -1925,6 +1926,7 @@ Value getmemorypool(const Array& params, bool fHelp) result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.push_back(Pair("transactions", transactions)); result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); + result.push_back(Pair("coinbaseflags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end()))); result.push_back(Pair("time", (int64_t)pblock->nTime)); union { diff --git a/src/main.cpp b/src/main.cpp index 3c3f0660..891dbed9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3130,12 +3130,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& hashPrevBlock = pblock->hashPrevBlock; } ++nExtraNonce; - pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nTime << CBigNum(nExtraNonce); - - // Put "/P2SH/" in the coinbase so everybody can tell when - // a majority of miners support it - const char* pszP2SH = "/P2SH/"; - pblock->vtx[0].vin[0].scriptSig += CScript() << std::vector(pszP2SH, pszP2SH+strlen(pszP2SH)); + pblock->vtx[0].vin[0].scriptSig = (CScript() << pblock->nTime << CBigNum(nExtraNonce)) + COINBASE_FLAGS; assert(pblock->vtx[0].vin[0].scriptSig.size() <= 100); pblock->hashMerkleRoot = pblock->BuildMerkleTree(); diff --git a/src/main.h b/src/main.h index 678c14cc..be5f2f58 100644 --- a/src/main.h +++ b/src/main.h @@ -49,6 +49,12 @@ static const int fHaveUPnP = false; #endif +// Put "/P2SH/" in the coinbase so everybody can tell when +// a majority of miners support it +static const char* pszP2SH = "/P2SH/"; +static const CScript COINBASE_FLAGS = CScript() << std::vector(pszP2SH, pszP2SH+strlen(pszP2SH)); + + From ab845122587ed5bef403fcce1891a52501602a5a Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Sat, 14 Jan 2012 18:52:23 -0500 Subject: [PATCH 2/2] Added mintime and curtime to RPC getmemorypool --- src/bitcoinrpc.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 50375dd9..5ac58de0 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1873,6 +1873,8 @@ Value getmemorypool(const Array& params, bool fHelp) " \"coinbasevalue\" : maximum allowable input to coinbase transaction, including the generation award and transaction fees\n" " \"coinbaseflags\" : data that should be included in coinbase so support for new features can be judged\n" " \"time\" : timestamp appropriate for next block\n" + " \"mintime\" : minimum timestamp appropriate for next block\n" + " \"curtime\" : current timestamp\n" " \"bits\" : compressed target of next block\n" "If [data] is specified, tries to solve the block and returns true if it was successful."); @@ -1928,6 +1930,8 @@ Value getmemorypool(const Array& params, bool fHelp) result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); result.push_back(Pair("coinbaseflags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end()))); result.push_back(Pair("time", (int64_t)pblock->nTime)); + result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1)); + result.push_back(Pair("curtime", (int64_t)GetAdjustedTime())); union { int32_t nBits;