| 387 | } |
| 388 | |
| 389 | bool MatchLiquidWatchman(const CScript& script) |
| 390 | { |
| 391 | CScript::const_iterator it = script.begin(); |
| 392 | std::vector<unsigned char> data; |
| 393 | opcodetype opcode; |
| 394 | |
| 395 | // Stack depth check for branch choice |
| 396 | if (!script.GetOp(it, opcode, data) || opcode != OP_DEPTH) { |
| 397 | return false; |
| 398 | } |
| 399 | // Take in value, then check equality |
| 400 | if (!script.GetOp(it, opcode, data) || |
| 401 | !script.GetOp(it, opcode, data) || |
| 402 | opcode != OP_EQUAL) { |
| 403 | return false; |
| 404 | } |
| 405 | // IF EQUAL |
| 406 | if (!script.GetOp(it, opcode, data) || opcode != OP_IF) { |
| 407 | return false; |
| 408 | } |
| 409 | // Take in value k, make sure minimally encoded number from 1 to 16 |
| 410 | if (!script.GetOp(it, opcode, data) || |
| 411 | opcode > OP_16 || |
| 412 | (opcode < OP_1NEGATE && !CheckMinimalPush(data, opcode))) { |
| 413 | return false; |
| 414 | } |
| 415 | opcodetype opcode2 = opcode; |
| 416 | std::vector<unsigned char> num = data; |
| 417 | // Iterate through multisig stuff until ELSE is hit |
| 418 | while (opcode != OP_ELSE) { |
| 419 | if (!script.GetOp(it, opcode, data)) { |
| 420 | return false; |
| 421 | } |
| 422 | } |
| 423 | // Take minimally-encoded CSV push number k' |
| 424 | if (!script.GetOp(it, opcode, data) || |
| 425 | opcode > OP_16 || (opcode < OP_1NEGATE && !CheckMinimalPush(data, opcode))) { |
| 426 | return false; |
| 427 | } |
| 428 | // CSV |
| 429 | if (!script.GetOp(it, opcode, data) || opcode != OP_CHECKSEQUENCEVERIFY) { |
| 430 | return false; |
| 431 | } |
| 432 | // Drop the CSV number |
| 433 | if (!script.GetOp(it, opcode, data) || opcode != OP_DROP) { |
| 434 | return false; |
| 435 | } |
| 436 | // Take the minimally-encoded n of k-of-n multisig arg |
| 437 | if (!script.GetOp(it, opcode, data) || |
| 438 | opcode > OP_16 || (opcode < OP_1NEGATE && !CheckMinimalPush(data, opcode)) ) { |
| 439 | return false; |
| 440 | } |
| 441 | |
| 442 | // The two multisig k-numbers must not match, otherwise ELSE branch can not be reached |
| 443 | if (opcode == opcode2 && num == data) { |
| 444 | return false; |
| 445 | } |
| 446 |
no test coverage detected