diff options
| author | Ben Woosley <[email protected]> | 2020-01-15 13:41:25 -0800 |
|---|---|---|
| committer | Ben Woosley <[email protected]> | 2020-06-19 12:14:08 -0700 |
| commit | f32c1e07fd6c174ff3f6406a619550d2f6c19360 (patch) | |
| tree | 12c70ed12c60e6feea3e6228c15bf12a7c64a6df /src/script | |
| parent | Use explicit conversion from PKHash -> CKeyID (diff) | |
| download | discoin-f32c1e07fd6c174ff3f6406a619550d2f6c19360.tar.xz discoin-f32c1e07fd6c174ff3f6406a619550d2f6c19360.zip | |
Use explicit conversion from WitnessV0KeyHash -> CKeyID
These types are equivalent, in data etc, so they need only their
data cast across.
Diffstat (limited to 'src/script')
| -rw-r--r-- | src/script/signingprovider.cpp | 4 | ||||
| -rw-r--r-- | src/script/standard.cpp | 5 | ||||
| -rw-r--r-- | src/script/standard.h | 1 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/script/signingprovider.cpp b/src/script/signingprovider.cpp index a4eb0a839..2d8dc7d47 100644 --- a/src/script/signingprovider.cpp +++ b/src/script/signingprovider.cpp @@ -183,7 +183,7 @@ CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& return ToKeyID(*id); } if (auto witness_id = boost::get<WitnessV0KeyHash>(&dest)) { - return CKeyID(*witness_id); + return ToKeyID(*witness_id); } if (auto script_hash = boost::get<ScriptHash>(&dest)) { CScript script; @@ -191,7 +191,7 @@ CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& CTxDestination inner_dest; if (store.GetCScript(script_id, script) && ExtractDestination(script, inner_dest)) { if (auto inner_witness_id = boost::get<WitnessV0KeyHash>(&inner_dest)) { - return CKeyID(*inner_witness_id); + return ToKeyID(*inner_witness_id); } } } diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 4b408d82e..a47ccef84 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -28,6 +28,11 @@ CKeyID ToKeyID(const PKHash& 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) { CSHA256().Write(in.data(), in.size()).Finalize(begin()); diff --git a/src/script/standard.h b/src/script/standard.h index 1c630744b..6c882e92a 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -106,6 +106,7 @@ struct WitnessV0KeyHash : public uint160 explicit WitnessV0KeyHash(const uint160& hash) : uint160(hash) {} explicit WitnessV0KeyHash(const CPubKey& pubkey); }; +CKeyID ToKeyID(const WitnessV0KeyHash& key_hash); //! CTxDestination subtype to encode any future Witness version struct WitnessUnknown |