mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
BIP141: Commitment structure and deployment
Includes a fix by Suhas Daftuar and LongShao007
This commit is contained in:
parent
449f9b8deb
commit
8b49040854
13 changed files with 225 additions and 13 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue