| 404 | } |
| 405 | |
| 406 | void LegacyScriptPubKeyMan::UpgradeKeyMetadata() |
| 407 | { |
| 408 | LOCK(cs_KeyStore); |
| 409 | if (m_storage.IsLocked() || m_storage.IsWalletFlagSet(WALLET_FLAG_KEY_ORIGIN_METADATA)) { |
| 410 | return; |
| 411 | } |
| 412 | |
| 413 | std::unique_ptr<WalletBatch> batch = std::make_unique<WalletBatch>(m_storage.GetDatabase()); |
| 414 | for (auto& meta_pair : mapKeyMetadata) { |
| 415 | CKeyMetadata& meta = meta_pair.second; |
| 416 | if (!meta.hd_seed_id.IsNull() && !meta.has_key_origin && meta.hdKeypath != "s") { // If the hdKeypath is "s", that's the seed and it doesn't have a key origin |
| 417 | CKey key; |
| 418 | GetKey(meta.hd_seed_id, key); |
| 419 | CExtKey masterKey; |
| 420 | masterKey.SetSeed(key); |
| 421 | // Add to map |
| 422 | CKeyID master_id = masterKey.key.GetPubKey().GetID(); |
| 423 | std::copy(master_id.begin(), master_id.begin() + 4, meta.key_origin.fingerprint); |
| 424 | if (!ParseHDKeypath(meta.hdKeypath, meta.key_origin.path)) { |
| 425 | throw std::runtime_error("Invalid stored hdKeypath"); |
| 426 | } |
| 427 | meta.has_key_origin = true; |
| 428 | if (meta.nVersion < CKeyMetadata::VERSION_WITH_KEY_ORIGIN) { |
| 429 | meta.nVersion = CKeyMetadata::VERSION_WITH_KEY_ORIGIN; |
| 430 | } |
| 431 | |
| 432 | // Write meta to wallet |
| 433 | CPubKey pubkey; |
| 434 | if (GetPubKey(meta_pair.first, pubkey)) { |
| 435 | batch->WriteKeyMetadata(meta, pubkey, true); |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | bool LegacyScriptPubKeyMan::SetupGeneration(bool force) |
| 442 | { |
nothing calls this directly
no test coverage detected