Skip to content

Commit 5b5a890

Browse files
author
Thomas Kerin
committed
type check unknowns array contents in PSBTOutput
1 parent 5fcb981 commit 5b5a890

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Transaction/PSBT/PSBTOutput.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,24 @@ class PSBTOutput
4949
* @param ScriptInterface|null $redeemScript
5050
* @param ScriptInterface|null $witnessScript
5151
* @param PSBTBip32Derivation[] $bip32Derivations
52-
* @param BufferInterface[] $unknown
52+
* @param BufferInterface[] $unknowns
5353
*/
5454
public function __construct(
5555
ScriptInterface $redeemScript = null,
5656
ScriptInterface $witnessScript = null,
5757
array $bip32Derivations = [],
58-
array $unknown = []
58+
array $unknowns = []
5959
) {
60+
foreach ($unknowns as $key => $unknown) {
61+
if (!is_string($key) || !($unknown instanceof BufferInterface)) {
62+
throw new \RuntimeException("Unknowns must be a map of string keys to Buffer values");
63+
}
64+
}
65+
6066
$this->redeemScript = $redeemScript;
6167
$this->witnessScript = $witnessScript;
6268
$this->bip32Derivations = $bip32Derivations;
63-
$this->unknown = $unknown;
69+
$this->unknown = $unknowns;
6470
}
6571

6672
/**

0 commit comments

Comments
 (0)