Enable time locked transactions to be recognized in the wallet
This commit is contained in:
@@ -133,8 +133,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
// Coinbase
|
||||
//
|
||||
CAmount nUnmatured = 0;
|
||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||
nUnmatured += wallet->GetCredit(txout, ISMINE_ALL);
|
||||
for (int i = 0; i < wtx.vout.size(); i++)
|
||||
nUnmatured += wallet->GetCredit(wtx, i, ISMINE_ALL);
|
||||
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> ";
|
||||
if (wtx.IsInMainChain())
|
||||
strHTML += BitcoinUnits::formatHtmlWithUnit(unit, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")";
|
||||
@@ -159,9 +160,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
}
|
||||
|
||||
isminetype fAllToMe = ISMINE_SPENDABLE;
|
||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||
for (int i = 0; i < wtx.vout.size(); i++)
|
||||
{
|
||||
isminetype mine = wallet->IsMine(txout);
|
||||
isminetype mine = wallet->IsMine(wtx, i);
|
||||
if(fAllToMe > mine) fAllToMe = mine;
|
||||
}
|
||||
|
||||
@@ -173,10 +174,11 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
//
|
||||
// Debit
|
||||
//
|
||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||
for (int i = 0; i < wtx.vout.size(); i++)
|
||||
{
|
||||
const CTxOut& txout = wtx.vout[i];
|
||||
// Ignore change
|
||||
isminetype toSelf = wallet->IsMine(txout);
|
||||
isminetype toSelf = wallet->IsMine(wtx, i);
|
||||
if ((toSelf == ISMINE_SPENDABLE) && (fAllFromMe == ISMINE_SPENDABLE))
|
||||
continue;
|
||||
|
||||
@@ -224,9 +226,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
||||
if (wallet->IsMine(txin))
|
||||
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "<br>";
|
||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||
if (wallet->IsMine(txout))
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "<br>";
|
||||
for (int i = 0; i < wtx.vout.size(); i++)
|
||||
if (wallet->IsMine(wtx, i))
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(wtx, i, ISMINE_ALL)) + "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,9 +283,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
||||
if(wallet->IsMine(txin))
|
||||
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "<br>";
|
||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||
if(wallet->IsMine(txout))
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "<br>";
|
||||
for (int i = 0; i < wtx.vout.size(); i++)
|
||||
if (wallet->IsMine(wtx, i))
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(wtx, i, ISMINE_ALL)) + "<br>";
|
||||
|
||||
strHTML += "<br><b>" + tr("Transaction") + ":</b><br>";
|
||||
strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true);
|
||||
@@ -310,8 +312,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
strHTML += QString::fromStdString(CBitcoinAddress(address).ToString());
|
||||
}
|
||||
strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatHtmlWithUnit(unit, vout.nValue);
|
||||
strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) & ISMINE_SPENDABLE ? tr("true") : tr("false")) + "</li>";
|
||||
strHTML = strHTML + " IsWatchOnly=" + (wallet->IsMine(vout) & ISMINE_WATCH_ONLY ? tr("true") : tr("false")) + "</li>";
|
||||
strHTML = strHTML + " IsMine=" + (wallet->IsMine(prev, prevout.n) & ISMINE_SPENDABLE ? tr("true") : tr("false")) + "</li>";
|
||||
strHTML = strHTML + " IsWatchOnly=" + (wallet->IsMine(prev, prevout.n) & ISMINE_WATCH_ONLY ? tr("true") : tr("false")) + "</li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1395,7 +1395,7 @@ isminetype CWallet::IsMine(const CTxIn &txin) const
|
||||
{
|
||||
const CWalletTx& prev = (*mi).second;
|
||||
if (txin.prevout.n < prev.vout.size())
|
||||
return IsMine(prev.vout[txin.prevout.n]);
|
||||
return IsMine(prev, txin.prevout.n);
|
||||
}
|
||||
}
|
||||
return ISMINE_NO;
|
||||
@@ -1410,7 +1410,7 @@ CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
|
||||
{
|
||||
const CWalletTx& prev = (*mi).second;
|
||||
if (txin.prevout.n < prev.vout.size())
|
||||
if (IsMine(prev.vout[txin.prevout.n]) & filter)
|
||||
if (IsMine(prev, txin.prevout.n) & filter)
|
||||
return prev.vout[txin.prevout.n].nValue; // komodo_interest?
|
||||
}
|
||||
}
|
||||
@@ -1487,7 +1487,7 @@ unsigned int HaveKeys(const vector<valtype>& pubkeys, const CKeyStore& keystore)
|
||||
|
||||
// special case handling for non-standard/Verus OP_RETURN script outputs, which need the transaction
|
||||
// to determine ownership
|
||||
isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum)
|
||||
isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum) const
|
||||
{
|
||||
vector<valtype> vSolutions;
|
||||
txnouttype whichType;
|
||||
@@ -1608,14 +1608,19 @@ CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) co
|
||||
return nDebit;
|
||||
}
|
||||
|
||||
CAmount CWallet::GetCredit(const CTransaction& tx, int32_t voutNum, const isminefilter& filter) const
|
||||
{
|
||||
if (voutNum >= tx.vout.size() || !MoneyRange(tx.vout[voutNum].nValue))
|
||||
throw std::runtime_error("CWallet::GetCredit(): value out of range");
|
||||
return ((IsMine(tx, voutNum) & filter) ? tx.vout[voutNum].nValue : 0);
|
||||
}
|
||||
|
||||
CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) const
|
||||
{
|
||||
CAmount nCredit = 0;
|
||||
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
||||
for (int i = 0; i < tx.vout.size(); i++)
|
||||
{
|
||||
nCredit += GetCredit(txout, filter);
|
||||
if (!MoneyRange(nCredit))
|
||||
throw std::runtime_error("CWallet::GetCredit(): value out of range");
|
||||
nCredit += GetCredit(tx, i, filter);
|
||||
}
|
||||
return nCredit;
|
||||
}
|
||||
@@ -2119,8 +2124,7 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache) const
|
||||
{
|
||||
if (!pwallet->IsSpent(hashTx, i))
|
||||
{
|
||||
const CTxOut &txout = vout[i];
|
||||
nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
|
||||
nCredit += pwallet->GetCredit(*this, i, ISMINE_SPENDABLE);
|
||||
if (!MoneyRange(nCredit))
|
||||
throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range");
|
||||
}
|
||||
@@ -2162,8 +2166,7 @@ CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool& fUseCache) const
|
||||
{
|
||||
if (!pwallet->IsSpent(GetHash(), i))
|
||||
{
|
||||
const CTxOut &txout = vout[i];
|
||||
nCredit += pwallet->GetCredit(txout, ISMINE_WATCH_ONLY);
|
||||
nCredit += pwallet->GetCredit(*this, i, ISMINE_WATCH_ONLY);
|
||||
if (!MoneyRange(nCredit))
|
||||
throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range");
|
||||
}
|
||||
@@ -2392,9 +2395,9 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
|
||||
if (nDepth < 0)
|
||||
continue;
|
||||
|
||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++)
|
||||
for (int i = 0; i < pcoin->vout.size(); i++)
|
||||
{
|
||||
isminetype mine = IsMine(pcoin->vout[i]);
|
||||
isminetype mine = IsMine(*pcoin, i);
|
||||
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
|
||||
!IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) &&
|
||||
(!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i)))
|
||||
|
||||
@@ -1050,7 +1050,7 @@ public:
|
||||
isminetype IsMine(const CTxIn& txin) const;
|
||||
CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
|
||||
isminetype IsMine(const CTxOut& txout) const;
|
||||
isminetype IsMine(const CTransaction& tx, uint32_t voutNum);
|
||||
isminetype IsMine(const CTransaction& tx, uint32_t voutNum) const;
|
||||
CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const;
|
||||
bool IsChange(const CTxOut& txout) const;
|
||||
CAmount GetChange(const CTxOut& txout) const;
|
||||
@@ -1058,6 +1058,7 @@ public:
|
||||
/** should probably be renamed to IsRelevantToMe */
|
||||
bool IsFromMe(const CTransaction& tx) const;
|
||||
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
|
||||
CAmount GetCredit(const CTransaction& tx, int32_t voutNum, const isminefilter& filter) const;
|
||||
CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const;
|
||||
CAmount GetChange(const CTransaction& tx) const;
|
||||
void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, ZCIncrementalMerkleTree tree, bool added);
|
||||
|
||||
Reference in New Issue
Block a user