| 735 | } |
| 736 | |
| 737 | bool LegacyScriptPubKeyMan::AddKeyPubKeyWithDB(WalletBatch& batch, const CKey& secret, const CPubKey& pubkey) |
| 738 | { |
| 739 | AssertLockHeld(cs_KeyStore); |
| 740 | |
| 741 | // Make sure we aren't adding private keys to private key disabled wallets |
| 742 | assert(!m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)); |
| 743 | |
| 744 | // FillableSigningProvider has no concept of wallet databases, but calls AddCryptedKey |
| 745 | // which is overridden below. To avoid flushes, the database handle is |
| 746 | // tunneled through to it. |
| 747 | bool needsDB = !encrypted_batch; |
| 748 | if (needsDB) { |
| 749 | encrypted_batch = &batch; |
| 750 | } |
| 751 | if (!AddKeyPubKeyInner(secret, pubkey)) { |
| 752 | if (needsDB) encrypted_batch = nullptr; |
| 753 | return false; |
| 754 | } |
| 755 | if (needsDB) encrypted_batch = nullptr; |
| 756 | |
| 757 | // check if we need to remove from watch-only |
| 758 | CScript script; |
| 759 | script = GetScriptForDestination(PKHash(pubkey)); |
| 760 | if (HaveWatchOnly(script)) { |
| 761 | RemoveWatchOnly(script); |
| 762 | } |
| 763 | script = GetScriptForRawPubKey(pubkey); |
| 764 | if (HaveWatchOnly(script)) { |
| 765 | RemoveWatchOnly(script); |
| 766 | } |
| 767 | |
| 768 | if (!m_storage.HasEncryptionKeys()) { |
| 769 | return batch.WriteKey(pubkey, |
| 770 | secret.GetPrivKey(), |
| 771 | mapKeyMetadata[pubkey.GetID()]); |
| 772 | } |
| 773 | m_storage.UnsetBlankWalletFlag(batch); |
| 774 | return true; |
| 775 | } |
| 776 | |
| 777 | bool LegacyScriptPubKeyMan::LoadCScript(const CScript& redeemScript) |
| 778 | { |
nothing calls this directly
no test coverage detected