@@ -1261,8 +1261,9 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
1261
1261
1262
1262
// All good, time to import
1263
1263
pwallet->MarkDirty ();
1264
+ WalletBatch batch (pwallet->GetDBHandle ());
1264
1265
for (const auto & entry : import_data.import_scripts ) {
1265
- if (!pwallet->HaveCScript (CScriptID (entry)) && !pwallet->AddCScript ( entry)) {
1266
+ if (!pwallet->HaveCScript (CScriptID (entry)) && !pwallet->AddCScriptWithDB (batch, entry)) {
1266
1267
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding script to wallet" );
1267
1268
}
1268
1269
}
@@ -1273,13 +1274,13 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
1273
1274
assert (key.VerifyPubKey (pubkey));
1274
1275
pwallet->mapKeyMetadata [id].nCreateTime = timestamp;
1275
1276
// If the private key is not present in the wallet, insert it.
1276
- if (!pwallet->HaveKey (id) && !pwallet->AddKeyPubKey ( key, pubkey)) {
1277
+ if (!pwallet->HaveKey (id) && !pwallet->AddKeyPubKeyWithDB (batch, key, pubkey)) {
1277
1278
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding key to wallet" );
1278
1279
}
1279
1280
pwallet->UpdateTimeFirstKey (timestamp);
1280
1281
}
1281
1282
for (const auto & entry : import_data.key_origins ) {
1282
- pwallet->AddKeyOrigin ( entry.second .first , entry.second .second );
1283
+ pwallet->AddKeyOriginWithDB (batch, entry.second .first , entry.second .second );
1283
1284
}
1284
1285
for (const CKeyID& id : ordered_pubkeys) {
1285
1286
auto entry = pubkey_map.find (id);
@@ -1288,20 +1289,20 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
1288
1289
}
1289
1290
const CPubKey& pubkey = entry->second ;
1290
1291
CPubKey temp;
1291
- if (!pwallet->GetPubKey (id, temp) && !pwallet->AddWatchOnly ( GetScriptForRawPubKey (pubkey), timestamp)) {
1292
+ if (!pwallet->GetPubKey (id, temp) && !pwallet->AddWatchOnlyWithDB (batch, GetScriptForRawPubKey (pubkey), timestamp)) {
1292
1293
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding address to wallet" );
1293
1294
}
1294
1295
pwallet->mapKeyMetadata [id].nCreateTime = timestamp;
1295
1296
1296
1297
// Add to keypool only works with pubkeys
1297
1298
if (add_keypool) {
1298
- pwallet->AddKeypoolPubkey (pubkey, internal);
1299
+ pwallet->AddKeypoolPubkeyWithDB (pubkey, internal, batch );
1299
1300
}
1300
1301
}
1301
1302
1302
1303
for (const CScript& script : script_pub_keys) {
1303
1304
if (!have_solving_data || !::IsMine (*pwallet, script)) { // Always call AddWatchOnly for non-solvable watch-only, so that watch timestamp gets updated
1304
- if (!pwallet->AddWatchOnly ( script, timestamp)) {
1305
+ if (!pwallet->AddWatchOnlyWithDB (batch, script, timestamp)) {
1305
1306
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding address to wallet" );
1306
1307
}
1307
1308
}
0 commit comments