listsinceblock now shows txns with 0 confirms, as well as allows the lastblock return property to be targeted to the block with the specified depth
This commit is contained in:
parent
5b2f35167f
commit
76aed0141c
1 changed files with 32 additions and 3 deletions
35
src/rpc.cpp
35
src/rpc.cpp
|
@ -1234,10 +1234,11 @@ Value listsinceblock(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp)
|
if (fHelp)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"listsinceblock [blockid]\n"
|
"listsinceblock [blockid] [target-confirmations]\n"
|
||||||
"Get all transactions in blocks since block [blockid], or all transactions if omitted");
|
"Get all transactions in blocks since block [blockid], or all transactions if omitted");
|
||||||
|
|
||||||
CBlockIndex *pindex = NULL;
|
CBlockIndex *pindex = NULL;
|
||||||
|
int target_confirms = 1;
|
||||||
|
|
||||||
if (params.size() > 0)
|
if (params.size() > 0)
|
||||||
{
|
{
|
||||||
|
@ -1247,6 +1248,14 @@ Value listsinceblock(const Array& params, bool fHelp)
|
||||||
pindex = CBlockLocator(blockId).GetBlockIndex();
|
pindex = CBlockLocator(blockId).GetBlockIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.size() > 1)
|
||||||
|
{
|
||||||
|
target_confirms = params[1].get_int();
|
||||||
|
|
||||||
|
if (target_confirms < 1)
|
||||||
|
throw JSONRPCError(-8, "Invalid parameter");
|
||||||
|
}
|
||||||
|
|
||||||
int depth = pindex ? (1 + nBestHeight - pindex->nHeight) : -1;
|
int depth = pindex ? (1 + nBestHeight - pindex->nHeight) : -1;
|
||||||
|
|
||||||
Array transactions;
|
Array transactions;
|
||||||
|
@ -1257,12 +1266,31 @@ Value listsinceblock(const Array& params, bool fHelp)
|
||||||
CWalletTx tx = (*it).second;
|
CWalletTx tx = (*it).second;
|
||||||
|
|
||||||
if (depth == -1 || tx.GetDepthInMainChain() < depth)
|
if (depth == -1 || tx.GetDepthInMainChain() < depth)
|
||||||
ListTransactions(tx, "*", 1, true, transactions);
|
ListTransactions(tx, "*", 0, true, transactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint256 lastblock;
|
||||||
|
|
||||||
|
if (target_confirms == 1)
|
||||||
|
{
|
||||||
|
printf("oops!\n");
|
||||||
|
lastblock = hashBestChain;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int target_height = pindexBest->nHeight + 1 - target_confirms;
|
||||||
|
|
||||||
|
CBlockIndex *block;
|
||||||
|
for (block = pindexBest;
|
||||||
|
block && block->nHeight > target_height;
|
||||||
|
block = block->pprev);
|
||||||
|
|
||||||
|
lastblock = block ? block->GetBlockHash() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object ret;
|
Object ret;
|
||||||
ret.push_back(Pair("transactions", transactions));
|
ret.push_back(Pair("transactions", transactions));
|
||||||
ret.push_back(Pair("lastblock", hashBestChain.GetHex()));
|
ret.push_back(Pair("lastblock", lastblock.GetHex()));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2168,6 +2196,7 @@ int CommandLineRPC(int argc, char *argv[])
|
||||||
if (strMethod == "listtransactions" && n > 1) ConvertTo<boost::int64_t>(params[1]);
|
if (strMethod == "listtransactions" && n > 1) ConvertTo<boost::int64_t>(params[1]);
|
||||||
if (strMethod == "listtransactions" && n > 2) ConvertTo<boost::int64_t>(params[2]);
|
if (strMethod == "listtransactions" && n > 2) ConvertTo<boost::int64_t>(params[2]);
|
||||||
if (strMethod == "listaccounts" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
if (strMethod == "listaccounts" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
||||||
|
if (strMethod == "listsinceblock" && n > 1) ConvertTo<boost::int64_t>(params[1]);
|
||||||
if (strMethod == "sendmany" && n > 1)
|
if (strMethod == "sendmany" && n > 1)
|
||||||
{
|
{
|
||||||
string s = params[1].get_str();
|
string s = params[1].get_str();
|
||||||
|
|
Loading…
Reference in a new issue