Skip to content

Commit f32c1e0

Browse files
committed
Use explicit conversion from WitnessV0KeyHash -> CKeyID
These types are equivalent, in data etc, so they need only their data cast across.
1 parent 2c54217 commit f32c1e0

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/script/signingprovider.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination&
183183
return ToKeyID(*id);
184184
}
185185
if (auto witness_id = boost::get<WitnessV0KeyHash>(&dest)) {
186-
return CKeyID(*witness_id);
186+
return ToKeyID(*witness_id);
187187
}
188188
if (auto script_hash = boost::get<ScriptHash>(&dest)) {
189189
CScript script;
190190
CScriptID script_id(*script_hash);
191191
CTxDestination inner_dest;
192192
if (store.GetCScript(script_id, script) && ExtractDestination(script, inner_dest)) {
193193
if (auto inner_witness_id = boost::get<WitnessV0KeyHash>(&inner_dest)) {
194-
return CKeyID(*inner_witness_id);
194+
return ToKeyID(*inner_witness_id);
195195
}
196196
}
197197
}

src/script/standard.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ CKeyID ToKeyID(const PKHash& key_hash)
2828
return CKeyID{static_cast<uint160>(key_hash)};
2929
}
3030

31+
CKeyID ToKeyID(const WitnessV0KeyHash& key_hash)
32+
{
33+
return CKeyID{static_cast<uint160>(key_hash)};
34+
}
35+
3136
WitnessV0ScriptHash::WitnessV0ScriptHash(const CScript& in)
3237
{
3338
CSHA256().Write(in.data(), in.size()).Finalize(begin());

src/script/standard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct WitnessV0KeyHash : public uint160
106106
explicit WitnessV0KeyHash(const uint160& hash) : uint160(hash) {}
107107
explicit WitnessV0KeyHash(const CPubKey& pubkey);
108108
};
109+
CKeyID ToKeyID(const WitnessV0KeyHash& key_hash);
109110

110111
//! CTxDestination subtype to encode any future Witness version
111112
struct WitnessUnknown

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3542,7 +3542,7 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
35423542
{
35433543
UniValue obj(UniValue::VOBJ);
35443544
CPubKey pubkey;
3545-
if (provider && provider->GetPubKey(CKeyID(id), pubkey)) {
3545+
if (provider && provider->GetPubKey(ToKeyID(id), pubkey)) {
35463546
obj.pushKV("pubkey", HexStr(pubkey));
35473547
}
35483548
return obj;

0 commit comments

Comments
 (0)