@@ -46,6 +46,36 @@ def setup_network(self, split=False):
46
46
if self .options .parent_type == 'bitcoin' and self .options .parent_binpath == "" :
47
47
raise Exception ("Can't run with --parent_type=bitcoin without specifying --parent_binpath" )
48
48
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
+
49
79
# Parent chain args
50
80
for n in range (2 ):
51
81
# 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):
68
98
self .extra_args .append ([
69
99
"-printtoconsole=0" ,
70
100
"-signet_blockscript=4104db082f6133b7d9cdb7be60d8384c818ae61233c20485b438e8c1d7772b7f2dbdc04f2f7273d534df0e6a54c8b333994f6275bb921df2438e9a672438e4ed4969ac" ,
101
+ # "-signet_blockscript=%s" % blockscript,
71
102
"-signet_siglen=77" ,
72
103
"-signet_seednode=178.128.221.177" ,
73
104
"-port=" + str (p2p_port (n )),
@@ -95,6 +126,7 @@ def setup_network(self, split=False):
95
126
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 ))
96
127
if self .options .parent_type == 'signet' :
97
128
self .nodes [n ].importprivkey ('8Hh8jNjkx1aSCgEk3iq9Vo2APZUSDQJVt3rJ2BRpb5Tavqb68vW' )
129
+ # self.nodes[n].importprivkey(wif)
98
130
99
131
connect_nodes_bi (self .nodes , 0 , 1 )
100
132
self .parentgenesisblockhash = self .nodes [0 ].getblockhash (0 )
0 commit comments