Skip to content

Commit 2cb47d1

Browse files
committed
Disallow coinbase output witness data, since outputs are explicit anyways
1 parent 8b2e885 commit 2cb47d1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/confidential_validation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,14 @@ bool VerifyAmounts(const std::vector<CTxOut>& inputs, const CTransaction& tx, st
406406

407407
bool VerifyCoinbaseAmount(const CTransaction& tx, const CAmountMap& mapFees) {
408408
assert(tx.IsCoinBase());
409+
410+
// Miner shouldn't be stuffing witness data
411+
for (const auto& outwit : tx.witness.vtxoutwit) {
412+
if (!outwit.IsNull()) {
413+
return false;
414+
}
415+
}
416+
409417
CAmountMap remaining = mapFees;
410418
for (unsigned int i = 0; i < tx.vout.size(); i++) {
411419
const CTxOut& out = tx.vout[i];

test/functional/feature_txwitness.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ def WitToHex(obj):
167167
block_witness_stuffed = copy.deepcopy(block_struct)
168168

169169

170-
# Add extra witness data that is covered by witness merkle root, make sure invalid until
171-
# witness merkle root is recalculated
170+
# Add extra witness data that is covered by witness merkle root, make sure invalid
172171
assert_equal(block_witness_stuffed.vtx[0].wit.vtxoutwit[0].vchSurjectionproof, b'')
173172
assert_equal(block_witness_stuffed.vtx[0].wit.vtxoutwit[0].vchRangeproof, b'')
174173
block_witness_stuffed.vtx[0].wit.vtxoutwit[0].vchRangeproof = b'\x00'*100000
@@ -180,7 +179,7 @@ def WitToHex(obj):
180179
block_witness_stuffed.vtx[0].rehash()
181180
block_witness_stuffed.hashMerkleRoot = block_witness_stuffed.calc_merkle_root()
182181
block_witness_stuffed.rehash()
183-
self.nodes[0].testproposedblock(WitToHex(block_witness_stuffed))
182+
assert_raises_rpc_error(-25, "bad-cb-amount", self.nodes[0].testproposedblock, WitToHex(block_witness_stuffed))
184183
assert_greater_than(len(WitToHex(block_witness_stuffed)), 100000*4) # Make sure the witness data is actually serialized
185184

186185
# Test that issuance inputs in coinbase don't survive a serialization round-trip

0 commit comments

Comments
 (0)