Bitcoin Core  24.99.0
P2P Digital Currency
miniscript.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <string>
6 #include <vector>
7 #include <script/script.h>
8 #include <script/standard.h>
9 #include <script/miniscript.h>
10 
11 #include <assert.h>
12 
13 namespace miniscript {
14 namespace internal {
15 
17  int num_types = (e << "K"_mst) + (e << "V"_mst) + (e << "B"_mst) + (e << "W"_mst);
18  if (num_types == 0) return ""_mst; // No valid type, don't care about the rest
19  assert(num_types == 1); // K, V, B, W all conflict with each other
20  assert(!(e << "z"_mst) || !(e << "o"_mst)); // z conflicts with o
21  assert(!(e << "n"_mst) || !(e << "z"_mst)); // n conflicts with z
22  assert(!(e << "n"_mst) || !(e << "W"_mst)); // n conflicts with W
23  assert(!(e << "V"_mst) || !(e << "d"_mst)); // V conflicts with d
24  assert(!(e << "K"_mst) || (e << "u"_mst)); // K implies u
25  assert(!(e << "V"_mst) || !(e << "u"_mst)); // V conflicts with u
26  assert(!(e << "e"_mst) || !(e << "f"_mst)); // e conflicts with f
27  assert(!(e << "e"_mst) || (e << "d"_mst)); // e implies d
28  assert(!(e << "V"_mst) || !(e << "e"_mst)); // V conflicts with e
29  assert(!(e << "d"_mst) || !(e << "f"_mst)); // d conflicts with f
30  assert(!(e << "V"_mst) || (e << "f"_mst)); // V implies f
31  assert(!(e << "K"_mst) || (e << "s"_mst)); // K implies s
32  assert(!(e << "z"_mst) || (e << "m"_mst)); // z implies m
33  return e;
34 }
35 
36 Type ComputeType(Fragment fragment, Type x, Type y, Type z, const std::vector<Type>& sub_types, uint32_t k, size_t data_size, size_t n_subs, size_t n_keys) {
37  // Sanity check on data
38  if (fragment == Fragment::SHA256 || fragment == Fragment::HASH256) {
39  assert(data_size == 32);
40  } else if (fragment == Fragment::RIPEMD160 || fragment == Fragment::HASH160) {
41  assert(data_size == 20);
42  } else {
43  assert(data_size == 0);
44  }
45  // Sanity check on k
46  if (fragment == Fragment::OLDER || fragment == Fragment::AFTER) {
47  assert(k >= 1 && k < 0x80000000UL);
48  } else if (fragment == Fragment::MULTI) {
49  assert(k >= 1 && k <= n_keys);
50  } else if (fragment == Fragment::THRESH) {
51  assert(k >= 1 && k <= n_subs);
52  } else {
53  assert(k == 0);
54  }
55  // Sanity check on subs
56  if (fragment == Fragment::AND_V || fragment == Fragment::AND_B || fragment == Fragment::OR_B ||
57  fragment == Fragment::OR_C || fragment == Fragment::OR_I || fragment == Fragment::OR_D) {
58  assert(n_subs == 2);
59  } else if (fragment == Fragment::ANDOR) {
60  assert(n_subs == 3);
61  } else if (fragment == Fragment::WRAP_A || fragment == Fragment::WRAP_S || fragment == Fragment::WRAP_C ||
62  fragment == Fragment::WRAP_D || fragment == Fragment::WRAP_V || fragment == Fragment::WRAP_J ||
63  fragment == Fragment::WRAP_N) {
64  assert(n_subs == 1);
65  } else if (fragment != Fragment::THRESH) {
66  assert(n_subs == 0);
67  }
68  // Sanity check on keys
69  if (fragment == Fragment::PK_K || fragment == Fragment::PK_H) {
70  assert(n_keys == 1);
71  } else if (fragment == Fragment::MULTI) {
72  assert(n_keys >= 1 && n_keys <= 20);
73  } else {
74  assert(n_keys == 0);
75  }
76 
77  // Below is the per-fragment logic for computing the expression types.
78  // It heavily relies on Type's << operator (where "X << a_mst" means
79  // "X has all properties listed in a").
80  switch (fragment) {
81  case Fragment::PK_K: return "Konudemsxk"_mst;
82  case Fragment::PK_H: return "Knudemsxk"_mst;
83  case Fragment::OLDER: return
85  "h"_mst.If(!(k & CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG)) |
86  "Bzfmxk"_mst;
87  case Fragment::AFTER: return
88  "i"_mst.If(k >= LOCKTIME_THRESHOLD) |
89  "j"_mst.If(k < LOCKTIME_THRESHOLD) |
90  "Bzfmxk"_mst;
91  case Fragment::SHA256: return "Bonudmk"_mst;
92  case Fragment::RIPEMD160: return "Bonudmk"_mst;
93  case Fragment::HASH256: return "Bonudmk"_mst;
94  case Fragment::HASH160: return "Bonudmk"_mst;
95  case Fragment::JUST_1: return "Bzufmxk"_mst;
96  case Fragment::JUST_0: return "Bzudemsxk"_mst;
97  case Fragment::WRAP_A: return
98  "W"_mst.If(x << "B"_mst) | // W=B_x
99  (x & "ghijk"_mst) | // g=g_x, h=h_x, i=i_x, j=j_x, k=k_x
100  (x & "udfems"_mst) | // u=u_x, d=d_x, f=f_x, e=e_x, m=m_x, s=s_x
101  "x"_mst; // x
102  case Fragment::WRAP_S: return
103  "W"_mst.If(x << "Bo"_mst) | // W=B_x*o_x
104  (x & "ghijk"_mst) | // g=g_x, h=h_x, i=i_x, j=j_x, k=k_x
105  (x & "udfemsx"_mst); // u=u_x, d=d_x, f=f_x, e=e_x, m=m_x, s=s_x, x=x_x
106  case Fragment::WRAP_C: return
107  "B"_mst.If(x << "K"_mst) | // B=K_x
108  (x & "ghijk"_mst) | // g=g_x, h=h_x, i=i_x, j=j_x, k=k_x
109  (x & "ondfem"_mst) | // o=o_x, n=n_x, d=d_x, f=f_x, e=e_x, m=m_x
110  "us"_mst; // u, s
111  case Fragment::WRAP_D: return
112  "B"_mst.If(x << "Vz"_mst) | // B=V_x*z_x
113  "o"_mst.If(x << "z"_mst) | // o=z_x
114  "e"_mst.If(x << "f"_mst) | // e=f_x
115  (x & "ghijk"_mst) | // g=g_x, h=h_x, i=i_x, j=j_x, k=k_x
116  (x & "ms"_mst) | // m=m_x, s=s_x
117  // NOTE: 'd:' is not 'u' under P2WSH as MINIMALIF is only a policy rule there.
118  "ndx"_mst; // n, d, x
119  case Fragment::WRAP_V: return
120  "V"_mst.If(x << "B"_mst) | // V=B_x
121  (x & "ghijk"_mst) | // g=g_x, h=h_x, i=i_x, j=j_x, k=k_x
122  (x & "zonms"_mst) | // z=z_x, o=o_x, n=n_x, m=m_x, s=s_x
123  "fx"_mst; // f, x
124  case Fragment::WRAP_J: return
125  "B"_mst.If(x << "Bn"_mst) | // B=B_x*n_x
126  "e"_mst.If(x << "f"_mst) | // e=f_x
127  (x & "ghijk"_mst) | // g=g_x, h=h_x, i=i_x, j=j_x, k=k_x
128  (x & "oums"_mst) | // o=o_x, u=u_x, m=m_x, s=s_x
129  "ndx"_mst; // n, d, x
130  case Fragment::WRAP_N: return
131  (x & "ghijk"_mst) | // g=g_x, h=h_x, i=i_x, j=j_x, k=k_x
132  (x & "Bzondfems"_mst) | // B=B_x, z=z_x, o=o_x, n=n_x, d=d_x, f=f_x, e=e_x, m=m_x, s=s_x
133  "ux"_mst; // u, x
134  case Fragment::AND_V: return
135  (y & "KVB"_mst).If(x << "V"_mst) | // B=V_x*B_y, V=V_x*V_y, K=V_x*K_y
136  (x & "n"_mst) | (y & "n"_mst).If(x << "z"_mst) | // n=n_x+z_x*n_y
137  ((x | y) & "o"_mst).If((x | y) << "z"_mst) | // o=o_x*z_y+z_x*o_y
138  (x & y & "dmz"_mst) | // d=d_x*d_y, m=m_x*m_y, z=z_x*z_y
139  ((x | y) & "s"_mst) | // s=s_x+s_y
140  "f"_mst.If((y << "f"_mst) || (x << "s"_mst)) | // f=f_y+s_x
141  (y & "ux"_mst) | // u=u_y, x=x_y
142  ((x | y) & "ghij"_mst) | // g=g_x+g_y, h=h_x+h_y, i=i_x+i_y, j=j_x+j_y
143  "k"_mst.If(((x & y) << "k"_mst) &&
144  !(((x << "g"_mst) && (y << "h"_mst)) ||
145  ((x << "h"_mst) && (y << "g"_mst)) ||
146  ((x << "i"_mst) && (y << "j"_mst)) ||
147  ((x << "j"_mst) && (y << "i"_mst)))); // k=k_x*k_y*!(g_x*h_y + h_x*g_y + i_x*j_y + j_x*i_y)
148  case Fragment::AND_B: return
149  (x & "B"_mst).If(y << "W"_mst) | // B=B_x*W_y
150  ((x | y) & "o"_mst).If((x | y) << "z"_mst) | // o=o_x*z_y+z_x*o_y
151  (x & "n"_mst) | (y & "n"_mst).If(x << "z"_mst) | // n=n_x+z_x*n_y
152  (x & y & "e"_mst).If((x & y) << "s"_mst) | // e=e_x*e_y*s_x*s_y
153  (x & y & "dzm"_mst) | // d=d_x*d_y, z=z_x*z_y, m=m_x*m_y
154  "f"_mst.If(((x & y) << "f"_mst) || (x << "sf"_mst) || (y << "sf"_mst)) | // f=f_x*f_y + f_x*s_x + f_y*s_y
155  ((x | y) & "s"_mst) | // s=s_x+s_y
156  "ux"_mst | // u, x
157  ((x | y) & "ghij"_mst) | // g=g_x+g_y, h=h_x+h_y, i=i_x+i_y, j=j_x+j_y
158  "k"_mst.If(((x & y) << "k"_mst) &&
159  !(((x << "g"_mst) && (y << "h"_mst)) ||
160  ((x << "h"_mst) && (y << "g"_mst)) ||
161  ((x << "i"_mst) && (y << "j"_mst)) ||
162  ((x << "j"_mst) && (y << "i"_mst)))); // k=k_x*k_y*!(g_x*h_y + h_x*g_y + i_x*j_y + j_x*i_y)
163  case Fragment::OR_B: return
164  "B"_mst.If(x << "Bd"_mst && y << "Wd"_mst) | // B=B_x*d_x*W_x*d_y
165  ((x | y) & "o"_mst).If((x | y) << "z"_mst) | // o=o_x*z_y+z_x*o_y
166  (x & y & "m"_mst).If((x | y) << "s"_mst && (x & y) << "e"_mst) | // m=m_x*m_y*e_x*e_y*(s_x+s_y)
167  (x & y & "zse"_mst) | // z=z_x*z_y, s=s_x*s_y, e=e_x*e_y
168  "dux"_mst | // d, u, x
169  ((x | y) & "ghij"_mst) | // g=g_x+g_y, h=h_x+h_y, i=i_x+i_y, j=j_x+j_y
170  (x & y & "k"_mst); // k=k_x*k_y
171  case Fragment::OR_D: return
172  (y & "B"_mst).If(x << "Bdu"_mst) | // B=B_y*B_x*d_x*u_x
173  (x & "o"_mst).If(y << "z"_mst) | // o=o_x*z_y
174  (x & y & "m"_mst).If(x << "e"_mst && (x | y) << "s"_mst) | // m=m_x*m_y*e_x*(s_x+s_y)
175  (x & y & "zes"_mst) | // z=z_x*z_y, e=e_x*e_y, s=s_x*s_y
176  (y & "ufd"_mst) | // u=u_y, f=f_y, d=d_y
177  "x"_mst | // x
178  ((x | y) & "ghij"_mst) | // g=g_x+g_y, h=h_x+h_y, i=i_x+i_y, j=j_x+j_y
179  (x & y & "k"_mst); // k=k_x*k_y
180  case Fragment::OR_C: return
181  (y & "V"_mst).If(x << "Bdu"_mst) | // V=V_y*B_x*u_x*d_x
182  (x & "o"_mst).If(y << "z"_mst) | // o=o_x*z_y
183  (x & y & "m"_mst).If(x << "e"_mst && (x | y) << "s"_mst) | // m=m_x*m_y*e_x*(s_x+s_y)
184  (x & y & "zs"_mst) | // z=z_x*z_y, s=s_x*s_y
185  "fx"_mst | // f, x
186  ((x | y) & "ghij"_mst) | // g=g_x+g_y, h=h_x+h_y, i=i_x+i_y, j=j_x+j_y
187  (x & y & "k"_mst); // k=k_x*k_y
188  case Fragment::OR_I: return
189  (x & y & "VBKufs"_mst) | // V=V_x*V_y, B=B_x*B_y, K=K_x*K_y, u=u_x*u_y, f=f_x*f_y, s=s_x*s_y
190  "o"_mst.If((x & y) << "z"_mst) | // o=z_x*z_y
191  ((x | y) & "e"_mst).If((x | y) << "f"_mst) | // e=e_x*f_y+f_x*e_y
192  (x & y & "m"_mst).If((x | y) << "s"_mst) | // m=m_x*m_y*(s_x+s_y)
193  ((x | y) & "d"_mst) | // d=d_x+d_y
194  "x"_mst | // x
195  ((x | y) & "ghij"_mst) | // g=g_x+g_y, h=h_x+h_y, i=i_x+i_y, j=j_x+j_y
196  (x & y & "k"_mst); // k=k_x*k_y
197  case Fragment::ANDOR: return
198  (y & z & "BKV"_mst).If(x << "Bdu"_mst) | // B=B_x*d_x*u_x*B_y*B_z, K=B_x*d_x*u_x*K_y*K_z, V=B_x*d_x*u_x*V_y*V_z
199  (x & y & z & "z"_mst) | // z=z_x*z_y*z_z
200  ((x | (y & z)) & "o"_mst).If((x | (y & z)) << "z"_mst) | // o=o_x*z_y*z_z+z_x*o_y*o_z
201  (y & z & "u"_mst) | // u=u_y*u_z
202  (z & "f"_mst).If((x << "s"_mst) || (y << "f"_mst)) | // f=(s_x+f_y)*f_z
203  (z & "d"_mst) | // d=d_z
204  (x & z & "e"_mst).If(x << "s"_mst || y << "f"_mst) | // e=e_x*e_z*(s_x+f_y)
205  (x & y & z & "m"_mst).If(x << "e"_mst && (x | y | z) << "s"_mst) | // m=m_x*m_y*m_z*e_x*(s_x+s_y+s_z)
206  (z & (x | y) & "s"_mst) | // s=s_z*(s_x+s_y)
207  "x"_mst | // x
208  ((x | y | z) & "ghij"_mst) | // g=g_x+g_y+g_z, h=h_x+h_y+h_z, i=i_x+i_y+i_z, j=j_x+j_y_j_z
209  "k"_mst.If(((x & y & z) << "k"_mst) &&
210  !(((x << "g"_mst) && (y << "h"_mst)) ||
211  ((x << "h"_mst) && (y << "g"_mst)) ||
212  ((x << "i"_mst) && (y << "j"_mst)) ||
213  ((x << "j"_mst) && (y << "i"_mst)))); // k=k_x*k_y*k_z* !(g_x*h_y + h_x*g_y + i_x*j_y + j_x*i_y)
214  case Fragment::MULTI: return "Bnudemsk"_mst;
215  case Fragment::THRESH: {
216  bool all_e = true;
217  bool all_m = true;
218  uint32_t args = 0;
219  uint32_t num_s = 0;
220  Type acc_tl = "k"_mst;
221  for (size_t i = 0; i < sub_types.size(); ++i) {
222  Type t = sub_types[i];
223  if (!(t << (i ? "Wdu"_mst : "Bdu"_mst))) return ""_mst; // Require Bdu, Wdu, Wdu, ...
224  if (!(t << "e"_mst)) all_e = false;
225  if (!(t << "m"_mst)) all_m = false;
226  if (t << "s"_mst) num_s += 1;
227  args += (t << "z"_mst) ? 0 : (t << "o"_mst) ? 1 : 2;
228  acc_tl = ((acc_tl | t) & "ghij"_mst) |
229  // Thresh contains a combination of timelocks if it has threshold > 1 and
230  // it contains two different children that have different types of timelocks
231  // Note how if any of the children don't have "k", the parent also does not have "k"
232  "k"_mst.If(((acc_tl & t) << "k"_mst) && ((k <= 1) ||
233  ((k > 1) && !(((acc_tl << "g"_mst) && (t << "h"_mst)) ||
234  ((acc_tl << "h"_mst) && (t << "g"_mst)) ||
235  ((acc_tl << "i"_mst) && (t << "j"_mst)) ||
236  ((acc_tl << "j"_mst) && (t << "i"_mst))))));
237  }
238  return "Bdu"_mst |
239  "z"_mst.If(args == 0) | // z=all z
240  "o"_mst.If(args == 1) | // o=all z except one o
241  "e"_mst.If(all_e && num_s == n_subs) | // e=all e and all s
242  "m"_mst.If(all_e && all_m && num_s >= n_subs - k) | // m=all e, >=(n-k) s
243  "s"_mst.If(num_s >= n_subs - k + 1) | // s= >=(n-k+1) s
244  acc_tl; // timelock info
245  }
246  }
247  assert(false);
248 }
249 
250 size_t ComputeScriptLen(Fragment fragment, Type sub0typ, size_t subsize, uint32_t k, size_t n_subs, size_t n_keys) {
251  switch (fragment) {
252  case Fragment::JUST_1:
253  case Fragment::JUST_0: return 1;
254  case Fragment::PK_K: return 34;
255  case Fragment::PK_H: return 3 + 21;
256  case Fragment::OLDER:
257  case Fragment::AFTER: return 1 + BuildScript(k).size();
258  case Fragment::HASH256:
259  case Fragment::SHA256: return 4 + 2 + 33;
260  case Fragment::HASH160:
261  case Fragment::RIPEMD160: return 4 + 2 + 21;
262  case Fragment::MULTI: return 1 + BuildScript(n_keys).size() + BuildScript(k).size() + 34 * n_keys;
263  case Fragment::AND_V: return subsize;
264  case Fragment::WRAP_V: return subsize + (sub0typ << "x"_mst);
265  case Fragment::WRAP_S:
266  case Fragment::WRAP_C:
267  case Fragment::WRAP_N:
268  case Fragment::AND_B:
269  case Fragment::OR_B: return subsize + 1;
270  case Fragment::WRAP_A:
271  case Fragment::OR_C: return subsize + 2;
272  case Fragment::WRAP_D:
273  case Fragment::OR_D:
274  case Fragment::OR_I:
275  case Fragment::ANDOR: return subsize + 3;
276  case Fragment::WRAP_J: return subsize + 4;
277  case Fragment::THRESH: return subsize + n_subs + BuildScript(k).size();
278  }
279  assert(false);
280 }
281 
282 std::optional<std::vector<Opcode>> DecomposeScript(const CScript& script)
283 {
284  std::vector<Opcode> out;
285  CScript::const_iterator it = script.begin(), itend = script.end();
286  while (it != itend) {
287  std::vector<unsigned char> push_data;
288  opcodetype opcode;
289  if (!script.GetOp(it, opcode, push_data)) {
290  return {};
291  } else if (opcode >= OP_1 && opcode <= OP_16) {
292  // Deal with OP_n (GetOp does not turn them into pushes).
293  push_data.assign(1, CScript::DecodeOP_N(opcode));
294  } else if (opcode == OP_CHECKSIGVERIFY) {
295  // Decompose OP_CHECKSIGVERIFY into OP_CHECKSIG OP_VERIFY
296  out.emplace_back(OP_CHECKSIG, std::vector<unsigned char>());
297  opcode = OP_VERIFY;
298  } else if (opcode == OP_CHECKMULTISIGVERIFY) {
299  // Decompose OP_CHECKMULTISIGVERIFY into OP_CHECKMULTISIG OP_VERIFY
300  out.emplace_back(OP_CHECKMULTISIG, std::vector<unsigned char>());
301  opcode = OP_VERIFY;
302  } else if (opcode == OP_EQUALVERIFY) {
303  // Decompose OP_EQUALVERIFY into OP_EQUAL OP_VERIFY
304  out.emplace_back(OP_EQUAL, std::vector<unsigned char>());
305  opcode = OP_VERIFY;
306  } else if (IsPushdataOp(opcode)) {
307  if (!CheckMinimalPush(push_data, opcode)) return {};
308  } else if (it != itend && (opcode == OP_CHECKSIG || opcode == OP_CHECKMULTISIG || opcode == OP_EQUAL) && (*it == OP_VERIFY)) {
309  // Rule out non minimal VERIFY sequences
310  return {};
311  }
312  out.emplace_back(opcode, std::move(push_data));
313  }
314  std::reverse(out.begin(), out.end());
315  return out;
316 }
317 
318 std::optional<int64_t> ParseScriptNumber(const Opcode& in) {
319  if (in.first == OP_0) {
320  return 0;
321  }
322  if (!in.second.empty()) {
323  if (IsPushdataOp(in.first) && !CheckMinimalPush(in.second, in.first)) return {};
324  try {
325  return CScriptNum(in.second, true).GetInt64();
326  } catch(const scriptnum_error&) {}
327  }
328  return {};
329 }
330 
331 int FindNextChar(Span<const char> sp, const char m)
332 {
333  for (int i = 0; i < (int)sp.size(); ++i) {
334  if (sp[i] == m) return i;
335  // We only search within the current parentheses
336  if (sp[i] == ')') break;
337  }
338  return -1;
339 }
340 
341 } // namespace internal
342 } // namespace miniscript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:411
static int DecodeOP_N(opcodetype opcode)
Encode/decode small integers:
Definition: script.h:503
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
Definition: script.h:492
int64_t GetInt64() const
Definition: script.h:338
static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG
If CTxIn::nSequence encodes a relative lock-time and this flag is set, the relative lock-time has uni...
Definition: transaction.h:111
A Span is an object that can refer to a contiguous sequence of objects.
Definition: span.h:97
constexpr std::size_t size() const noexcept
Definition: span.h:186
This type encapsulates the miniscript type system properties.
Definition: miniscript.h:121
constexpr Type If(bool x) const
The empty type if x is false, itself otherwise.
Definition: miniscript.h:148
size_type size() const
Definition: prevector.h:284
iterator begin()
Definition: prevector.h:292
iterator end()
Definition: prevector.h:294
int FindNextChar(Span< const char > sp, const char m)
Definition: miniscript.cpp:331
std::optional< int64_t > ParseScriptNumber(const Opcode &in)
Determine whether the passed pair (created by DecomposeScript) is pushing a number.
Definition: miniscript.cpp:318
Type SanitizeType(Type e)
A helper sanitizer/checker for the output of CalcType.
Definition: miniscript.cpp:16
Type ComputeType(Fragment fragment, Type x, Type y, Type z, const std::vector< Type > &sub_types, uint32_t k, size_t data_size, size_t n_subs, size_t n_keys)
Helper function for Node::CalcType.
Definition: miniscript.cpp:36
std::optional< std::vector< Opcode > > DecomposeScript(const CScript &script)
Decode a script into opcode/push pairs.
Definition: miniscript.cpp:282
size_t ComputeScriptLen(Fragment fragment, Type sub0typ, size_t subsize, uint32_t k, size_t n_subs, size_t n_keys)
Helper function for Node::CalcScriptLen.
Definition: miniscript.cpp:250
std::pair< opcodetype, std::vector< unsigned char > > Opcode
Definition: miniscript.h:183
Fragment
The different node types in miniscript.
Definition: miniscript.h:193
@ OR_I
OP_IF [X] OP_ELSE [Y] OP_ENDIF.
@ RIPEMD160
OP_SIZE 32 OP_EQUALVERIFY OP_RIPEMD160 [hash] OP_EQUAL.
@ HASH160
OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 [hash] OP_EQUAL.
@ OR_B
[X] [Y] OP_BOOLOR
@ WRAP_A
OP_TOALTSTACK [X] OP_FROMALTSTACK.
@ WRAP_V
[X] OP_VERIFY (or -VERIFY version of last opcode in X)
@ ANDOR
[X] OP_NOTIF [Z] OP_ELSE [Y] OP_ENDIF
@ THRESH
[X1] ([Xn] OP_ADD)* [k] OP_EQUAL
@ WRAP_N
[X] OP_0NOTEQUAL
@ WRAP_S
OP_SWAP [X].
@ OR_C
[X] OP_NOTIF [Y] OP_ENDIF
@ HASH256
OP_SIZE 32 OP_EQUALVERIFY OP_HASH256 [hash] OP_EQUAL.
@ OLDER
[n] OP_CHECKSEQUENCEVERIFY
@ SHA256
OP_SIZE 32 OP_EQUALVERIFY OP_SHA256 [hash] OP_EQUAL.
@ WRAP_J
OP_SIZE OP_0NOTEQUAL OP_IF [X] OP_ENDIF.
@ AFTER
[n] OP_CHECKLOCKTIMEVERIFY
@ OR_D
[X] OP_IFDUP OP_NOTIF [Y] OP_ENDIF
@ WRAP_D
OP_DUP OP_IF [X] OP_ENDIF.
@ AND_B
[X] [Y] OP_BOOLAND
@ PK_H
OP_DUP OP_HASH160 [keyhash] OP_EQUALVERIFY.
@ WRAP_C
[X] OP_CHECKSIG
@ MULTI
[k] [key_n]* [n] OP_CHECKMULTISIG
ArgsManager args
bool CheckMinimalPush(const std::vector< unsigned char > &data, opcodetype opcode)
Definition: script.cpp:343
static const unsigned int LOCKTIME_THRESHOLD
Definition: script.h:43
opcodetype
Script opcodes.
Definition: script.h:70
@ OP_CHECKMULTISIG
Definition: script.h:188
@ OP_CHECKSIG
Definition: script.h:186
@ OP_16
Definition: script.h:95
@ OP_EQUAL
Definition: script.h:142
@ OP_1
Definition: script.h:79
@ OP_VERIFY
Definition: script.h:106
@ OP_CHECKMULTISIGVERIFY
Definition: script.h:189
@ OP_CHECKSIGVERIFY
Definition: script.h:187
@ OP_0
Definition: script.h:72
@ OP_EQUALVERIFY
Definition: script.h:143
CScript BuildScript(Ts &&... inputs)
Build a script by concatenating other scripts, or any argument accepted by CScript::operator<<.
Definition: script.h:585
constexpr bool IsPushdataOp(opcodetype opcode)
Definition: standard.h:157
assert(!tx.IsCoinBase())