Skip to content

Commit c33baf7

Browse files
author
Thomas Kerin
committed
PSBT\Creator, compute length before loop
PSBT: fix phpdoc for function returning unknown key/values
1 parent 1c2681d commit c33baf7

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/Transaction/PSBT/Creator.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ class Creator
1010
{
1111
public function createPsbt(TransactionInterface $tx, array $unknowns = []): PSBT
1212
{
13+
$nIn = count($tx->getInputs());
1314
$inputs = [];
14-
for ($i = 0; $i < count($tx->getInputs()); $i++) {
15+
for ($i = 0; $i < $nIn; $i++) {
1516
$inputs[] = new PSBTInput();
1617
}
18+
$nOut = count($tx->getOutputs());
1719
$outputs = [];
18-
for ($i = 0; $i < count($tx->getOutputs()); $i++) {
20+
for ($i = 0; $i < $nOut; $i++) {
1921
$outputs[] = new PSBTOutput();
2022
}
21-
2223
return new PSBT($tx, $unknowns, $inputs, $outputs);
2324
}
2425
}

src/Transaction/PSBT/PSBT.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ public function getTransaction(): TransactionInterface
167167
{
168168
return $this->tx;
169169
}
170+
170171
/**
171-
* @return string[]
172+
* @return BufferInterface[]
172173
*/
173174
public function getUnknowns(): array
174175
{

src/Transaction/PSBT/PSBTInput.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ public function getFinalizedScriptWitness(): ScriptWitnessInterface
373373
return $this->finalScriptWitness;
374374
}
375375

376+
/**
377+
* @return BufferInterface[]
378+
*/
376379
public function getUnknownFields(): array
377380
{
378381
return $this->unknown;

src/Transaction/PSBT/PSBTOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function getBip32Derivations(): array
161161
}
162162

163163
/**
164-
* @return string[]
164+
* @return BufferInterface[]
165165
*/
166166
public function getUnknownFields(): array
167167
{

0 commit comments

Comments
 (0)