diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -464,8 +464,8 @@ nPayAmount += amount; if (amount > Amount::zero()) { - CTxOut txout(amount, - static_cast(std::vector(24, 0))); + // Assumes a p2pkh script size + CTxOut txout(amount, CScript() << std::vector(24, 0)); txDummy.vout.push_back(txout); fDust |= IsDust(txout, model->node().getDustRelayFee()); } @@ -551,8 +551,8 @@ // Never create dust outputs; if we would, just add the dust to the // fee. if (nChange > Amount::zero() && nChange < MIN_CHANGE) { - CTxOut txout(nChange, - static_cast(std::vector(24, 0))); + // Assumes a p2pkh script size + CTxOut txout(nChange, CScript() << std::vector(24, 0)); if (IsDust(txout, model->node().getDustRelayFee())) { nPayFee += nChange; nChange = Amount::zero(); diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -76,7 +76,7 @@ // Drop the signature in scripts when SIGHASH_FORKID is not used. SigHashType sigHashType = GetHashType(vchSig); if (!(flags & SCRIPT_ENABLE_SIGHASH_FORKID) || !sigHashType.hasForkId()) { - FindAndDelete(scriptCode, CScript(vchSig)); + FindAndDelete(scriptCode, CScript() << vchSig); } } diff --git a/src/script/script.h b/src/script/script.h --- a/src/script/script.h +++ b/src/script/script.h @@ -472,7 +472,9 @@ explicit CScript(opcodetype b) { operator<<(b); } explicit CScript(const CScriptNum &b) { operator<<(b); } - explicit CScript(const std::vector &b) { operator<<(b); } + // delete non-existent constructor to defend against future introduction + // e.g. via prevector + explicit CScript(const std::vector &b) = delete; CScript &operator<<(int64_t b) { return push_int64(b); }