diff options
| author | Andrew Chow <[email protected]> | 2018-03-05 16:37:24 -0500 |
|---|---|---|
| committer | Andrew Chow <[email protected]> | 2018-03-09 21:15:36 -0500 |
| commit | 12ec29d3bb0d46c61712210fe9bb96a0d543204a (patch) | |
| tree | 5570d616050510641d8f55d894da60048841e6cf /src/consensus/validation.h | |
| parent | Merge #9598: Improve readability by removing redundant casts to same type (on... (diff) | |
| download | discoin-12ec29d3bb0d46c61712210fe9bb96a0d543204a.tar.xz discoin-12ec29d3bb0d46c61712210fe9bb96a0d543204a.zip | |
Calculate and store the number of bytes required to spend an input
Diffstat (limited to 'src/consensus/validation.h')
| -rw-r--r-- | src/consensus/validation.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/consensus/validation.h b/src/consensus/validation.h index c2a343c15..757df518a 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -101,5 +101,10 @@ static inline int64_t GetBlockWeight(const CBlock& block) { return ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION); } +static inline int64_t GetTransationInputWeight(const CTxIn& txin) +{ + // scriptWitness size is added here because witnesses and txins are split up in segwit serialization. + return ::GetSerializeSize(txin, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(txin, SER_NETWORK, PROTOCOL_VERSION) + ::GetSerializeSize(txin.scriptWitness.stack, SER_NETWORK, PROTOCOL_VERSION); +} #endif // BITCOIN_CONSENSUS_VALIDATION_H |