xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
ledger
AcceptedLedgerTx.cpp
1
#include <xrpl/ledger/AcceptedLedgerTx.h>
2
3
#include <xrpl/basics/StringUtilities.h>
4
#include <xrpl/basics/strHex.h>
5
#include <xrpl/beast/utility/instrumentation.h>
6
#include <xrpl/json/json_value.h>
7
#include <xrpl/ledger/ReadView.h>
8
#include <xrpl/ledger/helpers/TokenHelpers.h>
9
#include <xrpl/protocol/AccountID.h>
10
#include <xrpl/protocol/SField.h>
11
#include <xrpl/protocol/STObject.h>
12
#include <xrpl/protocol/STTx.h>
13
#include <xrpl/protocol/Serializer.h>
14
#include <xrpl/protocol/TER.h>
15
#include <xrpl/protocol/TxFormats.h>
16
#include <xrpl/protocol/jss.h>
17
18
#include <
memory
>
19
#include <
string
>
20
#include <
utility
>
21
22
namespace
xrpl
{
23
24
AcceptedLedgerTx::AcceptedLedgerTx
(
25
std::shared_ptr<ReadView const>
const
& ledger,
26
std::shared_ptr<STTx const>
const
& txn,
27
std::shared_ptr<STObject const>
const
& met)
28
:
txn_
(txn)
29
,
meta_
(txn->
getTransactionID
(), ledger->seq(), *met)
30
,
affected_
(
meta_
.getAffectedAccounts())
31
{
32
XRPL_ASSERT(!ledger->open(),
"xrpl::AcceptedLedgerTx::AcceptedLedgerTx : valid ledger state"
);
33
34
Serializer
s;
35
met->add(s);
36
rawMeta_
= std::move(s.
modData
());
37
38
json_
=
json::ValueType::Object
;
39
json_
[jss::transaction] =
txn_
->getJson(
JsonOptions::Values::None
);
40
41
json_
[jss::meta] =
meta_
.getJson(
JsonOptions::Values::None
);
42
json_
[jss::raw_meta] =
strHex
(
rawMeta_
);
43
44
json_
[jss::result] =
transHuman
(
meta_
.getResultTER());
45
46
if
(!
affected_
.empty())
47
{
48
json::Value
& affected = (
json_
[jss::affected] =
json::ValueType::Array
);
49
for
(
auto
const
& account :
affected_
)
50
affected.
append
(
toBase58
(account));
51
}
52
53
if
(
txn_
->getTxnType() == ttOFFER_CREATE)
54
{
55
auto
const
& account =
txn_
->getAccountID(sfAccount);
56
auto
const
amount =
txn_
->getFieldAmount(sfTakerGets);
57
58
// If the offer create is not self funded then add the owner balance
59
if
(account != amount.getIssuer())
60
{
61
auto
const
ownerFunds =
accountFunds
(
62
*ledger,
63
account,
64
amount,
65
FreezeHandling::IgnoreFreeze
,
66
AuthHandling::IgnoreAuth
,
67
beast::Journal
{
beast::Journal::getNullSink
()});
68
json_
[jss::transaction][jss::owner_funds] = ownerFunds.getText();
69
}
70
}
71
}
72
73
std::string
74
AcceptedLedgerTx::getEscMeta
()
const
75
{
76
XRPL_ASSERT(!
rawMeta_
.empty(),
"xrpl::AcceptedLedgerTx::getEscMeta : metadata is set"
);
77
return
sqlBlobLiteral
(
rawMeta_
);
78
}
79
80
}
// namespace xrpl
std::string
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::Journal::getNullSink
static Sink & getNullSink()
Returns a Sink which does nothing.
Definition
beast_Journal.cpp:63
json::Value
Represents a JSON value.
Definition
json_value.h:117
json::Value::append
Value & append(Value const &value)
Append value to array at the end.
Definition
json_value.cpp:997
xrpl::AcceptedLedgerTx::json_
json::Value json_
Definition
AcceptedLedgerTx.h:94
xrpl::AcceptedLedgerTx::getEscMeta
std::string getEscMeta() const
Definition
AcceptedLedgerTx.cpp:74
xrpl::AcceptedLedgerTx::getTransactionID
TxID getTransactionID() const
Definition
AcceptedLedgerTx.h:61
xrpl::AcceptedLedgerTx::rawMeta_
Blob rawMeta_
Definition
AcceptedLedgerTx.h:93
xrpl::AcceptedLedgerTx::affected_
boost::container::flat_set< AccountID > affected_
Definition
AcceptedLedgerTx.h:92
xrpl::AcceptedLedgerTx::txn_
std::shared_ptr< STTx const > txn_
Definition
AcceptedLedgerTx.h:90
xrpl::AcceptedLedgerTx::meta_
TxMeta meta_
Definition
AcceptedLedgerTx.h:91
xrpl::AcceptedLedgerTx::AcceptedLedgerTx
AcceptedLedgerTx(std::shared_ptr< ReadView const > const &ledger, std::shared_ptr< STTx const > const &, std::shared_ptr< STObject const > const &)
Definition
AcceptedLedgerTx.cpp:24
xrpl::Serializer
Definition
Serializer.h:23
xrpl::Serializer::modData
Blob & modData()
Definition
Serializer.h:283
memory
json::ValueType::Array
@ Array
array value (ordered list)
Definition
json_value.h:28
json::ValueType::Object
@ Object
object value (collection of name/value pairs).
Definition
json_value.h:29
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::FreezeHandling::IgnoreFreeze
@ IgnoreFreeze
Definition
TokenHelpers.h:34
xrpl::strHex
std::string strHex(FwdIt begin, FwdIt end)
Definition
strHex.h:13
xrpl::toBase58
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition
AccountID.cpp:95
xrpl::transHuman
std::string transHuman(TER code)
Definition
TER.cpp:266
xrpl::accountFunds
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Definition
TokenHelpers.cpp:498
xrpl::AuthHandling::IgnoreAuth
@ IgnoreAuth
Definition
TokenHelpers.h:39
xrpl::sqlBlobLiteral
std::string sqlBlobLiteral(Blob const &blob)
Format arbitrary binary data as an SQLite "blob literal".
Definition
libxrpl/basics/StringUtilities.cpp:23
std::shared_ptr
string
xrpl::JsonOptions::Values::None
@ None
Definition
STBase.h:27
utility
Generated by
1.17.0