mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 15:48:05 +00:00
Sanity-check script sizes in bitcoin-tx
This commit is contained in:
parent
57ee73990f
commit
a6f33ea77d
@ -387,6 +387,10 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
|
|||||||
scriptPubKey = GetScriptForWitness(scriptPubKey);
|
scriptPubKey = GetScriptForWitness(scriptPubKey);
|
||||||
}
|
}
|
||||||
if (bScriptHash) {
|
if (bScriptHash) {
|
||||||
|
if (scriptPubKey.size() > MAX_SCRIPT_ELEMENT_SIZE) {
|
||||||
|
throw std::runtime_error(strprintf(
|
||||||
|
"redeemScript exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE));
|
||||||
|
}
|
||||||
// Get the ID for the script, and then construct a P2SH destination for it.
|
// Get the ID for the script, and then construct a P2SH destination for it.
|
||||||
scriptPubKey = GetScriptForDestination(CScriptID(scriptPubKey));
|
scriptPubKey = GetScriptForDestination(CScriptID(scriptPubKey));
|
||||||
}
|
}
|
||||||
@ -447,10 +451,19 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& str
|
|||||||
bScriptHash = (flags.find("S") != std::string::npos);
|
bScriptHash = (flags.find("S") != std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scriptPubKey.size() > MAX_SCRIPT_SIZE) {
|
||||||
|
throw std::runtime_error(strprintf(
|
||||||
|
"script exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
if (bSegWit) {
|
if (bSegWit) {
|
||||||
scriptPubKey = GetScriptForWitness(scriptPubKey);
|
scriptPubKey = GetScriptForWitness(scriptPubKey);
|
||||||
}
|
}
|
||||||
if (bScriptHash) {
|
if (bScriptHash) {
|
||||||
|
if (scriptPubKey.size() > MAX_SCRIPT_ELEMENT_SIZE) {
|
||||||
|
throw std::runtime_error(strprintf(
|
||||||
|
"redeemScript exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE));
|
||||||
|
}
|
||||||
scriptPubKey = GetScriptForDestination(CScriptID(scriptPubKey));
|
scriptPubKey = GetScriptForDestination(CScriptID(scriptPubKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user