rippled
SignerEntries.cpp
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 #include <ripple/app/tx/impl/SignerEntries.h>
21 #include <ripple/basics/Log.h>
22 #include <ripple/protocol/STObject.h>
23 #include <ripple/protocol/STArray.h>
24 #include <cstdint>
25 
26 namespace ripple {
27 
30  STObject const& obj, beast::Journal journal, std::string const& annotation)
31 {
33 
35  {
36  JLOG(journal.trace()) <<
37  "Malformed " << annotation << ": Need signer entry array.";
38  s.second = temMALFORMED;
39  return s;
40  }
41 
42  auto& accountVec = s.first;
43  accountVec.reserve (STTx::maxMultiSigners);
44 
45  STArray const& sEntries (obj.getFieldArray (sfSignerEntries));
46  for (STObject const& sEntry : sEntries)
47  {
48  // Validate the SignerEntry.
49  if (sEntry.getFName () != sfSignerEntry)
50  {
51  JLOG(journal.trace()) <<
52  "Malformed " << annotation << ": Expected SignerEntry.";
53  s.second = temMALFORMED;
54  return s;
55  }
56 
57  // Extract SignerEntry fields.
58  AccountID const account = sEntry.getAccountID (sfAccount);
59  std::uint16_t const weight = sEntry.getFieldU16 (sfSignerWeight);
60  accountVec.emplace_back (account, weight);
61  }
62 
63  s.second = tesSUCCESS;
64  return s;
65 }
66 
67 } // ripple
ripple::STObject::getFieldArray
const STArray & getFieldArray(SField const &field) const
Definition: STObject.cpp:567
std::string
STL class.
beast::Journal::trace
Stream trace() const
Severity stream access functions.
Definition: Journal.h:287
std::pair
ripple::sfAccount
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
Definition: SField.h:460
ripple::sfSignerEntries
const SField sfSignerEntries(access, STI_ARRAY, 4, "SignerEntries")
Definition: SField.h:496
ripple::base_uint< 160, detail::AccountIDTag >
ripple::TERSubset
Definition: TER.h:311
ripple::STArray
Definition: STArray.h:28
cstdint
ripple::sfSignerEntry
const SField sfSignerEntry(access, STI_OBJECT, 11, "SignerEntry")
Definition: SField.h:488
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:60
std::uint16_t
ripple::STObject
Definition: STObject.h:51
ripple::sfSignerWeight
const SF_U16 sfSignerWeight(access, STI_UINT16, 3, "SignerWeight")
Definition: SField.h:332
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::STTx::maxMultiSigners
static const std::size_t maxMultiSigners
Definition: STTx.h:51
ripple::STObject::isFieldPresent
bool isFieldPresent(SField const &field) const
Definition: STObject.cpp:392
ripple::SignerEntries::deserialize
static std::pair< std::vector< SignerEntry >, NotTEC > deserialize(STObject const &obj, beast::Journal journal, std::string const &annotation)
Definition: SignerEntries.cpp:29
ripple::temMALFORMED
@ temMALFORMED
Definition: TER.h:85
ripple::tesSUCCESS
@ tesSUCCESS
Definition: TER.h:219
ripple::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition: TER.h:461