MCPcopy Create free account
hub / github.com/BitVM/BitVM / OP_NDUP

Function OP_NDUP

bitvm/src/pseudo.rs:115–146  ·  view source on GitHub ↗
(n: usize)

Source from the content-addressed store, hash-verified

113}
114
115pub fn OP_NDUP(n: usize) -> Script {
116 let times_3_dup = if n > 3 { (n - 3) / 3 } else { 0 };
117 let remaining = if n > 3 { (n - 3) % 3 } else { 0 };
118
119 script! {
120
121 if n >= 1 {
122 OP_DUP
123 }
124
125
126 if n >= 3 {
127 OP_2DUP
128 }
129 else if n >= 2{
130 OP_DUP
131 }
132
133
134 for _ in 0..times_3_dup {
135 OP_3DUP
136 }
137
138 if remaining == 2{
139 OP_2DUP
140 }
141 else if remaining == 1{
142 OP_DUP
143 }
144
145 }
146}
147
148pub fn push_to_stack(element: usize, n: usize) -> Script {
149 script! {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected