Browse Source

Fixed keva amount in wallet.

cn
Jianping Wu 6 years ago
parent
commit
7d80f78f4e
  1. 4
      src/wallet/rpcwallet.cpp
  2. 19
      src/wallet/wallet.cpp
  3. 1
      src/wallet/wallet.h

4
src/wallet/rpcwallet.cpp

@ -1697,6 +1697,8 @@ void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const std::s
} }
entry.push_back(Pair("account", strSentAccount)); entry.push_back(Pair("account", strSentAccount));
MaybePushAddress(entry, s.destination); MaybePushAddress(entry, s.destination);
if(!s.kevaOp.empty())
entry.push_back(Pair("keva", s.kevaOp));
entry.push_back(Pair("category", "send")); entry.push_back(Pair("category", "send"));
entry.push_back(Pair("amount", ValueFromAmount(-s.amount))); entry.push_back(Pair("amount", ValueFromAmount(-s.amount)));
if (pwallet->mapAddressBook.count(s.destination)) { if (pwallet->mapAddressBook.count(s.destination)) {
@ -1728,6 +1730,8 @@ void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const std::s
} }
entry.push_back(Pair("account", account)); entry.push_back(Pair("account", account));
MaybePushAddress(entry, r.destination); MaybePushAddress(entry, r.destination);
if(!r.kevaOp.empty())
entry.push_back(Pair("keva", r.kevaOp));
if (wtx.IsCoinBase()) if (wtx.IsCoinBase())
{ {
if (wtx.GetDepthInMainChain() < 1) if (wtx.GetDepthInMainChain() < 1)

19
src/wallet/wallet.cpp

@ -1536,13 +1536,14 @@ void CWalletTx::GetAmounts(std::list<COutputEntry>& listReceived,
{ {
const CTxOut& txout = tx->vout[i]; const CTxOut& txout = tx->vout[i];
isminetype fIsMine = pwallet->IsMine(txout); isminetype fIsMine = pwallet->IsMine(txout);
const CKevaScript kevaOp(txout.scriptPubKey);
// Only need to handle txouts if AT LEAST one of these is true: // Only need to handle txouts if AT LEAST one of these is true:
// 1) they debit from us (sent) // 1) they debit from us (sent)
// 2) the output is to us (received) // 2) the output is to us (received)
if (nDebit > 0) if (nDebit > 0)
{ {
// Don't report 'change' txouts // Don't report 'change' txouts
if (pwallet->IsChange(txout)) if (pwallet->IsChange(txout) && !kevaOp.isKevaOp())
continue; continue;
} }
else if (!(fIsMine & filter)) else if (!(fIsMine & filter))
@ -1558,14 +1559,26 @@ void CWalletTx::GetAmounts(std::list<COutputEntry>& listReceived,
address = CNoDestination(); address = CNoDestination();
} }
COutputEntry output = {address, txout.nValue, (int)i}; COutputEntry output = {address, "", txout.nValue, (int)i};
// If we have a keva script, set the "keva" parameter.
if (kevaOp.isKevaOp())
{
if (kevaOp.isAnyUpdate())
output.kevaOp = "update: " + ValtypeToString(kevaOp.getOpNamespace());
else
output.kevaOp = "new: " + ValtypeToString(kevaOp.getOpNamespace());
output.amount = 0;
}
// If we are debited by the transaction, add the output as a "sent" entry // If we are debited by the transaction, add the output as a "sent" entry
if (nDebit > 0) if (nDebit > 0)
listSent.push_back(output); listSent.push_back(output);
// If we are receiving the output, add it as a "received" entry // If we are receiving the output, add it as a "received" entry
if (fIsMine & filter) if ((fIsMine & filter)
&& (!kevaOp.isKevaOp() || !(nDebit > 0)))
listReceived.push_back(output); listReceived.push_back(output);
} }

1
src/wallet/wallet.h

@ -193,6 +193,7 @@ static inline void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
struct COutputEntry struct COutputEntry
{ {
CTxDestination destination; CTxDestination destination;
std::string kevaOp;
CAmount amount; CAmount amount;
int vout; int vout;
}; };

Loading…
Cancel
Save