|
|
@ -35,8 +35,8 @@ CFeeRate CWallet::minTxFee = CFeeRate(10000); // Override with -mintxfee |
|
|
|
|
|
|
|
|
|
|
|
struct CompareValueOnly |
|
|
|
struct CompareValueOnly |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool operator()(const pair<int64_t, pair<const CWalletTx*, unsigned int> >& t1, |
|
|
|
bool operator()(const pair<CAmount, pair<const CWalletTx*, unsigned int> >& t1, |
|
|
|
const pair<int64_t, pair<const CWalletTx*, unsigned int> >& t2) const |
|
|
|
const pair<CAmount, pair<const CWalletTx*, unsigned int> >& t2) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return t1.first < t2.first; |
|
|
|
return t1.first < t2.first; |
|
|
|
} |
|
|
|
} |
|
|
@ -697,7 +697,7 @@ isminetype CWallet::IsMine(const CTxIn &txin) const |
|
|
|
return ISMINE_NO; |
|
|
|
return ISMINE_NO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const |
|
|
|
CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_wallet); |
|
|
|
LOCK(cs_wallet); |
|
|
@ -781,7 +781,7 @@ int CWalletTx::GetRequestCount() const |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CWalletTx::GetAmounts(list<COutputEntry>& listReceived, |
|
|
|
void CWalletTx::GetAmounts(list<COutputEntry>& listReceived, |
|
|
|
list<COutputEntry>& listSent, int64_t& nFee, string& strSentAccount, const isminefilter& filter) const |
|
|
|
list<COutputEntry>& listSent, CAmount& nFee, string& strSentAccount, const isminefilter& filter) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
nFee = 0; |
|
|
|
nFee = 0; |
|
|
|
listReceived.clear(); |
|
|
|
listReceived.clear(); |
|
|
@ -789,10 +789,10 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived, |
|
|
|
strSentAccount = strFromAccount; |
|
|
|
strSentAccount = strFromAccount; |
|
|
|
|
|
|
|
|
|
|
|
// Compute fee:
|
|
|
|
// Compute fee:
|
|
|
|
int64_t nDebit = GetDebit(filter); |
|
|
|
CAmount nDebit = GetDebit(filter); |
|
|
|
if (nDebit > 0) // debit>0 means we signed/sent this transaction
|
|
|
|
if (nDebit > 0) // debit>0 means we signed/sent this transaction
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nValueOut = GetValueOut(); |
|
|
|
CAmount nValueOut = GetValueOut(); |
|
|
|
nFee = nDebit - nValueOut; |
|
|
|
nFee = nDebit - nValueOut; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -835,12 +835,12 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived, |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CWalletTx::GetAccountAmounts(const string& strAccount, int64_t& nReceived, |
|
|
|
void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived, |
|
|
|
int64_t& nSent, int64_t& nFee, const isminefilter& filter) const |
|
|
|
CAmount& nSent, CAmount& nFee, const isminefilter& filter) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
nReceived = nSent = nFee = 0; |
|
|
|
nReceived = nSent = nFee = 0; |
|
|
|
|
|
|
|
|
|
|
|
int64_t allFee; |
|
|
|
CAmount allFee; |
|
|
|
string strSentAccount; |
|
|
|
string strSentAccount; |
|
|
|
list<COutputEntry> listReceived; |
|
|
|
list<COutputEntry> listReceived; |
|
|
|
list<COutputEntry> listSent; |
|
|
|
list<COutputEntry> listSent; |
|
|
@ -1011,9 +1011,9 @@ void CWallet::ResendWalletTransactions() |
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int64_t CWallet::GetBalance() const |
|
|
|
CAmount CWallet::GetBalance() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
@ -1027,9 +1027,9 @@ int64_t CWallet::GetBalance() const |
|
|
|
return nTotal; |
|
|
|
return nTotal; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t CWallet::GetUnconfirmedBalance() const |
|
|
|
CAmount CWallet::GetUnconfirmedBalance() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
@ -1042,9 +1042,9 @@ int64_t CWallet::GetUnconfirmedBalance() const |
|
|
|
return nTotal; |
|
|
|
return nTotal; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t CWallet::GetImmatureBalance() const |
|
|
|
CAmount CWallet::GetImmatureBalance() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
@ -1056,9 +1056,9 @@ int64_t CWallet::GetImmatureBalance() const |
|
|
|
return nTotal; |
|
|
|
return nTotal; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t CWallet::GetWatchOnlyBalance() const |
|
|
|
CAmount CWallet::GetWatchOnlyBalance() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
@ -1072,9 +1072,9 @@ int64_t CWallet::GetWatchOnlyBalance() const |
|
|
|
return nTotal; |
|
|
|
return nTotal; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t CWallet::GetUnconfirmedWatchOnlyBalance() const |
|
|
|
CAmount CWallet::GetUnconfirmedWatchOnlyBalance() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
@ -1087,9 +1087,9 @@ int64_t CWallet::GetUnconfirmedWatchOnlyBalance() const |
|
|
|
return nTotal; |
|
|
|
return nTotal; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t CWallet::GetImmatureWatchOnlyBalance() const |
|
|
|
CAmount CWallet::GetImmatureWatchOnlyBalance() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
@ -1137,8 +1137,8 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void ApproximateBestSubset(vector<pair<int64_t, pair<const CWalletTx*,unsigned int> > >vValue, int64_t nTotalLower, int64_t nTargetValue, |
|
|
|
static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,unsigned int> > >vValue, const CAmount& nTotalLower, const CAmount& nTargetValue, |
|
|
|
vector<char>& vfBest, int64_t& nBest, int iterations = 1000) |
|
|
|
vector<char>& vfBest, CAmount& nBest, int iterations = 1000) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vector<char> vfIncluded; |
|
|
|
vector<char> vfIncluded; |
|
|
|
|
|
|
|
|
|
|
@ -1150,7 +1150,7 @@ static void ApproximateBestSubset(vector<pair<int64_t, pair<const CWalletTx*,uns |
|
|
|
for (int nRep = 0; nRep < iterations && nBest != nTargetValue; nRep++) |
|
|
|
for (int nRep = 0; nRep < iterations && nBest != nTargetValue; nRep++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vfIncluded.assign(vValue.size(), false); |
|
|
|
vfIncluded.assign(vValue.size(), false); |
|
|
|
int64_t nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
bool fReachedTarget = false; |
|
|
|
bool fReachedTarget = false; |
|
|
|
for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++) |
|
|
|
for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1183,18 +1183,18 @@ static void ApproximateBestSubset(vector<pair<int64_t, pair<const CWalletTx*,uns |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins, |
|
|
|
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins, |
|
|
|
set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const |
|
|
|
set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
setCoinsRet.clear(); |
|
|
|
setCoinsRet.clear(); |
|
|
|
nValueRet = 0; |
|
|
|
nValueRet = 0; |
|
|
|
|
|
|
|
|
|
|
|
// List of values less than target
|
|
|
|
// List of values less than target
|
|
|
|
pair<int64_t, pair<const CWalletTx*,unsigned int> > coinLowestLarger; |
|
|
|
pair<CAmount, pair<const CWalletTx*,unsigned int> > coinLowestLarger; |
|
|
|
coinLowestLarger.first = std::numeric_limits<int64_t>::max(); |
|
|
|
coinLowestLarger.first = std::numeric_limits<CAmount>::max(); |
|
|
|
coinLowestLarger.second.first = NULL; |
|
|
|
coinLowestLarger.second.first = NULL; |
|
|
|
vector<pair<int64_t, pair<const CWalletTx*,unsigned int> > > vValue; |
|
|
|
vector<pair<CAmount, pair<const CWalletTx*,unsigned int> > > vValue; |
|
|
|
int64_t nTotalLower = 0; |
|
|
|
CAmount nTotalLower = 0; |
|
|
|
|
|
|
|
|
|
|
|
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); |
|
|
|
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); |
|
|
|
|
|
|
|
|
|
|
@ -1209,9 +1209,9 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
int i = output.i; |
|
|
|
int i = output.i; |
|
|
|
int64_t n = pcoin->vout[i].nValue; |
|
|
|
CAmount n = pcoin->vout[i].nValue; |
|
|
|
|
|
|
|
|
|
|
|
pair<int64_t,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i)); |
|
|
|
pair<CAmount,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i)); |
|
|
|
|
|
|
|
|
|
|
|
if (n == nTargetValue) |
|
|
|
if (n == nTargetValue) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1252,7 +1252,7 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT |
|
|
|
// Solve subset sum by stochastic approximation
|
|
|
|
// Solve subset sum by stochastic approximation
|
|
|
|
sort(vValue.rbegin(), vValue.rend(), CompareValueOnly()); |
|
|
|
sort(vValue.rbegin(), vValue.rend(), CompareValueOnly()); |
|
|
|
vector<char> vfBest; |
|
|
|
vector<char> vfBest; |
|
|
|
int64_t nBest; |
|
|
|
CAmount nBest; |
|
|
|
|
|
|
|
|
|
|
|
ApproximateBestSubset(vValue, nTotalLower, nTargetValue, vfBest, nBest, 1000); |
|
|
|
ApproximateBestSubset(vValue, nTotalLower, nTargetValue, vfBest, nBest, 1000); |
|
|
|
if (nBest != nTargetValue && nTotalLower >= nTargetValue + CENT) |
|
|
|
if (nBest != nTargetValue && nTotalLower >= nTargetValue + CENT) |
|
|
@ -1284,7 +1284,7 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl* coinControl) const |
|
|
|
bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
vector<COutput> vCoins; |
|
|
|
vector<COutput> vCoins; |
|
|
|
AvailableCoins(vCoins, true, coinControl); |
|
|
|
AvailableCoins(vCoins, true, coinControl); |
|
|
@ -1310,11 +1310,11 @@ bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsign |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, |
|
|
|
bool CWallet::CreateTransaction(const vector<pair<CScript, CAmount> >& vecSend, |
|
|
|
CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl) |
|
|
|
CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nValue = 0; |
|
|
|
CAmount nValue = 0; |
|
|
|
BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend) |
|
|
|
BOOST_FOREACH (const PAIRTYPE(CScript, CAmount)& s, vecSend) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (nValue < 0) |
|
|
|
if (nValue < 0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1343,10 +1343,10 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, |
|
|
|
txNew.vout.clear(); |
|
|
|
txNew.vout.clear(); |
|
|
|
wtxNew.fFromMe = true; |
|
|
|
wtxNew.fFromMe = true; |
|
|
|
|
|
|
|
|
|
|
|
int64_t nTotalValue = nValue + nFeeRet; |
|
|
|
CAmount nTotalValue = nValue + nFeeRet; |
|
|
|
double dPriority = 0; |
|
|
|
double dPriority = 0; |
|
|
|
// vouts to the payees
|
|
|
|
// vouts to the payees
|
|
|
|
BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend) |
|
|
|
BOOST_FOREACH (const PAIRTYPE(CScript, CAmount)& s, vecSend) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CTxOut txout(s.second, s.first); |
|
|
|
CTxOut txout(s.second, s.first); |
|
|
|
if (txout.IsDust(::minRelayTxFee)) |
|
|
|
if (txout.IsDust(::minRelayTxFee)) |
|
|
@ -1359,7 +1359,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, |
|
|
|
|
|
|
|
|
|
|
|
// Choose coins to use
|
|
|
|
// Choose coins to use
|
|
|
|
set<pair<const CWalletTx*,unsigned int> > setCoins; |
|
|
|
set<pair<const CWalletTx*,unsigned int> > setCoins; |
|
|
|
int64_t nValueIn = 0; |
|
|
|
CAmount nValueIn = 0; |
|
|
|
if (!SelectCoins(nTotalValue, setCoins, nValueIn, coinControl)) |
|
|
|
if (!SelectCoins(nTotalValue, setCoins, nValueIn, coinControl)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
strFailReason = _("Insufficient funds"); |
|
|
|
strFailReason = _("Insufficient funds"); |
|
|
@ -1367,14 +1367,14 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, |
|
|
|
} |
|
|
|
} |
|
|
|
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) |
|
|
|
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nCredit = pcoin.first->vout[pcoin.second].nValue; |
|
|
|
CAmount nCredit = pcoin.first->vout[pcoin.second].nValue; |
|
|
|
//The priority after the next block (depth+1) is used instead of the current,
|
|
|
|
//The priority after the next block (depth+1) is used instead of the current,
|
|
|
|
//reflecting an assumption the user would accept a bit more delay for
|
|
|
|
//reflecting an assumption the user would accept a bit more delay for
|
|
|
|
//a chance at a free transaction.
|
|
|
|
//a chance at a free transaction.
|
|
|
|
dPriority += (double)nCredit * (pcoin.first->GetDepthInMainChain()+1); |
|
|
|
dPriority += (double)nCredit * (pcoin.first->GetDepthInMainChain()+1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t nChange = nValueIn - nValue - nFeeRet; |
|
|
|
CAmount nChange = nValueIn - nValue - nFeeRet; |
|
|
|
|
|
|
|
|
|
|
|
if (nChange > 0) |
|
|
|
if (nChange > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1450,7 +1450,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, |
|
|
|
} |
|
|
|
} |
|
|
|
dPriority = wtxNew.ComputePriority(dPriority, nBytes); |
|
|
|
dPriority = wtxNew.ComputePriority(dPriority, nBytes); |
|
|
|
|
|
|
|
|
|
|
|
int64_t nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool); |
|
|
|
CAmount nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool); |
|
|
|
|
|
|
|
|
|
|
|
if (nFeeRet >= nFeeNeeded) |
|
|
|
if (nFeeRet >= nFeeNeeded) |
|
|
|
break; // Done, enough fee included.
|
|
|
|
break; // Done, enough fee included.
|
|
|
@ -1481,10 +1481,10 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool CWallet::CreateTransaction(CScript scriptPubKey, int64_t nValue, |
|
|
|
bool CWallet::CreateTransaction(CScript scriptPubKey, const CAmount& nValue, |
|
|
|
CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl) |
|
|
|
CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vector< pair<CScript, int64_t> > vecSend; |
|
|
|
vector< pair<CScript, CAmount> > vecSend; |
|
|
|
vecSend.push_back(make_pair(scriptPubKey, nValue)); |
|
|
|
vecSend.push_back(make_pair(scriptPubKey, nValue)); |
|
|
|
return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, strFailReason, coinControl); |
|
|
|
return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, strFailReason, coinControl); |
|
|
|
} |
|
|
|
} |
|
|
@ -1539,7 +1539,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string CWallet::SendMoney(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew) |
|
|
|
string CWallet::SendMoney(const CTxDestination &address, CAmount nValue, CWalletTx& wtxNew) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Check amount
|
|
|
|
// Check amount
|
|
|
|
if (nValue <= 0) |
|
|
|
if (nValue <= 0) |
|
|
@ -1560,7 +1560,7 @@ string CWallet::SendMoney(const CTxDestination &address, int64_t nValue, CWallet |
|
|
|
|
|
|
|
|
|
|
|
// Create and send the transaction
|
|
|
|
// Create and send the transaction
|
|
|
|
CReserveKey reservekey(this); |
|
|
|
CReserveKey reservekey(this); |
|
|
|
int64_t nFeeRequired; |
|
|
|
CAmount nFeeRequired; |
|
|
|
if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError)) |
|
|
|
if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (nValue + nFeeRequired > GetBalance()) |
|
|
|
if (nValue + nFeeRequired > GetBalance()) |
|
|
@ -1576,10 +1576,10 @@ string CWallet::SendMoney(const CTxDestination &address, int64_t nValue, CWallet |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int64_t CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool) |
|
|
|
CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// payTxFee is user-set "I want to pay this much"
|
|
|
|
// payTxFee is user-set "I want to pay this much"
|
|
|
|
int64_t nFeeNeeded = payTxFee.GetFee(nTxBytes); |
|
|
|
CAmount nFeeNeeded = payTxFee.GetFee(nTxBytes); |
|
|
|
// User didn't set: use -txconfirmtarget to estimate...
|
|
|
|
// User didn't set: use -txconfirmtarget to estimate...
|
|
|
|
if (nFeeNeeded == 0) |
|
|
|
if (nFeeNeeded == 0) |
|
|
|
nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFee(nTxBytes); |
|
|
|
nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFee(nTxBytes); |
|
|
@ -1838,9 +1838,9 @@ int64_t CWallet::GetOldestKeyPoolTime() |
|
|
|
return keypool.nTime; |
|
|
|
return keypool.nTime; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::map<CTxDestination, int64_t> CWallet::GetAddressBalances() |
|
|
|
std::map<CTxDestination, CAmount> CWallet::GetAddressBalances() |
|
|
|
{ |
|
|
|
{ |
|
|
|
map<CTxDestination, int64_t> balances; |
|
|
|
map<CTxDestination, CAmount> balances; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_wallet); |
|
|
|
LOCK(cs_wallet); |
|
|
@ -1866,7 +1866,7 @@ std::map<CTxDestination, int64_t> CWallet::GetAddressBalances() |
|
|
|
if(!ExtractDestination(pcoin->vout[i].scriptPubKey, addr)) |
|
|
|
if(!ExtractDestination(pcoin->vout[i].scriptPubKey, addr)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
int64_t n = IsSpent(walletEntry.first, i) ? 0 : pcoin->vout[i].nValue; |
|
|
|
CAmount n = IsSpent(walletEntry.first, i) ? 0 : pcoin->vout[i].nValue; |
|
|
|
|
|
|
|
|
|
|
|
if (!balances.count(addr)) |
|
|
|
if (!balances.count(addr)) |
|
|
|
balances[addr] = 0; |
|
|
|
balances[addr] = 0; |
|
|
|