Skip to content

Commit a277f83

Browse files
committed
wallet: migration bugfix, persist empty labels
addressbook records with no associated label could be treated as change. And we don't want that for external addresses.
1 parent 1b64f64 commit a277f83

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/wallet/wallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4059,10 +4059,10 @@ bool CWallet::ApplyMigrationData(MigrationData& data, bilingual_str& error)
40594059
WalletBatch batch{wallet.GetDatabase()};
40604060
for (const auto& [destination, addr_book_data] : wallet.m_address_book) {
40614061
auto address{EncodeDestination(destination)};
4062-
auto label{addr_book_data.GetLabel()};
4063-
// don't bother writing default values (unknown purpose, empty label)
4062+
std::optional<std::string> label = addr_book_data.IsChange() ? std::nullopt : std::make_optional(addr_book_data.GetLabel());
4063+
// don't bother writing default values (unknown purpose)
40644064
if (addr_book_data.purpose) batch.WritePurpose(address, PurposeToString(*addr_book_data.purpose));
4065-
if (!label.empty()) batch.WriteName(address, label);
4065+
if (label) batch.WriteName(address, *label);
40664066
}
40674067
};
40684068
if (data.watchonly_wallet) persist_address_book(*data.watchonly_wallet);

0 commit comments

Comments
 (0)