mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 22:36:34 +01:00
Fix containsOpSuccess
implementation (#4480)
* Fix containsOpSuccess implementation * Cache opSuccessBytes
This commit is contained in:
parent
0397ca6c78
commit
ec599a5c3d
2 changed files with 29 additions and 7 deletions
|
@ -1,3 +1,17 @@
|
|||
[
|
||||
{"tx": "0200000001d3d2f0976d67794790c9f874f40bc591fe8ebd8ad83377c1a9f5cf5d51930312f10100000082e96cc4016a4ca601000000001600145fdfb9b9d231797765d05fc245c9714dbb14e8407c2ae64f", "prevouts": ["0e92ba0100000000225120995c260ccfd5c31ba34ba028a98486a9bf1ed13cf91fbb2dbfc73a35ac9d5ccf"], "index": 0, "success": {"scriptSig": "", "witness": ["61", "8eb72183c9f60f81051641ec1119f4ca1048f83f6ebbfa3805731c0479a8c5d8bafbb397947548494548d50e6f6b436d2fda68af07b70b7f66f56c98db81bdc41bf45c0240e4cb2f2d96a2680887aed487322c91ce1c7e839db721c93b3195599ed1cc6539704683b9970669af51e2f3a8a75aa7b1d13b278bca97ad494a5d9220"]}, "failure": {"scriptSig": "", "witness": ["61", "c0b72183c9f60f81051641ec1119f4ca1048f83f6ebbfa3805731c0479a8c5d8ba7442ba539034b2067bd698804af25c3f58d06009743f0ed3b18819eff684c0368a7e9d8f4a71cf5b77c9ed0a0e8c125a5496e4c4f36e045b98cc64f611b56efb2712f4444661e1b026ee1a556cb176264536b2c722475596ff9c7b511a208212"]}, "flags": "P2SH,DERSIG,CHECKLOCKTIMEVERIFY,CHECKSEQUENCEVERIFY,WITNESS,NULLDUMMY,TAPROOT", "comment": "unkver/bare"}
|
||||
{
|
||||
"tx": "0200000001d3d2f0976d67794790c9f874f40bc591fe8ebd8ad83377c1a9f5cf5d51930312f10100000082e96cc4016a4ca601000000001600145fdfb9b9d231797765d05fc245c9714dbb14e8407c2ae64f",
|
||||
"prevouts": ["0e92ba0100000000225120995c260ccfd5c31ba34ba028a98486a9bf1ed13cf91fbb2dbfc73a35ac9d5ccf"],
|
||||
"index": 0,
|
||||
"success": {
|
||||
"scriptSig": "",
|
||||
"witness": ["61", "8eb72183c9f60f81051641ec1119f4ca1048f83f6ebbfa3805731c0479a8c5d8bafbb397947548494548d50e6f6b436d2fda68af07b70b7f66f56c98db81bdc41bf45c0240e4cb2f2d96a2680887aed487322c91ce1c7e839db721c93b3195599ed1cc6539704683b9970669af51e2f3a8a75aa7b1d13b278bca97ad494a5d9220"]
|
||||
},
|
||||
"failure": {
|
||||
"scriptSig": "",
|
||||
"witness": ["61", "c0b72183c9f60f81051641ec1119f4ca1048f83f6ebbfa3805731c0479a8c5d8ba7442ba539034b2067bd698804af25c3f58d06009743f0ed3b18819eff684c0368a7e9d8f4a71cf5b77c9ed0a0e8c125a5496e4c4f36e045b98cc64f611b56efb2712f4444661e1b026ee1a556cb176264536b2c722475596ff9c7b511a208212"]
|
||||
},
|
||||
"flags": "P2SH,DERSIG,CHECKLOCKTIMEVERIFY,CHECKSEQUENCEVERIFY,WITNESS,NULLDUMMY,TAPROOT",
|
||||
"comment": "unkver/bare"
|
||||
}
|
||||
]
|
|
@ -596,16 +596,24 @@ sealed abstract class ScriptInterpreter {
|
|||
}
|
||||
}
|
||||
|
||||
private val opSuccessBytes: Vector[Byte] = {
|
||||
Vector(80.toByte, 98.toByte) ++
|
||||
126.to(129).map(_.toByte).toVector ++
|
||||
131.to(134).map(_.toByte).toVector ++
|
||||
Vector(137.toByte, 138.toByte, 141.toByte, 142.toByte) ++
|
||||
149.to(153).map(_.toByte) ++
|
||||
187.to(254).map(_.toByte)
|
||||
}
|
||||
|
||||
/** Checks if there is an opcode defined as OP_SUCCESSx in BIP342
|
||||
* @see https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki#specification
|
||||
*/
|
||||
private def containsOpSuccess(asm: Vector[ScriptToken]): Boolean = {
|
||||
|
||||
val containsOPSuccess =
|
||||
asm.exists(o =>
|
||||
o.isInstanceOf[ReservedOperation] ||
|
||||
ScriptInterpreter.bip341DisabledOpCodes.exists(_ == o))
|
||||
containsOPSuccess
|
||||
asm.exists {
|
||||
case op: ScriptOperation =>
|
||||
opSuccessBytes.contains(op.toByte)
|
||||
case _: ScriptToken => false
|
||||
}
|
||||
}
|
||||
|
||||
private def executeTapscript(
|
||||
|
|
Loading…
Add table
Reference in a new issue