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

Function opcodeAdd

txscript/opcode.go:1534–1547  ·  view source on GitHub ↗

opcodeAdd treats the top two items on the data stack as integers and replaces them with their sum. Stack transformation: [... x1 x2] -> [... x1+x2]

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

Source from the content-addressed store, hash-verified

1532//
1533// Stack transformation: [... x1 x2] -> [... x1+x2]
1534func opcodeAdd(op *opcode, data []byte, vm *Engine) error {
1535 v0, err := vm.dstack.PopInt()
1536 if err != nil {
1537 return err
1538 }
1539
1540 v1, err := vm.dstack.PopInt()
1541 if err != nil {
1542 return err
1543 }
1544
1545 vm.dstack.PushInt(v0 + v1)
1546 return nil
1547}
1548
1549// opcodeSub treats the top two items on the data stack as integers and replaces
1550// them with the result of subtracting the top entry from the second-to-top

Callers

nothing calls this directly

Calls 2

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…