@@ -1679,7 +1679,7 @@ UniValue listsinceblock(const JSONRPCRequest& request)
1679
1679
1680
1680
LOCK2 (cs_main, pwalletMain->cs_wallet );
1681
1681
1682
- CBlockIndex *pindex = NULL ;
1682
+ const CBlockIndex *pindex = NULL ;
1683
1683
int target_confirms = 1 ;
1684
1684
isminefilter filter = ISMINE_SPENDABLE;
1685
1685
@@ -1690,7 +1690,16 @@ UniValue listsinceblock(const JSONRPCRequest& request)
1690
1690
blockId.SetHex (request.params [0 ].get_str ());
1691
1691
BlockMap::iterator it = mapBlockIndex.find (blockId);
1692
1692
if (it != mapBlockIndex.end ())
1693
+ {
1693
1694
pindex = it->second ;
1695
+ if (chainActive[pindex->nHeight ] != pindex)
1696
+ {
1697
+ // the block being asked for is a part of a deactivated chain;
1698
+ // we don't want to depend on its perceived height in the block
1699
+ // chain, we want to instead use the last common ancestor
1700
+ pindex = chainActive.FindFork (pindex);
1701
+ }
1702
+ }
1694
1703
}
1695
1704
1696
1705
if (request.params .size () > 1 )
@@ -1701,9 +1710,10 @@ UniValue listsinceblock(const JSONRPCRequest& request)
1701
1710
throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter" );
1702
1711
}
1703
1712
1704
- if (request.params .size () > 2 )
1705
- if (request.params [2 ].get_bool ())
1706
- filter = filter | ISMINE_WATCH_ONLY;
1713
+ if (request.params .size () > 2 && request.params [2 ].get_bool ())
1714
+ {
1715
+ filter = filter | ISMINE_WATCH_ONLY;
1716
+ }
1707
1717
1708
1718
int depth = pindex ? (1 + chainActive.Height () - pindex->nHeight ) : -1 ;
1709
1719
0 commit comments