| 873 | } |
| 874 | |
| 875 | bool 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 | |
| 913 | void CWallet::MarkDirty() |
| 914 | { |
no test coverage detected