mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-20 22:04:19 +02:00
Use explicit conversion from WitnessV0KeyHash -> CKeyID
These types are equivalent, in data etc, so they need only their data cast across.
This commit is contained in:
parent
2c54217f91
commit
f32c1e07fd
@ -183,7 +183,7 @@ CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination&
|
|||||||
return ToKeyID(*id);
|
return ToKeyID(*id);
|
||||||
}
|
}
|
||||||
if (auto witness_id = boost::get<WitnessV0KeyHash>(&dest)) {
|
if (auto witness_id = boost::get<WitnessV0KeyHash>(&dest)) {
|
||||||
return CKeyID(*witness_id);
|
return ToKeyID(*witness_id);
|
||||||
}
|
}
|
||||||
if (auto script_hash = boost::get<ScriptHash>(&dest)) {
|
if (auto script_hash = boost::get<ScriptHash>(&dest)) {
|
||||||
CScript script;
|
CScript script;
|
||||||
@ -191,7 +191,7 @@ CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination&
|
|||||||
CTxDestination inner_dest;
|
CTxDestination inner_dest;
|
||||||
if (store.GetCScript(script_id, script) && ExtractDestination(script, inner_dest)) {
|
if (store.GetCScript(script_id, script) && ExtractDestination(script, inner_dest)) {
|
||||||
if (auto inner_witness_id = boost::get<WitnessV0KeyHash>(&inner_dest)) {
|
if (auto inner_witness_id = boost::get<WitnessV0KeyHash>(&inner_dest)) {
|
||||||
return CKeyID(*inner_witness_id);
|
return ToKeyID(*inner_witness_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,11 @@ CKeyID ToKeyID(const PKHash& key_hash)
|
|||||||
return CKeyID{static_cast<uint160>(key_hash)};
|
return CKeyID{static_cast<uint160>(key_hash)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CKeyID ToKeyID(const WitnessV0KeyHash& key_hash)
|
||||||
|
{
|
||||||
|
return CKeyID{static_cast<uint160>(key_hash)};
|
||||||
|
}
|
||||||
|
|
||||||
WitnessV0ScriptHash::WitnessV0ScriptHash(const CScript& in)
|
WitnessV0ScriptHash::WitnessV0ScriptHash(const CScript& in)
|
||||||
{
|
{
|
||||||
CSHA256().Write(in.data(), in.size()).Finalize(begin());
|
CSHA256().Write(in.data(), in.size()).Finalize(begin());
|
||||||
|
@ -106,6 +106,7 @@ struct WitnessV0KeyHash : public uint160
|
|||||||
explicit WitnessV0KeyHash(const uint160& hash) : uint160(hash) {}
|
explicit WitnessV0KeyHash(const uint160& hash) : uint160(hash) {}
|
||||||
explicit WitnessV0KeyHash(const CPubKey& pubkey);
|
explicit WitnessV0KeyHash(const CPubKey& pubkey);
|
||||||
};
|
};
|
||||||
|
CKeyID ToKeyID(const WitnessV0KeyHash& key_hash);
|
||||||
|
|
||||||
//! CTxDestination subtype to encode any future Witness version
|
//! CTxDestination subtype to encode any future Witness version
|
||||||
struct WitnessUnknown
|
struct WitnessUnknown
|
||||||
|
@ -3542,7 +3542,7 @@ public:
|
|||||||
{
|
{
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
CPubKey pubkey;
|
CPubKey pubkey;
|
||||||
if (provider && provider->GetPubKey(CKeyID(id), pubkey)) {
|
if (provider && provider->GetPubKey(ToKeyID(id), pubkey)) {
|
||||||
obj.pushKV("pubkey", HexStr(pubkey));
|
obj.pushKV("pubkey", HexStr(pubkey));
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user