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

Method GetAccountDestination

src/wallet.cpp:812–850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810}
811
812bool CWallet::GetAccountDestination(CTxDestination &dest, std::string strAccount, bool bForceNew)
813{
814 CWalletDB walletdb(strWalletFile);
815
816 CAccount account;
817 walletdb.ReadAccount(strAccount, account);
818
819 if (!bForceNew) {
820 if (!account.vchPubKey.IsValid())
821 bForceNew = true;
822 else {
823 // Check if the current key has been used (TODO: check other addresses with the same key)
824 CScript scriptPubKey = GetScriptForDestination(GetDestinationForKey(account.vchPubKey, g_address_type));
825 for (std::map<uint256, CWalletTx>::iterator it = mapWallet.begin();
826 it != mapWallet.end() && account.vchPubKey.IsValid();
827 ++it)
828 for (const CTxOut& txout : (*it).second.vout)
829 if (txout.scriptPubKey == scriptPubKey) {
830 bForceNew = true;
831 break;
832 }
833 }
834 }
835
836 // Generate a new key
837 if (bForceNew) {
838 if (!GetKeyFromPool(account.vchPubKey, false))
839 return false;
840
841 LearnRelatedScripts(account.vchPubKey, g_address_type);
842 dest = GetDestinationForKey(account.vchPubKey, g_address_type);
843 SetAddressBook(dest, strAccount, "receive");
844 walletdb.WriteAccount(strAccount, account);
845 } else {
846 dest = GetDestinationForKey(account.vchPubKey, g_address_type);
847 }
848
849 return true;
850}
851
852CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries, std::string strAccount)
853{

Callers 1

GetAccountDestinationFunction · 0.80

Calls 7

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

Tested by

no test coverage detected