-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathkeyorigin.h
More file actions
55 lines (46 loc) · 1.47 KB
/
keyorigin.h
File metadata and controls
55 lines (46 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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 ClearCoin_SCRIPT_KEYORIGIN_H
#define ClearCoin_SCRIPT_KEYORIGIN_H
#include <serialize.h>
#include <vector>
struct KeyOriginInfo
{
unsigned char fingerprint[4]; //!< First 32 bits of the Hash160 of the public key at the root of the path
std::vector<uint32_t> 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 <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
{
READWRITE(FLATDATA(fingerprint));
READWRITE(path);
}
void clear()
{
memset(fingerprint, 0, 4);
path.clear();
}
std::string pathToString() const
{
std::string keypath_str = "m";
for (uint32_t num : path) {
keypath_str += "/";
bool hardened = false;
if (num & 0x80000000) {
hardened = true;
num &= ~0x80000000;
}
keypath_str += std::to_string(num);
if (hardened) {
keypath_str += "'";
}
}
return keypath_str;
}
};
#endif // PIVX_SCRIPT_KEYORIGIN_H