| Total Complexity | 9 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class UpdatableInput |
||
| 13 | { |
||
| 14 | private $psbt; |
||
| 15 | private $nIn; |
||
| 16 | private $input; |
||
| 17 | |||
| 18 | 10 | public function __construct( |
|
| 19 | PSBT $psbt, |
||
| 20 | int $nIn, |
||
| 21 | PSBTInput $input |
||
| 22 | ) { |
||
| 23 | 10 | $this->psbt = $psbt; |
|
| 24 | 10 | $this->nIn = $nIn; |
|
| 25 | 10 | $this->input = $input; |
|
| 26 | 10 | } |
|
| 27 | |||
| 28 | 8 | public function input(): PSBTInput |
|
| 31 | } |
||
| 32 | |||
| 33 | 4 | public function addNonWitnessTx(TransactionInterface $tx) |
|
| 34 | { |
||
| 35 | 4 | $outPoint = $this->psbt->getTransaction()->getInputs()[$this->nIn]->getOutPoint(); |
|
| 36 | 4 | if (!$outPoint->getTxId()->equals($tx->getTxId())) { |
|
| 37 | 1 | throw new \RuntimeException("Non-witness txid differs from unsigned tx input {$this->nIn}"); |
|
| 38 | } |
||
| 39 | 3 | if ($outPoint->getVout() > count($tx->getOutputs()) - 1) { |
|
| 40 | 1 | throw new \RuntimeException("unsigned tx outpoint does not exist in this transaction"); |
|
| 41 | } |
||
| 42 | 2 | $this->input = $this->input->withNonWitnessTx($tx); |
|
| 43 | 2 | } |
|
| 44 | |||
| 45 | 3 | public function addWitnessTxOut(TransactionOutputInterface $txOut) |
|
| 48 | 3 | } |
|
| 49 | |||
| 50 | 2 | public function addRedeemScript(ScriptInterface $script) |
|
| 53 | 2 | } |
|
| 54 | |||
| 55 | 2 | public function addWitnessScript(ScriptInterface $script) |
|
| 58 | 2 | } |
|
| 59 | |||
| 60 | 1 | public function addDerivation(PublicKeyInterface $key, PSBTBip32Derivation $derivation) |
|
| 63 | 1 | } |
|
| 64 | } |
||
| 65 |