File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,11 @@ class CPubKey
130
130
return a.vch [0 ] < b.vch [0 ] ||
131
131
(a.vch [0 ] == b.vch [0 ] && memcmp (a.vch , b.vch , a.size ()) < 0 );
132
132
}
133
+ friend bool operator >(const CPubKey& a, const CPubKey& b)
134
+ {
135
+ return a.vch [0 ] > b.vch [0 ] ||
136
+ (a.vch [0 ] == b.vch [0 ] && memcmp (a.vch , b.vch , a.size ()) > 0 );
137
+ }
133
138
134
139
// ! Implement serialization, as if this was a byte vector.
135
140
template <typename Stream>
@@ -305,6 +310,16 @@ struct CExtPubKey {
305
310
return !(a == b);
306
311
}
307
312
313
+ friend bool operator <(const CExtPubKey &a, const CExtPubKey &b)
314
+ {
315
+ if (a.pubkey < b.pubkey ) {
316
+ return true ;
317
+ } else if (a.pubkey > b.pubkey ) {
318
+ return false ;
319
+ }
320
+ return a.chaincode < b.chaincode ;
321
+ }
322
+
308
323
void Encode (unsigned char code[BIP32_EXTKEY_SIZE]) const ;
309
324
void Decode (const unsigned char code[BIP32_EXTKEY_SIZE]);
310
325
void EncodeWithVersion (unsigned char code[BIP32_EXTKEY_WITH_VERSION_SIZE]) const ;
Original file line number Diff line number Diff line change @@ -18,6 +18,25 @@ struct KeyOriginInfo
18
18
return std::equal (std::begin (a.fingerprint ), std::end (a.fingerprint ), std::begin (b.fingerprint )) && a.path == b.path ;
19
19
}
20
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
+
21
40
SERIALIZE_METHODS (KeyOriginInfo, obj) { READWRITE (obj.fingerprint , obj.path ); }
22
41
23
42
void clear ()
You can’t perform that action at this time.
0 commit comments