Skip to content

Commit

Permalink
fixup! discount: assert on witness size
Browse files Browse the repository at this point in the history
  • Loading branch information
delta1 committed May 6, 2024
1 parent a67b08f commit 4fb3706
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/policy/discount.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ static inline int64_t GetDiscountVirtualTransactionSize(const CTransaction& tx,
const CTxOut& output = tx.vout[i];
if (i < tx.witness.vtxoutwit.size()) {
// subtract the weight of the output witness, except the 2 bytes used to serialize the empty proofs
int64_t witness_size = ::GetSerializeSize(tx.witness.vtxoutwit[i], PROTOCOL_VERSION) - 2;
assert(witness_size >= 0);
weight -= witness_size;
size_t witness_size = ::GetSerializeSize(tx.witness.vtxoutwit[i], PROTOCOL_VERSION);
assert(witness_size >= 2);
weight -= (witness_size - 2);
}
if (output.nValue.IsCommitment()) {
// subtract the weight difference of amount commitment (33) vs explicit amount (9)
Expand Down
2 changes: 0 additions & 2 deletions test/functional/feature_discount_ct_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def run_test(self):
info = node1.getaddressinfo(addr)
txid = node0.sendtoaddress(info['unconfidential'], 1.0, "", "", False, None, None, None, None, None, None, feerate)
tx = node0.gettransaction(txid, True, True)
print(tx['hex'])
decoded = tx['decoded']
vin = decoded['vin']
vout = decoded['vout']
Expand Down Expand Up @@ -146,7 +145,6 @@ def run_test(self):
self.sync_mempools([node1, node2])
tx = node1.gettransaction(txid, True, True)
decoded = tx['decoded']
print(decoded['fee'])
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000820'))

# check that txs in the block template are in decreasing feerate according to their discount size
Expand Down

0 comments on commit 4fb3706

Please sign in to comment.