20#ifndef RIPPLE_PROTOCOL_STVALIDATION_H_INCLUDED
21#define RIPPLE_PROTOCOL_STVALIDATION_H_INCLUDED
23#include <xrpl/basics/Log.h>
24#include <xrpl/beast/utility/instrumentation.h>
25#include <xrpl/protocol/FeeUnits.h>
26#include <xrpl/protocol/PublicKey.h>
27#include <xrpl/protocol/STObject.h>
28#include <xrpl/protocol/SecretKey.h>
76 template <
class LookupNodeID>
79 LookupNodeID&& lookupNodeID,
174template <
class LookupNodeID>
177 LookupNodeID&& lookupNodeID,
179 :
STObject(validationFormat(), sit, sfValidation)
180 , signingPubKey_([this]() {
184 Throw<std::runtime_error>(
"Invalid public key in validation");
188 , nodeID_(lookupNodeID(signingPubKey_))
190 if (checkSignature && !isValid())
192 JLOG(
debugLog().error()) <<
"Invalid signature in validation: "
194 Throw<std::runtime_error>(
"Invalid signature in validation");
199 "ripple::STValidation::STValidation(SerialIter) : nonzero node");
217 :
STObject(validationFormat(), sfValidation)
220 , seenTime_(signTime)
224 "ripple::STValidation::STValidation(PublicKey, SecretKey) : nonzero "
229 LogicError(
"We can only use secp256k1 keys for signing validations");
247 "Required field '" + e.sField().getName() +
248 "' missing from validation.");
Tracks the number of instances of an object.
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
bool setFlag(std::uint32_t)
bool isFieldPresent(SField const &field) const
void setFieldU32(SField const &field, std::uint32_t)
void setFieldVL(SField const &field, Blob const &)
PublicKey const & getSignerPublic() const noexcept
uint256 getConsensusHash() const
std::string render() const
std::optional< bool > valid_
STValidation(SerialIter &sit, LookupNodeID &&lookupNodeID, bool checkSignature)
Construct a STValidation from a peer from serialized data.
Blob getSerialized() const
NetClock::time_point getSeenTime() const noexcept
void setSeen(NetClock::time_point s)
bool isTrusted() const noexcept
PublicKey const signingPubKey_
static SOTemplate const & validationFormat()
NodeID const & getNodeID() const noexcept
bool isFull() const noexcept
NetClock::time_point seenTime_
STBase * copy(std::size_t n, void *buf) const override
uint256 getLedgerHash() const
bool isValid() const noexcept
uint256 getSigningHash() const
Blob getSignature() const
STBase * move(std::size_t n, void *buf) override
NetClock::time_point getSignTime() const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
beast::Journal debugLog()
Returns a debug journal.
Buffer signDigest(PublicKey const &pk, SecretKey const &sk, uint256 const &digest)
Generate a signature for a message digest.
constexpr std::uint32_t vfFullyCanonicalSig
std::string to_string(base_uint< Bits, Tag > const &a)
constexpr std::uint32_t vfFullValidation
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
T time_since_epoch(T... args)