From 16f8096e911e4d59292240a17e2d4004f0500b9e Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 17 Jun 2019 15:47:12 -0400 Subject: [PATCH] Move KeyOriginInfo to its own header file --- src/Makefile.am | 1 + src/script/keyorigin.h | 37 +++++++++++++++++++++++++++++++++++++ src/script/sign.h | 26 +------------------------- 3 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 src/script/keyorigin.h diff --git a/src/Makefile.am b/src/Makefile.am index 39e8d3d6897..30058d9541a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -181,6 +181,7 @@ BITCOIN_CORE_H = \ rpc/util.h \ scheduler.h \ script/descriptor.h \ + script/keyorigin.h \ script/sigcache.h \ script/sign.h \ script/standard.h \ diff --git a/src/script/keyorigin.h b/src/script/keyorigin.h new file mode 100644 index 00000000000..610f2335009 --- /dev/null +++ b/src/script/keyorigin.h @@ -0,0 +1,37 @@ +// 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 +{ + unsigned char fingerprint[4]; //!< First 32 bits of the Hash160 of the public key at the root of the path + 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 index 9df4dc98fa4..7b4627cca2c 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -10,6 +10,7 @@ #include #include #include