Offline Transaction Signing (OTS) 0.1.0
Loading...
Searching...
No Matches
ots.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "ots-exceptions.hpp"
4#include <memory>
5#include <string>
6#include <vector>
7#include <array>
8#include <map>
9#include <utility>
10
22#ifndef DEFAULT_MAX_ACCOUNT_DEPTH
23#define DEFAULT_MAX_ACCOUNT_DEPTH 10
24#endif
25
31#ifndef DEFAULT_MAX_INDEX_DEPTH
32#define DEFAULT_MAX_INDEX_DEPTH 100
33#endif
34
35#define OUTPUT_EXPORT_FILE_MAGIC "Monero output export\004"
36
53namespace ots {
54
63 enum class Network {
64 MAIN,
65 TEST,
66 STAGE,
67 // WARNING: On extending the network types, the cryptonoteNetwork function in ots-internal.hpp needs to be updated, or at least reviewed.
68 // WARNING: keep OTS_NETWORK in sync with this enum, too!
69 };
70
80 enum class AddressType {
84 // WARNING: Keep OTS_ADDRESS_TYPE in sync with this enum!
85 };
86
94 enum class SeedType {
95 Monero,
97 // WARNING: Keep OTS_SEED_TYPE in sync with this enum!
98 };
99
100 // Forward declarations
101 class Seed;
102 class Address;
103 class Wallet;
104 class Account;
105 class KeyStore;
106 class PolyseedKeyStore;
107 class WipeableString;
108 class SeedIndices;
109 class MoneroSeed;
110 struct KeyStoreDeleter { // for std::unique_ptr, if not it will not compile
111 void operator()(KeyStore* p) const;
112 };
113 struct PolyseedKeyStoreDeleter { // for std::unique_ptr, if not it will not compile
114 void operator()(PolyseedKeyStore* p) const;
115 };
121 class Account;
122 struct AccountDeleter { // for std::unique_ptr, if not it will not compile
123 void operator()(Account* p) const;
124 };
125 class PolyseedKeyStore;
126 class TxDescription;
127 class TxWarning;
128
129 // Type aliases
130 using key_handle_t = size_t;
131 using seed_handle_t = size_t;
132
140 public:
145 [[nodiscard]] const std::string& name() const;
146
151 [[nodiscard]] const std::string& englishName() const;
152
157 [[nodiscard]] const std::string& code() const;
158
164 [[nodiscard]] bool supported(SeedType type = SeedType::Monero) const;
165
171 [[nodiscard]] bool isDefault(SeedType type = SeedType::Monero) const;
172
178 [[nodiscard]] int index(SeedType type = SeedType::Monero) const noexcept;
179
185 bool operator==(const SeedLanguage& other) const;
186
192 bool operator==(SeedLanguage& other) const;
193
199 bool operator==(const std::string& code) const;
200
205 operator const std::string&() const;
206
213 static const SeedLanguage& fromName(const std::string& name);
214
221 static const SeedLanguage& fromEnglishName(const std::string& name);
222
229 static const SeedLanguage& fromCode(const std::string& code);
230
231
236 static const std::vector<std::reference_wrapper<const SeedLanguage>> list();
237
243 static const std::vector<std::reference_wrapper<const SeedLanguage>> listFor(SeedType type);
244
251
258 static void setDefaultLanguage(SeedType type, const SeedLanguage& language);
259
260 private:
261 static std::vector<SeedLanguage> s_list;
262 static std::map<SeedType, std::reference_wrapper<const SeedLanguage>> s_default;
263 std::string m_code;
264 std::string m_name;
265 std::string m_englishName;
266 std::map<SeedType, bool> m_supported;
267 std::map<SeedType, int> m_index;
268 };
269
276 class Seed {
277 public:
281 virtual ~Seed() = default;
282
289 virtual const WipeableString phrase(const SeedLanguage& language, const std::string& password = "") const = 0;
290
295 virtual const SeedIndices indices(const std::string& password = "") const = 0;
296
304 virtual const std::string& fingerprint() const noexcept;
305
312 virtual const Address& address() const noexcept;
313
324 virtual const uint64_t timestamp() const noexcept;
325
334 virtual const uint64_t height() const noexcept;
335
343 virtual inline const Network& network() const noexcept { return m_network; };
344
351 virtual std::shared_ptr<Wallet> wallet() noexcept;
352
353 // Explicitly delete copy operations
354 Seed(const Seed&) = delete;
355 Seed& operator=(const Seed&) = delete;
356 // Allow move operations
357 Seed(Seed&&) noexcept = default;
358 Seed& operator=(Seed&&) noexcept = default;
359
369 static std::vector<uint16_t> mergeValues(
370 const std::vector<uint16_t>& values1,
371 const std::vector<uint16_t>& values2
372 );
373
383 static std::vector<uint16_t> mergeValues(const std::vector<std::vector<uint16_t>>& values);
384
395 static std::vector<uint16_t> mergeAndZeorizeValues(
396 std::vector<uint16_t>& values1,
397 std::vector<uint16_t>& values2,
398 bool del = true
399 );
400
411 static std::vector<uint16_t> mergeAndZeorizeValues(
412 std::vector<std::vector<uint16_t>>& values,
413 bool del = true
414 );
415
423 static std::vector<uint16_t> mergeWithPassword(
424 const std::string& password,
425 const std::vector<uint16_t>& values
426 );
427
436 static std::vector<uint16_t> mergeWithPasswordAndZeorize(
437 std::string& password,
438 std::vector<uint16_t>& values,
439 bool del = true
440 );
441
449 static std::vector<uint16_t> mergeWithPassword(
450 const WipeableString& password,
451 const std::vector<uint16_t>& values
452 );
453
461 static std::vector<uint16_t> mergeWithPasswordAndZeorize(
462 const WipeableString& password,
463 std::vector<uint16_t>& values,
464 bool del = true
465 );
466 protected:
467 Seed();
468 std::unique_ptr<Address> m_address;
469 std::shared_ptr<Wallet> m_wallet;
470 uint64_t m_timestamp = 0;
471 uint64_t m_height = 0;
472 std::unique_ptr<KeyStore, KeyStoreDeleter> m_key;
474 };
475
482 class LegacySeed: public Seed {
483 public:
489 const WipeableString phrase(const SeedLanguage& language, const std::string& password = "") const override;
490
495 const SeedIndices indices(const std::string& password = "") const override;
496
507 static LegacySeed decode(
508 const std::string& phrase,
509 uint64_t height = 0,
510 uint64_t time = 0,
512 );
513
522 static LegacySeed decode(
523 const SeedIndices& indices,
524 uint64_t height = 0,
525 uint64_t time = 0,
527 );
528
537 static LegacySeed decode(
538 const std::vector<uint16_t>& values,
539 uint64_t height = 0,
540 uint64_t time = 0,
542 );
543
544 protected:
545 explicit LegacySeed();
546 std::unique_ptr<KeyStore, KeyStoreDeleter> m_seed;
547 };
548
558 class MoneroSeed: public Seed {
559 public:
571 const WipeableString phrase(const SeedLanguage& language, const std::string& passphrase = "") const override;
572
583 const SeedIndices indices(const std::string& passphrase = "") const override;
584
599 static MoneroSeed decode(
600 const std::string& phrase,
601 uint64_t height = 0,
602 uint64_t time = 0,
603 Network network = Network::MAIN,
604 const std::string& passphrase = ""
605 );
606
617 static MoneroSeed decode(
618 const SeedIndices& indices,
619 uint64_t height = 0,
620 uint64_t time = 0,
621 Network network = Network::MAIN,
622 const std::string& passphrase = ""
623 );
624
635 static MoneroSeed decode(
636 const std::vector<uint16_t>& values,
637 uint64_t height = 0,
638 uint64_t time = 0,
639 Network network = Network::MAIN,
640 const std::string& password = ""
641 );
642
655 static MoneroSeed create(
656 const std::array<unsigned char, 32>& random,
657 uint64_t height = 0,
658 uint64_t time = 0,
659 const Network network = Network::MAIN
660 );
661
673 static MoneroSeed generate(
674 uint64_t height = 0,
675 uint64_t time = 0,
676 const Network network = Network::MAIN
677 );
678 protected:
679 MoneroSeed() = default;
680 };
681
706 class Polyseed: public Seed {
707 public:
708 const WipeableString phrase(const SeedLanguage& language, const std::string& password = "") const override;
709 const SeedIndices indices(const std::string& password = "") const override;
710
715 MoneroSeed moneroSeed() const;
716
725 static Polyseed create(
726 const std::array<unsigned char, 19>& random,
727 Network network = Network::MAIN,
728 uint64_t time = 0,
729 const std::string& passphrase = ""
730 );
731
740 static Polyseed create(
741 const std::array<unsigned char, 32>& random,
742 Network network = Network::MAIN,
743 uint64_t time = 0,
744 const std::string& passphrase = ""
745 );
746
754 static Polyseed generate(
755 Network network = Network::MAIN,
756 uint64_t time = 0,
757 const std::string& passphrase = ""
758 );
759
772 static Polyseed decode(
773 const std::string& phrase,
774 const Network network = Network::MAIN,
775 const std::string& password = "",
776 const std::string& passphrase = ""
777 );
778
790 static Polyseed decode(
791 const std::string& phrase,
792 const SeedLanguage& language,
793 const Network network = Network::MAIN,
794 const std::string& password = "",
795 const std::string& passphrase = ""
796 );
797
810 static Polyseed decode(
811 const SeedIndices& indices,
812 const Network network = Network::MAIN,
813 const std::string& password = "",
814 const std::string& passphrase = ""
815 );
816
829 static Polyseed decode(
830 const std::vector<uint16_t>& values,
831 const Network network = Network::MAIN,
832 const std::string& password = "",
833 const std::string& passphrase = ""
834 );
835 protected:
836 Polyseed();
837 std::unique_ptr<PolyseedKeyStore, PolyseedKeyStoreDeleter> m_seed;
838 };
839
848 class Address {
849 public:
855 explicit Address(const std::string& address);
856
861 [[nodiscard]] const Network network() const noexcept;
862
867 [[nodiscard]] const AddressType type() const noexcept;
868
874 virtual const std::string& fingerprint() const noexcept;
875
881 bool isIntegrated() const noexcept;
882
887 std::string paymentID() const noexcept;
888
894 Address integratedAddress() const;
895
900 [[nodiscard]] const size_t length() const noexcept;
901
906 explicit operator std::string() const noexcept;
907
912 operator const std::string&() const noexcept;
913
918 operator const uint8_t*() const noexcept;
919
924 bool operator==(const Address& other) const noexcept;
925
930 bool operator==(const std::string& other) const noexcept;
931
938 [[nodiscard]] static bool isValid(const std::string& address, const Network network = Network::MAIN) noexcept;
939
947 [[nodiscard]] static Network network(const std::string& address);
948
955 [[nodiscard]] static AddressType type(const std::string& address);
956
963 [[nodiscard]] static std::string fingerprint(const std::string& address);
964
971 [[nodiscard]] static bool isIntegrated(const std::string& address);
972
980 [[nodiscard]] static std::string paymentID(const std::string& address, Network network = Network::MAIN);
981
990 [[nodiscard]] static std::string integratedAddress(const std::string& address, Network network = Network::MAIN);
991
992 protected:
993 explicit Address(const std::string& address, Network network);
994 static Address validAddress(const std::string& address);
995 std::string m_address;
998 mutable std::string m_fingerprint;
999 };
1000
1005 class OTS {
1006 public:
1007 explicit OTS();
1008
1012 static const std::string version() noexcept;
1013
1017 static std::array<int, 3> versionComponents() noexcept;
1018
1027 static uint64_t heightFromTimestamp(uint64_t timestamp, Network network = Network::MAIN);
1028
1035 static uint64_t timestampFromHeight(uint64_t height, Network network = Network::MAIN);
1036
1042 static std::array<unsigned char, 32> random();
1043
1050 static void random(size_t size, uint8_t *bytes);
1051
1059 static bool lowEntropy(size_t size, const uint8_t* data, double minEntropy = 3.5) noexcept;
1060
1065 static void enforceEntropy(bool enforce = true) noexcept;
1066
1072 static void setMaxAccountDepth(uint32_t depth) noexcept;
1073
1080 static void setMaxIndexDepth(uint32_t depth) noexcept;
1081
1090 static void setMaxDepth(uint32_t account, uint32_t index) noexcept;
1091
1095 static void resetMaxDepth() noexcept;
1096
1105 static uint32_t maxAccountDepth(uint32_t depth = 0) noexcept;
1106
1115 static uint32_t maxIndexDepth(uint32_t depth = 0) noexcept;
1116
1133 static bool verifyData(
1134 const std::string& data,
1135 const std::string& address,
1136 const std::string& signature,
1137 bool legacyFallback = false
1138 );
1139
1140 protected:
1148 static void ensureEntropy(size_t size, const uint8_t* data, double minEntropy = 3.5);
1149
1150 private:
1151 static bool sEnforceEntropy;
1152 static uint32_t sMaxAccountDepth;
1153 static uint32_t sMaxIndexDepth;
1154 };
1155
1161 class SeedJar {
1162 public:
1171 seed_handle_t store(const Seed& seed) const noexcept;
1172
1179 const Seed& get(seed_handle_t handle) const;
1180
1187 const Seed& get(const std::string& fingerprint) const;
1188 uint32_t count() const noexcept;
1189 bool has(seed_handle_t handle) const noexcept;
1190 bool has(const std::string& fingerprint) const;
1191 std::vector<std::reference_wrapper<const Seed>> list() const noexcept;
1192 static const SeedJar& instance() noexcept;
1193 };
1194
1199 class Wallet {
1200 public:
1201
1210 uint64_t height() const noexcept { return m_height; };
1211
1218 Address address(uint32_t account = 0, uint32_t index = 0) const noexcept;
1219
1227 std::vector<Address> accounts(uint32_t max = 10, uint32_t offset = 0) const noexcept;
1228
1236 std::vector<Address> subAddresses(uint32_t account = 0, uint32_t max = 10, uint32_t offset = 0) const noexcept;
1237
1243 bool hasAddress(const std::string& address, uint32_t maxAccountDepth = 0, uint32_t maxIndexDepth = 0) const noexcept;
1244
1250 bool hasAddress(const Address& address, uint32_t maxAccountDepth = 0, uint32_t maxIndexDepth = 0) const noexcept;
1251
1259 std::pair<uint32_t, uint32_t> addressIndex(const std::string& address, uint32_t maxAccountDepth = 0, uint32_t maxIndexDepth = 0) const;
1260
1268 std::pair<uint32_t, uint32_t> addressIndex(const Address& address, uint32_t maxAccountDepth = 0, uint32_t maxIndexDepth = 0) const;
1269
1274 WipeableString secretViewKey() const noexcept;
1275
1280 WipeableString publicViewKey() const noexcept;
1281
1286 WipeableString secretSpendKey() const noexcept;
1287
1292 WipeableString publicSpendKey() const noexcept;
1293
1300 uint64_t importOutputs(const std::string& outputs);
1301
1308 WipeableString exportKeyImages() const;
1309
1316 TxDescription describeTransaction(const std::string& unsignedTransaction) const;
1317
1324 std::vector<TxWarning> checkTransaction(const std::string& unsignedTransaction) const;
1325
1331 std::vector<TxWarning> checkTransaction(const TxDescription& description) const noexcept;
1332
1339 std::string signTransaction(const std::string& unsignedTransaction) const;
1340
1346 std::string signData(const std::string& data) const noexcept;
1347
1355 std::string signData(const std::string& data, const std::pair<uint32_t, uint32_t>& index) const;
1356
1365 std::string signData(const std::string& data, const Address& address) const;
1366
1375 std::string signData(const std::string& data, const std::string& address) const;
1376
1385 static bool verifyData(
1386 const std::string& data,
1387 const std::string& address,
1388 const std::string& signature,
1389 bool legacyFallback = false
1390 );
1391
1401 static bool verifyData(
1402 const std::string& data,
1403 const Address& address,
1404 const std::string& signature,
1405 bool legacyFallback = false
1406 );
1407
1417 bool verifyData(
1418 const std::string& data,
1419 const std::pair<uint32_t, uint32_t>& index,
1420 const std::string& signature,
1421 bool legacyFallback = false
1422 ) const;
1423
1432 bool verifyData(
1433 const std::string& data,
1434 const std::string& signature,
1435 bool legacyFallback = false
1436 ) const;
1437
1444 Wallet(const std::array<unsigned char, 32>& key, uint64_t height, const Network network) noexcept;
1445
1453 Wallet(const KeyStore& key, uint64_t height, const Network network) noexcept;
1454
1463 Wallet(const Account& account, const KeyStore& key, uint64_t height, const Network network) noexcept;
1464
1465 protected:
1466 std::unique_ptr<KeyStore, KeyStoreDeleter> m_key;
1467 std::unique_ptr<Account, AccountDeleter> m_account;
1468 Network m_network;
1469 uint64_t m_height = 0;
1470 };
1471
1478
1486 class TxWarning {};
1487
1488 // set this on the end because there will be a lot of bloat in the documentation.
1495
1496 public:
1498 WipeableString() noexcept = default;
1499
1501 inline explicit WipeableString(const std::string& s): m_str(s) {};
1502
1504 explicit WipeableString(const char* s);
1505
1507 WipeableString(const char* s, size_t n);
1508
1510 WipeableString(const WipeableString& other);
1511
1513 WipeableString(WipeableString&& other) noexcept;
1514
1516 WipeableString& operator=(const WipeableString& other);
1517
1519 WipeableString& operator=(WipeableString&& other) noexcept;
1520
1522 WipeableString& operator=(const char* s);
1523
1526
1533 std::string insecure() const noexcept;
1534
1536 const char* c_str() const noexcept;
1537
1539 const char* data() const noexcept;
1540
1542 size_t size() const noexcept;
1543
1545 bool empty() const noexcept;
1546
1548 void clear() noexcept;
1549
1551 size_t capacity() const noexcept;
1552
1554 void reserve(size_t n);
1555
1557 WipeableString substr(size_t pos = 0, size_t len = std::string::npos) const;
1558
1560 size_t find(const WipeableString& str, size_t pos = 0) const noexcept;
1561
1563 size_t find(const char* s, size_t pos = 0) const noexcept;
1564
1566 WipeableString& append(const WipeableString& str);
1567
1569 WipeableString& append(const char* s);
1570
1572 WipeableString& operator+=(const WipeableString& str);
1573
1575 WipeableString& operator+=(const char* s);
1576
1578 bool operator==(const WipeableString& other) const noexcept;
1579
1581 bool operator!=(const WipeableString& other) const noexcept;
1582
1590 operator std::string() const;
1591
1593 int compare(const WipeableString& other) const noexcept;
1594
1596 friend std::ostream& operator<<(std::ostream& os, const WipeableString& str);
1597
1599 static constexpr size_t npos = std::string::npos;
1600
1601 private:
1603 std::string m_str;
1604
1606 void wipe() noexcept;
1607 };
1608
1614 public:
1616 SeedIndices() noexcept = default;
1617
1619 inline explicit SeedIndices(const std::vector<uint16_t>& v): m_vec(v) {};
1620
1622 explicit SeedIndices(size_t size): m_vec(size) {};
1623
1625 SeedIndices(size_t size, uint16_t value): m_vec(size, value) {};
1626
1628 SeedIndices(const SeedIndices& other): m_vec(other.m_vec) {};
1629
1631 SeedIndices(SeedIndices&& other) noexcept: m_vec(std::move(other.m_vec)) {};
1632
1634 SeedIndices& operator=(const SeedIndices& other);
1635
1637 SeedIndices& operator=(SeedIndices&& other) noexcept;
1638
1640 operator const uint8_t*() const noexcept;
1641
1643 operator const char*() const noexcept;
1644
1646 operator const std::vector<uint16_t>&() const noexcept;
1647
1649 operator const std::string() const noexcept;
1650
1652 bool operator==(const SeedIndices& other) const noexcept;
1653
1655 bool operator==(const std::vector<uint16_t>& other) const noexcept;
1656
1658 bool operator!=(const SeedIndices& other) const noexcept;
1659
1661 bool operator!=(const std::vector<uint16_t>& other) const noexcept;
1662
1667 const std::string numeric(const std::string& separator = "") const noexcept;
1668
1673 const std::string hex(const std::string& separator = "") const noexcept;
1674
1676 ~SeedIndices();
1677
1679 size_t size() const noexcept;
1680
1682 bool empty() const noexcept;
1683
1685 void clear() noexcept;
1686
1688 inline void reserve(size_t n) { m_vec.reserve(n); };
1689
1691 inline void shrink_to_fit() { m_vec.shrink_to_fit(); };
1692
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;
1698
1700 void push_back(uint16_t value);
1701
1703 uint16_t emplace_back(uint16_t value);
1704
1706 auto begin() noexcept { return m_vec.begin(); }
1707
1709 auto end() noexcept { return m_vec.end(); }
1710
1712 auto begin() const noexcept { return m_vec.begin(); }
1713
1715 auto end() const noexcept { return m_vec.end(); }
1716
1718 auto cbegin() const noexcept { return m_vec.cbegin(); }
1719
1721 auto cend() const noexcept { return m_vec.cend(); }
1722
1728 static SeedIndices fromNumeric(const std::string& numeric, const std::string& separator = "");
1729
1734 static SeedIndices fromHex(const std::string& hex, const std::string& separator = "");
1735 private:
1737 std::vector<uint16_t> m_vec;
1738
1740 void wipe() noexcept;
1741 };
1742} // namespace ots
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
MoneroSeed()=default
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.
Definition ots.hpp:122
void operator()(Account *p) const
Definition account.cpp:574
Definition ots.hpp:110
void operator()(KeyStore *p) const
Definition key-store.cpp:112
Definition ots.hpp:113
void operator()(PolyseedKeyStore *p) const
Definition polyseed-key-store.cpp:89