Convert wallet to new serialization

This commit is contained in:
Pieter Wuille
2020-05-24 10:34:52 -07:00
parent 65c589e45e
commit ef17c03e07
4 changed files with 61 additions and 77 deletions

View File

@@ -98,26 +98,22 @@ public:
int32_t next_index = 0; // Position of the next item to generate
DescriptorCache cache;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
if (ser_action.ForRead()) {
std::string desc;
std::string error;
READWRITE(desc);
FlatSigningProvider keys;
descriptor = Parse(desc, keys, error, true);
if (!descriptor) {
throw std::ios_base::failure("Invalid descriptor: " + error);
}
} else {
READWRITE(descriptor->ToString());
void DeserializeDescriptor(const std::string& str)
{
std::string error;
FlatSigningProvider keys;
descriptor = Parse(str, keys, error, true);
if (!descriptor) {
throw std::ios_base::failure("Invalid descriptor: " + error);
}
READWRITE(creation_time);
READWRITE(next_index);
READWRITE(range_start);
READWRITE(range_end);
}
SERIALIZE_METHODS(WalletDescriptor, obj)
{
std::string descriptor_str;
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() {}