Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1001("t21", CScript([pubs[1], OP_CHECKSIGVERIFY, OP_1] + [OP_DUP] * 999 + [OP_DROP] * 999)),1002# 22) Script that grows the stack to 1001 elements1003("t22", CScript([pubs[1], OP_CHECKSIGVERIFY, OP_1] + [OP_DUP] * 1000 + [OP_DROP] * 1000)),1004# 23) Script that expects an input stack of 1000 elements1005("t23", CScript([OP_DROP] * 999 + [pubs[1], OP_CHECKSIG])),1006# 24) Script that expects an input stack of 1001 elements1007("t24", CScript([OP_DROP] * 1000 + [pubs[1], OP_CHECKSIG])),1008# 25) Script that pushes a MAX_SCRIPT_ELEMENT_SIZE-bytes element1009("t25", CScript([random.randbytes(MAX_SCRIPT_ELEMENT_SIZE), OP_DROP, pubs[1], OP_CHECKSIG])),1010# 26) Script that pushes a (MAX_SCRIPT_ELEMENT_SIZE+1)-bytes element1011("t26", CScript([random.randbytes(MAX_SCRIPT_ELEMENT_SIZE+1), OP_DROP, pubs[1], OP_CHECKSIG])),1012# 27) CHECKSIGADD that must fail because numeric argument number is >4 bytes1013("t27", CScript([CScriptNum(OVERSIZE_NUMBER), pubs[1], OP_CHECKSIGADD])),1014# 28) Pushes random CScriptNum value, checks OP_CHECKSIGADD result1015("t28", CScript([csa_high_val, pubs[1], OP_CHECKSIGADD, csa_high_result, OP_EQUAL])),1016# 29) CHECKSIGADD that succeeds with proper sig because numeric argument number is <=4 bytes1017("t29", CScript([CScriptNum(OVERSIZE_NUMBER-1), pubs[1], OP_CHECKSIGADD])),1018# 30) Variant of t1 with "normal" 33-byte pubkey1019("t30", CScript([b'\x03' + pubs[1], OP_CHECKSIG])),1020# 31) Variant of t2 with "normal" 33-byte pubkey1021("t31", CScript([b'\x02' + pubs[1], OP_CHECKSIGVERIFY, OP_1])),1022# 32) Variant of t28 with "normal" 33-byte pubkey1023("t32", CScript([csa_high_val, b'\x03' + pubs[1], OP_CHECKSIGADD, csa_high_result, OP_EQUAL])),1024# 33) 999-of-999 multisig1025("t33", CScript(big_scriptops[:1998] + [OP_1])),1026# 34) 1000-of-1000 multisig1027("t34", CScript(big_scriptops[:2000] + [OP_1])),1028# 35) Variant of t9 that uses a non-minimally encoded input arg1029("t35", CScript([bytes([csa_low_val]), pubs[1], OP_CHECKSIGADD, csa_low_result, OP_EQUAL])),1030# 36) Empty script1031("t36", CScript([])),1032]1033# Add many dummies to test huge trees1034for j in range(100000):1035scripts.append((None, CScript([OP_RETURN, random.randrange(100000)])))1036random.shuffle(scripts)1037tap = taproot_construct(pubs[0], scripts)1038common = {1039"hashtype": hashtype,1040"key": secs[1],1041"tap": tap,1042}1043# Test that MAX_SCRIPT_ELEMENT_SIZE byte stack element inputs are valid, but not one more (and 80 bytes is standard but 81 is not).1044add_spender(spenders, "tapscript/inputmaxlimit", leaf="t0", **common, standard=False, inputs=[getter("sign"), random.randbytes(MAX_SCRIPT_ELEMENT_SIZE)], failure={"inputs": [getter("sign"), random.randbytes(MAX_SCRIPT_ELEMENT_SIZE+1)]}, **ERR_PUSH_SIZE)1045add_spender(spenders, "tapscript/input80limit", leaf="t0", **common, inputs=[getter("sign"), random.randbytes(80)])1046add_spender(spenders, "tapscript/input81limit", leaf="t0", **common, standard=False, inputs=[getter("sign"), random.randbytes(81)])1047# Test that OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY cause failure, but OP_CHECKSIG and OP_CHECKSIGVERIFY work.1048add_spender(spenders, "tapscript/disabled_checkmultisig", leaf="t1", **common, **SINGLE_SIG, failure={"leaf": "t3"}, **ERR_TAPSCRIPT_CHECKMULTISIG)1049add_spender(spenders, "tapscript/disabled_checkmultisigverify", leaf="t2", **common, **SINGLE_SIG, failure={"leaf": "t4"}, **ERR_TAPSCRIPT_CHECKMULTISIG)1050# Test that OP_IF and OP_NOTIF do not accept non-0x01 as truth value (the MINIMALIF rule is consensus in Tapscript)1051add_spender(spenders, "tapscript/minimalif", leaf="t5", **common, inputs=[getter("sign"), b'\x01'], failure={"inputs": [getter("sign"), b'\x02']}, **ERR_TAPSCRIPT_MINIMALIF)1052add_spender(spenders, "tapscript/minimalnotif", leaf="t6", **common, inputs=[getter("sign"), b'\x01'], failure={"inputs": [getter("sign"), b'\x03']}, **ERR_TAPSCRIPT_MINIMALIF)1053add_spender(spenders, "tapscript/minimalif", leaf="t5", **common, inputs=[getter("sign"), b'\x01'], failure={"inputs": [getter("sign"), b'\x0001']}, **ERR_TAPSCRIPT_MINIMALIF)1054add_spender(spenders, "tapscript/minimalnotif", leaf="t6", **common, inputs=[getter("sign"), b'\x01'], failure={"inputs": [getter("sign"), b'\x0100']}, **ERR_TAPSCRIPT_MINIMALIF)1055# Test that 1-byte public keys (which are unknown) are acceptable but nonstandard with unrelated signatures, but 0-byte public keys are not valid.1056add_spender(spenders, "tapscript/unkpk/checksig", leaf="t16", standard=False, **common, **SINGLE_SIG, failure={"leaf": "t7"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1057add_spender(spenders, "tapscript/unkpk/checksigadd", leaf="t17", standard=False, **common, **SINGLE_SIG, failure={"leaf": "t10"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1058add_spender(spenders, "tapscript/unkpk/checksigverify", leaf="t18", standard=False, **common, **SINGLE_SIG, failure={"leaf": "t8"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1059# Test that 33-byte public keys (which are unknown) are acceptable but nonstandard with valid signatures, but normal pubkeys are not valid in that case.1060add_spender(spenders, "tapscript/oldpk/checksig", leaf="t30", standard=False, **common, **SINGLE_SIG, sighash=bitflipper(default_sighash), failure={"leaf": "t1"}, **ERR_SCHNORR_SIG)1061add_spender(spenders, "tapscript/oldpk/checksigadd", leaf="t31", standard=False, **common, **SINGLE_SIG, sighash=bitflipper(default_sighash), failure={"leaf": "t2"}, **ERR_SCHNORR_SIG)1062add_spender(spenders, "tapscript/oldpk/checksigverify", leaf="t32", standard=False, **common, **SINGLE_SIG, sighash=bitflipper(default_sighash), failure={"leaf": "t28"}, **ERR_SCHNORR_SIG)1063# Test that 0-byte public keys are not acceptable.1064add_spender(spenders, "tapscript/emptypk/checksig", leaf="t1", **SINGLE_SIG, **common, failure={"leaf": "t7"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1065add_spender(spenders, "tapscript/emptypk/checksigverify", leaf="t2", **SINGLE_SIG, **common, failure={"leaf": "t8"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1066add_spender(spenders, "tapscript/emptypk/checksigadd", leaf="t9", **SINGLE_SIG, **common, failure={"leaf": "t10"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1067add_spender(spenders, "tapscript/emptypk/checksigadd", leaf="t35", standard=False, **SINGLE_SIG, **common, failure={"leaf": "t10"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1068# Test that OP_CHECKSIGADD results are as expected1069add_spender(spenders, "tapscript/checksigaddresults", leaf="t28", **SINGLE_SIG, **common, failure={"leaf": "t27"}, **ERR_SCRIPT_NUM)1070add_spender(spenders, "tapscript/checksigaddoversize", leaf="t29", **SINGLE_SIG, **common, failure={"leaf": "t27"}, **ERR_SCRIPT_NUM)1071# Test that OP_CHECKSIGADD requires 3 stack elements.1072add_spender(spenders, "tapscript/checksigadd3args", leaf="t9", **SINGLE_SIG, **common, failure={"leaf": "t11"}, **ERR_INVALID_STACK_OPERATION)1073# Test that empty signatures do not cause script failure in OP_CHECKSIG and OP_CHECKSIGADD (but do fail with empty pubkey, and do fail OP_CHECKSIGVERIFY)1074add_spender(spenders, "tapscript/emptysigs/checksig", leaf="t12", **common, inputs=[b'', getter("sign")], failure={"leaf": "t13"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1075add_spender(spenders, "tapscript/emptysigs/nochecksigverify", leaf="t12", **common, inputs=[b'', getter("sign")], failure={"leaf": "t20"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1076add_spender(spenders, "tapscript/emptysigs/checksigadd", leaf="t14", **common, inputs=[b'', getter("sign")], failure={"leaf": "t15"}, **ERR_TAPSCRIPT_EMPTY_PUBKEY)1077# Test that scripts over 10000 bytes (and over 201 non-push ops) are acceptable.1078add_spender(spenders, "tapscript/no10000limit", leaf="t19", **SINGLE_SIG, **common)1079# Test that a stack size of 1000 elements is permitted, but 1001 isn't.1080add_spender(spenders, "tapscript/1000stack", leaf="t21", **SINGLE_SIG, **common, failure={"leaf": "t22"}, **ERR_STACK_SIZE)1081# Test that an input stack size of 1000 elements is permitted, but 1001 isn't.1082add_spender(spenders, "tapscript/1000inputs", leaf="t23", **common, inputs=[getter("sign")] + [b'' for _ in range(999)], failure={"leaf": "t24", "inputs": [getter("sign")] + [b'' for _ in range(1000)]}, **ERR_STACK_SIZE)1083# Test that pushing a MAX_SCRIPT_ELEMENT_SIZE byte stack element is valid, but one longer is not.1084add_spender(spenders, "tapscript/pushmaxlimit", leaf="t25", **common, **SINGLE_SIG, failure={"leaf": "t26"}, **ERR_PUSH_SIZE)1085# Test that 999-of-999 multisig works (but 1000-of-1000 triggers stack size limits)1086add_spender(spenders, "tapscript/bigmulti", leaf="t33", **common, inputs=big_spend_inputs, num=999, failure={"leaf": "t34", "num": 1000}, **ERR_STACK_SIZE)1087# Test that the CLEANSTACK rule is consensus critical in tapscript1088add_spender(spenders, "tapscript/cleanstack", leaf="t36", tap=tap, inputs=[b'\x01'], failure={"inputs": [b'\x01', b'\x01']}, **ERR_CLEANSTACK)1090# == Test for sigops ratio limit ==1092# Given a number n, and a public key pk, functions that produce a (CScript, sigops). Each script takes as1093# input a valid signature with the passed pk followed by a dummy push of bytes that are to be dropped, and1094# will execute sigops signature checks.1095SIGOPS_RATIO_SCRIPTS = [1096# n OP_CHECKSIGVERIFYs and 1 OP_CHECKSIG.1097lambda n, pk: (CScript([OP_DROP, pk] + [OP_2DUP, OP_CHECKSIGVERIFY] * n + [OP_CHECKSIG]), n + 1),1098# n OP_CHECKSIGVERIFYs and 1 OP_CHECKSIGADD, but also one unexecuted OP_CHECKSIGVERIFY.1099lambda n, pk: (CScript([OP_DROP, pk, OP_0, OP_IF, OP_2DUP, OP_CHECKSIGVERIFY, OP_ENDIF] + [OP_2DUP, OP_CHECKSIGVERIFY] * n + [OP_2, OP_SWAP, OP_CHECKSIGADD, OP_3, OP_EQUAL]), n + 1),1100# n OP_CHECKSIGVERIFYs and 1 OP_CHECKSIGADD, but also one unexecuted OP_CHECKSIG.1101lambda n, pk: (CScript([random.randbytes(220), OP_2DROP, pk, OP_1, OP_NOTIF, OP_2DUP, OP_CHECKSIG, OP_VERIFY, OP_ENDIF] + [OP_2DUP, OP_CHECKSIGVERIFY] * n + [OP_4, OP_SWAP, OP_CHECKSIGADD, OP_5, OP_EQUAL]), n + 1),1102# n OP_CHECKSIGVERIFYs and 1 OP_CHECKSIGADD, but also one unexecuted OP_CHECKSIGADD.1103lambda n, pk: (CScript([OP_DROP, pk, OP_1, OP_IF, OP_ELSE, OP_2DUP, OP_6, OP_SWAP, OP_CHECKSIGADD, OP_7, OP_EQUALVERIFY, OP_ENDIF] + [OP_2DUP, OP_CHECKSIGVERIFY] * n + [OP_8, OP_SWAP, OP_CHECKSIGADD, OP_9, OP_EQUAL]), n + 1),1104# n+1 OP_CHECKSIGs, but also one OP_CHECKSIG with an empty signature.1105lambda n, pk: (CScript([OP_DROP, OP_0, pk, OP_CHECKSIG, OP_NOT, OP_VERIFY, pk] + [OP_2DUP, OP_CHECKSIG, OP_VERIFY] * n + [OP_CHECKSIG]), n + 1),1106# n OP_CHECKSIGADDs and 1 OP_CHECKSIG, but also an OP_CHECKSIGADD with an empty signature.1107lambda n, pk: (CScript([OP_DROP, OP_0, OP_10, pk, OP_CHECKSIGADD, OP_10, OP_EQUALVERIFY, pk] + [OP_2DUP, OP_16, OP_SWAP, OP_CHECKSIGADD, b'\x11', OP_EQUALVERIFY] * n + [OP_CHECKSIG]), n + 1),1108]1109for annex in [None, bytes([ANNEX_TAG]) + random.randbytes(random.randrange(1000))]:1110for hashtype in [SIGHASH_DEFAULT, SIGHASH_ALL]:1111for pubkey in [pubs[1], random.randbytes(random.choice([x for x in range(2, 81) if x != 32]))]:1112for fn_num, fn in enumerate(SIGOPS_RATIO_SCRIPTS):1113merkledepth = random.randrange(129)1116def predict_sigops_ratio(n, dummy_size):1117"""Predict whether spending fn(n, pubkey) with dummy_size will pass the ratio test."""1118script, sigops = fn(n, pubkey)1119# Predict the size of the witness for a given choice of n1120stacklen_size = 11121sig_size = 64 + (hashtype != SIGHASH_DEFAULT)1122siglen_size = 11123dummylen_size = 1 + 2 * (dummy_size >= 253)1124script_size = len(script)1125scriptlen_size = 1 + 2 * (script_size >= 253)1126control_size = 33 + 32 * merkledepth1127controllen_size = 1 + 2 * (control_size >= 253)1128annex_size = 0 if annex is None else len(annex)1129annexlen_size = 0 if annex is None else 1 + 2 * (annex_size >= 253)1130witsize = stacklen_size + sig_size + siglen_size + dummy_size + dummylen_size + script_size + scriptlen_size + control_size + controllen_size + annex_size + annexlen_size1131# sigops ratio test1132return witsize + 50 >= 50 * sigops1133# Make sure n is high enough that with empty dummy, the script is not valid1134n = 01135while predict_sigops_ratio(n, 0):1136n += 11137# But allow picking a bit higher still1138n += random.randrange(5)1139# Now pick dummy size *just* large enough that the overall construction passes1140dummylen = 01141while not predict_sigops_ratio(n, dummylen):1142dummylen += 11143scripts = [("s", fn(n, pubkey)[0])]1144for _ in range(merkledepth):1145scripts = [scripts, random.choice(PARTNER_MERKLE_FN)]1146tap = taproot_construct(pubs[0], scripts)1147standard = annex is None and dummylen <= 80 and len(pubkey) == 321148add_spender(spenders, "tapscript/sigopsratio_%i" % fn_num, tap=tap, leaf="s", annex=annex, hashtype=hashtype, key=secs[1], inputs=[getter("sign"), random.randbytes(dummylen)], standard=standard, failure={"inputs": [getter("sign"), random.randbytes(dummylen - 1)]}, **ERR_TAPSCRIPT_VALIDATION_WEIGHT)1150# Future leaf versions1151for leafver in range(0, 0x100, 2):1152if leafver == LEAF_VERSION_TAPSCRIPT or leafver == ANNEX_TAG:1153# Skip the defined LEAF_VERSION_TAPSCRIPT, and the ANNEX_TAG which is not usable as leaf version1154continue1155scripts = [1156("bare_c0", CScript([OP_NOP])),1157("bare_unkver", CScript([OP_NOP]), leafver),1158("return_c0", CScript([OP_RETURN])),1159("return_unkver", CScript([OP_RETURN]), leafver),1160("undecodable_c0", CScript([OP_PUSHDATA1])),1161("undecodable_unkver", CScript([OP_PUSHDATA1]), leafver),1162("bigpush_c0", CScript([random.randbytes(MAX_SCRIPT_ELEMENT_SIZE+1), OP_DROP])),1163("bigpush_unkver", CScript([random.randbytes(MAX_SCRIPT_ELEMENT_SIZE+1), OP_DROP]), leafver),1164("1001push_c0", CScript([OP_0] * 1001)),1165("1001push_unkver", CScript([OP_0] * 1001), leafver),1166]1167random.shuffle(scripts)1168tap = taproot_construct(pubs[0], scripts)1169add_spender(spenders, "unkver/bare", standard=False, tap=tap, leaf="bare_unkver", failure={"leaf": "bare_c0"}, **ERR_CLEANSTACK)1170add_spender(spenders, "unkver/return", standard=False, tap=tap, leaf="return_unkver", failure={"leaf": "return_c0"}, **ERR_OP_RETURN)1171add_spender(spenders, "unkver/undecodable", standard=False, tap=tap, leaf="undecodable_unkver", failure={"leaf": "undecodable_c0"}, **ERR_BAD_OPCODE)1172add_spender(spenders, "unkver/bigpush", standard=False, tap=tap, leaf="bigpush_unkver", failure={"leaf": "bigpush_c0"}, **ERR_PUSH_SIZE)1173add_spender(spenders, "unkver/1001push", standard=False, tap=tap, leaf="1001push_unkver", failure={"leaf": "1001push_c0"}, **ERR_STACK_SIZE)1174add_spender(spenders, "unkver/1001inputs", standard=False, tap=tap, leaf="bare_unkver", inputs=[b'']*1001, failure={"leaf": "bare_c0"}, **ERR_STACK_SIZE)1176# OP_SUCCESSx tests.1177def hashtype(_):1178return random.choice(VALID_SIGHASHES_TAPROOT)1180for opval in range(76, 0x100):1181opcode = CScriptOp(opval)1182if not is_op_success(opcode):1183continue1184scripts = [1185("bare_success", CScript([opcode])),1186("bare_nop", CScript([OP_NOP])),1187("unexecif_success", CScript([OP_0, OP_IF, opcode, OP_ENDIF])),1188("unexecif_nop", CScript([OP_0, OP_IF, OP_NOP, OP_ENDIF])),1189("return_success", CScript([OP_RETURN, opcode])),1190("return_nop", CScript([OP_RETURN, OP_NOP])),1191("undecodable_success", CScript([opcode, OP_PUSHDATA1])),1192("undecodable_nop", CScript([OP_NOP, OP_PUSHDATA1])),1193("undecodable_bypassed_success", CScript([OP_PUSHDATA1, OP_2, opcode])),1194("bigpush_success", CScript([random.randbytes(MAX_SCRIPT_ELEMENT_SIZE+1), OP_DROP, opcode])),1195("bigpush_nop", CScript([random.randbytes(MAX_SCRIPT_ELEMENT_SIZE+1), OP_DROP, OP_NOP])),1196("1001push_success", CScript([OP_0] * 1001 + [opcode])),1197("1001push_nop", CScript([OP_0] * 1001 + [OP_NOP])),1198]1199random.shuffle(scripts)1200tap = taproot_construct(pubs[0], scripts)1201add_spender(spenders, "opsuccess/bare", standard=False, tap=tap, leaf="bare_success", failure={"leaf": "bare_nop"}, **ERR_CLEANSTACK)1202add_spender(spenders, "opsuccess/unexecif", standard=False, tap=tap, leaf="unexecif_success", failure={"leaf": "unexecif_nop"}, **ERR_CLEANSTACK)1203add_spender(spenders, "opsuccess/return", standard=False, tap=tap, leaf="return_success", failure={"leaf": "return_nop"}, **ERR_OP_RETURN)1204add_spender(spenders, "opsuccess/undecodable", standard=False, tap=tap, leaf="undecodable_success", failure={"leaf": "undecodable_nop"}, **ERR_BAD_OPCODE)1205add_spender(spenders, "opsuccess/undecodable_bypass", standard=False, tap=tap, leaf="undecodable_success", failure={"leaf": "undecodable_bypassed_success"}, **ERR_BAD_OPCODE)1206add_spender(spenders, "opsuccess/bigpush", standard=False, tap=tap, leaf="bigpush_success", failure={"leaf": "bigpush_nop"}, **ERR_PUSH_SIZE)1207add_spender(spenders, "opsuccess/1001push", standard=False, tap=tap, leaf="1001push_success", failure={"leaf": "1001push_nop"}, **ERR_STACK_SIZE)1208add_spender(spenders, "opsuccess/1001inputs", standard=False, tap=tap, leaf="bare_success", inputs=[b'']*1001, failure={"leaf": "bare_nop"}, **ERR_STACK_SIZE)1209add_spender(spenders, "opsuccess/bigstackelem", standard=False, tap=tap, leaf="bare_success", inputs=[random.randbytes(MAX_SCRIPT_ELEMENT_SIZE+1)], failure={"leaf": "bare_nop"}, **ERR_PUSH_SIZE)1211# Non-OP_SUCCESSx (verify that those aren't accidentally treated as OP_SUCCESSx)1212for opval in range(0, 0x100):1213opcode = CScriptOp(opval)1214if is_op_success(opcode):1215continue1216scripts = [1217("normal", CScript([OP_RETURN, opcode] + [OP_NOP] * 75)),1218("op_success", CScript([OP_RETURN, CScriptOp(0x50)]))1219]1220tap = taproot_construct(pubs[0], scripts)1221add_spender(spenders, "alwaysvalid/notsuccessx", tap=tap, leaf="op_success", inputs=[], standard=False, failure={"leaf": "normal"}) # err_msg differs based on opcode1223# == Test case for https://github.com/bitcoin/bitcoin/issues/24765 ==1225def zero_fn(h):1226return bytes([0] * 32)1228tap = taproot_construct(pubs[0], [("leaf", CScript([pubs[1], OP_CHECKSIG, pubs[1], OP_CHECKSIGADD, OP_2, OP_EQUAL])), zero_fn])1229add_spender(spenders, "case24765", tap=tap, leaf="leaf", inputs=[getter("sign"), getter("sign")], key=secs[1], no_fail=True)1231# == Legacy tests ==1233# Also add a few legacy spends into the mix, so that transactions which combine taproot and pre-taproot spends get tested too.1234for compressed in [False, True]:1235eckey1, pubkey1 = generate_keypair(compressed=compressed)1236eckey2, _ = generate_keypair(compressed=compressed)1237for p2sh in [False, True]:1238for witv0 in [False, True]:1239for hashtype in VALID_SIGHASHES_ECDSA + [random.randrange(0x04, 0x80), random.randrange(0x84, 0x100)]:1240standard = (hashtype in VALID_SIGHASHES_ECDSA) and (compressed or not witv0)1241add_spender(spenders, "legacy/pk-wrongkey", hashtype=hashtype, p2sh=p2sh, witv0=witv0, standard=standard, script=key_to_p2pk_script(pubkey1), **SINGLE_SIG, key=eckey1, failure={"key": eckey2}, sigops_weight=4-3*witv0, **ERR_EVAL_FALSE)1242add_spender(spenders, "legacy/pkh-sighashflip", hashtype=hashtype, p2sh=p2sh, witv0=witv0, standard=standard, pkh=pubkey1, key=eckey1, **SIGHASH_BITFLIP, sigops_weight=4-3*witv0, **ERR_EVAL_FALSE)1244# Verify that OP_CHECKSIGADD wasn't accidentally added to pre-taproot validation logic.1245for p2sh in [False, True]:1246for witv0 in [False, True]:1247for hashtype in VALID_SIGHASHES_ECDSA + [random.randrange(0x04, 0x80), random.randrange(0x84, 0x100)]:1248standard = hashtype in VALID_SIGHASHES_ECDSA and (p2sh or witv0)1249add_spender(spenders, "compat/nocsa", hashtype=hashtype, p2sh=p2sh, witv0=witv0, standard=standard, script=CScript([OP_IF, OP_11, pubkey1, OP_CHECKSIGADD, OP_12, OP_EQUAL, OP_ELSE, pubkey1, OP_CHECKSIG, OP_ENDIF]), key=eckey1, sigops_weight=4-3*witv0, inputs=[getter("sign"), b''], failure={"inputs": [getter("sign"), b'\x01']}, **ERR_BAD_OPCODE)
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.