Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 2,726 Lines • ▼ Show 20 Lines | static UniValue listsinceblock(const Config &config, | ||||
if (!request.params[0].isNull() && !request.params[0].get_str().empty()) { | if (!request.params[0].isNull() && !request.params[0].get_str().empty()) { | ||||
BlockHash blockId(ParseHashV(request.params[0], "blockhash")); | BlockHash blockId(ParseHashV(request.params[0], "blockhash")); | ||||
paltindex = pindex = LookupBlockIndex(blockId); | paltindex = pindex = LookupBlockIndex(blockId); | ||||
if (!pindex) { | if (!pindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
if (chainActive[pindex->nHeight] != pindex) { | if (::ChainActive()[pindex->nHeight] != pindex) { | ||||
// the block being asked for is a part of a deactivated chain; | // 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 | // we don't want to depend on its perceived height in the block | ||||
// chain, we want to instead use the last common ancestor | // chain, we want to instead use the last common ancestor | ||||
pindex = chainActive.FindFork(pindex); | pindex = ::ChainActive().FindFork(pindex); | ||||
} | } | ||||
} | } | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
target_confirms = request.params[1].get_int(); | target_confirms = request.params[1].get_int(); | ||||
if (target_confirms < 1) { | if (target_confirms < 1) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter"); | throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter"); | ||||
} | } | ||||
} | } | ||||
if (!request.params[2].isNull() && request.params[2].get_bool()) { | if (!request.params[2].isNull() && request.params[2].get_bool()) { | ||||
filter = filter | ISMINE_WATCH_ONLY; | filter = filter | ISMINE_WATCH_ONLY; | ||||
} | } | ||||
bool include_removed = | bool include_removed = | ||||
(request.params[3].isNull() || request.params[3].get_bool()); | (request.params[3].isNull() || request.params[3].get_bool()); | ||||
int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1; | int depth = pindex ? (1 + ::ChainActive().Height() - pindex->nHeight) : -1; | ||||
UniValue transactions(UniValue::VARR); | UniValue transactions(UniValue::VARR); | ||||
for (const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) { | for (const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) { | ||||
CWalletTx tx = pairWtx.second; | CWalletTx tx = pairWtx.second; | ||||
if (depth == -1 || tx.GetDepthInMainChain(*locked_chain) < depth) { | if (depth == -1 || tx.GetDepthInMainChain(*locked_chain) < depth) { | ||||
ListTransactions(*locked_chain, pwallet, tx, "*", 0, true, | ListTransactions(*locked_chain, pwallet, tx, "*", 0, true, | ||||
Show All 21 Lines | while (include_removed && paltindex && paltindex != pindex) { | ||||
ListTransactions(*locked_chain, pwallet, it->second, "*", | ListTransactions(*locked_chain, pwallet, it->second, "*", | ||||
-100000000, true, removed, filter); | -100000000, true, removed, filter); | ||||
} | } | ||||
} | } | ||||
paltindex = paltindex->pprev; | paltindex = paltindex->pprev; | ||||
} | } | ||||
CBlockIndex *pblockLast = | CBlockIndex *pblockLast = | ||||
chainActive[chainActive.Height() + 1 - target_confirms]; | ::ChainActive()[::ChainActive().Height() + 1 - target_confirms]; | ||||
uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); | uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
ret.pushKV("transactions", transactions); | ret.pushKV("transactions", transactions); | ||||
if (include_removed) { | if (include_removed) { | ||||
ret.pushKV("removed", removed); | ret.pushKV("removed", removed); | ||||
} | } | ||||
ret.pushKV("lastblock", lastblock.GetHex()); | ret.pushKV("lastblock", lastblock.GetHex()); | ||||
▲ Show 20 Lines • Show All 1,891 Lines • ▼ Show 20 Lines | if (!reserver.reserve()) { | ||||
"Wallet is currently rescanning. Abort existing rescan or wait."); | "Wallet is currently rescanning. Abort existing rescan or wait."); | ||||
} | } | ||||
CBlockIndex *pindexStart = nullptr; | CBlockIndex *pindexStart = nullptr; | ||||
CBlockIndex *pindexStop = nullptr; | CBlockIndex *pindexStop = nullptr; | ||||
CBlockIndex *pChainTip = nullptr; | CBlockIndex *pChainTip = nullptr; | ||||
{ | { | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
pindexStart = chainActive.Genesis(); | pindexStart = ::ChainActive().Genesis(); | ||||
pChainTip = chainActive.Tip(); | pChainTip = ::ChainActive().Tip(); | ||||
if (!request.params[0].isNull()) { | if (!request.params[0].isNull()) { | ||||
pindexStart = chainActive[request.params[0].get_int()]; | pindexStart = ::ChainActive()[request.params[0].get_int()]; | ||||
if (!pindexStart) { | if (!pindexStart) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Invalid start_height"); | "Invalid start_height"); | ||||
} | } | ||||
} | } | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
pindexStop = chainActive[request.params[1].get_int()]; | pindexStop = ::ChainActive()[request.params[1].get_int()]; | ||||
if (!pindexStop) { | if (!pindexStop) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Invalid stop_height"); | "Invalid stop_height"); | ||||
} else if (pindexStop->nHeight < pindexStart->nHeight) { | } else if (pindexStop->nHeight < pindexStart->nHeight) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"stop_height must be greater than start_height"); | "stop_height must be greater than start_height"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 912 Lines • Show Last 20 Lines |