Skip to content

Commit b46bb2c

Browse files
author
Thomas Kerin
committed
PSBT\Creator, compute length before loop
1 parent ec24391 commit b46bb2c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
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
}

0 commit comments

Comments
 (0)