| 810 | } |
| 811 | |
| 812 | bool 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 | |
| 852 | CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries, std::string strAccount) |
| 853 | { |
no test coverage detected