rippled
Loading...
Searching...
No Matches
AcceptedLedgerTx.cpp
1#include <xrpl/basics/Log.h>
2#include <xrpl/basics/StringUtilities.h>
3#include <xrpl/ledger/AcceptedLedgerTx.h>
4#include <xrpl/ledger/View.h>
5#include <xrpl/protocol/UintTypes.h>
6#include <xrpl/protocol/jss.h>
7
8namespace xrpl {
9
14 : mTxn(txn), mMeta(txn->getTransactionID(), ledger->seq(), *met), mAffected(mMeta.getAffectedAccounts())
15{
16 XRPL_ASSERT(!ledger->open(), "xrpl::AcceptedLedgerTx::AcceptedLedgerTx : valid ledger state");
17
18 Serializer s;
19 met->add(s);
20 mRawMeta = std::move(s.modData());
21
23 mJson[jss::transaction] = mTxn->getJson(JsonOptions::none);
24
26 mJson[jss::raw_meta] = strHex(mRawMeta);
27
28 mJson[jss::result] = transHuman(mMeta.getResultTER());
29
30 if (!mAffected.empty())
31 {
32 Json::Value& affected = (mJson[jss::affected] = Json::arrayValue);
33 for (auto const& account : mAffected)
34 affected.append(toBase58(account));
35 }
36
37 if (mTxn->getTxnType() == ttOFFER_CREATE)
38 {
39 auto const& account = mTxn->getAccountID(sfAccount);
40 auto const amount = mTxn->getFieldAmount(sfTakerGets);
41
42 // If the offer create is not self funded then add the owner balance
43 if (account != amount.issue().account)
44 {
45 auto const ownerFunds =
47 mJson[jss::transaction][jss::owner_funds] = ownerFunds.getText();
48 }
49 }
50}
51
54{
55 XRPL_ASSERT(!mRawMeta.empty(), "xrpl::AcceptedLedgerTx::getEscMeta : metadata is set");
57}
58
59} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Value & append(Value const &value)
Append value to array at the end.
A generic endpoint for log messages.
Definition Journal.h:40
static Sink & getNullSink()
Returns a Sink which does nothing.
boost::container::flat_set< AccountID > mAffected
std::shared_ptr< STTx const > mTxn
std::string getEscMeta() const
AcceptedLedgerTx(std::shared_ptr< ReadView const > const &ledger, std::shared_ptr< STTx const > const &, std::shared_ptr< STObject const > const &)
TER getResultTER() const
Definition TxMeta.h:37
Json::Value getJson(JsonOptions p) const
Definition TxMeta.h:59
T empty(T... args)
@ arrayValue
array value (ordered list)
Definition json_value.h:25
@ objectValue
object value (collection of name/value pairs).
Definition json_value.h:26
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ fhIGNORE_FREEZE
Definition View.h:58
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:10
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition AccountID.cpp:92
std::string transHuman(TER code)
Definition TER.cpp:252
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Definition View.cpp:515
std::string sqlBlobLiteral(Blob const &blob)
Format arbitrary binary data as an SQLite "blob literal".