Skip to content

Commit

Permalink
Add serialization support to CScriptID and CNoDestination
Browse files Browse the repository at this point in the history
The serialization added to CScriptID and trivial (no-op)
serialization added to CNoDestination allows CTxDestination (variant)
to be serialized.
  • Loading branch information
jamescowens committed Dec 26, 2023
1 parent d88390d commit 18cb12b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "keystore.h"
#include "prevector.h"
#include <util/hash_type.h>
#include "serialize.h"
#include "wallet/ismine.h"

typedef std::vector<unsigned char> valtype;
Expand All @@ -30,7 +31,14 @@ class CScriptID : public BaseHash<uint160>
CScriptID() : BaseHash() {}
explicit CScriptID(const CScript& in);
explicit CScriptID(const uint160& in) : BaseHash(in) {}
// explicit CScriptID(const ScriptHash& in);

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
{
READWRITE(m_hash);
}
};

static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
Expand Down Expand Up @@ -85,6 +93,13 @@ class CNoDestination {
friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; }
friend bool operator!=(const CNoDestination &a, const CNoDestination &b) { return false; }
friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; }

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
{}

};

/** A txout script template with a specific destination. It is either:
Expand Down

0 comments on commit 18cb12b

Please sign in to comment.