diff options
| author | Gavin Andresen <[email protected]> | 2014-02-13 20:12:51 -0500 |
|---|---|---|
| committer | Gavin Andresen <[email protected]> | 2014-02-14 18:13:42 -0500 |
| commit | 731b89b8b53cb2ea4d2d5c8f2875def515766ea1 (patch) | |
| tree | 161b262a14cf8396ca47f9b3ddbc0790465c3760 /src/rpcwallet.cpp | |
| parent | qt: GUI for conflicted transactions (diff) | |
| download | discoin-731b89b8b53cb2ea4d2d5c8f2875def515766ea1.tar.xz discoin-731b89b8b53cb2ea4d2d5c8f2875def515766ea1.zip | |
Track and report wallet transaction clones
Adds a "walletconflicts" array to transaction info; if
a wallet transaction is mutated, the alternate transaction id
or ids are reported there (usually the array will be empty).
Metadata from the original transaction is copied to the mutant,
so the transaction time and "from" account of the mutant are
reported correctly.
Diffstat (limited to 'src/rpcwallet.cpp')
| -rw-r--r-- | src/rpcwallet.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 2b49762d4..97c4008da 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -51,7 +51,12 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry) entry.push_back(Pair("blockindex", wtx.nIndex)); entry.push_back(Pair("blocktime", (boost::int64_t)(mapBlockIndex[wtx.hashBlock]->nTime))); } - entry.push_back(Pair("txid", wtx.GetHash().GetHex())); + uint256 hash = wtx.GetHash(); + entry.push_back(Pair("txid", hash.GetHex())); + Array conflicts; + BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts()) + conflicts.push_back(conflict.GetHex()); + entry.push_back(Pair("walletconflicts", conflicts)); entry.push_back(Pair("time", (boost::int64_t)wtx.GetTxTime())); entry.push_back(Pair("timereceived", (boost::int64_t)wtx.nTimeReceived)); BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue) @@ -621,7 +626,7 @@ Value getbalance(const Array& params, bool fHelp) for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - if (!wtx.IsTrusted()) + if (!wtx.IsTrusted() || wtx.GetBlocksToMaturity() > 0) continue; int64_t allFee; @@ -1325,6 +1330,8 @@ Value listaccounts(const Array& params, bool fHelp) string strSentAccount; list<pair<CTxDestination, int64_t> > listReceived; list<pair<CTxDestination, int64_t> > listSent; + if (wtx.GetBlocksToMaturity() > 0) + continue; wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount); mapAccountBalances[strSentAccount] -= nFee; BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent) |