diff --git a/src/Makefile.am b/src/Makefile.am --- a/src/Makefile.am +++ b/src/Makefile.am @@ -215,6 +215,7 @@ rwcollection.h \ scheduler.h \ script/descriptor.h \ + script/keyorigin.h \ script/scriptcache.h \ script/sigcache.h \ script/sign.h \ diff --git a/src/script/keyorigin.h b/src/script/keyorigin.h new file mode 100644 --- /dev/null +++ b/src/script/keyorigin.h @@ -0,0 +1,36 @@ +// Copyright (c) 2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_SCRIPT_KEYORIGIN_H +#define BITCOIN_SCRIPT_KEYORIGIN_H + +#include +#include +#include + +struct KeyOriginInfo { + //! First 32 bits of the Hash160 of the public key at the root of the path + uint8_t fingerprint[4]; + std::vector path; + + friend bool operator==(const KeyOriginInfo &a, const KeyOriginInfo &b) { + return std::equal(std::begin(a.fingerprint), std::end(a.fingerprint), + std::begin(b.fingerprint)) && + a.path == b.path; + } + + ADD_SERIALIZE_METHODS; + template + inline void SerializationOp(Stream &s, Operation ser_action) { + READWRITE(fingerprint); + READWRITE(path); + } + + void clear() { + memset(fingerprint, 0, 4); + path.clear(); + } +}; + +#endif // BITCOIN_SCRIPT_KEYORIGIN_H diff --git a/src/script/sign.h b/src/script/sign.h --- a/src/script/sign.h +++ b/src/script/sign.h @@ -9,6 +9,7 @@ #include #include #include