aboutsummaryrefslogtreecommitdiff
path: root/src/pubkey.h
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2021-06-28 15:00:33 -0400
committerAndrew Chow <achow101-github@achow101.com>2021-08-23 21:38:34 -0400
commitd9d3ec07cfe45cfa55028cc879dc8a55aecb4d3c (patch)
tree32cb83e14faad38a733c603196d2625349cfac58 /src/pubkey.h
parentdbcb5742c48fd26f77e500291d7083e12eec741b (diff)
downloadbitcoin-d9d3ec07cfe45cfa55028cc879dc8a55aecb4d3c.tar.xz
Consolidate XOnlyPubKey lookup hack
The places where we need to lookup information for a XOnlyPubKey currently implement a hack which makes both serializations of the full pubkey in order to try the CKeyIDs for the lookup functions. Instead of duplicating this everywhere it is needed, we can consolidate the CKeyID generation into a function, and then have wrappers around GetPubKey, GetKey, and GetKeyOrigin which takes the XOnlyPubKey, retrieves all of the CKeyIDs (using the new GetKeyIDs() function in XOnlyPubKey), and tries their respective underlying lookup function.
Diffstat (limited to 'src/pubkey.h')
-rw-r--r--src/pubkey.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pubkey.h b/src/pubkey.h
index eec34a89c2..861a2cf500 100644
--- a/src/pubkey.h
+++ b/src/pubkey.h
@@ -267,6 +267,11 @@ public:
/** Construct a Taproot tweaked output point with this point as internal key. */
std::optional<std::pair<XOnlyPubKey, bool>> CreateTapTweak(const uint256* merkle_root) const;
+ /** Returns a list of CKeyIDs for the CPubKeys that could have been used to create this XOnlyPubKey.
+ * This is needed for key lookups since keys are indexed by CKeyID.
+ */
+ std::vector<CKeyID> GetKeyIDs() const;
+
const unsigned char& operator[](int pos) const { return *(m_keydata.begin() + pos); }
const unsigned char* data() const { return m_keydata.begin(); }
static constexpr size_t size() { return decltype(m_keydata)::size(); }