Skip to content

Commit 9a93c91

Browse files
committed
Keep full pubkeys in FlatSigningProvider::origins
1 parent daef20f commit 9a93c91

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

src/script/descriptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ class DescriptorImpl : public Descriptor
436436
pubkeys.reserve(entries.size());
437437
for (auto& entry : entries) {
438438
pubkeys.push_back(entry.first);
439-
out.origins.emplace(entry.first.GetID(), std::move(entry.second));
439+
out.origins.emplace(entry.first.GetID(), std::make_pair<CPubKey, KeyOriginInfo>(CPubKey(entry.first), std::move(entry.second)));
440440
}
441441
if (m_script_arg) {
442442
for (const auto& subscript : subscripts) {

src/script/sign.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,13 @@ bool HidingSigningProvider::GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& inf
483483

484484
bool FlatSigningProvider::GetCScript(const CScriptID& scriptid, CScript& script) const { return LookupHelper(scripts, scriptid, script); }
485485
bool FlatSigningProvider::GetPubKey(const CKeyID& keyid, CPubKey& pubkey) const { return LookupHelper(pubkeys, keyid, pubkey); }
486-
bool FlatSigningProvider::GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const { return LookupHelper(origins, keyid, info); }
486+
bool FlatSigningProvider::GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const
487+
{
488+
std::pair<CPubKey, KeyOriginInfo> out;
489+
bool ret = LookupHelper(origins, keyid, out);
490+
if (ret) info = std::move(out.second);
491+
return ret;
492+
}
487493
bool FlatSigningProvider::GetKey(const CKeyID& keyid, CKey& key) const { return LookupHelper(keys, keyid, key); }
488494

489495
FlatSigningProvider Merge(const FlatSigningProvider& a, const FlatSigningProvider& b)

src/script/sign.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct FlatSigningProvider final : public SigningProvider
7777
{
7878
std::map<CScriptID, CScript> scripts;
7979
std::map<CKeyID, CPubKey> pubkeys;
80-
std::map<CKeyID, KeyOriginInfo> origins;
80+
std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>> origins;
8181
std::map<CKeyID, CKey> keys;
8282

8383
bool GetCScript(const CScriptID& scriptid, CScript& script) const override;

src/test/descriptor_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ void Check(const std::string& prv, const std::string& pub, int flags, const std:
154154
// Test whether the observed key path is present in the 'paths' variable (which contains expected, unobserved paths),
155155
// and then remove it from that set.
156156
for (const auto& origin : script_provider.origins) {
157-
BOOST_CHECK_MESSAGE(paths.count(origin.second.path), "Unexpected key path: " + prv);
158-
left_paths.erase(origin.second.path);
157+
BOOST_CHECK_MESSAGE(paths.count(origin.second.second.path), "Unexpected key path: " + prv);
158+
left_paths.erase(origin.second.second.path);
159159
}
160160
}
161161
}

src/wallet/rpcdump.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ struct ImportData
900900
// Output data
901901
std::set<CScript> import_scripts;
902902
std::map<CKeyID, bool> used_keys; //!< Import these private keys if available (the value indicates whether if the key is required for solvability)
903-
std::map<CKeyID, KeyOriginInfo> key_origins;
903+
std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>> key_origins;
904904
};
905905

906906
enum class ScriptContext
@@ -1287,7 +1287,7 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
12871287
}
12881288
const auto& key_orig_it = import_data.key_origins.find(id);
12891289
if (key_orig_it != import_data.key_origins.end()) {
1290-
pwallet->AddKeyOrigin(pubkey, key_orig_it->second);
1290+
pwallet->AddKeyOrigin(pubkey, key_orig_it->second.second);
12911291
}
12921292
pwallet->mapKeyMetadata[id].nCreateTime = timestamp;
12931293

0 commit comments

Comments
 (0)