23
23
#include < wallet/fees.h>
24
24
#include < wallet/ismine.h>
25
25
#include < wallet/load.h>
26
+ #include < wallet/receive.h>
26
27
#include < wallet/rpcwallet.h>
28
+ #include < wallet/spend.h>
27
29
#include < wallet/wallet.h>
28
30
29
31
#include < memory>
@@ -55,7 +57,7 @@ WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx)
55
57
result.tx = wtx.tx ;
56
58
result.txin_is_mine .reserve (wtx.tx ->vin .size ());
57
59
for (const auto & txin : wtx.tx ->vin ) {
58
- result.txin_is_mine .emplace_back (wallet. IsMine ( txin));
60
+ result.txin_is_mine .emplace_back (InputIsMine (wallet, txin));
59
61
}
60
62
result.txout_is_mine .reserve (wtx.tx ->vout .size ());
61
63
result.txout_address .reserve (wtx.tx ->vout .size ());
@@ -67,9 +69,9 @@ WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx)
67
69
wallet.IsMine (result.txout_address .back ()) :
68
70
ISMINE_NO);
69
71
}
70
- result.credit = wtx. GetCredit ( ISMINE_ALL);
71
- result.debit = wtx. GetDebit ( ISMINE_ALL);
72
- result.change = wtx. GetChange ( );
72
+ result.credit = CachedTxGetCredit (wallet, wtx, ISMINE_ALL);
73
+ result.debit = CachedTxGetDebit (wallet, wtx, ISMINE_ALL);
74
+ result.change = CachedTxGetChange (wallet, wtx );
73
75
result.time = wtx.GetTxTime ();
74
76
result.value_map = wtx.mapValue ;
75
77
result.is_coinbase = wtx.IsCoinBase ();
@@ -81,15 +83,15 @@ WalletTxStatus MakeWalletTxStatus(const CWallet& wallet, const CWalletTx& wtx)
81
83
{
82
84
WalletTxStatus result;
83
85
result.block_height = wtx.m_confirm .block_height > 0 ? wtx.m_confirm .block_height : std::numeric_limits<int >::max ();
84
- result.blocks_to_maturity = wtx. GetBlocksToMaturity ( );
85
- result.depth_in_main_chain = wtx. GetDepthInMainChain ( );
86
+ result.blocks_to_maturity = wallet. GetTxBlocksToMaturity (wtx );
87
+ result.depth_in_main_chain = wallet. GetTxDepthInMainChain (wtx );
86
88
result.time_received = wtx.nTimeReceived ;
87
89
result.lock_time = wtx.tx ->nLockTime ;
88
90
result.is_final = wallet.chain ().checkFinalTx (*wtx.tx );
89
- result.is_trusted = wtx. IsTrusted ( );
91
+ result.is_trusted = CachedTxIsTrusted (wallet, wtx );
90
92
result.is_abandoned = wtx.isAbandoned ();
91
93
result.is_coinbase = wtx.IsCoinBase ();
92
- result.is_in_main_chain = wtx. IsInMainChain ( );
94
+ result.is_in_main_chain = wallet. IsTxInMainChain (wtx );
93
95
return result;
94
96
}
95
97
@@ -242,7 +244,7 @@ class WalletImpl : public Wallet
242
244
LOCK (m_wallet->cs_wallet );
243
245
CTransactionRef tx;
244
246
FeeCalculation fee_calc_out;
245
- if (!m_wallet-> CreateTransaction (recipients, tx, fee, change_pos,
247
+ if (!CreateTransaction (*m_wallet, recipients, tx, fee, change_pos,
246
248
fail_reason, coin_control, fee_calc_out, sign)) {
247
249
return {};
248
250
}
@@ -358,7 +360,7 @@ class WalletImpl : public Wallet
358
360
}
359
361
WalletBalances getBalances () override
360
362
{
361
- const auto bal = m_wallet-> GetBalance ();
363
+ const auto bal = GetBalance (*m_wallet );
362
364
WalletBalances result;
363
365
result.balance = bal.m_mine_trusted ;
364
366
result.unconfirmed_balance = bal.m_mine_untrusted_pending ;
@@ -381,15 +383,15 @@ class WalletImpl : public Wallet
381
383
balances = getBalances ();
382
384
return true ;
383
385
}
384
- CAmount getBalance () override { return m_wallet-> GetBalance ().m_mine_trusted ; }
386
+ CAmount getBalance () override { return GetBalance (*m_wallet ).m_mine_trusted ; }
385
387
CAmount getAvailableBalance (const CCoinControl& coin_control) override
386
388
{
387
- return m_wallet-> GetAvailableBalance (&coin_control);
389
+ return GetAvailableBalance (*m_wallet, &coin_control);
388
390
}
389
391
isminetype txinIsMine (const CTxIn& txin) override
390
392
{
391
393
LOCK (m_wallet->cs_wallet );
392
- return m_wallet-> IsMine ( txin);
394
+ return InputIsMine (*m_wallet, txin);
393
395
}
394
396
isminetype txoutIsMine (const CTxOut& txout) override
395
397
{
@@ -404,13 +406,13 @@ class WalletImpl : public Wallet
404
406
CAmount getCredit (const CTxOut& txout, isminefilter filter) override
405
407
{
406
408
LOCK (m_wallet->cs_wallet );
407
- return m_wallet-> GetCredit ( txout, filter);
409
+ return OutputGetCredit (*m_wallet, txout, filter);
408
410
}
409
411
CoinsList listCoins () override
410
412
{
411
413
LOCK (m_wallet->cs_wallet );
412
414
CoinsList result;
413
- for (const auto & entry : m_wallet-> ListCoins ()) {
415
+ for (const auto & entry : ListCoins (*m_wallet )) {
414
416
auto & group = result[entry.first ];
415
417
for (const auto & coin : entry.second ) {
416
418
group.emplace_back (COutPoint (coin.tx ->GetHash (), coin.i ),
@@ -428,7 +430,7 @@ class WalletImpl : public Wallet
428
430
result.emplace_back ();
429
431
auto it = m_wallet->mapWallet .find (output.hash );
430
432
if (it != m_wallet->mapWallet .end ()) {
431
- int depth = it->second . GetDepthInMainChain ( );
433
+ int depth = m_wallet-> GetTxDepthInMainChain ( it->second );
432
434
if (depth >= 0 ) {
433
435
result.back () = MakeWalletTxOut (*m_wallet, it->second , output.n , depth);
434
436
}
0 commit comments