mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Merge remote branch 'refs/remotes/svn/trunk' into svn
This commit is contained in:
commit
695aa2d5a2
14
main.cpp
14
main.cpp
@ -3400,7 +3400,7 @@ int64 GetBalance()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)
|
bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<CWalletTx*>& setCoinsRet)
|
||||||
{
|
{
|
||||||
setCoinsRet.clear();
|
setCoinsRet.clear();
|
||||||
|
|
||||||
@ -3422,6 +3422,11 @@ bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)
|
|||||||
{
|
{
|
||||||
if (!pcoin->IsFinal() || pcoin->fSpent || !pcoin->IsConfirmed())
|
if (!pcoin->IsFinal() || pcoin->fSpent || !pcoin->IsConfirmed())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
int nDepth = pcoin->GetDepthInMainChain();
|
||||||
|
if (nDepth < (pcoin->IsFromMe() ? nConfMine : nConfTheirs))
|
||||||
|
continue;
|
||||||
|
|
||||||
int64 n = pcoin->GetCredit();
|
int64 n = pcoin->GetCredit();
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
continue;
|
continue;
|
||||||
@ -3506,6 +3511,13 @@ bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)
|
||||||
|
{
|
||||||
|
return (SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet) ||
|
||||||
|
SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet) ||
|
||||||
|
SelectCoinsMinConf(nTargetValue, 0, 1, setCoinsRet));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
22
main.h
22
main.h
@ -487,6 +487,11 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsFromMe() const
|
||||||
|
{
|
||||||
|
return (GetDebit() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
int64 GetDebit() const
|
int64 GetDebit() const
|
||||||
{
|
{
|
||||||
int64 nDebit = 0;
|
int64 nDebit = 0;
|
||||||
@ -789,8 +794,23 @@ public:
|
|||||||
return nCreditCached;
|
return nCreditCached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsFromMe() const
|
||||||
|
{
|
||||||
|
return (GetDebit() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
bool IsConfirmed() const
|
bool IsConfirmed() const
|
||||||
{
|
{
|
||||||
|
// Quick answer in most cases
|
||||||
|
if (!IsFinal())
|
||||||
|
return false;
|
||||||
|
if (GetDepthInMainChain() >= 1)
|
||||||
|
return true;
|
||||||
|
if (!IsFromMe()) // using wtx's cached debit
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// If no confirmations but it's from us, we can still
|
||||||
|
// consider it confirmed if all dependencies are confirmed
|
||||||
map<uint256, const CMerkleTx*> mapPrev;
|
map<uint256, const CMerkleTx*> mapPrev;
|
||||||
vector<const CMerkleTx*> vWorkQueue;
|
vector<const CMerkleTx*> vWorkQueue;
|
||||||
vWorkQueue.reserve(vtxPrev.size()+1);
|
vWorkQueue.reserve(vtxPrev.size()+1);
|
||||||
@ -803,7 +823,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
if (ptx->GetDepthInMainChain() >= 1)
|
if (ptx->GetDepthInMainChain() >= 1)
|
||||||
return true;
|
return true;
|
||||||
if (ptx->GetDebit() <= 0)
|
if (!ptx->IsFromMe())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (mapPrev.empty())
|
if (mapPrev.empty())
|
||||||
|
Loading…
Reference in New Issue
Block a user