aboutsummaryrefslogtreecommitdiff
path: root/src/script/standard.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-11-30 16:48:38 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2018-01-03 05:43:06 -0800
commit985c79552ceb6a5f5812d421dc5c86fa3b1cc41d (patch)
tree682a791059736fe9e74a5314df7536f576e16645 /src/script/standard.cpp
parentcbe197470ecc1f7b48771c4e7b654ab030af4c9e (diff)
Improve witness destination types and use them more
Diffstat (limited to 'src/script/standard.cpp')
-rw-r--r--src/script/standard.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/script/standard.cpp b/src/script/standard.cpp
index b7b33fade6..0d9f6ae1f9 100644
--- a/src/script/standard.cpp
+++ b/src/script/standard.cpp
@@ -348,19 +348,14 @@ CScript GetScriptForWitness(const CScript& redeemscript)
std::vector<std::vector<unsigned char> > vSolutions;
if (Solver(redeemscript, typ, vSolutions)) {
if (typ == TX_PUBKEY) {
- unsigned char h160[20];
- CHash160().Write(&vSolutions[0][0], vSolutions[0].size()).Finalize(h160);
- ret << OP_0 << std::vector<unsigned char>(&h160[0], &h160[20]);
- return ret;
+ return GetScriptForDestination(WitnessV0KeyHash(Hash160(vSolutions[0].begin(), vSolutions[0].end())));
} else if (typ == TX_PUBKEYHASH) {
- ret << OP_0 << vSolutions[0];
- return ret;
+ return GetScriptForDestination(WitnessV0KeyHash(vSolutions[0]));
}
}
uint256 hash;
CSHA256().Write(&redeemscript[0], redeemscript.size()).Finalize(hash.begin());
- ret << OP_0 << ToByteVector(hash);
- return ret;
+ return GetScriptForDestination(WitnessV0ScriptHash(hash));
}
bool IsValidDestination(const CTxDestination& dest) {