MCPcopy Index your code
hub / github.com/btcsuite/btcd / opcodeNot

Function opcodeNot

txscript/opcode.go:1497–1509  ·  view source on GitHub ↗

opcodeNot treats the top item on the data stack as an integer and replaces it with its "inverted" value (0 becomes 1, non-zero becomes 0). NOTE: While it would probably make more sense to treat the top item as a boolean, and push the opposite, which is really what the intention of this opcode is, i

(op *opcode, data []byte, vm *Engine)

Source from the content-addressed store, hash-verified

1495// Stack transformation (x2!=0): [... x1 1] -> [... x1 0]
1496// Stack transformation (x2!=0): [... x1 17] -> [... x1 0]
1497func opcodeNot(op *opcode, data []byte, vm *Engine) error {
1498 m, err := vm.dstack.PopInt()
1499 if err != nil {
1500 return err
1501 }
1502
1503 if m == 0 {
1504 vm.dstack.PushInt(scriptNum(1))
1505 } else {
1506 vm.dstack.PushInt(scriptNum(0))
1507 }
1508 return nil
1509}
1510
1511// opcode0NotEqual treats the top item on the data stack as an integer and
1512// replaces it with either a 0 if it is zero, or a 1 if it is not zero.

Callers

nothing calls this directly

Calls 3

scriptNumTypeAlias · 0.85
PopIntMethod · 0.80
PushIntMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…