rippled
Loading...
Searching...
No Matches
deposit.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2018 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <test/jtx/deposit.h>
21
22#include <xrpl/protocol/jss.h>
23
24namespace ripple {
25namespace test {
26namespace jtx {
27
28namespace deposit {
29
30// Add DepositPreauth.
32auth(jtx::Account const& account, jtx::Account const& auth)
33{
34 Json::Value jv;
35 jv[sfAccount.jsonName] = account.human();
36 jv[sfAuthorize.jsonName] = auth.human();
37 jv[sfTransactionType.jsonName] = jss::DepositPreauth;
38 return jv;
39}
40
41// Remove DepositPreauth.
43unauth(jtx::Account const& account, jtx::Account const& unauth)
44{
45 Json::Value jv;
46 jv[sfAccount.jsonName] = account.human();
47 jv[sfUnauthorize.jsonName] = unauth.human();
48 jv[sfTransactionType.jsonName] = jss::DepositPreauth;
49 return jv;
50}
51
52// Add DepositPreauth.
55 jtx::Account const& account,
57{
58 Json::Value jv;
59 jv[sfAccount.jsonName] = account.human();
60 jv[sfAuthorizeCredentials.jsonName] = Json::arrayValue;
61 auto& arr(jv[sfAuthorizeCredentials.jsonName]);
62 for (auto const& o : auth)
63 {
64 Json::Value j2;
65 j2[jss::Credential] = o.toJson();
66 arr.append(std::move(j2));
67 }
68 jv[sfTransactionType.jsonName] = jss::DepositPreauth;
69 return jv;
70}
71
72// Remove DepositPreauth.
75 jtx::Account const& account,
77{
78 Json::Value jv;
79 jv[sfAccount.jsonName] = account.human();
80 jv[sfUnauthorizeCredentials.jsonName] = Json::arrayValue;
81 auto& arr(jv[sfUnauthorizeCredentials.jsonName]);
82 for (auto const& o : auth)
83 {
84 Json::Value j2;
85 j2[jss::Credential] = o.toJson();
86 arr.append(std::move(j2));
87 }
88 jv[sfTransactionType.jsonName] = jss::DepositPreauth;
89 return jv;
90}
91
92} // namespace deposit
93
94} // namespace jtx
95} // namespace test
96} // namespace ripple
Represents a JSON value.
Definition json_value.h:149
Value & append(Value const &value)
Append value to array at the end.
Immutable cryptographic account descriptor.
Definition Account.h:39
@ arrayValue
array value (ordered list)
Definition json_value.h:44
Json::Value unauth(Account const &account, Account const &unauth)
Remove preauthorization for deposit.
Definition deposit.cpp:43
Json::Value unauthCredentials(jtx::Account const &account, std::vector< AuthorizeCredentials > const &auth)
Definition deposit.cpp:74
Json::Value authCredentials(jtx::Account const &account, std::vector< AuthorizeCredentials > const &auth)
Definition deposit.cpp:54
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25