| 191 | } |
| 192 | |
| 193 | bool IsStandardTx(CBaseTx *pBaseTx, string &reason) { |
| 194 | AssertLockHeld(cs_main); |
| 195 | if (pBaseTx->nVersion > CBaseTx::CURRENT_VERSION || pBaseTx->nVersion < 1) { |
| 196 | reason = "version"; |
| 197 | return false; |
| 198 | } |
| 199 | |
| 200 | // Extremely large transactions with lots of inputs can cost the network |
| 201 | // almost as much to process as they cost the sender in fees, because |
| 202 | // computing signature hashes is O(ninputs*txsize). Limiting transactions |
| 203 | // to MAX_STANDARD_TX_SIZE mitigates CPU exhaustion attacks. |
| 204 | uint32_t sz = ::GetSerializeSize(pBaseTx->GetNewInstance(), SER_NETWORK, CBaseTx::CURRENT_VERSION); |
| 205 | if (pBaseTx->nTxType != UNIVERSAL_TX && sz >= MAX_STANDARD_TX_SIZE) { |
| 206 | reason = strprintf("common tx siz exceeds max: %d", MAX_STANDARD_TX_SIZE); |
| 207 | return false; |
| 208 | } |
| 209 | |
| 210 | if (pBaseTx->nTxType == UNIVERSAL_TX && sz >= MAX_CONTRACT_TX_SIZE) { |
| 211 | reason = strprintf("contract tx size exceeds max: %d", MAX_CONTRACT_TX_SIZE); |
| 212 | return false; |
| 213 | } |
| 214 | |
| 215 | return true; |
| 216 | } |
| 217 | |
| 218 | bool VerifySignature(const uint256 &sigHash, const std::vector<uint8_t> &signature, const CPubKey &pubKey) { |
| 219 | if (signature.size() == 0 && signature.size() >= MAX_SIGNATURE_SIZE) { |
no test coverage detected