Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update script builder for BIP0062 and enforce limits.
BIP0062 defines specific rules and canonical encodings for data pushes. The existing script builder code already conformed to all but one of the canonical data push rules that was added after it was originally implemented (adding a single byte of 0x81 must be converted to OP_1NEGATE). This commit implements that case and expands the existing tests to explicitly cover all cases mentioned in BIP0062. In addition, as a part of this change, the AddData function has been modified so that any attempt to push more than the maximum script element size bytes (520) in one push or any pushes the would cause the script to exceed the maximum script bytes allowed by the script engine (10000) will result in the final call to the Script function to only return the script up to the point of the first error along with the error. This change should have little effect on existing callers since they are almost positively not creating scripts which violate these rules as they could never be executed, however it does mean they need to check the new error return. Since the regression tests intentionally need to be able to exceed that limit, a new function named AddFullData has been added which does not enforce the limits, but still provides canonical encoding of the pushed data. Note that this commit does not affect consensus rules nor modify the script engine. Also, the tests have been marked so they can run in parallel.
- Loading branch information
Showing
5 changed files
with
481 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.