aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_segwit.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-06-28 20:45:04 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-07-05 20:40:52 +0200
commit905d672b743edf31531d095ffe800449eaffec69 (patch)
treee027a699270a2c863d944573fa30265060516ba4 /test/functional/feature_segwit.py
parent285a65ccfde2e811cfe01e916b998c02ee534a97 (diff)
downloadbitcoin-905d672b743edf31531d095ffe800449eaffec69.tar.xz
test: use script_util helpers for creating P2W{PKH,SH} scripts
Diffstat (limited to 'test/functional/feature_segwit.py')
-rwxr-xr-xtest/functional/feature_segwit.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/test/functional/feature_segwit.py b/test/functional/feature_segwit.py
index dadccbd73e..9cf46d9d11 100755
--- a/test/functional/feature_segwit.py
+++ b/test/functional/feature_segwit.py
@@ -23,7 +23,6 @@ from test_framework.messages import (
CTransaction,
CTxIn,
CTxOut,
- sha256,
tx_from_hex,
)
from test_framework.script import (
@@ -35,11 +34,12 @@ from test_framework.script import (
OP_CHECKSIG,
OP_DROP,
OP_TRUE,
- hash160,
)
from test_framework.script_util import (
key_to_p2pkh_script,
+ key_to_p2wpkh_script,
script_to_p2sh_script,
+ script_to_p2wsh_script,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
@@ -428,9 +428,9 @@ class SegWitTest(BitcoinTestFramework):
# 2N7MGY19ti4KDMSzRfPAssP6Pxyuxoi6jLe is the P2SH(P2PKH) version of mjoE3sSrb8ByYEvgnC3Aox86u1CHnfJA4V
unsolvable_address_key = hex_str_to_bytes("02341AEC7587A51CDE5279E0630A531AEA2615A9F80B17E8D9376327BAEAA59E3D")
unsolvablep2pkh = key_to_p2pkh_script(unsolvable_address_key)
- unsolvablep2wshp2pkh = CScript([OP_0, sha256(unsolvablep2pkh)])
+ unsolvablep2wshp2pkh = script_to_p2wsh_script(unsolvablep2pkh)
p2shop0 = script_to_p2sh_script(op0)
- p2wshop1 = CScript([OP_0, sha256(op1)])
+ p2wshop1 = script_to_p2wsh_script(op1)
unsolvable_after_importaddress.append(unsolvablep2pkh)
unsolvable_after_importaddress.append(unsolvablep2wshp2pkh)
unsolvable_after_importaddress.append(op1) # OP_1 will be imported as script
@@ -450,16 +450,16 @@ class SegWitTest(BitcoinTestFramework):
if (v['isscript']):
bare = hex_str_to_bytes(v['hex'])
importlist.append(bare.hex())
- importlist.append(CScript([OP_0, sha256(bare)]).hex())
+ importlist.append(script_to_p2wsh_script(bare).hex())
else:
pubkey = hex_str_to_bytes(v['pubkey'])
p2pk = CScript([pubkey, OP_CHECKSIG])
p2pkh = key_to_p2pkh_script(pubkey)
importlist.append(p2pk.hex())
importlist.append(p2pkh.hex())
- importlist.append(CScript([OP_0, hash160(pubkey)]).hex())
- importlist.append(CScript([OP_0, sha256(p2pk)]).hex())
- importlist.append(CScript([OP_0, sha256(p2pkh)]).hex())
+ importlist.append(key_to_p2wpkh_script(pubkey).hex())
+ importlist.append(script_to_p2wsh_script(p2pk).hex())
+ importlist.append(script_to_p2wsh_script(p2pkh).hex())
importlist.append(unsolvablep2pkh.hex())
importlist.append(unsolvablep2wshp2pkh.hex())
@@ -614,20 +614,20 @@ class SegWitTest(BitcoinTestFramework):
def p2sh_address_to_script(self, v):
bare = CScript(hex_str_to_bytes(v['hex']))
p2sh = CScript(hex_str_to_bytes(v['scriptPubKey']))
- p2wsh = CScript([OP_0, sha256(bare)])
+ p2wsh = script_to_p2wsh_script(bare)
p2sh_p2wsh = script_to_p2sh_script(p2wsh)
return([bare, p2sh, p2wsh, p2sh_p2wsh])
def p2pkh_address_to_script(self, v):
pubkey = hex_str_to_bytes(v['pubkey'])
- p2wpkh = CScript([OP_0, hash160(pubkey)])
+ p2wpkh = key_to_p2wpkh_script(pubkey)
p2sh_p2wpkh = script_to_p2sh_script(p2wpkh)
p2pk = CScript([pubkey, OP_CHECKSIG])
p2pkh = CScript(hex_str_to_bytes(v['scriptPubKey']))
p2sh_p2pk = script_to_p2sh_script(p2pk)
p2sh_p2pkh = script_to_p2sh_script(p2pkh)
- p2wsh_p2pk = CScript([OP_0, sha256(p2pk)])
- p2wsh_p2pkh = CScript([OP_0, sha256(p2pkh)])
+ p2wsh_p2pk = script_to_p2wsh_script(p2pk)
+ p2wsh_p2pkh = script_to_p2wsh_script(p2pkh)
p2sh_p2wsh_p2pk = script_to_p2sh_script(p2wsh_p2pk)
p2sh_p2wsh_p2pkh = script_to_p2sh_script(p2wsh_p2pkh)
return [p2wpkh, p2sh_p2wpkh, p2pk, p2pkh, p2sh_p2pk, p2sh_p2pkh, p2wsh_p2pk, p2wsh_p2pkh, p2sh_p2wsh_p2pk, p2sh_p2wsh_p2pkh]