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/SignerUtils.h>
25#include <test/jtx/amount.h>
26#include <test/jtx/owners.h>
27#include <test/jtx/tags.h>
28
29#include <concepts>
30#include <cstdint>
31#include <optional>
32
33namespace ripple {
34namespace test {
35namespace jtx {
36
38struct signer
39{
43
45 Account account_,
46 std::uint32_t weight_ = 1,
48 : weight(weight_), account(std::move(account_)), tag(std::move(tag_))
49 {
50 }
51};
52
55 Account const& account,
56 std::uint32_t quorum,
57 std::vector<signer> const& v);
58
61signers(Account const& account, none_t);
62
63//------------------------------------------------------------------------------
64
66class msig
67{
68public:
74 SField const* const subField = nullptr;
77 static constexpr SField* const topLevel = nullptr;
78
79 msig(SField const* subField_, std::vector<Reg> signers_)
80 : signers(std::move(signers_)), subField(subField_)
81 {
83 }
84
85 msig(SField const& subField_, std::vector<Reg> signers_)
86 : msig{&subField_, signers_}
87 {
88 }
89
90 msig(std::vector<Reg> signers_) : msig(topLevel, signers_)
91 {
92 }
93
94 template <class AccountType, class... Accounts>
96 explicit msig(SField const* subField_, AccountType&& a0, Accounts&&... aN)
97 : msig{
98 subField_,
99 std::vector<Reg>{
102 {
103 }
104
105 template <class AccountType, class... Accounts>
107 explicit msig(SField const& subField_, AccountType&& a0, Accounts&&... aN)
108 : msig{
109 &subField_,
110 std::vector<Reg>{
113 {
114 }
115
116 template <class AccountType, class... Accounts>
117 requires(
120 explicit msig(AccountType&& a0, Accounts&&... aN)
121 : msig{
122 topLevel,
126 {
127 }
128
129 void
130 operator()(Env&, JTx& jt) const;
131};
132
133//------------------------------------------------------------------------------
134
137
138} // namespace jtx
139} // namespace test
140} // namespace ripple
141
142#endif
Represents a JSON value.
Definition json_value.h:149
Identifies fields.
Definition SField.h:146
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:67
msig(AccountType &&a0, Accounts &&... aN)
Definition multisign.h:120
SField const *const subField
Alternative transaction object field in which to place the signer list.
Definition multisign.h:74
msig(SField const *subField_, std::vector< Reg > signers_)
Definition multisign.h:79
msig(SField const &subField_, AccountType &&a0, Accounts &&... aN)
Definition multisign.h:107
msig(SField const &subField_, std::vector< Reg > signers_)
Definition multisign.h:85
msig(SField const *subField_, AccountType &&a0, Accounts &&... aN)
Definition multisign.h:96
static constexpr SField *const topLevel
Used solely as a convenience placeholder for ctors that do not specify a subfield.
Definition multisign.h:77
msig(std::vector< Reg > signers_)
Definition multisign.h:90
std::vector< Reg > signers
Definition multisign.h:69
T is_same_v
Json::Value signers(Account const &account, std::uint32_t quorum, std::vector< signer > const &v)
Definition multisign.cpp:34
void sortSigners(std::vector< Reg > &signers)
Definition SignerUtils.h:44
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
STL namespace.
Execution context for applying a JSON transaction.
Definition JTx.h:45
A signer in a SignerList.
Definition multisign.h:39
std::optional< uint256 > tag
Definition multisign.h:42
signer(Account account_, std::uint32_t weight_=1, std::optional< uint256 > tag_=std::nullopt)
Definition multisign.h:44