Skip to content

Commit 16f8096

Browse files
committed
Move KeyOriginInfo to its own header file
1 parent d9becff commit 16f8096

File tree

3 files changed

+39
-25
lines changed

3 files changed

+39
-25
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ BITCOIN_CORE_H = \
181181
rpc/util.h \
182182
scheduler.h \
183183
script/descriptor.h \
184+
script/keyorigin.h \
184185
script/sigcache.h \
185186
script/sign.h \
186187
script/standard.h \

src/script/keyorigin.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2019 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_SCRIPT_KEYORIGIN_H
6+
#define BITCOIN_SCRIPT_KEYORIGIN_H
7+
8+
#include <serialize.h>
9+
#include <streams.h>
10+
#include <vector>
11+
12+
struct KeyOriginInfo
13+
{
14+
unsigned char fingerprint[4]; //!< First 32 bits of the Hash160 of the public key at the root of the path
15+
std::vector<uint32_t> path;
16+
17+
friend bool operator==(const KeyOriginInfo& a, const KeyOriginInfo& b)
18+
{
19+
return std::equal(std::begin(a.fingerprint), std::end(a.fingerprint), std::begin(b.fingerprint)) && a.path == b.path;
20+
}
21+
22+
ADD_SERIALIZE_METHODS;
23+
template <typename Stream, typename Operation>
24+
inline void SerializationOp(Stream& s, Operation ser_action)
25+
{
26+
READWRITE(fingerprint);
27+
READWRITE(path);
28+
}
29+
30+
void clear()
31+
{
32+
memset(fingerprint, 0, 4);
33+
path.clear();
34+
}
35+
};
36+
37+
#endif // BITCOIN_SCRIPT_KEYORIGIN_H

src/script/sign.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <hash.h>
1111
#include <pubkey.h>
1212
#include <script/interpreter.h>
13+
#include <script/keyorigin.h>
1314
#include <streams.h>
1415

1516
class CKey;
@@ -20,31 +21,6 @@ class CTransaction;
2021

2122
struct CMutableTransaction;
2223

23-
struct KeyOriginInfo
24-
{
25-
unsigned char fingerprint[4]; //!< First 32 bits of the Hash160 of the public key at the root of the path
26-
std::vector<uint32_t> path;
27-
28-
friend bool operator==(const KeyOriginInfo& a, const KeyOriginInfo& b)
29-
{
30-
return std::equal(std::begin(a.fingerprint), std::end(a.fingerprint), std::begin(b.fingerprint)) && a.path == b.path;
31-
}
32-
33-
ADD_SERIALIZE_METHODS;
34-
template <typename Stream, typename Operation>
35-
inline void SerializationOp(Stream& s, Operation ser_action)
36-
{
37-
READWRITE(fingerprint);
38-
READWRITE(path);
39-
}
40-
41-
void clear()
42-
{
43-
memset(fingerprint, 0, 4);
44-
path.clear();
45-
}
46-
};
47-
4824
/** An interface to be implemented by keystores that support signing. */
4925
class SigningProvider
5026
{

0 commit comments

Comments
 (0)