| 154 | } |
| 155 | |
| 156 | static 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 */ |
| 171 | inline int GetWitnessCommitmentIndex(const CBlock& block) |