Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletutil.h
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | public: | ||||
int32_t range_start = 0; | int32_t range_start = 0; | ||||
// Item after the last; end of range, exclusive, i.e. | // Item after the last; end of range, exclusive, i.e. | ||||
// [range_start, range_end). This will increment with each TopUp() | // [range_start, range_end). This will increment with each TopUp() | ||||
int32_t range_end = 0; | int32_t range_end = 0; | ||||
// Position of the next item to generate | // Position of the next item to generate | ||||
int32_t next_index = 0; | int32_t next_index = 0; | ||||
DescriptorCache cache; | DescriptorCache cache; | ||||
ADD_SERIALIZE_METHODS; | void DeserializeDescriptor(const std::string &str) { | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
if (ser_action.ForRead()) { | |||||
std::string desc; | |||||
std::string error; | std::string error; | ||||
READWRITE(desc); | |||||
FlatSigningProvider keys; | FlatSigningProvider keys; | ||||
descriptor = Parse(desc, keys, error, true); | descriptor = Parse(str, keys, error, true); | ||||
if (!descriptor) { | if (!descriptor) { | ||||
throw std::ios_base::failure("Invalid descriptor: " + error); | throw std::ios_base::failure("Invalid descriptor: " + error); | ||||
} | } | ||||
} else { | |||||
READWRITE(descriptor->ToString()); | |||||
} | } | ||||
READWRITE(creation_time); | |||||
READWRITE(next_index); | SERIALIZE_METHODS(WalletDescriptor, obj) { | ||||
READWRITE(range_start); | std::string descriptor_str; | ||||
READWRITE(range_end); | SER_WRITE(obj, descriptor_str = obj.descriptor->ToString()); | ||||
READWRITE(descriptor_str, obj.creation_time, obj.next_index, | |||||
obj.range_start, obj.range_end); | |||||
SER_READ(obj, obj.DeserializeDescriptor(descriptor_str)); | |||||
} | } | ||||
WalletDescriptor() {} | WalletDescriptor() {} | ||||
WalletDescriptor(std::shared_ptr<Descriptor> descriptor_, | WalletDescriptor(std::shared_ptr<Descriptor> descriptor_, | ||||
uint64_t creation_time_, int32_t range_start_, | uint64_t creation_time_, int32_t range_start_, | ||||
int32_t range_end_, int32_t next_index_) | int32_t range_end_, int32_t next_index_) | ||||
: descriptor(descriptor_), creation_time(creation_time_), | : descriptor(descriptor_), creation_time(creation_time_), | ||||
range_start(range_start_), range_end(range_end_), | range_start(range_start_), range_end(range_end_), | ||||
next_index(next_index_) {} | next_index(next_index_) {} | ||||
}; | }; | ||||
#endif // BITCOIN_WALLET_WALLETUTIL_H | #endif // BITCOIN_WALLET_WALLETUTIL_H |