@@ -734,6 +734,9 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
734734 // Script verification errors
735735 UniValue vErrors (UniValue::VARR);
736736
737+ // Use CTransaction for the constant parts of the
738+ // transaction to avoid rehashing.
739+ const CTransaction txConst (mergedTx);
737740 // Sign what we can:
738741 for (unsigned int i = 0 ; i < mergedTx.vin .size (); i++) {
739742 CTxIn& txin = mergedTx.vin [i];
@@ -767,10 +770,10 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
767770
768771 // ... and merge in other signatures:
769772 for (const CMutableTransaction& txv : txVariants) {
770- txin.scriptSig = CombineSignatures (prevPubKey, mergedTx , i, txin.scriptSig , txv.vin [i].scriptSig );
773+ txin.scriptSig = CombineSignatures (prevPubKey, txConst , i, txin.scriptSig , txv.vin [i].scriptSig );
771774 }
772775 ScriptError serror = SCRIPT_ERR_OK;
773- if (!VerifyScript (txin.scriptSig , prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker (&mergedTx , i), &serror)) {
776+ if (!VerifyScript (txin.scriptSig , prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker (&txConst , i), &serror)) {
774777 TxInErrorToJSON (txin, vErrors, ScriptErrorString (serror));
775778 }
776779 }
0 commit comments