22#ifndef DEFAULT_MAX_ACCOUNT_DEPTH
23#define DEFAULT_MAX_ACCOUNT_DEPTH 10
31#ifndef DEFAULT_MAX_INDEX_DEPTH
32#define DEFAULT_MAX_INDEX_DEPTH 100
35#define OUTPUT_EXPORT_FILE_MAGIC "Monero output export\004"
106 class PolyseedKeyStore;
107 class WipeableString;
145 [[nodiscard]]
const std::string&
name()
const;
151 [[nodiscard]]
const std::string&
englishName()
const;
157 [[nodiscard]]
const std::string&
code()
const;
205 operator const std::string&()
const;
236 static const std::vector<std::reference_wrapper<const SeedLanguage>>
list();
243 static const std::vector<std::reference_wrapper<const SeedLanguage>>
listFor(
SeedType type);
261 static std::vector<SeedLanguage> s_list;
262 static std::map<SeedType, std::reference_wrapper<const SeedLanguage>> s_default;
265 std::string m_englishName;
266 std::map<SeedType, bool> m_supported;
267 std::map<SeedType, int> m_index;
304 virtual const std::string&
fingerprint() const noexcept;
324 virtual const uint64_t
timestamp() const noexcept;
334 virtual const uint64_t
height() const noexcept;
351 virtual std::shared_ptr<Wallet>
wallet() noexcept;
370 const std::vector<uint16_t>& values1,
371 const std::vector<uint16_t>& values2
383 static std::vector<uint16_t>
mergeValues(const std::vector<std::vector<uint16_t>>& values);
396 std::vector<uint16_t>& values1,
397 std::vector<uint16_t>& values2,
412 std::vector<std::vector<uint16_t>>& values,
424 const std::
string& password,
425 const std::vector<uint16_t>& values
437 std::
string& password,
438 std::vector<uint16_t>& values,
451 const std::vector<uint16_t>& values
463 std::vector<uint16_t>& values,
508 const std::string&
phrase,
538 const std::vector<uint16_t>& values,
546 std::unique_ptr<KeyStore, KeyStoreDeleter>
m_seed;
583 const SeedIndices indices(
const std::string& passphrase =
"")
const override;
600 const std::string& phrase,
603 Network network = Network::MAIN,
604 const std::string& passphrase =
""
621 Network network = Network::MAIN,
622 const std::string& passphrase =
""
636 const std::vector<uint16_t>& values,
639 Network network = Network::MAIN,
640 const std::string& password =
""
656 const std::array<unsigned char, 32>& random,
659 const Network network = Network::MAIN
676 const Network network = Network::MAIN
709 const SeedIndices indices(
const std::string& password =
"")
const override;
726 const std::array<unsigned char, 19>& random,
727 Network network = Network::MAIN,
729 const std::string& passphrase =
""
741 const std::array<unsigned char, 32>& random,
742 Network network = Network::MAIN,
744 const std::string& passphrase =
""
755 Network network = Network::MAIN,
757 const std::string& passphrase =
""
773 const std::string& phrase,
774 const Network network = Network::MAIN,
775 const std::string& password =
"",
776 const std::string& passphrase =
""
791 const std::string& phrase,
793 const Network network = Network::MAIN,
794 const std::string& password =
"",
795 const std::string& passphrase =
""
812 const Network network = Network::MAIN,
813 const std::string& password =
"",
814 const std::string& passphrase =
""
830 const std::vector<uint16_t>& values,
831 const Network network = Network::MAIN,
832 const std::string& password =
"",
833 const std::string& passphrase =
""
837 std::unique_ptr<PolyseedKeyStore, PolyseedKeyStoreDeleter>
m_seed;
855 explicit Address(
const std::string& address);
861 [[nodiscard]]
const Network network()
const noexcept;
867 [[nodiscard]]
const AddressType type()
const noexcept;
874 virtual const std::string& fingerprint()
const noexcept;
881 bool isIntegrated()
const noexcept;
887 std::string paymentID()
const noexcept;
894 Address integratedAddress()
const;
900 [[nodiscard]]
const size_t length()
const noexcept;
906 explicit operator std::string()
const noexcept;
912 operator const std::string&()
const noexcept;
918 operator const uint8_t*()
const noexcept;
924 bool operator==(
const Address& other)
const noexcept;
930 bool operator==(
const std::string& other)
const noexcept;
938 [[nodiscard]]
static bool isValid(
const std::string& address,
const Network network = Network::MAIN)
noexcept;
947 [[nodiscard]]
static Network network(
const std::string& address);
955 [[nodiscard]]
static AddressType type(
const std::string& address);
963 [[nodiscard]]
static std::string fingerprint(
const std::string& address);
971 [[nodiscard]]
static bool isIntegrated(
const std::string& address);
980 [[nodiscard]]
static std::string paymentID(
const std::string& address,
Network network = Network::MAIN);
990 [[nodiscard]]
static std::string integratedAddress(
const std::string& address,
Network network = Network::MAIN);
1012 static const std::string version()
noexcept;
1017 static std::array<int, 3> versionComponents()
noexcept;
1027 static uint64_t heightFromTimestamp(uint64_t timestamp,
Network network = Network::MAIN);
1035 static uint64_t timestampFromHeight(uint64_t height,
Network network = Network::MAIN);
1042 static std::array<unsigned char, 32> random();
1050 static void random(
size_t size, uint8_t *bytes);
1059 static bool lowEntropy(
size_t size,
const uint8_t* data,
double minEntropy = 3.5)
noexcept;
1065 static void enforceEntropy(
bool enforce =
true)
noexcept;
1072 static void setMaxAccountDepth(uint32_t depth)
noexcept;
1080 static void setMaxIndexDepth(uint32_t depth)
noexcept;
1090 static void setMaxDepth(uint32_t account, uint32_t index)
noexcept;
1095 static void resetMaxDepth()
noexcept;
1105 static uint32_t maxAccountDepth(uint32_t depth = 0)
noexcept;
1115 static uint32_t maxIndexDepth(uint32_t depth = 0)
noexcept;
1133 static bool verifyData(
1134 const std::string& data,
1135 const std::string& address,
1136 const std::string& signature,
1137 bool legacyFallback =
false
1148 static void ensureEntropy(
size_t size,
const uint8_t* data,
double minEntropy = 3.5);
1151 static bool sEnforceEntropy;
1152 static uint32_t sMaxAccountDepth;
1153 static uint32_t sMaxIndexDepth;
1187 const Seed&
get(
const std::string& fingerprint)
const;
1190 bool has(const std::
string& fingerprint) const;
1191 std::vector<std::reference_wrapper<const
Seed>> list() const noexcept;
1210 uint64_t
height() const noexcept {
return m_height; };
1218 Address address(uint32_t account = 0, uint32_t index = 0) const noexcept;
1227 std::vector<
Address> accounts(uint32_t max = 10, uint32_t offset = 0) const noexcept;
1236 std::vector<
Address> subAddresses(uint32_t account = 0, uint32_t max = 10, uint32_t offset = 0) const noexcept;
1243 bool hasAddress(const std::
string& address, uint32_t maxAccountDepth = 0, uint32_t maxIndexDepth = 0) const noexcept;
1250 bool hasAddress(const
Address& address, uint32_t maxAccountDepth = 0, uint32_t maxIndexDepth = 0) const noexcept;
1259 std::pair<uint32_t, uint32_t> addressIndex(const std::
string& address, uint32_t maxAccountDepth = 0, uint32_t maxIndexDepth = 0) const;
1268 std::pair<uint32_t, uint32_t> addressIndex(const
Address& address, uint32_t maxAccountDepth = 0, uint32_t maxIndexDepth = 0) const;
1300 uint64_t importOutputs(const std::
string& outputs);
1316 TxDescription describeTransaction(const std::
string& unsignedTransaction) const;
1324 std::vector<
TxWarning> checkTransaction(const std::
string& unsignedTransaction) const;
1339 std::
string signTransaction(const std::
string& unsignedTransaction) const;
1346 std::
string signData(const std::
string& data) const noexcept;
1355 std::
string signData(const std::
string& data, const std::pair<uint32_t, uint32_t>& index) const;
1365 std::
string signData(const std::
string& data, const
Address& address) const;
1375 std::
string signData(const std::
string& data, const std::
string& address) const;
1385 static
bool verifyData(
1386 const std::
string& data,
1387 const std::
string& address,
1388 const std::
string& signature,
1389 bool legacyFallback = false
1401 static
bool verifyData(
1402 const std::
string& data,
1404 const std::
string& signature,
1405 bool legacyFallback = false
1418 const std::
string& data,
1419 const std::pair<uint32_t, uint32_t>& index,
1420 const std::
string& signature,
1421 bool legacyFallback = false
1433 const std::
string& data,
1434 const std::
string& signature,
1435 bool legacyFallback = false
1444 Wallet(const std::array<
unsigned char, 32>& key, uint64_t height, const
Network network) noexcept;
1469 uint64_t m_height = 0;
1533 std::string insecure() const noexcept;
1536 const
char* c_str() const noexcept;
1539 const
char* data() const noexcept;
1542 size_t size() const noexcept;
1545 bool empty() const noexcept;
1548 void clear() noexcept;
1551 size_t capacity() const noexcept;
1554 void reserve(
size_t n);
1557 WipeableString substr(
size_t pos = 0,
size_t len = std::
string::npos) const;
1560 size_t find(const
WipeableString& str,
size_t pos = 0) const noexcept;
1563 size_t find(const
char* s,
size_t pos = 0) const noexcept;
1590 operator std::
string() const;
1596 friend std::ostream& operator<<(std::ostream& os, const
WipeableString& str);
1599 static constexpr
size_t npos = std::
string::npos;
1606 void wipe() noexcept;
1619 inline explicit
SeedIndices(const std::vector<uint16_t>& v): m_vec(v) {};
1640 operator const uint8_t*()
const noexcept;
1643 operator const char*()
const noexcept;
1646 operator const std::vector<uint16_t>&()
const noexcept;
1649 operator const std::string() const noexcept;
1652 bool operator==(const
SeedIndices& other) const noexcept;
1655 bool operator==(const std::vector<uint16_t>& other) const noexcept;
1658 bool operator!=(const
SeedIndices& other) const noexcept;
1661 bool operator!=(const std::vector<uint16_t>& other) const noexcept;
1667 const std::
string numeric(const std::
string& separator = "") const noexcept;
1673 const std::
string hex(const std::
string& separator = "") const noexcept;
1679 size_t size() const noexcept;
1682 bool empty() const noexcept;
1685 void clear() noexcept;
1688 inline
void reserve(
size_t n) { m_vec.
reserve(n); };
1694 uint16_t& operator[](
size_t pos);
1695 const uint16_t& operator[](
size_t pos)
const;
1696 uint16_t& at(
size_t pos);
1697 const uint16_t& at(
size_t pos)
const;
1700 void push_back(uint16_t value);
1703 uint16_t emplace_back(uint16_t value);
1706 auto begin() noexcept {
return m_vec.begin(); }
1709 auto end() noexcept {
return m_vec.end(); }
1712 auto begin() const noexcept {
return m_vec.begin(); }
1715 auto end() const noexcept {
return m_vec.end(); }
1718 auto cbegin() const noexcept {
return m_vec.cbegin(); }
1721 auto cend() const noexcept {
return m_vec.cend(); }
1728 static SeedIndices fromNumeric(
const std::string& numeric,
const std::string& separator =
"");
1734 static SeedIndices fromHex(
const std::string& hex,
const std::string& separator =
"");
1737 std::vector<uint16_t> m_vec;
1740 void wipe() noexcept;
holds monero internal account and internal functions
Definition account.hpp:40
Represents a Monero address.
Definition ots.hpp:848
std::string m_fingerprint
Definition ots.hpp:998
Network m_network
Definition ots.hpp:996
AddressType m_type
Definition ots.hpp:997
std::string m_address
Definition ots.hpp:995
static Address validAddress(const std::string &address)
essentialy wraps crypto::secret_key
Definition key-store.hpp:18
Represents a monero 13-words seed type for backward compatibility.
Definition ots.hpp:482
std::unique_ptr< KeyStore, KeyStoreDeleter > m_seed
Definition ots.hpp:546
Represents a Monero 25-words seed.
Definition ots.hpp:558
General functionality.
Definition ots.hpp:1005
Extends KeyStore with specific functionality for polyseed-based cryptographic operations.
Definition polyseed-key-store.hpp:19
Represents a Polyseed type.
Definition ots.hpp:706
std::unique_ptr< PolyseedKeyStore, PolyseedKeyStoreDeleter > m_seed
Definition ots.hpp:837
Secure container for seed word indices.
Definition ots.hpp:1613
SeedIndices() noexcept=default
Default constructor.
void reserve(size_t n)
Reserve elements.
Definition ots.hpp:1688
auto begin() noexcept
Iterator support.
Definition ots.hpp:1706
auto cbegin() const noexcept
Iterator support.
Definition ots.hpp:1718
auto end() noexcept
Iterator support.
Definition ots.hpp:1709
SeedIndices(const SeedIndices &other)
Copy constructor.
Definition ots.hpp:1628
auto end() const noexcept
Iterator support.
Definition ots.hpp:1715
auto begin() const noexcept
Iterator support.
Definition ots.hpp:1712
void shrink_to_fit()
shrink to fit
Definition ots.hpp:1691
auto cend() const noexcept
Iterator support.
Definition ots.hpp:1721
SeedIndices(size_t size)
Construct with size.
Definition ots.hpp:1622
SeedIndices(SeedIndices &&other) noexcept
Move constructor.
Definition ots.hpp:1631
SeedIndices(size_t size, uint16_t value)
Construct with size and value.
Definition ots.hpp:1625
Storage for the Seed objects, mainly for the purpose of the C ABI.
Definition ots.hpp:1161
const Seed & get(seed_handle_t handle) const
retrieve a Seed object via a handle
uint32_t count() const noexcept
seed_handle_t store(const Seed &seed) const noexcept
Stores a Seed object and returns a handle, to retrieve later.
const Seed & get(const std::string &fingerprint) const
retrieve a Seed object from the jar from the fingerprint of the Seed object
Manages seed phrase languages and their properties.
Definition ots.hpp:139
static const SeedLanguage & fromName(const std::string &name)
Retrieves a SeedLanguage by its native name.
Definition seed-language.cpp:56
bool operator==(const SeedLanguage &other) const
Compares two SeedLanguage objects for equality.
Definition seed-language.cpp:40
static const SeedLanguage & fromEnglishName(const std::string &name)
Retrieves a SeedLanguage by its English name.
Definition seed-language.cpp:63
const std::string & code() const
Retrieves the two-letter language code, which could be extended by a dash with a variation.
Definition seed-language.cpp:17
bool isDefault(SeedType type=SeedType::Monero) const
Checks if this is the default language for a given seed type.
Definition seed-language.cpp:28
static const std::vector< std::reference_wrapper< const SeedLanguage > > list()
Retrieves the complete list of available seed languages.
Definition seed-language.cpp:77
const std::string & englishName() const
Retrieves the English name of the seed language.
Definition seed-language.cpp:13
static void setDefaultLanguage(SeedType type, const SeedLanguage &language)
Sets the default language for a given seed type.
Definition seed-language.cpp:172
int index(SeedType type=SeedType::Monero) const noexcept
The native language index.
Definition seed-language.cpp:33
static const SeedLanguage & defaultLanguage(SeedType type=SeedType::Monero)
Gets the default language for a given seed type.
Definition seed-language.cpp:165
static const SeedLanguage & fromCode(const std::string &code)
Retrieves a SeedLanguage by its language code.
Definition seed-language.cpp:70
bool supported(SeedType type=SeedType::Monero) const
Checks if the language is supported for a specific seed type.
Definition seed-language.cpp:21
static const std::vector< std::reference_wrapper< const SeedLanguage > > listFor(SeedType type)
Retrieves languages supported for a specific seed type.
Definition seed-language.cpp:156
const std::string & name() const
Retrieves the native name of the seed language.
Definition seed-language.cpp:9
Abstract base class for cryptographic seed management.
Definition ots.hpp:276
virtual const uint64_t timestamp() const noexcept
Gets the seed's creation timestamp.
Definition seed.cpp:14
virtual const uint64_t height() const noexcept
Gets the blockchain height associated with the seed.
Definition seed.cpp:20
virtual const Address & address() const noexcept
Address of the seed.
Definition seed.cpp:30
static std::vector< uint16_t > mergeWithPassword(const std::string &password, const std::vector< uint16_t > &values)
Merge password with seed values.
Definition seed.cpp:80
virtual const Network & network() const noexcept
Gets the network associated with the seed.
Definition ots.hpp:343
Network m_network
Definition ots.hpp:473
virtual std::shared_ptr< Wallet > wallet() noexcept
Creates a wallet from the seed.
Definition seed.cpp:147
virtual ~Seed()=default
Virtual destructor to ensure proper cleanup of derived classes.
uint64_t m_timestamp
Definition ots.hpp:470
virtual const WipeableString phrase(const SeedLanguage &language, const std::string &password="") const =0
Generates the seed phrase in a specified language.
virtual const SeedIndices indices(const std::string &password="") const =0
Gets the raw numeric values representing the seed (indices)
static std::vector< uint16_t > mergeAndZeorizeValues(std::vector< uint16_t > &values1, std::vector< uint16_t > &values2, bool del=true)
Merges two seed values, so you can join multiple SeedQRs to one seed.
Definition seed.cpp:59
std::unique_ptr< KeyStore, KeyStoreDeleter > m_key
Definition ots.hpp:472
std::shared_ptr< Wallet > m_wallet
Definition ots.hpp:469
static std::vector< uint16_t > mergeValues(const std::vector< uint16_t > &values1, const std::vector< uint16_t > &values2)
Merges two seed values, so you can join multiple SeedQRs to one seed.
Definition seed.cpp:36
uint64_t m_height
Definition ots.hpp:471
static std::vector< uint16_t > mergeWithPasswordAndZeorize(std::string &password, std::vector< uint16_t > &values, bool del=true)
Merge password with seed values and zeroize password.
Definition seed.cpp:112
virtual const std::string & fingerprint() const noexcept
Provides a unique fingerprint for the seed.
Definition seed.cpp:26
std::unique_ptr< Address > m_address
Definition ots.hpp:468
detailed information about a transaction, used to check transaction before signing
Definition ots.hpp:1477
Warnings directed to the actual user related to a transaction to be signed, to make it easier to the ...
Definition ots.hpp:1486
provides all offline wallet functionality
Definition ots.hpp:1199
uint64_t height() const noexcept
The block height on creation of the wallet.
Definition ots.hpp:1210
String class that wipes its memory on destruction.
Definition ots.hpp:1494
WipeableString() noexcept=default
Default constructor.
The library exists complete only in this namespace.
Definition account.hpp:39
size_t seed_handle_t
Definition ots.hpp:131
SeedType
Represents the seed type, and is used for the different dictionaries (languages) available.
Definition ots.hpp:94
size_t key_handle_t
Definition ots.hpp:130
Network
Represents the monero network.
Definition ots.hpp:63
AddressType
Represents the monero address type.
Definition ots.hpp:80
Header for the C++ library Exceptions.
void operator()(Account *p) const
Definition account.cpp:574
void operator()(KeyStore *p) const
Definition key-store.cpp:112
void operator()(PolyseedKeyStore *p) const
Definition polyseed-key-store.cpp:89