diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-01-23 16:13:29 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-01-23 16:16:37 +0100 |
commit | 727a79836035b02e82e31a3c941396146eabc207 (patch) | |
tree | b6e7f412e439c36896db28237c343dfe0097df07 /src | |
parent | 5cf3c60fccb198c16819fcf8a0c5635b5b630496 (diff) | |
parent | 7ba0a00aae03b438e63d0ada9ff68a7618c7f907 (diff) |
Merge #9516: Bug-fix: listsinceblock: use fork point as reference for blocks in reorg'd chains
7ba0a00 Testing: listsinceblock should not use orphan block height. (Karl-Johan Alm)
ee5c1ce Bug-fix: listsinceblock: use closest common ancestor when a block hash was provided for a chain that was not the main chain. (Karl-Johan Alm)
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/rpcwallet.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 55e7558498..6d08f60483 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1681,7 +1681,7 @@ UniValue listsinceblock(const JSONRPCRequest& request) LOCK2(cs_main, pwalletMain->cs_wallet); - CBlockIndex *pindex = NULL; + const CBlockIndex *pindex = NULL; int target_confirms = 1; isminefilter filter = ISMINE_SPENDABLE; @@ -1692,7 +1692,16 @@ UniValue listsinceblock(const JSONRPCRequest& request) blockId.SetHex(request.params[0].get_str()); BlockMap::iterator it = mapBlockIndex.find(blockId); if (it != mapBlockIndex.end()) + { pindex = it->second; + if (chainActive[pindex->nHeight] != pindex) + { + // the block being asked for is a part of a deactivated chain; + // we don't want to depend on its perceived height in the block + // chain, we want to instead use the last common ancestor + pindex = chainActive.FindFork(pindex); + } + } } if (request.params.size() > 1) @@ -1703,9 +1712,10 @@ UniValue listsinceblock(const JSONRPCRequest& request) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter"); } - if(request.params.size() > 2) - if(request.params[2].get_bool()) - filter = filter | ISMINE_WATCH_ONLY; + if (request.params.size() > 2 && request.params[2].get_bool()) + { + filter = filter | ISMINE_WATCH_ONLY; + } int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1; |