aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpcwallet.cpp
diff options
context:
space:
mode:
authorRussell Yanofsky <[email protected]>2017-07-27 10:08:31 -0400
committerRussell Yanofsky <[email protected]>2019-01-15 12:42:00 -0400
commit700c42b85d20e624bef4228eef062c93084efab5 (patch)
tree60f0213d9b6671995ae6e7d2015d57ffdda89f4b /src/wallet/rpcwallet.cpp
parentMerge #14433: Add checksum in gitian build scripts for ossl (diff)
downloaddiscoin-700c42b85d20e624bef4228eef062c93084efab5.tar.xz
discoin-700c42b85d20e624bef4228eef062c93084efab5.zip
Add height, depth, and hash methods to the Chain interface
And use them to remove uses of chainActive and mapBlockIndex in wallet code This commit does not change behavior. Co-authored-by: Ben Woosley <[email protected]>
Diffstat (limited to 'src/wallet/rpcwallet.cpp')
-rw-r--r--src/wallet/rpcwallet.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 39c17743e..c835d2928 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -1607,7 +1607,8 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
- int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1;
+ const Optional<int> tip_height = locked_chain->getHeight();
+ int depth = tip_height && pindex ? (1 + *tip_height - pindex->nHeight) : -1;
UniValue transactions(UniValue::VARR);
@@ -1638,8 +1639,8 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
paltindex = paltindex->pprev;
}
- CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms];
- uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256();
+ int last_height = tip_height ? *tip_height + 1 - target_confirms : -1;
+ uint256 lastblock = last_height >= 0 ? locked_chain->getBlockHash(last_height) : uint256();
UniValue ret(UniValue::VOBJ);
ret.pushKV("transactions", transactions);