Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115388
D4491.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D4491.diff
View Options
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -5090,28 +5090,9 @@
if (!pwallet->GetPubKey(keyID, vchPubKey)) {
return;
}
- CKeyMetadata meta;
- auto it = pwallet->mapKeyMetadata.find(keyID);
- if (it != pwallet->mapKeyMetadata.end()) {
- meta = it->second;
- }
KeyOriginInfo info;
- if (!meta.hdKeypath.empty()) {
- if (!ParseHDKeypath(meta.hdKeypath, info.path)) {
- throw JSONRPCError(RPC_INTERNAL_ERROR,
- "Internal keypath is broken");
- }
- // Get the proper master key id
- CKey key;
- pwallet->GetKey(meta.hd_seed_id, key);
- CExtKey masterKey;
- masterKey.SetSeed(key.begin(), key.size());
- // Compute identifier
- CKeyID masterid = masterKey.key.GetPubKey().GetID();
- std::copy(masterid.begin(), masterid.begin() + 4, info.fingerprint);
- } else {
- // Single pubkeys get the master fingerprint of themselves
- std::copy(keyID.begin(), keyID.begin() + 4, info.fingerprint);
+ if (!pwallet->GetKeyOrigin(keyID, info)) {
+ throw JSONRPCError(RPC_INTERNAL_ERROR, "Internal keypath is broken");
}
hd_keypaths.emplace(vchPubKey, std::move(info));
}
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -1376,6 +1376,11 @@
* Returns false if unknown, non-tolerable flags are present.
*/
bool SetWalletFlags(uint64_t overwriteFlags, bool memOnly);
+
+ /**
+ * Implement lookup of key origin information through wallet key metadata.
+ */
+ bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override;
};
/** A key allocated from the key pool. */
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -4906,3 +4906,31 @@
}
return groups;
}
+
+bool CWallet::GetKeyOrigin(const CKeyID &keyID, KeyOriginInfo &info) const {
+ CKeyMetadata meta;
+ {
+ LOCK(cs_wallet);
+ auto it = mapKeyMetadata.find(keyID);
+ if (it != mapKeyMetadata.end()) {
+ meta = it->second;
+ }
+ }
+ if (!meta.hdKeypath.empty()) {
+ if (!ParseHDKeypath(meta.hdKeypath, info.path)) {
+ return false;
+ }
+ // Get the proper master key id
+ CKey key;
+ GetKey(meta.hd_seed_id, key);
+ CExtKey masterKey;
+ masterKey.SetSeed(key.begin(), key.size());
+ // Compute identifier
+ CKeyID masterid = masterKey.key.GetPubKey().GetID();
+ std::copy(masterid.begin(), masterid.begin() + 4, info.fingerprint);
+ } else {
+ // Single pubkeys get the master fingerprint of themselves
+ std::copy(keyID.begin(), keyID.begin() + 4, info.fingerprint);
+ }
+ return true;
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:01 (16 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187452
Default Alt Text
D4491.diff (2 KB)
Attached To
D4491: Implement key origin lookup in CWallet
Event Timeline
Log In to Comment