3#include <xrpl/basics/Blob.h>
4#include <xrpl/basics/CountedObject.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/basics/Slice.h>
7#include <xrpl/basics/base_uint.h>
8#include <xrpl/basics/chrono.h>
9#include <xrpl/basics/contract.h>
10#include <xrpl/beast/utility/instrumentation.h>
11#include <xrpl/protocol/KeyType.h>
12#include <xrpl/protocol/PublicKey.h>
13#include <xrpl/protocol/SField.h>
14#include <xrpl/protocol/SOTemplate.h>
15#include <xrpl/protocol/STBase.h>
16#include <xrpl/protocol/STObject.h>
17#include <xrpl/protocol/SecretKey.h>
18#include <xrpl/protocol/Serializer.h>
19#include <xrpl/protocol/UintTypes.h>
20#include <xrpl/protocol/tokens.h>
87 template <
class LookupNodeID>
124 [[nodiscard]]
NodeID const&
154 [[nodiscard]]
std::
string
181template <
class LookupNodeID>
192 , nodeID_(lookupNodeID(signingPubKey_))
194 if (options.checkSignature && !isValid())
196 JLOG(
debugLog().error()) <<
"Invalid signature in validation: "
201 XRPL_ASSERT(nodeID_.isNonZero(),
"xrpl::STValidation::STValidation(SerialIter) : nonzero node");
227 "xrpl::STValidation::STValidation(PublicKey, SecretKey) : nonzero "
232 logicError(
"We can only use secp256k1 keys for signing validations");
249 logicError(
"Required field '" + e.sField().getName() +
"' missing from validation.");
std::chrono::time_point< NetClock > time_point
Slice slice() const noexcept
Defines the fields and their attributes within a STObject.
A type which can be exported to a well known binary format.
Blob getFieldVL(SField const &field) const
void setFieldVL(SField const &field, Blob const &)
void setFieldU32(SField const &field, std::uint32_t)
bool isFieldPresent(SField const &field) const
STObject(STObject const &)=default
bool setFlag(std::uint32_t)
NetClock::time_point getSignTime() const
static SOTemplate const & validationFormat()
STBase * move(std::size_t n, void *buf) override
Blob getSignature() const
NetClock::time_point getSeenTime() const noexcept
std::optional< bool > valid_
void setSeen(NetClock::time_point s)
uint256 getConsensusHash() const
STBase * copy(std::size_t n, void *buf) const override
std::string render() const
NodeID const & getNodeID() const noexcept
bool isValid() const noexcept
bool isFull() const noexcept
uint256 getLedgerHash() const
PublicKey const signingPubKey_
PublicKey const & getSignerPublic() const noexcept
uint256 getSigningHash() const
Blob getSerialized() const
STValidation(SerialIter &sit, LookupNodeID &&lookupNodeID, DeserializeOptions options)
Construct a STValidation from a peer from serialized data.
bool isTrusted() const noexcept
NetClock::time_point seenTime_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
beast::Journal debugLog()
Returns a debug journal.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::string to_string(BaseUInt< Bits, Tag > const &a)
void logicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
Slice makeSlice(std::array< T, N > const &a)
json::Value getJson(LedgerFill const &fill)
Return a new json::Value representing the ledger with given options.
Buffer signDigest(PublicKey const &pk, SecretKey const &sk, uint256 const &digest)
Generate a signature for a message digest.
constexpr std::uint32_t kVfFullValidation
constexpr std::uint32_t kVfFullyCanonicalSig
std::vector< unsigned char > Blob
Storage for linear binary data.
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
BaseUInt< 160, detail::NodeIDTag > NodeID
NodeID is a 160-bit hash representing one node.
Options controlling deserialization of a STValidation.
bool checkSignature
Whether to verify the data was signed properly.
bool requireCanonicalOrder
Whether to require the fields to be in canonical order.
T time_since_epoch(T... args)