mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
Add P2WSH destination helper and use it instead of manual hashing
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <script/standard.h>
|
||||
|
||||
#include <crypto/sha256.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/script.h>
|
||||
#include <util.h>
|
||||
@@ -18,6 +19,11 @@ unsigned nMaxDatacarrierBytes = MAX_OP_RETURN_RELAY;
|
||||
|
||||
CScriptID::CScriptID(const CScript& in) : uint160(Hash160(in.begin(), in.end())) {}
|
||||
|
||||
WitnessV0ScriptHash::WitnessV0ScriptHash(const CScript& in)
|
||||
{
|
||||
CSHA256().Write(in.data(), in.size()).Finalize(begin());
|
||||
}
|
||||
|
||||
const char* GetTxnOutputType(txnouttype t)
|
||||
{
|
||||
switch (t)
|
||||
@@ -329,9 +335,7 @@ CScript GetScriptForWitness(const CScript& redeemscript)
|
||||
return GetScriptForDestination(WitnessV0KeyHash(vSolutions[0]));
|
||||
}
|
||||
}
|
||||
uint256 hash;
|
||||
CSHA256().Write(&redeemscript[0], redeemscript.size()).Finalize(hash.begin());
|
||||
return GetScriptForDestination(WitnessV0ScriptHash(hash));
|
||||
return GetScriptForDestination(WitnessV0ScriptHash(redeemscript));
|
||||
}
|
||||
|
||||
bool IsValidDestination(const CTxDestination& dest) {
|
||||
|
||||
Reference in New Issue
Block a user