Skip to content

Commit d0c18ed

Browse files
committed
CTxOut: add IsConfidential method
1 parent 971cbe1 commit d0c18ed

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/policy/discount.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ static inline int64_t GetDiscountVirtualTransactionSize(const CTransaction& tx,
2424
// for each confidential output
2525
for (size_t i = 0; i < tx.vout.size(); ++i) {
2626
const CTxOut& output = tx.vout[i];
27-
if (output.IsFee()) continue;
28-
if (output.nAsset.IsCommitment() && output.nValue.IsCommitment()) {
27+
if (output.IsFee()) {
28+
continue;
29+
} else if (output.IsConfidential()) {
2930
// subtract the weight of the output witness
3031
weight -= ::GetSerializeSize(tx.witness.vtxoutwit[i], PROTOCOL_VERSION);
3132
// subtract the weight difference of amount commitment (33) vs explicit amount (9)

src/primitives/transaction.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,12 @@ class CTxOut
345345
{
346346
return a.scriptPubKey < b.scriptPubKey;
347347
}
348+
349+
// ELEMENTS: a "confidential" output has commitments instead of explicit values
350+
bool IsConfidential() const
351+
{
352+
return nValue.IsCommitment() && nAsset.IsCommitment() && nNonce.IsCommitment();
353+
}
348354
};
349355

350356
struct CMutableTransaction;

0 commit comments

Comments
 (0)