1 | <?php |
||
19 | class TxSigner |
||
20 | { |
||
21 | /** |
||
22 | * @var TransactionInterface |
||
23 | */ |
||
24 | private $transaction; |
||
25 | |||
26 | /** |
||
27 | * @var \BitWasp\Bitcoin\Transaction\SignatureHash\Hasher |
||
28 | */ |
||
29 | private $signatureHash; |
||
30 | |||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | private $deterministicSignatures = true; |
||
35 | |||
36 | /** |
||
37 | * @var TxSignerContext[] |
||
38 | */ |
||
39 | private $inputStates = []; |
||
40 | |||
41 | /** |
||
42 | * @var EcAdapterInterface |
||
43 | */ |
||
44 | private $ecAdapter; |
||
45 | |||
46 | /** |
||
47 | * @param EcAdapterInterface $ecAdapter |
||
48 | * @param TransactionInterface $tx |
||
49 | */ |
||
50 | 90 | public function __construct(EcAdapterInterface $ecAdapter, TransactionInterface $tx) |
|
51 | { |
||
52 | 90 | $this->transaction = $tx; |
|
53 | 90 | $this->signatureHash = $tx->getSignatureHash(); |
|
54 | 90 | $this->ecAdapter = $ecAdapter; |
|
55 | 90 | } |
|
56 | |||
57 | /** |
||
58 | * @return $this |
||
59 | */ |
||
60 | 81 | public function useRandomSignatures() |
|
69 | |||
70 | /** |
||
71 | * @return $this |
||
72 | */ |
||
73 | 6 | public function useDeterministicSignatures() |
|
78 | |||
79 | /** |
||
80 | * @param PrivateKeyInterface $privKey |
||
81 | * @param Buffer $hash |
||
82 | * @param $sigHashType |
||
83 | * @return TransactionSignature |
||
84 | */ |
||
85 | 81 | public function makeSignature(PrivateKeyInterface $privKey, Buffer $hash, $sigHashType) |
|
104 | |||
105 | /** |
||
106 | * @param integer $input |
||
107 | * @return TxSignerContext |
||
108 | * @throws BuilderNoInputState |
||
109 | */ |
||
110 | 81 | public function inputState($input) |
|
119 | |||
120 | /** |
||
121 | * @param integer $inputToSign |
||
122 | * @param ScriptInterface $outputScript |
||
123 | * @param ScriptInterface $redeemScript |
||
124 | * @return TxSignerContext |
||
125 | */ |
||
126 | 81 | private function createInputState($inputToSign, $outputScript, ScriptInterface $redeemScript = null) |
|
135 | |||
136 | /** |
||
137 | * @param integer $inputToSign |
||
138 | * @param PrivateKeyInterface $privateKey |
||
139 | * @param ScriptInterface $outputScript |
||
140 | * @param ScriptInterface $redeemScript |
||
141 | * @param int $sigHashType |
||
142 | * @return $this |
||
143 | */ |
||
144 | 81 | public function sign( |
|
178 | |||
179 | /** |
||
180 | * @return TransactionInterface |
||
181 | */ |
||
182 | 69 | public function get() |
|
203 | |||
204 | /** |
||
205 | * @return bool |
||
206 | */ |
||
207 | 18 | public function isFullySigned() |
|
221 | } |
||
222 |