Skip to content

Commit ab28e31

Browse files
committed
Change ImportScriptPubKeys' internal to apply_label
The internal bool was only to indicate whether the given label should be applied as things that are internal should not have a label. To make this clearer, we change internal to apply_label and invert its usage so things that have labels set this to true in order to have their labels applied.
1 parent 7400135 commit ab28e31

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/wallet/rpcdump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
12831283
if (!pwallet->ImportPubKeys(ordered_pubkeys, pubkey_map, import_data.key_origins, add_keypool, internal, timestamp)) {
12841284
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
12851285
}
1286-
if (!pwallet->ImportScriptPubKeys(label, script_pub_keys, have_solving_data, internal, timestamp)) {
1286+
if (!pwallet->ImportScriptPubKeys(label, script_pub_keys, have_solving_data, !internal, timestamp)) {
12871287
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
12881288
}
12891289

src/wallet/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ bool CWallet::ImportPubKeys(const std::vector<CKeyID>& ordered_pubkeys, const st
17171717
return true;
17181718
}
17191719

1720-
bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScript>& script_pub_keys, const bool have_solving_data, const bool internal, const int64_t timestamp)
1720+
bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScript>& script_pub_keys, const bool have_solving_data, const bool apply_label, const int64_t timestamp)
17211721
{
17221722
WalletBatch batch(*database);
17231723
for (const CScript& script : script_pub_keys) {
@@ -1728,7 +1728,7 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri
17281728
}
17291729
CTxDestination dest;
17301730
ExtractDestination(script, dest);
1731-
if (!internal && IsValidDestination(dest)) {
1731+
if (apply_label && IsValidDestination(dest)) {
17321732
SetAddressBookWithDB(batch, dest, label, "receive");
17331733
}
17341734
}

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ class CWallet final : public CCryptoKeyStore, private interfaces::Chain::Notific
10951095
bool ImportScripts(const std::set<CScript> scripts) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
10961096
bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
10971097
bool ImportPubKeys(const std::vector<CKeyID>& ordered_pubkeys, const std::map<CKeyID, CPubKey>& pubkey_map, const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>>& key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1098-
bool ImportScriptPubKeys(const std::string& label, const std::set<CScript>& script_pub_keys, const bool have_solving_data, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1098+
bool ImportScriptPubKeys(const std::string& label, const std::set<CScript>& script_pub_keys, const bool have_solving_data, const bool apply_label, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
10991099

11001100
CFeeRate m_pay_tx_fee{DEFAULT_PAY_TX_FEE};
11011101
unsigned int m_confirm_target{DEFAULT_TX_CONFIRM_TARGET};

0 commit comments

Comments
 (0)