mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-22 08:09:19 +01:00
Sanity-check script sizes in bitcoin-tx
Github-Pull: #11554
Rebased-From: a6f33ea77d
This commit is contained in:
committed by
Luke Dashjr
parent
9828f9a996
commit
f455bfd78a
@@ -355,6 +355,10 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
|
||||
scriptPubKey = GetScriptForWitness(scriptPubKey);
|
||||
}
|
||||
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 address for the redeem script, then call
|
||||
// GetScriptForDestination() to construct a P2SH scriptPubKey.
|
||||
CBitcoinAddress addr(scriptPubKey);
|
||||
@@ -417,10 +421,19 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& str
|
||||
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) {
|
||||
scriptPubKey = GetScriptForWitness(scriptPubKey);
|
||||
}
|
||||
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));
|
||||
}
|
||||
CBitcoinAddress addr(scriptPubKey);
|
||||
scriptPubKey = GetScriptForDestination(addr.Get());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user