Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
script
keyorigin.h
Go to the documentation of this file.
1
// Copyright (c) 2019-present 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 <vector>
10
11
struct
KeyOriginInfo
12
{
13
unsigned
char
fingerprint
[4];
14
std::vector<uint32_t>
path
;
15
16
friend
bool
operator==
(
const
KeyOriginInfo
& a,
const
KeyOriginInfo
& b)
17
{
18
return
std::equal(std::begin(a.
fingerprint
), std::end(a.
fingerprint
), std::begin(b.
fingerprint
)) && a.
path
== b.
path
;
19
}
20
21
friend
bool
operator<
(
const
KeyOriginInfo
& a,
const
KeyOriginInfo
& b)
22
{
23
// Compare the fingerprints lexicographically
24
int
fpr_cmp = memcmp(a.
fingerprint
, b.
fingerprint
, 4);
25
if
(fpr_cmp < 0) {
26
return
true
;
27
}
else
if
(fpr_cmp > 0) {
28
return
false
;
29
}
30
// Compare the sizes of the paths, shorter is "less than"
31
if
(a.
path
.size() < b.
path
.size()) {
32
return
true
;
33
}
else
if
(a.
path
.size() > b.
path
.size()) {
34
return
false
;
35
}
36
// Paths same length, compare them lexicographically
37
return
a.
path
< b.
path
;
38
}
39
40
SERIALIZE_METHODS
(
KeyOriginInfo
, obj) {
READWRITE
(obj.fingerprint, obj.path); }
41
42
void
clear
()
43
{
44
memset(
fingerprint
, 0, 4);
45
path
.clear();
46
}
47
};
48
49
#endif
// BITCOIN_SCRIPT_KEYORIGIN_H
serialize.h
READWRITE
#define READWRITE(...)
Definition
serialize.h:145
KeyOriginInfo
Definition
keyorigin.h:12
KeyOriginInfo::operator==
friend bool operator==(const KeyOriginInfo &a, const KeyOriginInfo &b)
Definition
keyorigin.h:16
KeyOriginInfo::SERIALIZE_METHODS
SERIALIZE_METHODS(KeyOriginInfo, obj)
Definition
keyorigin.h:40
KeyOriginInfo::fingerprint
unsigned char fingerprint[4]
First 32 bits of the Hash160 of the public key at the root of the path.
Definition
keyorigin.h:13
KeyOriginInfo::path
std::vector< uint32_t > path
Definition
keyorigin.h:14
KeyOriginInfo::operator<
friend bool operator<(const KeyOriginInfo &a, const KeyOriginInfo &b)
Definition
keyorigin.h:21
KeyOriginInfo::clear
void clear()
Definition
keyorigin.h:42
Generated on
for Bitcoin Core by
1.17.0