@@ -288,12 +288,12 @@ class CWallet : public CCryptoKeyStore, public CWalletInterface
288
288
std::set<CTxDestination> GetAccountAddresses (std::string strAccount) const ;
289
289
290
290
isminetype IsMine (const CTxIn& txin) const ;
291
- int64_t GetDebit (const CTxIn& txin) const ;
291
+ int64_t GetDebit (const CTxIn& txin, const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY) ) const ;
292
292
isminetype IsMine (const CTxOut& txout) const
293
293
{
294
294
return ::IsMine (*this , txout.scriptPubKey );
295
295
}
296
- int64_t GetCredit (const CTxOut& txout, const isminefilter& filter = (MINE_WATCH_ONLY | MINE_SPENDABLE)) const
296
+ int64_t GetCredit (const CTxOut& txout, const isminefilter& filter= (MINE_WATCH_ONLY| MINE_SPENDABLE)) const
297
297
{
298
298
if (!MoneyRange (txout.nValue ))
299
299
throw std::runtime_error (" CWallet::GetCredit() : value out of range" );
@@ -324,12 +324,12 @@ class CWallet : public CCryptoKeyStore, public CWalletInterface
324
324
return true ;
325
325
return false ;
326
326
}
327
- int64_t GetDebit (const CTransaction& tx) const
327
+ int64_t GetDebit (const CTransaction& tx, const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY) ) const
328
328
{
329
329
int64_t nDebit = 0 ;
330
330
BOOST_FOREACH (const CTxIn& txin, tx.vin )
331
331
{
332
- nDebit += GetDebit (txin);
332
+ nDebit += GetDebit (txin, filter );
333
333
if (!MoneyRange (nDebit))
334
334
throw std::runtime_error (" CWallet::GetDebit() : value out of range" );
335
335
}
@@ -486,13 +486,17 @@ class CWalletTx : public CMerkleTx
486
486
mutable bool fCreditCached ;
487
487
mutable bool fImmatureCreditCached ;
488
488
mutable bool fAvailableCreditCached ;
489
+ mutable bool fWatchDebitCached ;
490
+ mutable bool fWatchCreditCached ;
489
491
mutable bool fImmatureWatchCreditCached ;
490
492
mutable bool fAvailableWatchCreditCached ;
491
493
mutable bool fChangeCached ;
492
494
mutable int64_t nDebitCached;
493
495
mutable int64_t nCreditCached;
494
496
mutable int64_t nImmatureCreditCached;
495
497
mutable int64_t nAvailableCreditCached;
498
+ mutable int64_t nWatchDebitCached;
499
+ mutable int64_t nWatchCreditCached;
496
500
mutable int64_t nImmatureWatchCreditCached;
497
501
mutable int64_t nAvailableWatchCreditCached;
498
502
mutable int64_t nChangeCached;
@@ -531,13 +535,17 @@ class CWalletTx : public CMerkleTx
531
535
fCreditCached = false ;
532
536
fImmatureCreditCached = false ;
533
537
fAvailableCreditCached = false ;
538
+ fWatchDebitCached = false ;
539
+ fWatchCreditCached = false ;
534
540
fImmatureWatchCreditCached = false ;
535
541
fAvailableWatchCreditCached = false ;
536
542
fChangeCached = false ;
537
543
nDebitCached = 0 ;
538
544
nCreditCached = 0 ;
539
545
nImmatureCreditCached = 0 ;
540
546
nAvailableCreditCached = 0 ;
547
+ nWatchDebitCached = 0 ;
548
+ nWatchCreditCached = 0 ;
541
549
nAvailableWatchCreditCached = 0 ;
542
550
nImmatureWatchCreditCached = 0 ;
543
551
nChangeCached = 0 ;
@@ -592,6 +600,8 @@ class CWalletTx : public CMerkleTx
592
600
{
593
601
fCreditCached = false ;
594
602
fAvailableCreditCached = false ;
603
+ fWatchDebitCached = false ;
604
+ fWatchCreditCached = false ;
595
605
fAvailableWatchCreditCached = false ;
596
606
fImmatureWatchCreditCached = false ;
597
607
fDebitCached = false ;
@@ -604,15 +614,35 @@ class CWalletTx : public CMerkleTx
604
614
MarkDirty ();
605
615
}
606
616
607
- int64_t GetDebit () const
617
+ int64_t GetDebit (const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY) ) const
608
618
{
609
619
if (vin.empty ())
610
620
return 0 ;
611
- if (fDebitCached )
612
- return nDebitCached;
613
- nDebitCached = pwallet->GetDebit (*this );
614
- fDebitCached = true ;
615
- return nDebitCached;
621
+
622
+ int64_t debit = 0 ;
623
+ if (filter & MINE_SPENDABLE)
624
+ {
625
+ if (fDebitCached )
626
+ debit += nDebitCached;
627
+ else
628
+ {
629
+ nDebitCached = pwallet->GetDebit (*this , MINE_SPENDABLE);
630
+ fDebitCached = true ;
631
+ debit += nDebitCached;
632
+ }
633
+ }
634
+ if (filter & MINE_WATCH_ONLY)
635
+ {
636
+ if (fWatchDebitCached )
637
+ debit += nWatchDebitCached;
638
+ else
639
+ {
640
+ nWatchDebitCached = pwallet->GetDebit (*this , MINE_WATCH_ONLY);
641
+ fWatchDebitCached = true ;
642
+ debit += nWatchDebitCached;
643
+ }
644
+ }
645
+ return debit;
616
646
}
617
647
618
648
int64_t GetCredit (bool fUseCache =true ) const
@@ -729,7 +759,7 @@ class CWalletTx : public CMerkleTx
729
759
std::list<std::pair<CTxDestination, int64_t > >& listSent, int64_t & nFee, std::string& strSentAccount, const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY)) const ;
730
760
731
761
void GetAccountAmounts (const std::string& strAccount, int64_t & nReceived,
732
- int64_t & nSent, int64_t & nFee) const ;
762
+ int64_t & nSent, int64_t & nFee, const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY) ) const ;
733
763
734
764
bool IsFromMe () const
735
765
{
0 commit comments