MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetAccountPubkey

Method GetAccountPubkey

src/wallet.cpp:875–911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

873}
874
875bool CWallet::GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bForceNew)
876{
877 CWalletDB walletdb(strWalletFile);
878
879 CAccount account;
880 walletdb.ReadAccount(strAccount, account);
881
882 if (!bForceNew) {
883 if (!account.vchPubKey.IsValid())
884 bForceNew = true;
885 else {
886 // Check if the current key has been used
887 CScript scriptPubKey = GetScriptForDestination(account.vchPubKey.GetID());
888 for (map<uint256, CWalletTx>::iterator it = mapWallet.begin();
889 it != mapWallet.end() && account.vchPubKey.IsValid();
890 ++it)
891 for (const CTxOut& txout : (*it).second.vout)
892 if (txout.scriptPubKey == scriptPubKey) {
893 bForceNew = true;
894 break;
895 }
896 }
897 }
898
899 // Generate a new key
900 if (bForceNew) {
901 if (!GetKeyFromPool(account.vchPubKey, false))
902 return false;
903
904 SetAddressBook(account.vchPubKey.GetID(), strAccount, "receive");
905 walletdb.WriteAccount(strAccount, account);
906 }
907
908 pubKey = account.vchPubKey;
909
910 return true;
911}
912
913void CWallet::MarkDirty()
914{

Callers 1

GetAccountDestinationFunction · 0.80

Calls 7

GetScriptForDestinationFunction · 0.85
ReadAccountMethod · 0.80
WriteAccountMethod · 0.80
IsValidMethod · 0.45
GetIDMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected