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

Method DropN

txscript/stack.go:205–218  ·  view source on GitHub ↗

DropN removes the top N items from the stack. Stack transformation: DropN(1): [... x1 x2] -> [... x1] DropN(2): [... x1 x2] -> [...]

(n int32)

Source from the content-addressed store, hash-verified

203// DropN(1): [... x1 x2] -> [... x1]
204// DropN(2): [... x1 x2] -> [...]
205func (s *stack) DropN(n int32) error {
206 if n < 1 {
207 str := fmt.Sprintf("attempt to drop %d items from stack", n)
208 return scriptError(ErrInvalidStackOperation, str)
209 }
210
211 for ; n > 0; n-- {
212 _, err := s.PopByteArray()
213 if err != nil {
214 return err
215 }
216 }
217 return nil
218}
219
220// DupN duplicates the top N items on the stack.
221//

Callers 5

TestStackFunction · 0.95
StepMethod · 0.80
setStackFunction · 0.80
opcode2DropFunction · 0.80
opcodeDropFunction · 0.80

Calls 2

PopByteArrayMethod · 0.95
scriptErrorFunction · 0.85

Tested by 1

TestStackFunction · 0.76