Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
walletutil.h
Go to the documentation of this file.
1// Copyright (c) 2017 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_WALLET_WALLETUTIL_H
6#define BITCOIN_WALLET_WALLETUTIL_H
7
8#include <script/descriptor.h>
9#include <util/fs.h>
10
11#include <vector>
12
15 // the earliest version new wallets supports (only useful for
16 // getwalletinfo's clientversion output)
17 FEATURE_BASE = 10500,
18
19 // wallet encryption
21 // compressed public keys
23
24 // Hierarchical key derivation after BIP32 (HD Wallet)
25 FEATURE_HD = 130000,
26
27 // Wallet with HD chain split (change outputs will use m/0'/1'/k)
29
30 // Wallet without a default key written
32
33 // Upgraded to HD SPLIT and can have a pre-split keypool
35
37};
38
40 // Wallet flags in the upper section (> 1 << 31) will lead to not opening
41 // the wallet if flag is unknown.
42 // Unknown wallet flags in the lower section <= (1 << 31) will be tolerated.
43
44 // will categorize coins as clean (not reused) and dirty (reused), and
45 // handle
46 // them with privacy considerations in mind
48
49 // Indicates that the metadata has already been upgraded to contain key
50 // origins
52
53 // Will enforce the rule that the wallet can't contain any private keys
54 // (only watch-only/pubkeys).
56
68
71};
72
75
77std::vector<fs::path> ListWalletDir();
78
81public:
82 std::shared_ptr<Descriptor> descriptor;
84 // First item in range; start of range, inclusive, i.e.
85 // [range_start, range_end). This never changes.
87 // Item after the last; end of range, exclusive, i.e.
88 // [range_start, range_end). This will increment with each TopUp()
90 // Position of the next item to generate
93
94 void DeserializeDescriptor(const std::string &str) {
95 std::string error;
97 descriptor = Parse(str, keys, error, true);
98 if (!descriptor) {
99 throw std::ios_base::failure("Invalid descriptor: " + error);
100 }
101 }
102
104 std::string descriptor_str;
105 SER_WRITE(obj, descriptor_str = obj.descriptor->ToString());
106 READWRITE(descriptor_str, obj.creation_time, obj.next_index,
107 obj.range_start, obj.range_end);
108 SER_READ(obj, obj.DeserializeDescriptor(descriptor_str));
109 }
110
118};
119
120#endif // BITCOIN_WALLET_WALLETUTIL_H
Cache for single descriptor's derived extended pubkeys.
Definition descriptor.h:19
Descriptor with some wallet metadata.
Definition walletutil.h:80
int32_t range_end
Definition walletutil.h:89
DescriptorCache cache
Definition walletutil.h:92
SERIALIZE_METHODS(WalletDescriptor, obj)
Definition walletutil.h:103
void DeserializeDescriptor(const std::string &str)
Definition walletutil.h:94
int32_t next_index
Definition walletutil.h:91
int32_t range_start
Definition walletutil.h:86
uint64_t creation_time
Definition walletutil.h:83
WalletDescriptor(std::shared_ptr< Descriptor > descriptor_, uint64_t creation_time_, int32_t range_start_, int32_t range_end_, int32_t next_index_)
Definition walletutil.h:112
std::shared_ptr< Descriptor > descriptor
Definition walletutil.h:82
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition fs.h:30
static UniValue Parse(std::string_view raw)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
Definition client.cpp:225
bool error(const char *fmt, const Args &...args)
Definition logging.h:226
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
#define SER_WRITE(obj, code)
Definition serialize.h:173
#define SER_READ(obj, code)
Definition serialize.h:169
#define READWRITE(...)
Definition serialize.h:166
WalletFlags
Definition walletutil.h:39
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
Definition walletutil.h:55
@ WALLET_FLAG_AVOID_REUSE
Definition walletutil.h:47
@ WALLET_FLAG_KEY_ORIGIN_METADATA
Definition walletutil.h:51
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
Definition walletutil.h:70
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...
Definition walletutil.h:67
WalletFeature
(client) version numbers for particular wallet features
Definition walletutil.h:14
@ FEATURE_HD_SPLIT
Definition walletutil.h:28
@ FEATURE_WALLETCRYPT
Definition walletutil.h:20
@ FEATURE_NO_DEFAULT_KEY
Definition walletutil.h:31
@ FEATURE_PRE_SPLIT_KEYPOOL
Definition walletutil.h:34
@ FEATURE_BASE
Definition walletutil.h:17
@ FEATURE_HD
Definition walletutil.h:25
@ FEATURE_LATEST
Definition walletutil.h:36
@ FEATURE_COMPRPUBKEY
Definition walletutil.h:22
fs::path GetWalletDir()
Get the path of the wallet directory.
std::vector< fs::path > ListWalletDir()
Get wallets in wallet directory.