MCPcopy Create free account
hub / github.com/ElementsProject/elements / AddKeyPubKeyWithDB

Method AddKeyPubKeyWithDB

src/wallet/scriptpubkeyman.cpp:737–775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

735}
736
737bool 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
777bool LegacyScriptPubKeyMan::LoadCScript(const CScript& redeemScript)
778{

Callers

nothing calls this directly

Calls 9

GetScriptForDestinationFunction · 0.85
PKHashClass · 0.85
GetScriptForRawPubKeyFunction · 0.85
IsWalletFlagSetMethod · 0.80
HasEncryptionKeysMethod · 0.80
UnsetBlankWalletFlagMethod · 0.80
WriteKeyMethod · 0.45
GetPrivKeyMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected