MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / IsStandardTx

Function IsStandardTx

src/main.cpp:193–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193bool 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
218bool VerifySignature(const uint256 &sigHash, const std::vector<uint8_t> &signature, const CPubKey &pubKey) {
219 if (signature.size() == 0 && signature.size() >= MAX_SIGNATURE_SIZE) {

Callers 1

AcceptToMemoryPoolFunction · 0.85

Calls 2

GetSerializeSizeFunction · 0.85
GetNewInstanceMethod · 0.45

Tested by

no test coverage detected