rippled
Loading...
Searching...
No Matches
AcceptedLedgerTx.cpp
1#include <xrpld/app/ledger/AcceptedLedgerTx.h>
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/StringUtilities.h>
5#include <xrpl/protocol/UintTypes.h>
6#include <xrpl/protocol/jss.h>
7
8namespace ripple {
9
14 : mTxn(txn)
15 , mMeta(txn->getTransactionID(), ledger->seq(), *met)
16 , mAffected(mMeta.getAffectedAccounts())
17{
18 XRPL_ASSERT(
19 !ledger->open(),
20 "ripple::AcceptedLedgerTx::AcceptedLedgerTx : valid ledger state");
21
22 Serializer s;
23 met->add(s);
24 mRawMeta = std::move(s.modData());
25
27 mJson[jss::transaction] = mTxn->getJson(JsonOptions::none);
28
30 mJson[jss::raw_meta] = strHex(mRawMeta);
31
32 mJson[jss::result] = transHuman(mMeta.getResultTER());
33
34 if (!mAffected.empty())
35 {
36 Json::Value& affected = (mJson[jss::affected] = Json::arrayValue);
37 for (auto const& account : mAffected)
38 affected.append(toBase58(account));
39 }
40
41 if (mTxn->getTxnType() == ttOFFER_CREATE)
42 {
43 auto const& account = mTxn->getAccountID(sfAccount);
44 auto const amount = mTxn->getFieldAmount(sfTakerGets);
45
46 // If the offer create is not self funded then add the owner balance
47 if (account != amount.issue().account)
48 {
49 auto const ownerFunds = accountFunds(
50 *ledger,
51 account,
52 amount,
55 mJson[jss::transaction][jss::owner_funds] = ownerFunds.getText();
56 }
57 }
58}
59
62{
63 XRPL_ASSERT(
64 !mRawMeta.empty(),
65 "ripple::AcceptedLedgerTx::getEscMeta : metadata is set");
67}
68
69} // namespace ripple
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:41
static Sink & getNullSink()
Returns a Sink which does nothing.
boost::container::flat_set< AccountID > mAffected
std::shared_ptr< STTx const > mTxn
AcceptedLedgerTx(std::shared_ptr< ReadView const > const &ledger, std::shared_ptr< STTx const > const &, std::shared_ptr< STObject const > const &)
std::string getEscMeta() const
Json::Value getJson(JsonOptions p) const
Definition TxMeta.h:60
TER getResultTER() const
Definition TxMeta.h:38
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:6
std::string transHuman(TER code)
Definition TER.cpp:254
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition AccountID.cpp:95
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Definition View.cpp:535
@ fhIGNORE_FREEZE
Definition View.h:58
std::string sqlBlobLiteral(Blob const &blob)
Format arbitrary binary data as an SQLite "blob literal".
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:11