MCPcopy Create free account
hub / github.com/btcsuite/btcd / opcodeLessThan

Function opcodeLessThan

txscript/opcode.go:1694–1712  ·  view source on GitHub ↗

opcodeLessThan treats the top two items on the data stack as integers. When the second-to-top item is less than the top item, they are replaced with a 1, otherwise a 0. Stack transformation: [... x1 x2] -> [... bool]

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

Source from the content-addressed store, hash-verified

1692//
1693// Stack transformation: [... x1 x2] -> [... bool]
1694func opcodeLessThan(op *opcode, data []byte, vm *Engine) error {
1695 v0, err := vm.dstack.PopInt()
1696 if err != nil {
1697 return err
1698 }
1699
1700 v1, err := vm.dstack.PopInt()
1701 if err != nil {
1702 return err
1703 }
1704
1705 if v1 < v0 {
1706 vm.dstack.PushInt(scriptNum(1))
1707 } else {
1708 vm.dstack.PushInt(scriptNum(0))
1709 }
1710
1711 return nil
1712}
1713
1714// opcodeGreaterThan treats the top two items on the data stack as integers.
1715// When the second-to-top item is greater than the top item, they are replaced

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…