Skip to content

Commit 5bebb81

Browse files
committed
Add new RPC to list unconfirmed Omni transactions
``` Returns a list of unconfirmed Omni transactions, pending in the memory pool. An optional filter can be provided to only include transactions which involve the given address. # "txid" : "hash", (string) the hex-encoded hash of the transaction
1 parent 21a0cf8 commit 5bebb81

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

src/omnicore/rpc.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,57 @@ Value omni_listtransactions(const Array& params, bool fHelp)
13631363
return response;
13641364
}
13651365

1366+
Value omni_listpendingtransactions(const Array& params, bool fHelp)
1367+
{
1368+
if (fHelp || params.size() > 1)
1369+
throw runtime_error(
1370+
"omni_listpendingtransactions ( \"address\" )\n"
1371+
"\nReturns a list of unconfirmed Omni transactions, pending in the memory pool.\n"
1372+
"\nAn optional filter can be provided to only include transactions which involve the given address.\n"
1373+
"\nNote: the validity of pending transactions is uncertain, and the state of the memory pool may "
1374+
"change at any moment. It is recommended to check transactions after confirmation, and pending "
1375+
"transactions should be considered as invalid.\n"
1376+
"\nArguments:\n"
1377+
"1. address (string, optional) address filter (default: \"\" for no filter)\n"
1378+
"\nResult:\n"
1379+
"[ (array of JSON objects)\n"
1380+
" {\n"
1381+
" \"txid\" : \"hash\", (string) the hex-encoded hash of the transaction\n"
1382+
" \"sendingaddress\" : \"address\", (string) the Bitcoin address of the sender\n"
1383+
" \"referenceaddress\" : \"address\", (string) a Bitcoin address used as reference (if any)\n"
1384+
" \"ismine\" : true|false, (boolean) whether the transaction involes an address in the wallet\n"
1385+
" \"fee\" : \"n.nnnnnnnn\", (string) the transaction fee in bitcoins\n"
1386+
" \"version\" : n, (number) the transaction version\n"
1387+
" \"type_int\" : n, (number) the transaction type as number\n"
1388+
" \"type\" : \"type\", (string) the transaction type as string\n"
1389+
" [...] (mixed) other transaction type specific properties\n"
1390+
" },\n"
1391+
" ...\n"
1392+
"]\n"
1393+
"\nExamples:\n"
1394+
+ HelpExampleCli("omni_listpendingtransactions", "")
1395+
+ HelpExampleRpc("omni_listpendingtransactions", "")
1396+
);
1397+
1398+
std::string filterAddress;
1399+
if (params.size() > 0) {
1400+
filterAddress = ParseAddressOrEmpty(params[0]);
1401+
}
1402+
1403+
std::vector<uint256> vTxid;
1404+
mempool.queryHashes(vTxid);
1405+
1406+
Array result;
1407+
BOOST_FOREACH(const uint256& hash, vTxid) {
1408+
Object txObj;
1409+
if (populateRPCTransactionObject(hash, txObj, filterAddress) == 0) {
1410+
result.push_back(txObj);
1411+
}
1412+
}
1413+
1414+
return result;
1415+
}
1416+
13661417
Value omni_getinfo(const Array& params, bool fHelp)
13671418
{
13681419
if (fHelp || params.size() != 0)

src/rpcserver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ static const CRPCCommand vRPCCommands[] =
371371
{ "omni layer (data retrieval)", "omni_gettrade", &omni_gettrade, false, true, false },
372372
{ "omni layer (data retrieval)", "omni_getsto", &omni_getsto, false, true, false },
373373
{ "omni layer (data retrieval)", "omni_listblocktransactions", &omni_listblocktransactions, false, true, false },
374+
{ "omni layer (data retrieval)", "omni_listpendingtransactions", &omni_listpendingtransactions, false, true, false },
374375
{ "omni layer (data retrieval)", "omni_getallbalancesforaddress", &omni_getallbalancesforaddress, false, true, false },
375376
{ "omni layer (data retrieval)", "omni_gettradehistoryforaddress", &omni_gettradehistoryforaddress, false, true, false },
376377
{ "omni layer (data retrieval)", "omni_gettradehistoryforpair", &omni_gettradehistoryforpair, false, true, false },

src/rpcserver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ extern json_spirit::Value omni_getorderbook(const json_spirit::Array& params, bo
242242
extern json_spirit::Value omni_gettrade(const json_spirit::Array& params, bool fHelp);
243243
extern json_spirit::Value omni_getsto(const json_spirit::Array& params, bool fHelp);
244244
extern json_spirit::Value omni_listblocktransactions(const json_spirit::Array& params, bool fHelp);
245+
extern json_spirit::Value omni_listpendingtransactions(const json_spirit::Array& params, bool fHelp);
245246
extern json_spirit::Value omni_getallbalancesforaddress(const json_spirit::Array& params, bool fHelp);
246247
extern json_spirit::Value omni_gettradehistoryforaddress(const json_spirit::Array& params, bool fHelp);
247248
extern json_spirit::Value omni_gettradehistoryforpair(const json_spirit::Array& params, bool fHelp);

0 commit comments

Comments
 (0)