This pull request adds a new function CheckScriptPushSize
to the transaction validation logic to ensure that the push data within script elements does not exceed the maximum allowed size, as defined by MAX_SCRIPT_ELEMENT_SIZE
.
Motivation and Context
Scripts within transaction outputs are not currently checked for the size of their push data elements. This oversight could potentially allow for scripts with oversized data elements, which might introduce security risks and non-standard transactions into the blockchain. By enforcing this check, we ensure that all scripts adhere to the existing size constraints, improving the robustness of transaction validation.
Changes
- Added
CheckScriptPushSize
function totx_check.cpp
. - Integrated this function into the
CheckTransaction
routine to validate each output’sscriptPubKey
.
Testing
Unit tests have been updated to include tests for CheckScriptPushSize
:
check_script_push_size_tests
ensures that scripts with data elements within and beyond the allowed size are handled correctly.
Impact
This change does not affect the existing blockchain data but will apply to all new transactions, preventing the inclusion of any transactions that violate script size rules in future blocks.
Please review the changes and provide feedback.