aboutsummaryrefslogtreecommitdiff
path: root/src/consensus
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2018-03-05 16:37:24 -0500
committerAndrew Chow <achow101-github@achow101.com>2018-03-09 21:15:36 -0500
commit12ec29d3bb0d46c61712210fe9bb96a0d543204a (patch)
tree5570d616050510641d8f55d894da60048841e6cf /src/consensus
parenta34ac6ae0788b50e12dd2c8ac59dbda2a03a3c2e (diff)
downloadbitcoin-12ec29d3bb0d46c61712210fe9bb96a0d543204a.tar.xz
Calculate and store the number of bytes required to spend an input
Diffstat (limited to 'src/consensus')
-rw-r--r--src/consensus/validation.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/consensus/validation.h b/src/consensus/validation.h
index c2a343c155..757df518ae 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