@@ -224,10 +224,11 @@ void ImportScript(CWallet* const pwallet, const CScript& script, const std::stri
224224 }
225225
226226 if (isRedeemScript) {
227- if (!pwallet->HaveCScript (script) && !pwallet->AddCScript (script)) {
227+ const CScriptID id (script);
228+ if (!pwallet->HaveCScript (id) && !pwallet->AddCScript (script)) {
228229 throw JSONRPCError (RPC_WALLET_ERROR, " Error adding p2sh redeemScript to wallet" );
229230 }
230- ImportAddress (pwallet, CScriptID (script) , strLabel);
231+ ImportAddress (pwallet, id , strLabel);
231232 } else {
232233 CTxDestination destination;
233234 if (ExtractDestination (script, destination)) {
@@ -602,7 +603,8 @@ UniValue importwallet(const JSONRPCRequest& request)
602603 } else if (IsHex (vstr[0 ])) {
603604 std::vector<unsigned char > vData (ParseHex (vstr[0 ]));
604605 CScript script = CScript (vData.begin (), vData.end ());
605- if (pwallet->HaveCScript (script)) {
606+ CScriptID id (script);
607+ if (pwallet->HaveCScript (id)) {
606608 LogPrintf (" Skipping import of %s (script already present)\n " , vstr[0 ]);
607609 continue ;
608610 }
@@ -613,7 +615,7 @@ UniValue importwallet(const JSONRPCRequest& request)
613615 }
614616 int64_t birth_time = DecodeDumpTime (vstr[1 ]);
615617 if (birth_time > 0 ) {
616- pwallet->m_script_metadata [CScriptID (script) ].nCreateTime = birth_time;
618+ pwallet->m_script_metadata [id ].nCreateTime = birth_time;
617619 nTimeBegin = std::min (nTimeBegin, birth_time);
618620 }
619621 }
@@ -899,12 +901,12 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
899901 throw JSONRPCError (RPC_WALLET_ERROR, " Error adding address to wallet" );
900902 }
901903
902- if (!pwallet->HaveCScript (redeemScript) && !pwallet->AddCScript (redeemScript)) {
904+ CScriptID redeem_id (redeemScript);
905+ if (!pwallet->HaveCScript (redeem_id) && !pwallet->AddCScript (redeemScript)) {
903906 throw JSONRPCError (RPC_WALLET_ERROR, " Error adding p2sh redeemScript to wallet" );
904907 }
905908
906- CTxDestination redeem_dest = CScriptID (redeemScript);
907- CScript redeemDestination = GetScriptForDestination (redeem_dest);
909+ CScript redeemDestination = GetScriptForDestination (redeem_id);
908910
909911 if (::IsMine (*pwallet, redeemDestination) == ISMINE_SPENDABLE) {
910912 throw JSONRPCError (RPC_WALLET_ERROR, " The wallet already contains the private key for this address or script" );
0 commit comments