mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
finalizecompactblock: Fix it, make test easier to fail
This commit is contained in:
parent
8fd1b52f9d
commit
7126d1fe38
2 changed files with 15 additions and 4 deletions
|
|
@ -1368,7 +1368,7 @@ UniValue finalizecompactblock(const JSONRPCRequest& request)
|
|||
|
||||
// Cached transactions
|
||||
std::vector<unsigned char> found_tx(ParseHex(request.params[2].get_str()));
|
||||
CDataStream ssFound(block_tx, SER_NETWORK, PROTOCOL_VERSION);
|
||||
CDataStream ssFound(found_tx, SER_NETWORK, PROTOCOL_VERSION);
|
||||
|
||||
std::vector<CTransactionRef> found;
|
||||
ssFound >> found;
|
||||
|
|
@ -1380,10 +1380,21 @@ UniValue finalizecompactblock(const JSONRPCRequest& request)
|
|||
CTxMemPool dummy_pool;
|
||||
PartiallyDownloadedBlock partialBlock(&dummy_pool);
|
||||
|
||||
const std::vector<std::pair<uint256, CTransactionRef>> dummy;
|
||||
// "Extra" list is really our combined list that will be put into place using InitData
|
||||
std::vector<std::pair<uint256, CTransactionRef>> extra_txn;
|
||||
for (const auto& found_tx : found) {
|
||||
extra_txn.push_back(std::make_pair(found_tx->GetWitnessHash(), found_tx));
|
||||
}
|
||||
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
||||
if (partialBlock.InitData(cmpctblock, dummy) != READ_STATUS_OK || partialBlock.FillBlock(*pblock, found, false /* pow_check*/) != READ_STATUS_OK) {
|
||||
if (partialBlock.InitData(cmpctblock, extra_txn) != READ_STATUS_OK) {
|
||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "compact_hex appears malformed.");
|
||||
}
|
||||
const std::vector<CTransactionRef> dummy_missing;
|
||||
auto result = partialBlock.FillBlock(*pblock, dummy_missing, false /* pow_check*/);
|
||||
if (result == READ_STATUS_FAILED) {
|
||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Failed to complete block though all transactions were apparently found. Could be random short ID collision; requires full block instead.");
|
||||
} else if (result != READ_STATUS_OK) {
|
||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Failed to complete block though all transactions were apparently found.");
|
||||
}
|
||||
|
||||
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class BlockSignTest(BitcoinTestFramework):
|
|||
|
||||
# Make a few transactions to make non-empty blocks for compact transmission
|
||||
if make_transactions:
|
||||
for i in range(5):
|
||||
for i in range(20):
|
||||
miner.sendtoaddress(miner_next.getnewaddress(), int(miner.getbalance()['bitcoin']/10), "", "", True)
|
||||
# miner makes a block
|
||||
block = miner.getnewblockhex()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue