xrpld
Loading...
Searching...
No Matches
Wallet.h
1#pragma once
2
3#include <xrpl/basics/UnorderedContainers.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/hash/uhash.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/core/PeerReservationTable.h>
8#include <xrpl/protocol/PublicKey.h>
9#include <xrpl/protocol/SecretKey.h>
10#include <xrpl/rdb/DatabaseCon.h>
11#include <xrpl/server/Manifest.h>
12
13// boost::optional (not std::optional) appears in the declarations below,
14// because SOCI's into()/use() bindings only support boost::optional.
15#include <boost/optional/optional.hpp>
16
17#include <functional>
18#include <memory>
19#include <string>
20#include <unordered_set>
21#include <utility>
22
23namespace xrpl {
24
31std::unique_ptr<DatabaseCon>
32makeWalletDB(DatabaseCon::Setup const& setup, beast::Journal j);
33
41std::unique_ptr<DatabaseCon>
42makeTestWalletDB(DatabaseCon::Setup const& setup, std::string const& dbname, beast::Journal j);
43
53void
55 soci::session& session,
56 std::string const& dbTable,
57 ManifestCache& cache,
58 beast::Journal j);
59
68void
70 soci::session& session,
71 std::string const& dbTable,
72 std::function<bool(PublicKey const&)> const& isTrusted,
74 beast::Journal j);
75
82void
83addValidatorManifest(soci::session& session, std::string const& serialized);
84
88void
89clearNodeIdentity(soci::session& session);
90
102std::pair<PublicKey, SecretKey>
103getNodeIdentity(soci::session& session);
104
111std::unordered_set<PeerReservation, beast::Uhash<>, KeyEqual>
112getPeerReservationTable(soci::session& session, beast::Journal j);
113
120void
122 soci::session& session,
123 PublicKey const& nodeId,
124 std::string const& description);
125
132void
133deletePeerReservation(soci::session& session, PublicKey const& nodeId);
134
140bool
141createFeatureVotes(soci::session& session);
142
143// For historical reasons the up-vote and down-vote integer representations
144// are unintuitive.
145enum class AmendmentVote : int { Obsolete = -1, Up = 0, Down = 1 };
146
153void
155 soci::session& session,
156 std::function<void(
157 boost::optional<std::string> amendmentHash,
158 boost::optional<std::string> amendmentName,
159 boost::optional<AmendmentVote> vote)> const& callback);
160
168void
170 soci::session& session,
171 uint256 const& amendment,
172 std::string const& name,
173 AmendmentVote vote);
174
175} // namespace xrpl
Remembers manifests with the highest sequence number.
Definition Manifest.h:374
A public key.
Definition PublicKey.h:53
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
void saveManifests(soci::session &session, std::string const &dbTable, std::function< bool(PublicKey const &)> const &isTrusted, hash_map< PublicKey, Manifest > const &map, beast::Journal j)
saveManifests Saves all given manifests to the database.
Definition Wallet.cpp:104
void deletePeerReservation(soci::session &session, PublicKey const &nodeId)
deletePeerReservation Deletes an entry from the peer reservation table.
Definition Wallet.cpp:234
std::pair< PublicKey, SecretKey > getNodeIdentity(soci::session &session)
Returns a stable public and private key for this node.
Definition Wallet.cpp:151
void insertPeerReservation(soci::session &session, PublicKey const &nodeId, std::string const &description)
insertPeerReservation Adds an entry to the peer reservation table.
Definition Wallet.cpp:220
void readAmendments(soci::session &session, std::function< void(boost::optional< std::string > amendmentHash, boost::optional< std::string > amendmentName, boost::optional< AmendmentVote > vote)> const &callback)
readAmendments Reads all amendments from the FeatureVotes table.
Definition Wallet.cpp:265
std::unordered_set< PeerReservation, beast::Uhash<>, KeyEqual > getPeerReservationTable(soci::session &session, beast::Journal j)
getPeerReservationTable Returns the peer reservation table.
Definition Wallet.cpp:185
void addValidatorManifest(soci::session &session, std::string const &serialized)
addValidatorManifest Saves the manifest of a validator to the database.
Definition Wallet.cpp:137
std::unique_ptr< DatabaseCon > makeWalletDB(DatabaseCon::Setup const &setup, beast::Journal j)
makeWalletDB Opens the wallet database and returns it.
Definition Wallet.cpp:42
bool createFeatureVotes(soci::session &session)
createFeatureVotes Creates the FeatureVote table if it does not exist.
Definition Wallet.cpp:241
AmendmentVote
Definition Wallet.h:145
std::unordered_map< Key, Value, Hash, Pred, Allocator > hash_map
void clearNodeIdentity(soci::session &session)
Delete any saved public/private key associated with this node.
Definition Wallet.cpp:145
void getManifests(soci::session &session, std::string const &dbTable, ManifestCache &cache, beast::Journal j)
getManifests Loads a manifest from the wallet database and stores it in the cache.
Definition Wallet.cpp:58
std::unique_ptr< DatabaseCon > makeTestWalletDB(DatabaseCon::Setup const &setup, std::string const &dbname, beast::Journal j)
makeTestWalletDB Opens a test wallet database with an arbitrary name.
Definition Wallet.cpp:50
void voteAmendment(soci::session &session, uint256 const &amendment, std::string const &name, AmendmentVote vote)
voteAmendment Set the veto value for a particular amendment.
Definition Wallet.cpp:300
BaseUInt< 256 > uint256
Definition base_uint.h:580