| 847 | } |
| 848 | |
| 849 | int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& inputs, int flags) |
| 850 | { |
| 851 | int64_t nSigOps = GetLegacySigOpCount(tx) * WITNESS_SCALE_FACTOR; |
| 852 | |
| 853 | if (tx.IsCoinBase()) |
| 854 | return nSigOps; |
| 855 | |
| 856 | if (flags & SCRIPT_VERIFY_P2SH) { |
| 857 | nSigOps += GetP2SHSigOpCount(tx, inputs) * WITNESS_SCALE_FACTOR; |
| 858 | } |
| 859 | |
| 860 | for (unsigned int i = 0; i < tx.vin.size(); i++) |
| 861 | { |
| 862 | const CTxOut &prevout = inputs.GetOutputFor(tx.vin[i]); |
| 863 | nSigOps += CountWitnessSigOps(tx.vin[i].scriptSig, prevout.scriptPubKey, i < tx.wit.vtxinwit.size() ? &tx.wit.vtxinwit[i].scriptWitness : NULL, flags); |
| 864 | } |
| 865 | return nSigOps; |
| 866 | } |
| 867 | |
| 868 | bool CheckTransaction(const CTransaction& tx, CValidationState& state) |
| 869 | { |