Skip to content

Commit fa1f840

Browse files
author
MarcoFalke
committed
rpcwallet: Replace pwallet-> with wallet.
pwallet is never null everywhere where it is dereferenced, so simply replace it with a reference, which can not be null by definition.
1 parent fa182a8 commit fa1f840

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,10 +1482,9 @@ UniValue listtransactions(const JSONRPCRequest& request)
14821482

14831483
static UniValue listsinceblock(const JSONRPCRequest& request)
14841484
{
1485-
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
1486-
const CWallet* const pwallet = wallet.get();
1485+
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
14871486

1488-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
1487+
if (!EnsureWalletIsAvailable(pwallet.get(), request.fHelp)) {
14891488
return NullUniValue;
14901489
}
14911490

@@ -1542,11 +1541,12 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
15421541
},
15431542
}.Check(request);
15441543

1544+
const CWallet& wallet = *pwallet;
15451545
// Make sure the results are valid at least up to the most recent block
15461546
// the user could have gotten from another RPC command prior to now
1547-
pwallet->BlockUntilSyncedToCurrentChain();
1547+
wallet.BlockUntilSyncedToCurrentChain();
15481548

1549-
LOCK(pwallet->cs_wallet);
1549+
LOCK(wallet.cs_wallet);
15501550

15511551
// The way the 'height' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0.
15521552
Optional<int> height = MakeOptional(false, int()); // Height of the specified block or the common ancestor, if the block provided was in a deactivated chain.
@@ -1559,7 +1559,7 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
15591559
blockId = ParseHashV(request.params[0], "blockhash");
15601560
height = int{};
15611561
altheight = int{};
1562-
if (!pwallet->chain().findCommonAncestor(blockId, pwallet->GetLastBlockHash(), /* ancestor out */ FoundBlock().height(*height), /* blockId out */ FoundBlock().height(*altheight))) {
1562+
if (!wallet.chain().findCommonAncestor(blockId, wallet.GetLastBlockHash(), /* ancestor out */ FoundBlock().height(*height), /* blockId out */ FoundBlock().height(*altheight))) {
15631563
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
15641564
}
15651565
}
@@ -1572,21 +1572,21 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
15721572
}
15731573
}
15741574

1575-
if (ParseIncludeWatchonly(request.params[2], *pwallet)) {
1575+
if (ParseIncludeWatchonly(request.params[2], wallet)) {
15761576
filter |= ISMINE_WATCH_ONLY;
15771577
}
15781578

15791579
bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
15801580

1581-
int depth = height ? pwallet->GetLastBlockHeight() + 1 - *height : -1;
1581+
int depth = height ? wallet.GetLastBlockHeight() + 1 - *height : -1;
15821582

15831583
UniValue transactions(UniValue::VARR);
15841584

1585-
for (const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
1585+
for (const std::pair<const uint256, CWalletTx>& pairWtx : wallet.mapWallet) {
15861586
const CWalletTx& tx = pairWtx.second;
15871587

15881588
if (depth == -1 || abs(tx.GetDepthInMainChain()) < depth) {
1589-
ListTransactions(pwallet, tx, 0, true, transactions, filter, nullptr /* filter_label */);
1589+
ListTransactions(&wallet, tx, 0, true, transactions, filter, nullptr /* filter_label */);
15901590
}
15911591
}
15921592

@@ -1595,23 +1595,23 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
15951595
UniValue removed(UniValue::VARR);
15961596
while (include_removed && altheight && *altheight > *height) {
15971597
CBlock block;
1598-
if (!pwallet->chain().findBlock(blockId, FoundBlock().data(block)) || block.IsNull()) {
1598+
if (!wallet.chain().findBlock(blockId, FoundBlock().data(block)) || block.IsNull()) {
15991599
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
16001600
}
16011601
for (const CTransactionRef& tx : block.vtx) {
1602-
auto it = pwallet->mapWallet.find(tx->GetHash());
1603-
if (it != pwallet->mapWallet.end()) {
1602+
auto it = wallet.mapWallet.find(tx->GetHash());
1603+
if (it != wallet.mapWallet.end()) {
16041604
// We want all transactions regardless of confirmation count to appear here,
16051605
// even negative confirmation ones, hence the big negative.
1606-
ListTransactions(pwallet, it->second, -100000000, true, removed, filter, nullptr /* filter_label */);
1606+
ListTransactions(&wallet, it->second, -100000000, true, removed, filter, nullptr /* filter_label */);
16071607
}
16081608
}
16091609
blockId = block.hashPrevBlock;
16101610
--*altheight;
16111611
}
16121612

16131613
uint256 lastblock;
1614-
CHECK_NONFATAL(pwallet->chain().findAncestorByHeight(pwallet->GetLastBlockHash(), pwallet->GetLastBlockHeight() + 1 - target_confirms, FoundBlock().hash(lastblock)));
1614+
CHECK_NONFATAL(wallet.chain().findAncestorByHeight(wallet.GetLastBlockHash(), wallet.GetLastBlockHeight() + 1 - target_confirms, FoundBlock().hash(lastblock)));
16151615

16161616
UniValue ret(UniValue::VOBJ);
16171617
ret.pushKV("transactions", transactions);

0 commit comments

Comments
 (0)