@@ -224,10 +224,11 @@ void ImportScript(CWallet* const pwallet, const CScript& script, const std::stri
224
224
}
225
225
226
226
if (isRedeemScript) {
227
- if (!pwallet->HaveCScript (script) && !pwallet->AddCScript (script)) {
227
+ const CScriptID id (script);
228
+ if (!pwallet->HaveCScript (id) && !pwallet->AddCScript (script)) {
228
229
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding p2sh redeemScript to wallet" );
229
230
}
230
- ImportAddress (pwallet, CScriptID (script) , strLabel);
231
+ ImportAddress (pwallet, id , strLabel);
231
232
} else {
232
233
CTxDestination destination;
233
234
if (ExtractDestination (script, destination)) {
@@ -602,7 +603,8 @@ UniValue importwallet(const JSONRPCRequest& request)
602
603
} else if (IsHex (vstr[0 ])) {
603
604
std::vector<unsigned char > vData (ParseHex (vstr[0 ]));
604
605
CScript script = CScript (vData.begin (), vData.end ());
605
- if (pwallet->HaveCScript (script)) {
606
+ CScriptID id (script);
607
+ if (pwallet->HaveCScript (id)) {
606
608
LogPrintf (" Skipping import of %s (script already present)\n " , vstr[0 ]);
607
609
continue ;
608
610
}
@@ -613,7 +615,7 @@ UniValue importwallet(const JSONRPCRequest& request)
613
615
}
614
616
int64_t birth_time = DecodeDumpTime (vstr[1 ]);
615
617
if (birth_time > 0 ) {
616
- pwallet->m_script_metadata [CScriptID (script) ].nCreateTime = birth_time;
618
+ pwallet->m_script_metadata [id ].nCreateTime = birth_time;
617
619
nTimeBegin = std::min (nTimeBegin, birth_time);
618
620
}
619
621
}
@@ -899,12 +901,12 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
899
901
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding address to wallet" );
900
902
}
901
903
902
- if (!pwallet->HaveCScript (redeemScript) && !pwallet->AddCScript (redeemScript)) {
904
+ CScriptID redeem_id (redeemScript);
905
+ if (!pwallet->HaveCScript (redeem_id) && !pwallet->AddCScript (redeemScript)) {
903
906
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding p2sh redeemScript to wallet" );
904
907
}
905
908
906
- CTxDestination redeem_dest = CScriptID (redeemScript);
907
- CScript redeemDestination = GetScriptForDestination (redeem_dest);
909
+ CScript redeemDestination = GetScriptForDestination (redeem_id);
908
910
909
911
if (::IsMine (*pwallet, redeemDestination) == ISMINE_SPENDABLE) {
910
912
throw JSONRPCError (RPC_WALLET_ERROR, " The wallet already contains the private key for this address or script" );
0 commit comments