aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/mining.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2015-11-06 01:42:38 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2016-06-22 15:42:59 +0200
commit8b49040854be2e26b66366aeae1cba4716f93d93 (patch)
treeb217f3fb71bc0745c1f74ab239fbe0ebcf52a751 /src/rpc/mining.cpp
parent449f9b8debcceb61a92043bc7031528a53627c47 (diff)
downloadbitcoin-8b49040854be2e26b66366aeae1cba4716f93d93.tar.xz
BIP141: Commitment structure and deployment
Includes a fix by Suhas Daftuar and LongShao007
Diffstat (limited to 'src/rpc/mining.cpp')
-rw-r--r--src/rpc/mining.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 94eeea91f3..291314b8b5 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -348,7 +348,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
" \"transactions\" : [ (array) contents of non-coinbase transactions that should be included in the next block\n"
" {\n"
" \"data\" : \"xxxx\", (string) transaction data encoded in hexadecimal (byte-for-byte)\n"
- " \"hash\" : \"xxxx\", (string) hash/id encoded in little-endian hexadecimal\n"
+ " \"txid\" : \"xxxx\", (string) transaction id encoded in little-endian hexadecimal\n"
+ " \"hash\" : \"xxxx\", (string) hash encoded in little-endian hexadecimal\n"
" \"depends\" : [ (array) array of numbers \n"
" n (numeric) transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is\n"
" ,...\n"
@@ -546,7 +547,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
UniValue transactions(UniValue::VARR);
map<uint256, int64_t> setTxIndex;
int i = 0;
- BOOST_FOREACH (const CTransaction& tx, pblock->vtx) {
+ BOOST_FOREACH (CTransaction& tx, pblock->vtx) {
uint256 txHash = tx.GetHash();
setTxIndex[txHash] = i++;
@@ -556,8 +557,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
UniValue entry(UniValue::VOBJ);
entry.push_back(Pair("data", EncodeHexTx(tx)));
-
- entry.push_back(Pair("hash", txHash.GetHex()));
+ entry.push_back(Pair("txid", txHash.GetHex()));
+ entry.push_back(Pair("hash", tx.GetWitnessHash().GetHex()));
UniValue deps(UniValue::VARR);
BOOST_FOREACH (const CTxIn &in, tx.vin)
@@ -656,6 +657,9 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
result.push_back(Pair("curtime", pblock->GetBlockTime()));
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
+ if (!pblocktemplate->vchCoinbaseCommitment.empty()) {
+ result.push_back(Pair("default_witness_commitment", HexStr(pblocktemplate->vchCoinbaseCommitment.begin(), pblocktemplate->vchCoinbaseCommitment.end())));
+ }
return result;
}
@@ -719,6 +723,14 @@ UniValue submitblock(const UniValue& params, bool fHelp)
}
}
+ {
+ LOCK(cs_main);
+ BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
+ if (mi != mapBlockIndex.end()) {
+ UpdateUncommittedBlockStructures(block, mi->second, Params().GetConsensus());
+ }
+ }
+
CValidationState state;
submitblock_StateCatcher sc(block.GetHash());
RegisterValidationInterface(&sc);