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#include <concepts>
28#include <cstdint>
29#include <optional>
30
31namespace ripple {
32namespace test {
33namespace jtx {
34
36struct signer
37{
41
43 Account account_,
44 std::uint32_t weight_ = 1,
45 std::optional<uint256> tag_ = std::nullopt)
46 : weight(weight_), account(std::move(account_)), tag(std::move(tag_))
47 {
48 }
49};
50
53 Account const& account,
54 std::uint32_t quorum,
55 std::vector<signer> const& v);
56
59signers(Account const& account, none_t);
60
61//------------------------------------------------------------------------------
62
64class msig
65{
66public:
67 struct Reg
68 {
71
72 Reg(Account const& masterSig) : acct(masterSig), sig(masterSig)
73 {
74 }
75
76 Reg(Account const& acct_, Account const& regularSig)
77 : acct(acct_), sig(regularSig)
78 {
79 }
80
81 Reg(char const* masterSig) : acct(masterSig), sig(masterSig)
82 {
83 }
84
85 Reg(char const* acct_, char const* regularSig)
86 : acct(acct_), sig(regularSig)
87 {
88 }
89
90 bool
91 operator<(Reg const& rhs) const
92 {
93 return acct < rhs.acct;
94 }
95 };
96
98
99public:
100 msig(std::vector<Reg> signers_);
101
102 template <class AccountType, class... Accounts>
103 requires std::convertible_to<AccountType, Reg>
104 explicit msig(AccountType&& a0, Accounts&&... aN)
105 : msig{std::vector<Reg>{
106 std::forward<AccountType>(a0),
107 std::forward<Accounts>(aN)...}}
108 {
109 }
110
111 void
112 operator()(Env&, JTx& jt) const;
113};
114
115//------------------------------------------------------------------------------
116
119
120} // namespace jtx
121} // namespace test
122} // namespace ripple
123
124#endif
Represents a JSON value.
Definition: json_value.h:147
Immutable cryptographic account descriptor.
Definition: Account.h:38
Set a multisignature on a JTx.
Definition: multisign.h:65
msig(AccountType &&a0, Accounts &&... aN)
Definition: multisign.h:104
std::vector< Reg > signers
Definition: multisign.h:97
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:35
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
STL namespace.
Reg(char const *acct_, char const *regularSig)
Definition: multisign.h:85
Reg(char const *masterSig)
Definition: multisign.h:81
bool operator<(Reg const &rhs) const
Definition: multisign.h:91
Reg(Account const &acct_, Account const &regularSig)
Definition: multisign.h:76
Reg(Account const &masterSig)
Definition: multisign.h:72
A signer in a SignerList.
Definition: multisign.h:37
std::optional< uint256 > tag
Definition: multisign.h:40
signer(Account account_, std::uint32_t weight_=1, std::optional< uint256 > tag_=std::nullopt)
Definition: multisign.h:42
std::uint32_t weight
Definition: multisign.h:38