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

Function opcodeRoll

txscript/opcode.go:1348–1355  ·  view source on GitHub ↗

opcodeRoll treats the top item on the data stack as an integer and moves the item on the stack that number of items back to the top. Stack transformation: [xn ... x2 x1 x0 n] -> [... x2 x1 x0 xn] Example with n=1: [x2 x1 x0 1] -> [x2 x0 x1] Example with n=2: [x2 x1 x0 2] -> [x1 x0 x2]

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

Source from the content-addressed store, hash-verified

1346// Example with n=1: [x2 x1 x0 1] -> [x2 x0 x1]
1347// Example with n=2: [x2 x1 x0 2] -> [x1 x0 x2]
1348func opcodeRoll(op *opcode, data []byte, vm *Engine) error {
1349 val, err := vm.dstack.PopInt()
1350 if err != nil {
1351 return err
1352 }
1353
1354 return vm.dstack.RollN(val.Int32())
1355}
1356
1357// opcodeRot rotates the top 3 items on the data stack to the left.
1358//

Callers

nothing calls this directly

Calls 3

PopIntMethod · 0.80
RollNMethod · 0.80
Int32Method · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…