mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
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.
This commit is contained in:
parent
1b64f6498c
commit
a277f8357a
1 changed files with 3 additions and 3 deletions
|
@ -4059,10 +4059,10 @@ bool CWallet::ApplyMigrationData(MigrationData& data, bilingual_str& error)
|
|||
WalletBatch batch{wallet.GetDatabase()};
|
||||
for (const auto& [destination, addr_book_data] : wallet.m_address_book) {
|
||||
auto address{EncodeDestination(destination)};
|
||||
auto label{addr_book_data.GetLabel()};
|
||||
// don't bother writing default values (unknown purpose, empty label)
|
||||
std::optional<std::string> label = addr_book_data.IsChange() ? std::nullopt : std::make_optional(addr_book_data.GetLabel());
|
||||
// don't bother writing default values (unknown purpose)
|
||||
if (addr_book_data.purpose) batch.WritePurpose(address, PurposeToString(*addr_book_data.purpose));
|
||||
if (!label.empty()) batch.WriteName(address, label);
|
||||
if (label) batch.WriteName(address, *label);
|
||||
}
|
||||
};
|
||||
if (data.watchonly_wallet) persist_address_book(*data.watchonly_wallet);
|
||||
|
|
Loading…
Reference in a new issue