Skip to content

Commit 4d9ad55

Browse files
committed
NOMERGE: WIP: Generator for signet's p2pk script and wif
1 parent b463d68 commit 4d9ad55

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

qa/rpc-tests/feature_fedpeg.py

+32
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,36 @@ def setup_network(self, split=False):
4646
if self.options.parent_type == 'bitcoin' and self.options.parent_binpath == "":
4747
raise Exception("Can't run with --parent_type=bitcoin without specifying --parent_binpath")
4848

49+
if self.options.parent_type == 'signet':
50+
import hashlib, random, codecs
51+
from test_framework import script, key, address
52+
from binascii import hexlify
53+
k = key.CECKey()
54+
pk_bytes = hashlib.sha256(str(random.getrandbits(256)).encode('utf-8')).digest()
55+
k.set_secretbytes(pk_bytes)
56+
wif = address.byte_to_base58(pk_bytes, 217)
57+
pubkey = key.CPubKey(k.get_pubkey())
58+
script = script.CScript([pubkey, script.OP_CHECKSIG])
59+
blockscript = hexlify(script).decode('ascii')
60+
print('blockscript', blockscript)
61+
print('wif', wif)
62+
63+
# import hashlib, random, codecs
64+
# from test_framework import script, key, address
65+
# k = key.CECKey()
66+
# pk_bytes = hashlib.sha256(str(random.getrandbits(256)).encode('utf-8')).digest()
67+
# k.set_secretbytes(pk_bytes)
68+
# w = address.byte_to_base58(pk_bytes, 217)
69+
# print("generated key {}: \n pub: {}\n wif: {}".format(n+1,
70+
# codecs.encode(k.get_pubkey(), 'hex_codec').decode("utf-8"),
71+
# w))
72+
# pubkey = key.CPubKey(k.get_pubkey())
73+
# script = script.CScript([pubkey, script.OP_CHECKSIG])
74+
# from binascii import hexlify
75+
# print('script', hexlify(script).decode('ascii'))
76+
# self.nodes[n].importprivkey(w)
77+
78+
4979
# Parent chain args
5080
for n in range(2):
5181
# We want to test the rpc cookie method so we force the use of a
@@ -68,6 +98,7 @@ def setup_network(self, split=False):
6898
self.extra_args.append([
6999
"-printtoconsole=0",
70100
"-signet_blockscript=4104db082f6133b7d9cdb7be60d8384c818ae61233c20485b438e8c1d7772b7f2dbdc04f2f7273d534df0e6a54c8b333994f6275bb921df2438e9a672438e4ed4969ac",
101+
# "-signet_blockscript=%s" % blockscript,
71102
"-signet_siglen=77",
72103
"-signet_seednode=178.128.221.177",
73104
"-port=" + str(p2p_port(n)),
@@ -95,6 +126,7 @@ def setup_network(self, split=False):
95126
self.nodes.append(start_node(n, self.options.tmpdir, self.extra_args[n], binary=self.binary, chain=self.parent_chain, cookie_auth=use_cookie_auth))
96127
if self.options.parent_type == 'signet':
97128
self.nodes[n].importprivkey('8Hh8jNjkx1aSCgEk3iq9Vo2APZUSDQJVt3rJ2BRpb5Tavqb68vW')
129+
# self.nodes[n].importprivkey(wif)
98130

99131
connect_nodes_bi(self.nodes, 0, 1)
100132
self.parentgenesisblockhash = self.nodes[0].getblockhash(0)

0 commit comments

Comments
 (0)