|
25 | 25 | DUMMY_P2WPKH_SCRIPT = CScript([b'a' * 21])
|
26 | 26 | DUMMY_2_P2WPKH_SCRIPT = CScript([b'b' * 21])
|
27 | 27 |
|
28 |
| -def keyhash_to_p2pkh_script(hash, main = False): |
| 28 | +def keyhash_to_p2pkh_script(hash): |
29 | 29 | assert len(hash) == 20
|
30 | 30 | return CScript([OP_DUP, OP_HASH160, hash, OP_EQUALVERIFY, OP_CHECKSIG])
|
31 | 31 |
|
32 |
| -def scripthash_to_p2sh_script(hash, main = False): |
| 32 | +def scripthash_to_p2sh_script(hash): |
33 | 33 | assert len(hash) == 20
|
34 | 34 | return CScript([OP_HASH160, hash, OP_EQUAL])
|
35 | 35 |
|
36 |
| -def key_to_p2pkh_script(key, main = False): |
| 36 | +def key_to_p2pkh_script(key): |
37 | 37 | key = check_key(key)
|
38 |
| - return keyhash_to_p2pkh_script(hash160(key), main) |
| 38 | + return keyhash_to_p2pkh_script(hash160(key)) |
39 | 39 |
|
40 |
| -def script_to_p2sh_script(script, main = False): |
| 40 | +def script_to_p2sh_script(script): |
41 | 41 | script = check_script(script)
|
42 |
| - return scripthash_to_p2sh_script(hash160(script), main) |
| 42 | + return scripthash_to_p2sh_script(hash160(script)) |
43 | 43 |
|
44 |
| -def key_to_p2sh_p2wpkh_script(key, main = False): |
| 44 | +def key_to_p2sh_p2wpkh_script(key): |
45 | 45 | key = check_key(key)
|
46 | 46 | p2shscript = CScript([OP_0, hash160(key)])
|
47 |
| - return script_to_p2sh_script(p2shscript, main) |
| 47 | + return script_to_p2sh_script(p2shscript) |
48 | 48 |
|
49 |
| -def program_to_witness_script(version, program, main = False): |
| 49 | +def program_to_witness_script(version, program): |
50 | 50 | if isinstance(program, str):
|
51 | 51 | program = bytes.fromhex(program)
|
52 | 52 | assert 0 <= version <= 16
|
53 | 53 | assert 2 <= len(program) <= 40
|
54 | 54 | assert version > 0 or len(program) in [20, 32]
|
55 | 55 | return CScript([version, program])
|
56 | 56 |
|
57 |
| -def script_to_p2wsh_script(script, main = False): |
| 57 | +def script_to_p2wsh_script(script): |
58 | 58 | script = check_script(script)
|
59 |
| - return program_to_witness_script(0, sha256(script), main) |
| 59 | + return program_to_witness_script(0, sha256(script)) |
60 | 60 |
|
61 |
| -def key_to_p2wpkh_script(key, main = False): |
| 61 | +def key_to_p2wpkh_script(key): |
62 | 62 | key = check_key(key)
|
63 |
| - return program_to_witness_script(0, hash160(key), main) |
| 63 | + return program_to_witness_script(0, hash160(key)) |
64 | 64 |
|
65 |
| -def script_to_p2sh_p2wsh_script(script, main = False): |
| 65 | +def script_to_p2sh_p2wsh_script(script): |
66 | 66 | script = check_script(script)
|
67 | 67 | p2shscript = CScript([OP_0, sha256(script)])
|
68 |
| - return script_to_p2sh_script(p2shscript, main) |
| 68 | + return script_to_p2sh_script(p2shscript) |
69 | 69 |
|
70 | 70 | def check_key(key):
|
71 | 71 | if isinstance(key, str):
|
|
0 commit comments