aboutsummaryrefslogtreecommitdiff
path: root/src/test/wallet_tests.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-06-07 13:53:27 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-06-21 22:59:03 +0200
commit4949004d68dc08382df2c34ae519c1b1cfd60f1a (patch)
treee3c4b2d6fa162af1cfbe44f6deb39278c12c5672 /src/test/wallet_tests.cpp
parent8f59251b83cd9c862aee53dd50ce32bcab12ed6d (diff)
Add CMutableTransaction and make CTransaction immutable.
In addition, introduce a cached hash inside CTransaction, to prevent recalculating it over and over again.
Diffstat (limited to 'src/test/wallet_tests.cpp')
-rw-r--r--src/test/wallet_tests.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/test/wallet_tests.cpp b/src/test/wallet_tests.cpp
index 1993358826..86a83f5163 100644
--- a/src/test/wallet_tests.cpp
+++ b/src/test/wallet_tests.cpp
@@ -31,16 +31,18 @@ static vector<COutput> vCoins;
static void add_coin(int64_t nValue, int nAge = 6*24, bool fIsFromMe = false, int nInput=0)
{
static int nextLockTime = 0;
- CTransaction tx;
+ CMutableTransaction tx;
tx.nLockTime = nextLockTime++; // so all transactions get different hashes
tx.vout.resize(nInput+1);
tx.vout[nInput].nValue = nValue;
+ if (fIsFromMe) {
+ // IsFromMe() returns (GetDebit() > 0), and GetDebit() is 0 if vin.empty(),
+ // so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe()
+ tx.vin.resize(1);
+ }
CWalletTx* wtx = new CWalletTx(&wallet, tx);
if (fIsFromMe)
{
- // IsFromMe() returns (GetDebit() > 0), and GetDebit() is 0 if vin.empty(),
- // so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe()
- wtx->vin.resize(1);
wtx->fDebitCached = true;
wtx->nDebitCached = 1;
}