mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Disallow coinbase output witness data, since outputs are explicit anyways
This commit is contained in:
parent
8b2e8859d6
commit
2cb47d1705
2 changed files with 10 additions and 3 deletions
|
|
@ -406,6 +406,14 @@ bool VerifyAmounts(const std::vector<CTxOut>& inputs, const CTransaction& tx, st
|
|||
|
||||
bool VerifyCoinbaseAmount(const CTransaction& tx, const CAmountMap& mapFees) {
|
||||
assert(tx.IsCoinBase());
|
||||
|
||||
// Miner shouldn't be stuffing witness data
|
||||
for (const auto& outwit : tx.witness.vtxoutwit) {
|
||||
if (!outwit.IsNull()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
CAmountMap remaining = mapFees;
|
||||
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
||||
const CTxOut& out = tx.vout[i];
|
||||
|
|
|
|||
|
|
@ -167,8 +167,7 @@ class TxWitnessTest(BitcoinTestFramework):
|
|||
block_witness_stuffed = copy.deepcopy(block_struct)
|
||||
|
||||
|
||||
# Add extra witness data that is covered by witness merkle root, make sure invalid until
|
||||
# witness merkle root is recalculated
|
||||
# Add extra witness data that is covered by witness merkle root, make sure invalid
|
||||
assert_equal(block_witness_stuffed.vtx[0].wit.vtxoutwit[0].vchSurjectionproof, b'')
|
||||
assert_equal(block_witness_stuffed.vtx[0].wit.vtxoutwit[0].vchRangeproof, b'')
|
||||
block_witness_stuffed.vtx[0].wit.vtxoutwit[0].vchRangeproof = b'\x00'*100000
|
||||
|
|
@ -180,7 +179,7 @@ class TxWitnessTest(BitcoinTestFramework):
|
|||
block_witness_stuffed.vtx[0].rehash()
|
||||
block_witness_stuffed.hashMerkleRoot = block_witness_stuffed.calc_merkle_root()
|
||||
block_witness_stuffed.rehash()
|
||||
self.nodes[0].testproposedblock(WitToHex(block_witness_stuffed))
|
||||
assert_raises_rpc_error(-25, "bad-cb-amount", self.nodes[0].testproposedblock, WitToHex(block_witness_stuffed))
|
||||
assert_greater_than(len(WitToHex(block_witness_stuffed)), 100000*4) # Make sure the witness data is actually serialized
|
||||
|
||||
# Test that issuance inputs in coinbase don't survive a serialization round-trip
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue