12 #include <boost/algorithm/string/replace.hpp>
25 const pair<
int64, pair<const CWalletTx*, unsigned int> >& t2)
const
27 return t1.first < t2.first;
44 if (!AddKeyPubKey(secret, pubkey))
45 throw std::runtime_error(
"CWallet::GenerateNewKey() : AddKey failed");
69 if (pwalletdbEncryption)
70 return pwalletdbEncryption->WriteCryptedKey(vchPubKey, vchCryptedSecret);
101 BOOST_FOREACH(
const MasterKeyMap::value_type& pMasterKey, mapMasterKeys)
103 if(!crypter.
SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
105 if (!crypter.
Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey))
116 bool fWasLocked = IsLocked();
124 BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys)
126 if(!crypter.
SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
128 if (!crypter.
Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey))
133 crypter.
SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod);
134 pMasterKey.second.nDeriveIterations = pMasterKey.second.nDeriveIterations * (100 / ((double)(
GetTimeMillis() - nStartTime)));
137 crypter.
SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod);
138 pMasterKey.second.nDeriveIterations = (pMasterKey.second.nDeriveIterations + pMasterKey.second.nDeriveIterations * 100 / ((double)(
GetTimeMillis() - nStartTime))) / 2;
140 if (pMasterKey.second.nDeriveIterations < 25000)
141 pMasterKey.second.nDeriveIterations = 25000;
143 printf(
"Wallet passphrase changed to an nDeriveIterations of %i\n", pMasterKey.second.nDeriveIterations);
145 if (!crypter.
SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
147 if (!crypter.
Encrypt(vMasterKey, pMasterKey.second.vchCryptedKey))
180 if (nWalletVersion >= nVersion)
184 if (fExplicit && nVersion > nWalletMaxVersion)
187 nWalletVersion = nVersion;
189 if (nVersion > nWalletMaxVersion)
190 nWalletMaxVersion = nVersion;
195 if (nWalletVersion >= 40000)
200 pwalletdb->
WriteSetting(
"addrIncoming", corruptAddress);
202 if (nWalletVersion > 40000)
214 if (nWalletVersion > nVersion)
217 nWalletMaxVersion = nVersion;
260 mapMasterKeys[++nMasterKeyMaxID] = kMasterKey;
263 pwalletdbEncryption =
new CWalletDB(strWalletFile);
264 if (!pwalletdbEncryption->TxnBegin())
266 pwalletdbEncryption->WriteMasterKey(nMasterKeyMaxID, kMasterKey);
269 if (!EncryptKeys(vMasterKey))
272 pwalletdbEncryption->TxnAbort();
281 if (!pwalletdbEncryption->TxnCommit())
284 delete pwalletdbEncryption;
285 pwalletdbEncryption = NULL;
289 Unlock(strWalletPassphrase);
298 NotifyStatusChanged(
this);
305 int64 nRet = nOrderPosNext++;
323 for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
345 BOOST_FOREACH(
const CTxIn& txin, tx.
vin)
347 map<uint256, CWalletTx>::iterator mi = mapWallet.find(txin.
prevout.
hash);
348 if (mi != mapWallet.end())
380 pair<map<uint256, CWalletTx>::iterator,
bool> ret = mapWallet.insert(make_pair(hash, wtxIn));
383 bool fInsertedNew = ret.second;
395 unsigned int latestEntry = 0;
398 int64 latestTolerated = latestNow + 300;
399 std::list<CAccountingEntry> acentries;
400 TxItems txOrdered = OrderedTxItems(acentries);
401 for (TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
403 CWalletTx *
const pwtx = (*it).second.first;
415 nSmartTime = pacentry->
nTime;
416 if (nSmartTime <= latestTolerated)
418 latestEntry = nSmartTime;
419 if (nSmartTime > latestNow)
420 latestNow = nSmartTime;
427 wtx.
nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow));
430 printf(
"AddToWallet() : found %s in block %s not in index\n",
436 bool fUpdated =
false;
456 fUpdated |= wtx.UpdateSpent(wtxIn.
vfSpent);
460 printf(
"AddToWallet %s %s%s\n", wtxIn.
GetHash().
ToString().c_str(), (fInsertedNew ?
"new" :
""), (fUpdated ?
"update" :
""));
463 if (fInsertedNew || fUpdated)
468 if (vchDefaultKey.IsValid()) {
476 if (GetKeyFromPool(newDefaultKey,
false))
478 SetDefaultKey(newDefaultKey);
479 SetAddressBookName(vchDefaultKey.GetID(),
"");
486 WalletUpdateSpent(wtx);
492 std::string strCmd =
GetArg(
"-walletnotify",
"");
494 if ( !strCmd.empty())
511 bool fExisted = mapWallet.count(hash);
512 if (fExisted && !fUpdate)
return false;
513 if (fExisted ||
IsMine(tx) || IsFromMe(tx))
518 wtx.SetMerkleBranch(pblock);
519 return AddToWallet(wtx);
522 WalletUpdateSpent(tx);
533 if (mapWallet.erase(hash))
544 map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(txin.
prevout.
hash);
545 if (mi != mapWallet.end())
560 map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(txin.
prevout.
hash);
561 if (mi != mapWallet.end())
586 if (!mapAddressBook.count(address))
594 int64 n = nTimeSmart;
595 return n ? n : nTimeReceived;
603 LOCK(pwallet->cs_wallet);
609 map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(hashBlock);
610 if (mi != pwallet->mapRequestCount.end())
611 nRequests = (*mi).second;
617 map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(GetHash());
618 if (mi != pwallet->mapRequestCount.end())
620 nRequests = (*mi).second;
623 if (nRequests == 0 && hashBlock != 0)
625 map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(hashBlock);
626 if (mi != pwallet->mapRequestCount.end())
627 nRequests = (*mi).second;
638 list<pair<CTxDestination, int64> >& listSent,
int64& nFee,
string& strSentAccount)
const
641 listReceived.clear();
643 strSentAccount = strFromAccount;
646 int64 nDebit = GetDebit();
649 int64 nValueOut = GetValueOut();
650 nFee = nDebit - nValueOut;
654 BOOST_FOREACH(
const CTxOut& txout, vout)
657 vector<unsigned char> vchPubKey;
660 printf(
"CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
661 this->GetHash().ToString().c_str());
665 if (nDebit > 0 && pwallet->IsChange(txout))
669 listSent.push_back(make_pair(address, txout.
nValue));
671 if (pwallet->IsMine(txout))
672 listReceived.push_back(make_pair(address, txout.
nValue));
680 nReceived = nSent = nFee = 0;
683 string strSentAccount;
684 list<pair<CTxDestination, int64> > listReceived;
685 list<pair<CTxDestination, int64> > listSent;
686 GetAmounts(listReceived, listSent, allFee, strSentAccount);
688 if (strAccount == strSentAccount)
695 LOCK(pwallet->cs_wallet);
698 if (pwallet->mapAddressBook.count(r.first))
700 map<CTxDestination, string>::const_iterator mi = pwallet->mapAddressBook.find(r.first);
701 if (mi != pwallet->mapAddressBook.end() && (*mi).second == strAccount)
702 nReceived += r.second;
704 else if (strAccount.empty())
706 nReceived += r.second;
716 const int COPY_DEPTH = 3;
717 if (SetMerkleBranch() < COPY_DEPTH)
719 vector<uint256> vWorkQueue;
720 BOOST_FOREACH(
const CTxIn& txin, vin)
724 LOCK(pwallet->cs_wallet);
725 map<uint256, const CMerkleTx*> mapWalletPrev;
726 set<uint256> setAlreadyDone;
727 for (
unsigned int i = 0; i < vWorkQueue.size(); i++)
730 if (setAlreadyDone.count(hash))
732 setAlreadyDone.insert(hash);
735 map<uint256, CWalletTx>::const_iterator mi = pwallet->mapWallet.find(hash);
736 if (mi != pwallet->mapWallet.end())
739 BOOST_FOREACH(
const CMerkleTx& txWalletPrev, (*mi).second.vtxPrev)
740 mapWalletPrev[txWalletPrev.
GetHash()] = &txWalletPrev;
742 else if (mapWalletPrev.count(hash))
744 tx = *mapWalletPrev[
hash];
751 int nDepth = tx.SetMerkleBranch();
752 vtxPrev.push_back(tx);
754 if (nDepth < COPY_DEPTH)
756 BOOST_FOREACH(
const CTxIn& txin, tx.
vin)
763 reverse(vtxPrev.begin(), vtxPrev.end());
787 if (AddToWalletIfInvolvingMe(tx.
GetHash(), tx, &block, fUpdate))
790 pindex = pindex->
pnext;
803 bool fMissing =
false;
811 bool fUpdated =
false;
816 for (
unsigned int i = 0; i < wtx.
vout.size(); i++)
852 BOOST_FOREACH(
const CMerkleTx& tx, vtxPrev)
863 if (GetDepthInMainChain() == 0) {
875 static int64 nNextTime;
878 bool fFirst = (nNextTime == 0);
884 static int64 nLastTime;
890 printf(
"ResendWalletTransactions()\n");
894 multimap<unsigned int, CWalletTx*> mapSorted;
927 for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
943 for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
958 for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
974 for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
987 for (
unsigned int i = 0; i < pcoin->
vout.size(); i++) {
997 static void ApproximateBestSubset(vector<pair<
int64, pair<const CWalletTx*,unsigned int> > >vValue,
int64 nTotalLower,
int64 nTargetValue,
998 vector<char>& vfBest,
int64& nBest,
int iterations = 1000)
1000 vector<char> vfIncluded;
1002 vfBest.assign(vValue.size(),
true);
1003 nBest = nTotalLower;
1007 for (
int nRep = 0; nRep < iterations && nBest != nTargetValue; nRep++)
1009 vfIncluded.assign(vValue.size(),
false);
1011 bool fReachedTarget =
false;
1012 for (
int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
1014 for (
unsigned int i = 0; i < vValue.size(); i++)
1022 if (nPass == 0 ? insecure_rand()&1 : !vfIncluded[i])
1024 nTotal += vValue[i].first;
1025 vfIncluded[i] =
true;
1026 if (nTotal >= nTargetValue)
1028 fReachedTarget =
true;
1032 vfBest = vfIncluded;
1034 nTotal -= vValue[i].first;
1035 vfIncluded[i] =
false;
1044 set<pair<const CWalletTx*,unsigned int> >& setCoinsRet,
int64& nValueRet)
const
1046 setCoinsRet.clear();
1050 pair<int64, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
1051 coinLowestLarger.first = std::numeric_limits<int64>::max();
1052 coinLowestLarger.second.first = NULL;
1053 vector<pair<int64, pair<const CWalletTx*,unsigned int> > > vValue;
1054 int64 nTotalLower = 0;
1056 random_shuffle(vCoins.begin(), vCoins.end(),
GetRandInt);
1058 BOOST_FOREACH(
COutput output, vCoins)
1062 if (output.
nDepth < (pcoin->
IsFromMe() ? nConfMine : nConfTheirs))
1068 pair<int64,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i));
1070 if (n == nTargetValue)
1072 setCoinsRet.insert(coin.second);
1073 nValueRet += coin.first;
1076 else if (n < nTargetValue + CENT)
1078 vValue.push_back(coin);
1081 else if (n < coinLowestLarger.first)
1083 coinLowestLarger = coin;
1087 if (nTotalLower == nTargetValue)
1089 for (
unsigned int i = 0; i < vValue.size(); ++i)
1091 setCoinsRet.insert(vValue[i].second);
1092 nValueRet += vValue[i].first;
1097 if (nTotalLower < nTargetValue)
1099 if (coinLowestLarger.second.first == NULL)
1101 setCoinsRet.insert(coinLowestLarger.second);
1102 nValueRet += coinLowestLarger.first;
1108 vector<char> vfBest;
1111 ApproximateBestSubset(vValue, nTotalLower, nTargetValue, vfBest, nBest, 1000);
1112 if (nBest != nTargetValue && nTotalLower >= nTargetValue + CENT)
1113 ApproximateBestSubset(vValue, nTotalLower, nTargetValue + CENT, vfBest, nBest, 1000);
1117 if (coinLowestLarger.second.first &&
1118 ((nBest != nTargetValue && nBest < nTargetValue + CENT) || coinLowestLarger.first <= nBest))
1120 setCoinsRet.insert(coinLowestLarger.second);
1121 nValueRet += coinLowestLarger.first;
1124 for (
unsigned int i = 0; i < vValue.size(); i++)
1127 setCoinsRet.insert(vValue[i].second);
1128 nValueRet += vValue[i].first;
1132 printf(
"SelectCoins() best subset: ");
1133 for (
unsigned int i = 0; i < vValue.size(); i++)
1144 vector<COutput> vCoins;
1145 AvailableCoins(vCoins,
true, coinControl);
1150 BOOST_FOREACH(
const COutput& out, vCoins)
1152 nValueRet += out.
tx->
vout[out.
i].nValue;
1153 setCoinsRet.insert(make_pair(out.
tx, out.
i));
1155 return (nValueRet >= nTargetValue);
1158 return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet) ||
1159 SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet) ||
1160 SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet));
1174 strFailReason =
_(
"Transaction amounts must be positive");
1179 if (vecSend.empty() || nValue < 0)
1181 strFailReason =
_(
"Transaction amounts must be positive");
1194 wtxNew.
vout.clear();
1197 int64 nTotalValue = nValue + nFeeRet;
1198 double dPriority = 0;
1202 CTxOut txout(s.second, s.first);
1205 strFailReason =
_(
"Transaction amount too small");
1208 wtxNew.
vout.push_back(txout);
1212 set<pair<const CWalletTx*,unsigned int> > setCoins;
1214 if (!SelectCoins(nTotalValue, setCoins, nValueIn, coinControl))
1216 strFailReason =
_(
"Insufficient funds");
1221 int64 nCredit = pcoin.first->vout[pcoin.second].nValue;
1225 dPriority += (double)nCredit * (pcoin.first->GetDepthInMainChain()+1);
1228 int64 nChange = nValueIn - nValue - nFeeRet;
1232 if (nFeeRet < CTransaction::nMinTxFee && nChange > 0 && nChange < CENT)
1235 nChange -= nMoveToFee;
1236 nFeeRet += nMoveToFee;
1247 if (coinControl && !boost::get<CNoDestination>(&coinControl->
destChange))
1267 CTxOut newTxOut(nChange, scriptChange);
1271 if (newTxOut.IsDust())
1279 vector<CTxOut>::iterator position = wtxNew.
vout.begin()+
GetRandInt(wtxNew.
vout.size()+1);
1280 wtxNew.
vout.insert(position, newTxOut);
1288 wtxNew.vin.push_back(
CTxIn(coin.first->GetHash(),coin.second));
1295 strFailReason =
_(
"Signing transaction failed");
1301 if (nBytes >= MAX_STANDARD_TX_SIZE)
1303 strFailReason =
_(
"Transaction too large");
1306 dPriority /= nBytes;
1312 if (nFeeRet < max(nPayFee, nMinFee))
1314 nFeeRet = max(nPayFee, nMinFee);
1332 vector< pair<CScript, int64> > vecSend;
1333 vecSend.push_back(make_pair(scriptPubKey, nValue));
1334 return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, strFailReason, coinControl);
1354 AddToWallet(wtxNew);
1357 set<CWalletTx*> setCoins;
1358 BOOST_FOREACH(
const CTxIn& txin, wtxNew.
vin)
1372 mapRequestCount[wtxNew.
GetHash()] = 0;
1378 printf(
"CommitTransaction() : Error: Transaction not valid");
1396 string strError =
_(
"Error: Wallet locked, unable to create transaction!");
1397 printf(
"SendMoney() : %s", strError.c_str());
1401 if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError))
1403 if (nValue + nFeeRequired > GetBalance())
1404 strError =
strprintf(
_(
"Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!"),
FormatMoney(nFeeRequired).c_str());
1405 printf(
"SendMoney() : %s\n", strError.c_str());
1412 if (!CommitTransaction(wtxNew, reservekey))
1413 return _(
"Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
1424 return _(
"Invalid amount");
1426 return _(
"Insufficient funds");
1432 return SendMoney(scriptPubKey, nValue, wtxNew, fAskFee);
1442 fFirstRunRet =
false;
1456 return nLoadWalletRet;
1457 fFirstRunRet = !vchDefaultKey.IsValid();
1465 std::map<CTxDestination, std::string>::iterator mi = mapAddressBook.find(address);
1466 mapAddressBook[address] = strName;
1467 NotifyAddressBookChanged(
this, address, strName, ::
IsMine(*
this, address), (mi == mapAddressBook.end()) ?
CT_NEW :
CT_UPDATED);
1475 mapAddressBook.erase(address);
1476 NotifyAddressBookChanged(
this, address,
"", ::
IsMine(*
this, address),
CT_DELETED);
1487 if (mapWallet.count(block.
vtx[0].GetHash()))
1500 map<uint256, CWalletTx>::iterator mi = mapWallet.find(hashTx);
1501 if (mi != mapWallet.end())
1514 if (!
CWalletDB(strWalletFile).WriteDefaultKey(vchPubKey))
1517 vchDefaultKey = vchPubKey;
1538 BOOST_FOREACH(
int64 nIndex, setKeyPool)
1546 for (
int i = 0; i < nKeys; i++)
1550 setKeyPool.insert(nIndex);
1552 printf(
"CWallet::NewKeyPool wrote %"PRI64d" new keys\n", nKeys);
1568 unsigned int nTargetSize = max(
GetArg(
"-keypool", 100), 0LL);
1569 while (setKeyPool.size() < (nTargetSize + 1))
1572 if (!setKeyPool.empty())
1573 nEnd = *(--setKeyPool.end()) + 1;
1575 throw runtime_error(
"TopUpKeyPool() : writing generated key failed");
1576 setKeyPool.insert(nEnd);
1594 if(setKeyPool.empty())
1599 nIndex = *(setKeyPool.begin());
1600 setKeyPool.erase(setKeyPool.begin());
1601 if (!walletdb.
ReadPool(nIndex, keypool))
1602 throw runtime_error(
"ReserveKeyFromKeyPool() : read failed");
1604 throw runtime_error(
"ReserveKeyFromKeyPool() : unknown key in key pool");
1616 int64 nIndex = 1 + *(--setKeyPool.end());
1617 if (!walletdb.
WritePool(nIndex, keypool))
1618 throw runtime_error(
"AddReserveKey() : writing added key failed");
1619 setKeyPool.insert(nIndex);
1641 setKeyPool.insert(nIndex);
1652 ReserveKeyFromKeyPool(nIndex, keypool);
1655 if (fAllowReuse && vchDefaultKey.IsValid())
1657 result = vchDefaultKey;
1660 if (IsLocked())
return false;
1661 result = GenerateNewKey();
1674 ReserveKeyFromKeyPool(nIndex, keypool);
1678 return keypool.
nTime;
1683 map<CTxDestination, int64> balances;
1698 if (nDepth < (pcoin->
IsFromMe() ? 0 : 1))
1701 for (
unsigned int i = 0; i < pcoin->
vout.size(); i++)
1711 if (!balances.count(addr))
1713 balances[addr] += n;
1723 set< set<CTxDestination> > groupings;
1724 set<CTxDestination> grouping;
1730 if (pcoin->
vin.size() > 0)
1732 bool any_mine =
false;
1734 BOOST_FOREACH(
CTxIn txin, pcoin->
vin)
1741 grouping.insert(address);
1749 if (IsChange(txout))
1754 grouping.insert(txoutAddr);
1757 if (grouping.size() > 0)
1759 groupings.insert(grouping);
1765 for (
unsigned int i = 0; i < pcoin->
vout.size(); i++)
1771 grouping.insert(address);
1772 groupings.insert(grouping);
1777 set< set<CTxDestination>* > uniqueGroupings;
1778 map< CTxDestination, set<CTxDestination>* > setmap;
1779 BOOST_FOREACH(set<CTxDestination> grouping, groupings)
1782 set< set<CTxDestination>* > hits;
1783 map< CTxDestination, set<CTxDestination>* >::iterator it;
1785 if ((it = setmap.find(address)) != setmap.end())
1786 hits.insert((*it).second);
1789 set<CTxDestination>* merged =
new set<CTxDestination>(grouping);
1790 BOOST_FOREACH(set<CTxDestination>* hit, hits)
1792 merged->insert(hit->begin(), hit->end());
1793 uniqueGroupings.erase(hit);
1796 uniqueGroupings.insert(merged);
1800 setmap[element] = merged;
1803 set< set<CTxDestination> > ret;
1804 BOOST_FOREACH(set<CTxDestination>* uniqueGrouping, uniqueGroupings)
1806 ret.insert(*uniqueGrouping);
1807 delete uniqueGrouping;
1818 pwallet->ReserveKeyFromKeyPool(nIndex, keypool);
1822 if (pwallet->vchDefaultKey.IsValid()) {
1823 printf(
"CReserveKey::GetReservedKey(): Warning: Using default key instead of a new key, top up your keypool!");
1824 vchPubKey = pwallet->vchDefaultKey;
1837 pwallet->KeepKey(nIndex);
1845 pwallet->ReturnKey(nIndex);
1857 BOOST_FOREACH(
const int64&
id, setKeyPool)
1860 if (!walletdb.
ReadPool(
id, keypool))
1861 throw runtime_error(
"GetAllReserveKeyHashes() : read failed");
1864 if (!HaveKey(keyID))
1865 throw runtime_error(
"GetAllReserveKeyHashes() : unknown key in key pool");
1866 setAddress.insert(keyID);
1875 map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(hashTx);
1876 if (mi != mapWallet.end())
1877 NotifyTransactionChanged(
this, hashTx,
CT_UPDATED);
1883 setLockedCoins.insert(output);
1888 setLockedCoins.erase(output);
1893 setLockedCoins.clear();
1900 return (setLockedCoins.count(outpt) > 0);
1905 for (std::set<COutPoint>::iterator it = setLockedCoins.begin();
1906 it != setLockedCoins.end(); it++) {
1908 vOutpts.push_back(outpt);
bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret)
bool WriteMinVersion(int nVersion)
bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector< unsigned char > &chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
bool GetWalletFile(CWallet *pwallet, string &strWalletFileOut)
bool IsFinal(int nBlockHeight=0, int64 nBlockTime=0) const
void GetAccountAmounts(const std::string &strAccount, int64 &nReceived, int64 &nSent, int64 &nFee) const
#define strprintf(format,...)
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey)
void BindWallet(CWallet *pwalletIn)
unsigned int nDerivationMethod
bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey)
bool EraseFromWallet(uint256 hash)
bool IsMine(const CTxIn &txin) const
bool Encrypt(const CKeyingMaterial &vchPlaintext, std::vector< unsigned char > &vchCiphertext)
const unsigned int WALLET_CRYPTO_KEY_SIZE
std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx &wtxNew, bool fAskFee=false)
std::vector< CTxOut > vout
void ListLockedCoins(std::vector< COutPoint > &vOutpts)
static bool Rewrite(const std::string &strFile, const char *pszSkip=NULL)
Encryption/decryption context with key information.
int64 GetUnconfirmedBalance() const
std::vector< unsigned char > vchCryptedKey
std::string SendMoneyToDestination(const CTxDestination &address, int64 nValue, CWalletTx &wtxNew, bool fAskFee=false)
WalletFeature
(client) version numbers for particular wallet features
bool WriteMasterKey(unsigned int nID, const CMasterKey &kMasterKey)
bool AddToWalletIfInvolvingMe(const uint256 &hash, const CTransaction &tx, const CBlock *pblock, bool fUpdate=false, bool fFindBlock=false)
Master key for wallet encryption.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
int64 GetOldestKeyPoolTime()
bool SignSignature(const CKeyStore &keystore, const CScript &fromPubKey, CTransaction &txTo, unsigned int nIn, int nHashType)
void seed_insecure_rand(bool fDeterministic)
Seed insecure_rand using the random pool.
bool IsSpent(unsigned int nOut) const
void GetAllReserveKeys(std::set< CKeyID > &setAddress)
static bool AllowFree(double dPriority)
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
bool WriteSetting(const std::string &strKey, const T &value)
bool ReadPool(int64 nPool, CKeyPool &keypool)
bool IsSelected(const uint256 &hash, unsigned int n) const
void ListAccountCreditDebit(const std::string &strAccount, std::list< CAccountingEntry > &acentries)
#define IMPLEMENT_SERIALIZE(statements)
int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true, enum GetMinFee_mode mode=GMF_BLOCK) const
pruned version of CTransaction: only retains metadata and unspent transaction outputs ...
int64 GetDebit(const CTxIn &txin) const
std::vector< char > vfSpent
uint160 Hash160(const T1 pbegin, const T1 pend)
bool SetMaxVersion(int nVersion)
virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret)
DBErrors
Error statuses for the wallet database.
void RandAddSeedPerfmon()
void ReacceptWalletTransactions()
bool SetDefaultKey(const CPubKey &vchPubKey)
int64 AddReserveKey(const CKeyPool &keypool)
bool GetCoins(const uint256 &txid, CCoins &coins)
int64 GetCredit(bool fUseCache=true) const
bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, std::vector< COutput > vCoins, std::set< std::pair< const CWalletTx *, unsigned int > > &setCoinsRet, int64 &nValueRet) const
bool SetAddressBookName(const CTxDestination &address, const std::string &strName)
void SetBestChain(const CBlockLocator &loc)
bool EraseTx(uint256 hash)
static int64 nMinTxFee
Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) ...
void SetDestination(const CTxDestination &address)
virtual bool AddCScript(const CScript &redeemScript)
bool SelectCoins(int64 nTargetValue, std::set< std::pair< const CWalletTx *, unsigned int > > &setCoinsRet, int64 &nValueRet, const CCoinControl *coinControl=NULL) const
bool SetMinVersion(enum WalletFeature, CWalletDB *pwalletdbIn=NULL, bool fExplicit=false)
bool GetTransaction(const uint256 &hashTx, CWalletTx &wtx)
int GetBlocksToMaturity() const
void WalletUpdateSpent(const CTransaction &prevout)
void KeepKey(int64 nIndex)
int GetRequestCount() const
bool operator()(const pair< int64, pair< const CWalletTx *, unsigned int > > &t1, const pair< int64, pair< const CWalletTx *, unsigned int > > &t2) const
void LockCoin(COutPoint &output)
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
unsigned int GetSerializeSize(char a, int, int=0)
int64 GetAvailableCredit(bool fUseCache=true) const
int64 GetImmatureCredit(bool fUseCache=true) const
An input of a transaction.
uint64 GetRand(uint64 nMax)
CPubKey GetPubKey() const
bool WriteName(const std::string &strAddress, const std::string &strName)
CPrivKey GetPrivKey() const
std::vector< CTxOut > vout
DBErrors LoadWallet(CWallet *pwallet)
bool WritePool(int64 nPool, const CKeyPool &keypool)
CTxDestination destChange
void UnlockCoin(COutPoint &output)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
int64 GetImmatureBalance() const
An encapsulated public key.
bool Unlock(const CKeyingMaterial &vMasterKeyIn)
bool Decrypt(const std::vector< unsigned char > &vchCiphertext, CKeyingMaterial &vchPlaintext)
CClientUIInterface uiInterface
void MakeNewKey(bool fCompressed)
std::vector< uint256 > vMerkleBranch
boost::signals2::signal< bool(int64 nFeeRequired), boost::signals2::last_value< bool > > ThreadSafeAskFee
Ask the user whether they want to pay a fee or not.
void RelayTransaction(const CTransaction &tx, const uint256 &hash)
bool DelAddressBookName(const CTxDestination &address)
bool CommitTransaction(CWalletTx &wtxNew, CReserveKey &reservekey)
bool AcceptToMemoryPool(bool fCheckInputs=true, bool fLimitFree=true)
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey)
void RelayWalletTransaction()
An output of a transaction.
bool GetReservedKey(CPubKey &pubkey)
std::set< std::set< CTxDestination > > GetAddressGroupings()
void AvailableCoins(std::vector< COutput > &vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL) const
An outpoint - a combination of a transaction hash and an index n into its vout.
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
std::string GetHex() const
unsigned int fTimeReceivedIsTxTime
bool WriteTx(uint256 hash, const CWalletTx &wtx)
std::string ToString() const
Access to the wallet database (wallet.dat)
A transaction with a bunch of additional info that only the owner cares about.
std::string strWalletFile
void UpdatedTransaction(const uint256 &hashTx)
bool WriteBestBlock(const CBlockLocator &locator)
const unsigned int WALLET_CRYPTO_SALT_SIZE
CBlockIndex * pindexGenesisBlock
bool WriteCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, bool fEraseUnencryptedKey=true)
int ScanForWalletTransactions(CBlockIndex *pindexStart, bool fUpdate=false)
bool EncryptWallet(const SecureString &strWalletPassphrase)
A key allocated from the key pool.
void GetAmounts(std::list< std::pair< CTxDestination, int64 > > &listReceived, std::list< std::pair< CTxDestination, int64 > > &listSent, int64 &nFee, std::string &strSentAccount) const
The block chain is a tree shaped structure starting with the genesis block at the root...
Serialized script, used inside transaction inputs and outputs.
std::string ToString() const
string FormatMoney(int64 n, bool fPlus)
bool WriteOrderPosNext(int64 nOrderPosNext)
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
bool IsMine(const CKeyStore &keystore, const CTxDestination &dest)
A reference to a CKey: the Hash160 of its serialized public key.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
bool GetKeyFromPool(CPubKey &key, bool fAllowReuse=true)
bool Unlock(const SecureString &strWalletPassphrase)
bool IsChange(const CTxOut &txout) const
void ResendWalletTransactions()
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
int GetDepthInMainChain(CBlockIndex *&pindexRet) const
std::vector< unsigned char > vchSalt
bool AddCScript(const CScript &redeemScript)
DBErrors LoadWallet(bool &fFirstRunRet)
std::vector< CTransaction > vtx
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
std::map< CTxDestination, int64 > GetAddressBalances()
unsigned int nTimeReceived
An encapsulated private key.
bool EraseName(const std::string &strAddress)
The basic transaction that is broadcasted on the network and contained in blocks. ...
unsigned int nDeriveIterations
bool WriteCScript(const uint160 &hash, const CScript &redeemScript)
bool AcceptWalletTransaction(bool fCheckInputs=true)
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret)
std::pair< CWalletTx *, CAccountingEntry * > TxPair
void ReserveKeyFromKeyPool(int64 &nIndex, CKeyPool &keypool)
bool IsLockedCoin(uint256 hash, unsigned int n) const
void PrintWallet(const CBlock &block)
bool ReadFromDisk(const CDiskBlockPos &pos)
bool ErasePool(int64 nPool)
map< uint256, CBlockIndex * > mapBlockIndex
void ReturnKey(int64 nIndex)
void MarkSpent(unsigned int nOut)
std::multimap< int64, TxPair > TxItems
int64 IncOrderPosNext(CWalletDB *pwalletdb=NULL)
Increment the next transaction order id.
bool CreateTransaction(const std::vector< std::pair< CScript, int64 > > &vecSend, CWalletTx &wtxNew, CReserveKey &reservekey, int64 &nFeeRet, std::string &strFailReason, const CCoinControl *coinControl=NULL)
void AddSupportingTransactions()
A transaction with a merkle branch linking it to the block chain.
void runCommand(std::string strCommand)
bool AddToWallet(const CWalletTx &wtxIn)
TxItems OrderedTxItems(std::list< CAccountingEntry > &acentries, std::string strAccount="")
Get the wallet's activity log.