Skip to content

Commit

Permalink
PSBT\Creator, compute length before loop
Browse files Browse the repository at this point in the history
PSBT: fix phpdoc for function returning unknown key/values
  • Loading branch information
Thomas Kerin committed Jan 9, 2019
1 parent 1c2681d commit c33baf7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Transaction/PSBT/Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ class Creator
{
public function createPsbt(TransactionInterface $tx, array $unknowns = []): PSBT
{
$nIn = count($tx->getInputs());
$inputs = [];
for ($i = 0; $i < count($tx->getInputs()); $i++) {
for ($i = 0; $i < $nIn; $i++) {
$inputs[] = new PSBTInput();
}
$nOut = count($tx->getOutputs());
$outputs = [];
for ($i = 0; $i < count($tx->getOutputs()); $i++) {
for ($i = 0; $i < $nOut; $i++) {
$outputs[] = new PSBTOutput();
}

return new PSBT($tx, $unknowns, $inputs, $outputs);
}
}
3 changes: 2 additions & 1 deletion src/Transaction/PSBT/PSBT.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ public function getTransaction(): TransactionInterface
{
return $this->tx;
}

/**
* @return string[]
* @return BufferInterface[]
*/
public function getUnknowns(): array
{
Expand Down
3 changes: 3 additions & 0 deletions src/Transaction/PSBT/PSBTInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ public function getFinalizedScriptWitness(): ScriptWitnessInterface
return $this->finalScriptWitness;
}

/**
* @return BufferInterface[]
*/
public function getUnknownFields(): array
{
return $this->unknown;
Expand Down
2 changes: 1 addition & 1 deletion src/Transaction/PSBT/PSBTOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function getBip32Derivations(): array
}

/**
* @return string[]
* @return BufferInterface[]
*/
public function getUnknownFields(): array
{
Expand Down

0 comments on commit c33baf7

Please sign in to comment.