5 #include <fc/io/raw.hpp>
6 #include <fc/bitutil.hpp>
7 #include <fc/smart_ref_impl.hpp>
16 digest_type::encoder enc;
17 fc::raw::pack(enc, *
this);
23 digest_type::encoder enc;
24 fc::raw::pack(enc, *
this);
30 digest_type::encoder enc;
31 fc::raw::pack(enc, chain_id);
32 fc::raw::pack(enc, *
this);
38 FC_ASSERT(
operations.size() > 0,
"A transaction must have at least one operation", (
"trx", *
this));
47 memcpy(
result._hash, h._hash, std::min(
sizeof(
result),
sizeof(h)));
55 signatures.push_back(key.sign_compact(h));
56 return signatures.back();
62 digest_type::encoder enc;
63 fc::raw::pack(enc, chain_id);
64 fc::raw::pack(enc, *
this);
65 return key.sign_compact(enc.result());
75 ref_block_num = fc::endian_reverse_u32(reference_block._hash[0]);
80 flat_set<account_name_type>&
owner,
81 flat_set<account_name_type>&
posting,
82 std::vector<authority>& other)
const
89 const flat_set<public_key_type>& sigs,
93 uint32_t max_recursion_depth,
95 const flat_set<account_name_type>& active_aprovals,
96 const flat_set<account_name_type>& owner_approvals,
97 const flat_set<account_name_type>& posting_approvals)
101 flat_set<account_name_type> required_active;
102 flat_set<account_name_type> required_owner;
103 flat_set<account_name_type> required_posting;
104 std::vector<authority> other;
106 for (
const auto& op : ops)
107 operation_get_required_authorities(op, required_active, required_owner, required_posting, other);
115 if (required_posting.size())
117 FC_ASSERT(required_active.size() == 0);
118 FC_ASSERT(required_owner.size() == 0);
119 FC_ASSERT(other.size() == 0);
121 flat_set<public_key_type> avail;
124 for (
auto&
id : posting_approvals)
126 for (
auto id : required_posting)
130 tx_missing_posting_auth,
"Missing Posting Authority ${id}",
131 (
"id",
id)(
"posting", get_posting(
id))(
"active", get_active(
id))(
"owner", get_owner(
id)));
137 flat_set<public_key_type> avail;
140 for (
auto&
id : active_aprovals)
142 for (
auto&
id : owner_approvals)
145 for (
const auto& auth : other)
148 (
"auth", auth)(
"sigs", sigs));
152 for (
auto id : required_active)
155 "Missing Active Authority ${id}", (
"id",
id)(
"auth", get_active(
id))(
"owner", get_owner(
id)));
158 for (
auto id : required_owner)
161 tx_missing_owner_auth,
"Missing Owner Authority ${id}", (
"id",
id)(
"auth", get_owner(
id)));
166 FC_CAPTURE_AND_RETHROW((ops)(sigs))
174 flat_set<public_key_type>
result;
178 "Duplicate Signature detected");
182 FC_CAPTURE_AND_RETHROW()
186 const flat_set<public_key_type>& available_keys,
190 uint32_t max_recursion_depth)
const
192 flat_set<account_name_type> required_active;
193 flat_set<account_name_type> required_owner;
194 flat_set<account_name_type> required_posting;
195 std::vector<authority> other;
199 if (required_posting.size())
204 FC_ASSERT(!required_owner.size());
205 FC_ASSERT(!required_active.size());
206 for (
auto&
posting : required_posting)
211 std::set<public_key_type>
result;
214 if (available_keys.find(provided_sig.first) != available_keys.end())
215 result.insert(provided_sig.first);
223 for (
const auto& auth : other)
225 for (
auto&
owner : required_owner)
227 for (
auto&
active : required_active)
232 std::set<public_key_type>
result;
235 if (available_keys.find(provided_sig.first) != available_keys.end())
236 result.insert(provided_sig.first);
241 std::set<public_key_type>
243 const flat_set<public_key_type>& available_keys,
247 uint32_t max_recursion)
const
249 std::set<public_key_type> s
251 flat_set<public_key_type>
result(s.begin(), s.end());
261 catch (
const tx_missing_owner_auth& e)
264 catch (
const tx_missing_active_auth& e)
267 catch (
const tx_missing_posting_auth& e)
270 catch (
const tx_missing_other_auth& e)
275 return std::set<public_key_type>(
result.begin(),
result.end());
282 uint32_t max_recursion)
const
289 FC_CAPTURE_AND_RETHROW((*
this))
#define SCORUM_ASSERT(expr, exc_type, FORMAT,...)
fc::ecc::private_key private_key_type
fc::ripemd160 transaction_id_type
void verify_authority(const std::vector< operation > &ops, const flat_set< public_key_type > &sigs, const authority_getter &get_active, const authority_getter &get_owner, const authority_getter &get_posting, uint32_t max_recursion=SCORUM_MAX_SIG_CHECK_DEPTH, bool allow_committe=false, const flat_set< account_name_type > &active_aprovals=flat_set< account_name_type >(), const flat_set< account_name_type > &owner_aprovals=flat_set< account_name_type >(), const flat_set< account_name_type > &posting_approvals=flat_set< account_name_type >())
fc::ripemd160 block_id_type
std::function< authority(const std::string &)> authority_getter
void operation_validate(const proposal_operation &op)
fc::ecc::compact_signature signature_type
bool check_authority(const std::string &id)
flat_set< std::string > approved_by
bool remove_unused_signatures()
flat_map< public_key_type, bool > provided_signatures
const signature_type & sign(const private_key_type &key, const chain_id_type &chain_id)
flat_set< public_key_type > get_signature_keys(const chain_id_type &chain_id) const
void verify_authority(const chain_id_type &chain_id, const authority_getter &get_active, const authority_getter &get_owner, const authority_getter &get_posting, uint32_t max_recursion=SCORUM_MAX_SIG_CHECK_DEPTH) const
std::set< public_key_type > get_required_signatures(const chain_id_type &chain_id, const flat_set< public_key_type > &available_keys, const authority_getter &get_active, const authority_getter &get_owner, const authority_getter &get_posting, uint32_t max_recursion=SCORUM_MAX_SIG_CHECK_DEPTH) const
digest_type merkle_digest() const
std::set< public_key_type > minimize_required_signatures(const chain_id_type &chain_id, const flat_set< public_key_type > &available_keys, const authority_getter &get_active, const authority_getter &get_owner, const authority_getter &get_posting, uint32_t max_recursion=SCORUM_MAX_SIG_CHECK_DEPTH) const
std::vector< signature_type > signatures
transaction_id_type id() const
std::vector< operation > operations
fc::time_point_sec expiration
void get_required_authorities(flat_set< account_name_type > &active, flat_set< account_name_type > &owner, flat_set< account_name_type > &posting, std::vector< authority > &other) const
void set_reference_block(const block_id_type &reference_block)
digest_type sig_digest(const chain_id_type &chain_id) const
digest_type digest() const
void set_expiration(fc::time_point_sec expiration_time)
uint32_t ref_block_prefix