@@ -351,7 +351,10 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
351351 CScript scriptPubKey = GetScriptForMultisig (required, pubkeys);
352352
353353 if (bScriptHash) {
354- // Get the address for the redeem script, then call
354+ if (scriptPubKey.size () > MAX_SCRIPT_ELEMENT_SIZE) {
355+ throw std::runtime_error (strprintf (
356+ " redeemScript exceeds size limit: %d > %d" , scriptPubKey.size (), MAX_SCRIPT_ELEMENT_SIZE));
357+ }
355358 // GetScriptForDestination() to construct a P2SH scriptPubKey.
356359 CBitcoinAddress addr (scriptPubKey);
357360 scriptPubKey = GetScriptForDestination (addr.Get ());
@@ -411,9 +414,18 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& str
411414 bScriptHash = (flags.find (" S" ) != std::string::npos);
412415 }
413416
417+ if (scriptPubKey.size () > MAX_SCRIPT_SIZE) {
418+ throw std::runtime_error (strprintf (
419+ " script exceeds size limit: %d > %d" , scriptPubKey.size (), MAX_SCRIPT_SIZE));
420+ }
421+
414422 if (bScriptHash) {
415- CBitcoinAddress addr (scriptPubKey);
416- scriptPubKey = GetScriptForDestination (addr.Get ());
423+ if (scriptPubKey.size () > MAX_SCRIPT_ELEMENT_SIZE) {
424+ throw std::runtime_error (strprintf (
425+ " redeemScript exceeds size limit: %d > %d" , scriptPubKey.size (), MAX_SCRIPT_ELEMENT_SIZE));
426+ }
427+ CBitcoinAddress addr (scriptPubKey);
428+ scriptPubKey = GetScriptForDestination (addr.Get ());
417429 }
418430
419431 // construct TxOut, append to transaction output list
0 commit comments