rippled
Loading...
Searching...
No Matches
trust.cpp
1#include <test/jtx/trust.h>
2
3#include <xrpl/basics/contract.h>
4#include <xrpl/protocol/jss.h>
5
6#include <stdexcept>
7
8namespace xrpl {
9namespace test {
10namespace jtx {
11
14{
15 if (isXRP(amount))
16 Throw<std::runtime_error>("trust() requires IOU");
17 Json::Value jv;
18 jv[jss::Account] = account.human();
19 jv[jss::LimitAmount] = amount.getJson(JsonOptions::none);
20 jv[jss::TransactionType] = jss::TrustSet;
21 jv[jss::Flags] = flags;
22 return jv;
23}
24
25// This function overload is especially useful for modelling Authorised trust
26// lines. account (first function parameter) is the issuing authority, it
27// authorises peer (third function parameter) to hold a certain currency
28// (amount, the second function parameter)
30trust(Account const& account, STAmount const& amount, Account const& peer, std::uint32_t flags)
31{
32 if (isXRP(amount))
33 Throw<std::runtime_error>("trust() requires IOU");
34 Json::Value jv;
35 jv[jss::Account] = account.human();
36 {
37 auto& ja = jv[jss::LimitAmount] = amount.getJson(JsonOptions::none);
38 ja[jss::issuer] = peer.human();
39 }
40 jv[jss::TransactionType] = jss::TrustSet;
41 jv[jss::Flags] = flags;
42 return jv;
43}
44
46claw(Account const& account, STAmount const& amount, std::optional<Account> const& mptHolder)
47{
48 Json::Value jv;
49 jv[jss::Account] = account.human();
50 jv[jss::Amount] = amount.getJson(JsonOptions::none);
51 jv[jss::TransactionType] = jss::Clawback;
52
53 if (mptHolder)
54 jv[sfHolder.jsonName] = mptHolder->human();
55
56 return jv;
57}
58
59} // namespace jtx
60} // namespace test
61} // namespace xrpl
Represents a JSON value.
Definition json_value.h:131
Immutable cryptographic account descriptor.
Definition Account.h:20
std::string const & human() const
Returns the human readable public key.
Definition Account.h:95
Match set account flags.
Definition flags.h:109
Json::Value claw(Account const &account, STAmount const &amount, std::optional< Account > const &mptHolder)
Definition trust.cpp:46
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:13
auto const amount
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
bool isXRP(AccountID const &c)
Definition AccountID.h:71