aboutsummaryrefslogtreecommitdiff
path: root/src/pubkey.h
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-07-25 11:58:14 -0400
committerAndrew Chow <achow101-github@achow101.com>2021-12-10 08:29:47 -0500
commitc5c63b8e4f3fbdb6b5a423a39d6e318fecab991f (patch)
tree45768b268c8bbf9529ebb5f4ff6197c5b6e1bd87 /src/pubkey.h
parentd3dbb16168145ccbcc7ef0a8e150695711b661b7 (diff)
Implement operator< for KeyOriginInfo and CExtPubKey
Diffstat (limited to 'src/pubkey.h')
-rw-r--r--src/pubkey.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pubkey.h b/src/pubkey.h
index f37e24bc47..204e96f49e 100644
--- a/src/pubkey.h
+++ b/src/pubkey.h
@@ -130,6 +130,11 @@ public:
return a.vch[0] < b.vch[0] ||
(a.vch[0] == b.vch[0] && memcmp(a.vch, b.vch, a.size()) < 0);
}
+ friend bool operator>(const CPubKey& a, const CPubKey& b)
+ {
+ return a.vch[0] > b.vch[0] ||
+ (a.vch[0] == b.vch[0] && memcmp(a.vch, b.vch, a.size()) > 0);
+ }
//! Implement serialization, as if this was a byte vector.
template <typename Stream>
@@ -305,6 +310,16 @@ struct CExtPubKey {
return !(a == b);
}
+ friend bool operator<(const CExtPubKey &a, const CExtPubKey &b)
+ {
+ if (a.pubkey < b.pubkey) {
+ return true;
+ } else if (a.pubkey > b.pubkey) {
+ return false;
+ }
+ return a.chaincode < b.chaincode;
+ }
+
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const;
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE]);
void EncodeWithVersion(unsigned char code[BIP32_EXTKEY_WITH_VERSION_SIZE]) const;