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

Function opcodePick

txscript/opcode.go:1333–1340  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

1331// Example with n=1: [x2 x1 x0 1] -> [x2 x1 x0 x1]
1332// Example with n=2: [x2 x1 x0 2] -> [x2 x1 x0 x2]
1333func opcodePick(op *opcode, data []byte, vm *Engine) error {
1334 val, err := vm.dstack.PopInt()
1335 if err != nil {
1336 return err
1337 }
1338
1339 return vm.dstack.PickN(val.Int32())
1340}
1341
1342// opcodeRoll treats the top item on the data stack as an integer and moves
1343// the item on the stack that number of items back to the top.

Callers

nothing calls this directly

Calls 3

PopIntMethod · 0.80
PickNMethod · 0.80
Int32Method · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…