rippled
Loading...
Searching...
No Matches
multisign.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 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#ifndef RIPPLE_TEST_JTX_MULTISIGN_H_INCLUDED
21#define RIPPLE_TEST_JTX_MULTISIGN_H_INCLUDED
22
23#include <test/jtx/Account.h>
24#include <test/jtx/amount.h>
25#include <test/jtx/owners.h>
26#include <test/jtx/tags.h>
27
28#include <concepts>
29#include <cstdint>
30#include <optional>
31
32namespace ripple {
33namespace test {
34namespace jtx {
35
37struct signer
38{
42
44 Account account_,
45 std::uint32_t weight_ = 1,
46 std::optional<uint256> tag_ = std::nullopt)
47 : weight(weight_), account(std::move(account_)), tag(std::move(tag_))
48 {
49 }
50};
51
54 Account const& account,
55 std::uint32_t quorum,
56 std::vector<signer> const& v);
57
60signers(Account const& account, none_t);
61
62//------------------------------------------------------------------------------
63
65class msig
66{
67public:
68 struct Reg
69 {
72
73 Reg(Account const& masterSig) : acct(masterSig), sig(masterSig)
74 {
75 }
76
77 Reg(Account const& acct_, Account const& regularSig)
78 : acct(acct_), sig(regularSig)
79 {
80 }
81
82 Reg(char const* masterSig) : acct(masterSig), sig(masterSig)
83 {
84 }
85
86 Reg(char const* acct_, char const* regularSig)
87 : acct(acct_), sig(regularSig)
88 {
89 }
90
91 bool
92 operator<(Reg const& rhs) const
93 {
94 return acct < rhs.acct;
95 }
96 };
97
99
100public:
101 msig(std::vector<Reg> signers_);
102
103 template <class AccountType, class... Accounts>
104 requires std::convertible_to<AccountType, Reg>
105 explicit msig(AccountType&& a0, Accounts&&... aN)
106 : msig{std::vector<Reg>{
107 std::forward<AccountType>(a0),
108 std::forward<Accounts>(aN)...}}
109 {
110 }
111
112 void
113 operator()(Env&, JTx& jt) const;
114};
115
116//------------------------------------------------------------------------------
117
120
121} // namespace jtx
122} // namespace test
123} // namespace ripple
124
125#endif
Represents a JSON value.
Definition: json_value.h:150
Immutable cryptographic account descriptor.
Definition: Account.h:39
A transaction testing environment.
Definition: Env.h:121
Set a multisignature on a JTx.
Definition: multisign.h:66
msig(AccountType &&a0, Accounts &&... aN)
Definition: multisign.h:105
std::vector< Reg > signers
Definition: multisign.h:98
Set the regular signature on a JTx.
Definition: sig.h:35
Json::Value signers(Account const &account, std::uint32_t quorum, std::vector< signer > const &v)
Definition: multisign.cpp:34
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
STL namespace.
Execution context for applying a JSON transaction.
Definition: JTx.h:45
Reg(char const *acct_, char const *regularSig)
Definition: multisign.h:86
Reg(char const *masterSig)
Definition: multisign.h:82
bool operator<(Reg const &rhs) const
Definition: multisign.h:92
Reg(Account const &acct_, Account const &regularSig)
Definition: multisign.h:77
Reg(Account const &masterSig)
Definition: multisign.h:73
A signer in a SignerList.
Definition: multisign.h:38
std::optional< uint256 > tag
Definition: multisign.h:41
signer(Account account_, std::uint32_t weight_=1, std::optional< uint256 > tag_=std::nullopt)
Definition: multisign.h:43
std::uint32_t weight
Definition: multisign.h:39