@@ -967,29 +967,6 @@ static std::string RecurseImportData(const CScript& script, ImportData& import_d
967
967
static UniValue ProcessImportLegacy (ImportData& import_data, std::map<CKeyID, CPubKey>& pubkey_map, std::map<CKeyID, CKey>& privkey_map, std::set<CScript>& script_pub_keys, bool & have_solving_data, const UniValue& data)
968
968
{
969
969
UniValue warnings (UniValue::VARR);
970
- return warnings;
971
- }
972
-
973
- static UniValue ProcessImport (CWallet * const pwallet, const UniValue& data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
974
- {
975
- UniValue warnings (UniValue::VARR);
976
- UniValue result (UniValue::VOBJ);
977
-
978
- try {
979
- const bool internal = data.exists (" internal" ) ? data[" internal" ].get_bool () : false ;
980
- // Internal addresses should not have a label
981
- if (internal && data.exists (" label" )) {
982
- throw JSONRPCError (RPC_INVALID_PARAMETER, " Internal addresses should not have a label" );
983
- }
984
- const std::string& label = data.exists (" label" ) ? data[" label" ].get_str () : " " ;
985
-
986
- ImportData import_data;
987
- std::map<CKeyID, CPubKey> pubkey_map;
988
- std::map<CKeyID, CKey> privkey_map;
989
- std::set<CScript> script_pub_keys;
990
- bool have_solving_data;
991
-
992
- warnings = ProcessImportLegacy (import_data, pubkey_map, privkey_map, script_pub_keys, have_solving_data, data);
993
970
994
971
// First ensure scriptPubKey has either a script or JSON with "address" string
995
972
const UniValue& scriptPubKey = data[" scriptPubKey" ];
@@ -1004,13 +981,9 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
1004
981
const std::string& witness_script_hex = data.exists (" witnessscript" ) ? data[" witnessscript" ].get_str () : " " ;
1005
982
const UniValue& pubKeys = data.exists (" pubkeys" ) ? data[" pubkeys" ].get_array () : UniValue ();
1006
983
const UniValue& keys = data.exists (" keys" ) ? data[" keys" ].get_array () : UniValue ();
984
+ const bool internal = data.exists (" internal" ) ? data[" internal" ].get_bool () : false ;
1007
985
const bool watchOnly = data.exists (" watchonly" ) ? data[" watchonly" ].get_bool () : false ;
1008
986
1009
- // If private keys are disabled, abort if private keys are being imported
1010
- if (pwallet->IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS) && !keys.isNull ()) {
1011
- throw JSONRPCError (RPC_WALLET_ERROR, " Cannot import private keys to a wallet with private keys disabled" );
1012
- }
1013
-
1014
987
// Generate the script and destination for the scriptPubKey provided
1015
988
CScript script;
1016
989
CTxDestination dest;
@@ -1127,6 +1100,35 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
1127
1100
}
1128
1101
}
1129
1102
1103
+ return warnings;
1104
+ }
1105
+
1106
+ static UniValue ProcessImport (CWallet * const pwallet, const UniValue& data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
1107
+ {
1108
+ UniValue warnings (UniValue::VARR);
1109
+ UniValue result (UniValue::VOBJ);
1110
+
1111
+ try {
1112
+ const bool internal = data.exists (" internal" ) ? data[" internal" ].get_bool () : false ;
1113
+ // Internal addresses should not have a label
1114
+ if (internal && data.exists (" label" )) {
1115
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Internal addresses should not have a label" );
1116
+ }
1117
+ const std::string& label = data.exists (" label" ) ? data[" label" ].get_str () : " " ;
1118
+
1119
+ ImportData import_data;
1120
+ std::map<CKeyID, CPubKey> pubkey_map;
1121
+ std::map<CKeyID, CKey> privkey_map;
1122
+ std::set<CScript> script_pub_keys;
1123
+ bool have_solving_data;
1124
+
1125
+ warnings = ProcessImportLegacy (import_data, pubkey_map, privkey_map, script_pub_keys, have_solving_data, data);
1126
+
1127
+ // If private keys are disabled, abort if private keys are being imported
1128
+ if (pwallet->IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS) && !privkey_map.empty ()) {
1129
+ throw JSONRPCError (RPC_WALLET_ERROR, " Cannot import private keys to a wallet with private keys disabled" );
1130
+ }
1131
+
1130
1132
// Check whether we have any work to do
1131
1133
for (const CScript& script : script_pub_keys) {
1132
1134
if (::IsMine (*pwallet, script) & ISMINE_SPENDABLE) {
0 commit comments