rippled
Loading...
Searching...
No Matches
check.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2019 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/check.h>
21
22#include <xrpl/protocol/TxFlags.h>
23#include <xrpl/protocol/jss.h>
24
25namespace ripple {
26namespace test {
27namespace jtx {
28
29namespace check {
30
31// Cash a check requiring that a specific amount be delivered.
33cash(jtx::Account const& dest, uint256 const& checkId, STAmount const& amount)
34{
35 Json::Value jv;
36 jv[sfAccount.jsonName] = dest.human();
37 jv[sfAmount.jsonName] = amount.getJson(JsonOptions::none);
38 jv[sfCheckID.jsonName] = to_string(checkId);
39 jv[sfTransactionType.jsonName] = jss::CheckCash;
40 return jv;
41}
42
43// Cash a check requiring that at least a minimum amount be delivered.
46 jtx::Account const& dest,
47 uint256 const& checkId,
48 DeliverMin const& atLeast)
49{
50 Json::Value jv;
51 jv[sfAccount.jsonName] = dest.human();
52 jv[sfDeliverMin.jsonName] = atLeast.value.getJson(JsonOptions::none);
53 jv[sfCheckID.jsonName] = to_string(checkId);
54 jv[sfTransactionType.jsonName] = jss::CheckCash;
55 return jv;
56}
57
58// Cancel a check.
60cancel(jtx::Account const& dest, uint256 const& checkId)
61{
62 Json::Value jv;
63 jv[sfAccount.jsonName] = dest.human();
64 jv[sfCheckID.jsonName] = to_string(checkId);
65 jv[sfTransactionType.jsonName] = jss::CheckCancel;
66 return jv;
67}
68
69} // namespace check
70
71} // namespace jtx
72} // namespace test
73} // namespace ripple
Represents a JSON value.
Definition json_value.h:149
Json::Value getJson(JsonOptions=JsonOptions::none) const override
Definition STAmount.cpp:795
Immutable cryptographic account descriptor.
Definition Account.h:39
std::string const & human() const
Returns the human readable public key.
Definition Account.h:118
void check(bool condition, std::string const &message)
Json::Value cancel(jtx::Account const &dest, uint256 const &checkId)
Cancel a check.
Definition check.cpp:60
Json::Value cash(jtx::Account const &dest, uint256 const &checkId, STAmount const &amount)
Cash a check requiring that a specific amount be delivered.
Definition check.cpp:33
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:630
Type used to specify DeliverMin for cashing a check.
Definition check.h:40