1 | <?php |
||
15 | class ScriptCreator |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $script = ''; |
||
21 | |||
22 | /** |
||
23 | * @var Opcodes |
||
24 | */ |
||
25 | private $opcodes; |
||
26 | |||
27 | /** |
||
28 | * @var Math |
||
29 | */ |
||
30 | private $math; |
||
31 | |||
32 | /** |
||
33 | * @param Math $math |
||
34 | * @param Opcodes $opcodes |
||
35 | * @param BufferInterface|null $buffer |
||
36 | */ |
||
37 | 5337 | public function __construct(Math $math, Opcodes $opcodes, BufferInterface $buffer = null) |
|
46 | |||
47 | /** |
||
48 | * Add a data-push instruction to the script, |
||
49 | * pushing x bytes of $data from $data, with |
||
50 | * the appropriate marker for the different |
||
51 | * PUSHDATA opcodes. |
||
52 | * |
||
53 | * @param BufferInterface $data |
||
54 | * @return $this |
||
55 | */ |
||
56 | 356 | public function push(BufferInterface $data) |
|
80 | |||
81 | /** |
||
82 | * Concatenate $script onto $this. |
||
83 | * @param ScriptInterface $script |
||
84 | * @return $this |
||
85 | */ |
||
86 | 5319 | public function concat(ScriptInterface $script) |
|
91 | |||
92 | /** |
||
93 | * This function accepts an array of elements, builds |
||
94 | * an intermediate script composed of the items in $sequence, |
||
95 | * and concatenates it in one step. |
||
96 | * |
||
97 | * The allowed types are: |
||
98 | * - opcode (integer form) |
||
99 | * - script number (Number class) |
||
100 | * - data (BufferInterface) |
||
101 | * - script (ScriptInterface) |
||
102 | * |
||
103 | * @param int[]|\BitWasp\Bitcoin\Script\Interpreter\Number[]|BufferInterface[] $sequence |
||
104 | * @return $this |
||
105 | */ |
||
106 | 5319 | public function sequence(array $sequence) |
|
130 | |||
131 | /** |
||
132 | * This function accepts an integer, and adds the appropriate |
||
133 | * data-push instruction to the script, minimally encoding it |
||
134 | * where possible. |
||
135 | * |
||
136 | * @param int $n |
||
137 | * @return $this |
||
138 | */ |
||
139 | 22 | public function int(int $n) |
|
151 | |||
152 | /** |
||
153 | * Takes a list of opcodes (the name as a string) |
||
154 | * and adds the opcodes to the script. |
||
155 | * |
||
156 | * @param string... $opNames |
||
|
|||
157 | * @return $this |
||
158 | */ |
||
159 | 2 | public function op(string... $opNames) |
|
168 | |||
169 | /** |
||
170 | * Takes a list of opcodes (in integer form) and |
||
171 | * adds them to the script. |
||
172 | * |
||
173 | * @param int ...$opcodes |
||
174 | * @return $this |
||
175 | */ |
||
176 | 34 | public function opcode(int ...$opcodes) |
|
181 | |||
182 | /** |
||
183 | * Takes a list of data elements and adds the |
||
184 | * push-data instructions to the script. |
||
185 | * |
||
186 | * @param BufferInterface ...$dataList |
||
187 | * @return $this |
||
188 | */ |
||
189 | 3 | public function data(BufferInterface ...$dataList) |
|
194 | |||
195 | /** |
||
196 | * Generates a script based on the current state. |
||
197 | * @return ScriptInterface |
||
198 | */ |
||
199 | 5336 | public function getScript(): ScriptInterface |
|
203 | } |
||
204 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.