diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2012-05-28 18:45:12 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-08-23 18:38:22 +0000 |
commit | c3f95ef13f48d21db53992984976eac93e7a08fc (patch) | |
tree | 0caa89a1b21692c7e9a1dc03404280455186773f /src/wallet.h | |
parent | bdbfd2329a92ab3fa7ad51e50a9fb0411ec64dae (diff) |
Choose reasonable "smart" times to display for transactions
Logic:
- If sending a transaction, assign its timestamp to the current time.
- If receiving a transaction outside a block, assign its timestamp to the current time.
- If receiving a block with a future timestamp, assign all its (not already known) transactions' timestamps to the current time.
- If receiving a block with a past timestamp, before the most recent known transaction (that we care about), assign all its (not already known) transactions' timestamps to the same timestamp as that most-recent-known transaction.
- If receiving a block with a past timestamp, but after the most recent known transaction, assign all its (not already known) transactions' timestamps to the block time.
Diffstat (limited to 'src/wallet.h')
-rw-r--r-- | src/wallet.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/wallet.h b/src/wallet.h index b32face5bf..9103aa675e 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -17,6 +17,7 @@ #include "ui_interface.h" #include "util.h" +class CAccountingEntry; class CWalletTx; class CReserveKey; class CWalletDB; @@ -143,6 +144,10 @@ public: bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase); bool EncryptWallet(const SecureString& strWalletPassphrase); + typedef std::pair<CWalletTx*, CAccountingEntry*> TxPair; + typedef std::multimap<int64, TxPair > TxItems; + TxItems OrderedTxItems(std::string strAccount = ""); + void MarkDirty(); bool AddToWallet(const CWalletTx& wtxIn); bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate = false, bool fFindBlock = false); @@ -351,6 +356,7 @@ public: std::vector<std::pair<std::string, std::string> > vOrderForm; unsigned int fTimeReceivedIsTxTime; unsigned int nTimeReceived; // time received by this node + unsigned int nTimeSmart; char fFromMe; std::string strFromAccount; std::vector<char> vfSpent; // which outputs are already spent @@ -394,6 +400,7 @@ public: vOrderForm.clear(); fTimeReceivedIsTxTime = false; nTimeReceived = 0; + nTimeSmart = 0; fFromMe = false; strFromAccount.clear(); vfSpent.clear(); @@ -429,6 +436,9 @@ public: pthis->mapValue["spent"] = str; WriteOrderPos(pthis->nOrderPos, pthis->mapValue); + + if (nTimeSmart) + pthis->mapValue["timesmart"] = strprintf("%u", nTimeSmart); } nSerSize += SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion,ser_action); @@ -449,15 +459,17 @@ public: pthis->vfSpent.push_back(c != '0'); else pthis->vfSpent.assign(vout.size(), fSpent); - } - if (fRead) ReadOrderPos(pthis->nOrderPos, pthis->mapValue); + pthis->nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(pthis->mapValue["timesmart"]) : 0; + } + pthis->mapValue.erase("fromaccount"); pthis->mapValue.erase("version"); pthis->mapValue.erase("spent"); pthis->mapValue.erase("n"); + pthis->mapValue.erase("timesmart"); ) // marks certain txout's as spent |