3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/utility/instrumentation.h>
5#include <xrpl/protocol/PublicKey.h>
6#include <xrpl/protocol/STObject.h>
7#include <xrpl/protocol/SecretKey.h>
8#include <xrpl/protocol/Units.h>
55 template <
class LookupNodeID>
140template <
class LookupNodeID>
142 :
STObject(validationFormat(), sit, sfValidation)
143 , signingPubKey_([this]() {
147 Throw<std::runtime_error>(
"Invalid public key in validation");
151 , nodeID_(lookupNodeID(signingPubKey_))
153 if (checkSignature && !isValid())
156 Throw<std::runtime_error>(
"Invalid signature in validation");
159 XRPL_ASSERT(nodeID_.isNonZero(),
"xrpl::STValidation::STValidation(SerialIter) : nonzero node");
177 :
STObject(validationFormat(), sfValidation), signingPubKey_(pk), nodeID_(nodeID), seenTime_(signTime)
181 "xrpl::STValidation::STValidation(PublicKey, SecretKey) : nonzero "
186 LogicError(
"We can only use secp256k1 keys for signing validations");
203 LogicError(
"Required field '" + e.sField().getName() +
"' 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
void setFieldVL(SField const &field, Blob const &)
void setFieldU32(SField const &field, std::uint32_t)
bool isFieldPresent(SField const &field) const
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
STValidation(SerialIter &sit, LookupNodeID &&lookupNodeID, bool checkSignature)
Construct a STValidation from a peer from serialized data.
PublicKey const signingPubKey_
PublicKey const & getSignerPublic() const noexcept
uint256 getSigningHash() const
Blob getSerialized() const
bool isTrusted() const noexcept
NetClock::time_point seenTime_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
beast::Journal debugLog()
Returns a debug journal.
std::string to_string(base_uint< Bits, Tag > const &a)
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.
Buffer signDigest(PublicKey const &pk, SecretKey const &sk, uint256 const &digest)
Generate a signature for a message digest.
constexpr std::uint32_t vfFullValidation
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)
constexpr std::uint32_t vfFullyCanonicalSig
T time_since_epoch(T... args)