From 5b5a8902ae9475175e296ea94938f2d67cb7b80a Mon Sep 17 00:00:00 2001 From: Thomas Kerin Date: Wed, 9 Jan 2019 02:59:32 +0100 Subject: [PATCH] type check unknowns array contents in PSBTOutput --- src/Transaction/PSBT/PSBTOutput.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Transaction/PSBT/PSBTOutput.php b/src/Transaction/PSBT/PSBTOutput.php index bf70675b3..866591c0a 100644 --- a/src/Transaction/PSBT/PSBTOutput.php +++ b/src/Transaction/PSBT/PSBTOutput.php @@ -49,18 +49,24 @@ class PSBTOutput * @param ScriptInterface|null $redeemScript * @param ScriptInterface|null $witnessScript * @param PSBTBip32Derivation[] $bip32Derivations - * @param BufferInterface[] $unknown + * @param BufferInterface[] $unknowns */ public function __construct( ScriptInterface $redeemScript = null, ScriptInterface $witnessScript = null, array $bip32Derivations = [], - array $unknown = [] + array $unknowns = [] ) { + foreach ($unknowns as $key => $unknown) { + if (!is_string($key) || !($unknown instanceof BufferInterface)) { + throw new \RuntimeException("Unknowns must be a map of string keys to Buffer values"); + } + } + $this->redeemScript = $redeemScript; $this->witnessScript = $witnessScript; $this->bip32Derivations = $bip32Derivations; - $this->unknown = $unknown; + $this->unknown = $unknowns; } /**