txscript: Add remove signature reference test.

An important (and easy for implementations to miss) aspect of the
CHECKSIG opcodes is that the full signature (signature plus hash type)
that is being checked is first removed from the script prior to
calculating the signature hash against which the signature is verified.

It appears the test in the upstream btcsuite code for this was removed
during the initial Decred port instead of being converted as it should
have been.

Consequently, this converts the relevant test so it is correct for
Decred and adds it to the reference tests.  Note that the first of the
two added tests is to ensure the original signature is valid prior to
testing the actual removal condition.
This commit is contained in:
Dave Collins 2019-02-12 21:16:34 -06:00
parent 8cbc7ed672
commit 1f5abadc08
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -5,6 +5,14 @@
["serializedTransaction, verifyFlags]"],
["Objects that are only a single string (like this one) are ignored"],
["A nearly-standard transaction with CHECKSIGVERIFY 1 instead of CHECKSIG"],
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0xe280cb6e66b96679aec288b1fbdbd4db08077a1b EQUALVERIFY CHECKSIGVERIFY 1"]],
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff01000000000000000000000151000000000000000001ffffffffffffffff00000000ffffffff6b483045022100d403cac2b75374b53e7ee906b182d4470e3f7a42195c912c89624b41a9f8d0cd022018f3da9a174f8635b4e54ef5961e0d986d59aebdac56cfacbaaed0c7168aef1c01210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "NONE"],
["Same as above, but with the signature duplicated in the scriptPubKey with the proper pushdata prefix"],
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0xe280cb6e66b96679aec288b1fbdbd4db08077a1b EQUALVERIFY CHECKSIGVERIFY 1 0x48 0x3045022100d403cac2b75374b53e7ee906b182d4470e3f7a42195c912c89624b41a9f8d0cd022018f3da9a174f8635b4e54ef5961e0d986d59aebdac56cfacbaaed0c7168aef1c01"]],
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff01000000000000000000000151000000000000000001ffffffffffffffff00000000ffffffff6b483045022100d403cac2b75374b53e7ee906b182d4470e3f7a42195c912c89624b41a9f8d0cd022018f3da9a174f8635b4e54ef5961e0d986d59aebdac56cfacbaaed0c7168aef1c01210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "NONE"],
["Coinbase of size 2"],
["Note the input is just required to make the tester happy"],
[[["0000000000000000000000000000000000000000000000000000000000000000", -1, "1"]],