(opcode, stack, err_raiser)
| 235 | } |
| 236 | |
| 237 | def _UnaryOp(opcode, stack, err_raiser): |
| 238 | if len(stack) < 1: |
| 239 | err_raiser(MissingOpArgumentsError, opcode, stack, 1) |
| 240 | bn = _CastToBigNum(stack[-1], err_raiser) |
| 241 | stack.pop() |
| 242 | |
| 243 | if opcode == OP_1ADD: |
| 244 | bn += 1 |
| 245 | |
| 246 | elif opcode == OP_1SUB: |
| 247 | bn -= 1 |
| 248 | |
| 249 | elif opcode == OP_NEGATE: |
| 250 | bn = -bn |
| 251 | |
| 252 | elif opcode == OP_ABS: |
| 253 | if bn < 0: |
| 254 | bn = -bn |
| 255 | |
| 256 | elif opcode == OP_NOT: |
| 257 | bn = int(bn == 0) |
| 258 | |
| 259 | elif opcode == OP_0NOTEQUAL: |
| 260 | bn = int(bn != 0) |
| 261 | |
| 262 | else: |
| 263 | raise AssertionError("Unknown unary opcode encountered; this should not happen") |
| 264 | |
| 265 | stack.append(bitcoin.core._bignum.bn2vch(bn)) |
| 266 | |
| 267 | |
| 268 | # OP_LSHIFT and OP_RSHIFT are *not* included in this list as they are disabled |
no test coverage detected