1 | <?php |
||
16 | class OutputScriptFactory |
||
17 | { |
||
18 | /** |
||
19 | * @param PublicKeyInterface $publicKey |
||
20 | * @return ScriptInterface |
||
21 | */ |
||
22 | 7 | public function p2pk(PublicKeyInterface $publicKey) |
|
23 | { |
||
24 | 7 | return $this->payToPubKey($publicKey); |
|
25 | 2 | } |
|
26 | 7 | ||
27 | /** |
||
28 | * @param BufferInterface $pubKeyHash |
||
29 | * @return ScriptInterface |
||
30 | */ |
||
31 | public function p2pkh(BufferInterface $pubKeyHash) |
||
32 | { |
||
33 | 1 | return $this->payToPubKeyHash($pubKeyHash); |
|
34 | } |
||
35 | 1 | ||
36 | /** |
||
37 | * @param BufferInterface $scriptHash |
||
38 | * @return ScriptInterface |
||
39 | */ |
||
40 | public function p2sh(BufferInterface $scriptHash) |
||
41 | { |
||
42 | 3 | return $this->payToScriptHash($scriptHash); |
|
43 | } |
||
44 | 3 | ||
45 | /** |
||
46 | * @param BufferInterface $witnessScriptHash |
||
47 | * @return ScriptInterface |
||
48 | */ |
||
49 | public function p2wsh(BufferInterface $witnessScriptHash) |
||
50 | { |
||
51 | 22 | return $this->witnessScriptHash($witnessScriptHash); |
|
52 | } |
||
53 | 22 | ||
54 | /** |
||
55 | * @param BufferInterface $witnessKeyHash |
||
56 | * @return ScriptInterface |
||
57 | */ |
||
58 | public function p2wkh(BufferInterface $witnessKeyHash) |
||
59 | { |
||
60 | 4 | return $this->witnessKeyHash($witnessKeyHash); |
|
61 | } |
||
62 | 4 | /** |
|
63 | * Create a Pay to pubkey output |
||
64 | * |
||
65 | * @param PublicKeyInterface $publicKey |
||
66 | * @return ScriptInterface |
||
67 | */ |
||
68 | public function payToPubKey(PublicKeyInterface $publicKey) |
||
72 | |||
73 | /** |
||
74 | * Create a P2PKH output script |
||
75 | * |
||
76 | * @param BufferInterface $pubKeyHash |
||
77 | * @return ScriptInterface |
||
78 | */ |
||
79 | 5 | public function payToPubKeyHash(BufferInterface $pubKeyHash) |
|
87 | |||
88 | /** |
||
89 | /** |
||
90 | 49 | * Create a P2SH output script |
|
91 | * |
||
92 | 49 | * @param BufferInterface $scriptHash |
|
93 | * @return ScriptInterface |
||
94 | */ |
||
95 | public function payToScriptHash(BufferInterface $scriptHash) |
||
103 | |||
104 | /** |
||
105 | * @param int $m |
||
106 | 31 | * @param PublicKeyInterface[] $keys |
|
107 | * @param bool|true $sort |
||
108 | 31 | * @return ScriptInterface |
|
109 | */ |
||
110 | public function multisig($m, array $keys = [], $sort = true) |
||
116 | |||
117 | /** |
||
118 | * @param int $m |
||
119 | * @param BufferInterface[] $keys |
||
120 | * @param bool|true $sort |
||
121 | * @return ScriptInterface |
||
122 | */ |
||
123 | 16 | public function multisigKeyBuffers($m, array $keys = [], $sort = true) |
|
154 | 20 | ||
155 | 20 | /** |
|
156 | 20 | * @param BufferInterface $keyHash |
|
157 | * @return ScriptInterface |
||
158 | */ |
||
159 | public function witnessKeyHash(BufferInterface $keyHash) |
||
167 | |||
168 | /** |
||
169 | * @param BufferInterface $scriptHash |
||
170 | 2 | * @return ScriptInterface |
|
171 | */ |
||
172 | 2 | public function witnessScriptHash(BufferInterface $scriptHash) |
|
180 | |||
181 | /** |
||
182 | * @param BufferInterface $commitment |
||
183 | 5 | * @return ScriptInterface |
|
184 | */ |
||
185 | 5 | public function witnessCoinbaseCommitment(BufferInterface $commitment) |
|
196 | } |
||
197 |