Skip to content

Commit

Permalink
Prefer explicit uint160 conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Empact committed Jun 19, 2020
1 parent f3d776b commit 0a5ea32
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ static UniValue decodescript(const JSONRPCRequest& request)
if (which_type == TX_PUBKEY) {
segwitScr = GetScriptForDestination(WitnessV0KeyHash(Hash160(solutions_data[0].begin(), solutions_data[0].end())));
} else if (which_type == TX_PUBKEYHASH) {
segwitScr = GetScriptForDestination(WitnessV0KeyHash(solutions_data[0]));
segwitScr = GetScriptForDestination(WitnessV0KeyHash(uint160{solutions_data[0]}));
} else {
// Scripts that are not fit for P2WPKH are encoded as P2WSH.
// Newer segwit program versions should be considered when then become available.
Expand Down
2 changes: 1 addition & 1 deletion src/script/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ CScript GetScriptForWitness(const CScript& redeemscript)
if (typ == TX_PUBKEY) {
return GetScriptForDestination(WitnessV0KeyHash(Hash160(vSolutions[0].begin(), vSolutions[0].end())));
} else if (typ == TX_PUBKEYHASH) {
return GetScriptForDestination(WitnessV0KeyHash(vSolutions[0]));
return GetScriptForDestination(WitnessV0KeyHash(uint160{vSolutions[0]}));
}
return GetScriptForDestination(WitnessV0ScriptHash(redeemscript));
}
Expand Down
4 changes: 0 additions & 4 deletions src/script/standard.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ struct PKHash : public uint160
PKHash() : uint160() {}
explicit PKHash(const uint160& hash) : uint160(hash) {}
explicit PKHash(const CPubKey& pubkey);
using uint160::uint160;
};

struct WitnessV0KeyHash;
Expand All @@ -91,22 +90,19 @@ struct ScriptHash : public uint160
explicit ScriptHash(const PKHash& hash) = delete;
explicit ScriptHash(const uint160& hash) : uint160(hash) {}
explicit ScriptHash(const CScript& script);
using uint160::uint160;
};

struct WitnessV0ScriptHash : public uint256
{
WitnessV0ScriptHash() : uint256() {}
explicit WitnessV0ScriptHash(const uint256& hash) : uint256(hash) {}
explicit WitnessV0ScriptHash(const CScript& script);
using uint256::uint256;
};

struct WitnessV0KeyHash : public uint160
{
WitnessV0KeyHash() : uint160() {}
explicit WitnessV0KeyHash(const uint160& hash) : uint160(hash) {}
using uint160::uint160;
};

//! CTxDestination subtype to encode any future Witness version
Expand Down

0 comments on commit 0a5ea32

Please sign in to comment.