MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetTransactionInputWeight

Function GetTransactionInputWeight

src/consensus/validation.h:156–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156static inline int64_t GetTransactionInputWeight(const CTransaction& tx, const size_t nIn)
157{
158 // scriptWitness size is added here because witnesses and txins are split up in segwit serialization.
159 assert(tx.witness.vtxinwit.size() > nIn);
160 // ELEMENTS: This is only used for change size calculation in wallet, assert if
161 // anything is unexpected for this call e.g. issuances, rangeproofs
162 assert(tx.witness.vtxinwit[nIn].vchIssuanceAmountRangeproof.empty());
163 assert(tx.witness.vtxinwit[nIn].vchInflationKeysRangeproof.empty());
164
165 return ::GetSerializeSize(tx.vin[nIn], PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1)
166 + ::GetSerializeSize(tx.vin[nIn], PROTOCOL_VERSION)
167 + ::GetSerializeSize(tx.witness.vtxinwit[nIn].scriptWitness.stack, PROTOCOL_VERSION);
168}
169
170/** Compute at which vout of the block's coinbase transaction the witness commitment occurs, or -1 if not found */
171inline int GetWitnessCommitmentIndex(const CBlock& block)

Callers 6

FillInputToWeightFunction · 0.85
TestFillInputToWeightFunction · 0.85
BOOST_FIXTURE_TEST_CASEFunction · 0.85
FundTransactionFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls 3

GetSerializeSizeFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45

Tested by 3

TestFillInputToWeightFunction · 0.68
BOOST_FIXTURE_TEST_CASEFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68