mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
WS: Add transaction_entry request.
This commit is contained in:
@@ -86,6 +86,7 @@ public:
|
||||
void doLedgerCurrent(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doLedgerEntry(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doSubmit(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doTransactionEntry(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
|
||||
// Streaming Commands
|
||||
void doAccountInfoSubscribe(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
@@ -161,7 +162,7 @@ public:
|
||||
{
|
||||
Json::FastWriter jfwWriter;
|
||||
|
||||
cLog(lsDEBUG) << "Ws:: Object '" << jfwWriter.write(jvObj) << "'";
|
||||
// cLog(lsDEBUG) << "Ws:: Object '" << jfwWriter.write(jvObj) << "'";
|
||||
|
||||
send(cpClient, jfwWriter.write(jvObj));
|
||||
}
|
||||
@@ -311,6 +312,7 @@ Json::Value WSConnection::invokeCommand(const Json::Value& jvRequest)
|
||||
{ "ledger_current", &WSConnection::doLedgerCurrent },
|
||||
{ "ledger_entry", &WSConnection::doLedgerEntry },
|
||||
{ "submit", &WSConnection::doSubmit },
|
||||
{ "transaction_entry", &WSConnection::doTransactionEntry },
|
||||
|
||||
// Streaming commands:
|
||||
{ "account_info_subscribe", &WSConnection::doAccountInfoSubscribe },
|
||||
@@ -984,6 +986,52 @@ void WSConnection::doSubmit(Json::Value& jvResult, const Json::Value& jvRequest)
|
||||
}
|
||||
}
|
||||
|
||||
void WSConnection::doTransactionEntry(Json::Value& jvResult, const Json::Value& jvRequest)
|
||||
{
|
||||
if (!jvRequest.isMember("transaction"))
|
||||
{
|
||||
jvResult["error"] = "fieldNotFoundTransaction";
|
||||
}
|
||||
if (!jvRequest.isMember("ledger_closed"))
|
||||
{
|
||||
jvResult["error"] = "notYetImplemented"; // XXX We don't support any transaction yet.
|
||||
}
|
||||
else
|
||||
{
|
||||
uint256 uTransID;
|
||||
// XXX Relying on trusted WSS client. Would be better to have a strict routine, returning success or failure.
|
||||
uTransID.SetHex(jvRequest["transaction"].asString());
|
||||
|
||||
uint256 uLedgerID;
|
||||
// XXX Relying on trusted WSS client. Would be better to have a strict routine, returning success or failure.
|
||||
uLedgerID.SetHex(jvRequest["ledger_closed"].asString());
|
||||
|
||||
Ledger::pointer lpLedger = theApp->getMasterLedger().getLedgerByHash(uLedgerID);
|
||||
|
||||
if (!lpLedger) {
|
||||
jvResult["error"] = "ledgerNotFound";
|
||||
}
|
||||
else
|
||||
{
|
||||
Transaction::pointer tpTrans;
|
||||
TransactionMetaSet::pointer tmTrans;
|
||||
|
||||
if (!lpLedger-> getTransaction(uTransID, tpTrans, tmTrans))
|
||||
{
|
||||
jvResult["error"] = "transactionNotFound";
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult["transaction"] = tpTrans->getJson(0);
|
||||
jvResult["metadata"] = tmTrans->getJson(0);
|
||||
// 'accounts'
|
||||
// 'engine_...'
|
||||
// 'ledger_...'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WSConnection::doTransactionSubcribe(Json::Value& jvResult, const Json::Value& jvRequest)
|
||||
{
|
||||
if (!mNetwork.subTransaction(this))
|
||||
|
||||
Reference in New Issue
Block a user