@@ -34,18 +34,46 @@ def add_options(self, parser):
34
34
parser .add_option ("--parent_binpath" , dest = "parent_binpath" , default = "" ,
35
35
help = "Use a different binary for launching nodes" )
36
36
parser .add_option ("--parent_type" , dest = "parent_type" , default = "elements" ,
37
- help = "Type of parent nodes {elements, bitcoin}" )
37
+ help = "Type of parent nodes {elements, bitcoin, signet }" )
38
38
39
39
def setup_network (self , split = False ):
40
40
self .nodes = []
41
41
self .extra_args = []
42
42
43
- if self .options .parent_type not in ['elements' , 'bitcoin' ]:
44
- raise Exception ("Invalid option --parent_type=%s, valid options: elements, bitcoin" % self .options .parent_type )
43
+ if self .options .parent_type not in ['elements' , 'bitcoin' , 'signet' ]:
44
+ raise Exception ("Invalid option --parent_type=%s, valid values: { elements, bitcoin, signet} " % self .options .parent_type )
45
45
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
+ self .binary = self .options .parent_binpath if self .options .parent_binpath != "" else None
50
+
51
+ if self .options .parent_type == 'signet' :
52
+ from binascii import hexlify
53
+ from test_framework import script , key
54
+ from test_framework .util import hex_str_to_bytes
55
+ import shutil
56
+ temp_args = [
57
+ "-port=" + str (p2p_port (0 )),
58
+ "-rpcport=" + str (rpc_port (0 )),
59
+ "-addresstype=legacy" ,
60
+ "-deprecatedrpc=validateaddress"
61
+ ]
62
+ temp_node = start_node (0 , self .options .tmpdir , temp_args , binary = self .binary , chain = 'signet' , cookie_auth = True )
63
+ addr = temp_node .getnewaddress ()
64
+ k = key .CECKey ()
65
+ pub = temp_node .validateaddress (addr )["pubkey" ]
66
+ k .set_pubkey (hex_str_to_bytes (pub ))
67
+ pubkey = key .CPubKey (k .get_pubkey ())
68
+ wif = temp_node .dumpprivkey (addr )
69
+ stop_node (temp_node , 0 )
70
+ shutil .rmtree (os .path .join (self .options .tmpdir , 'node0' , 'signet' ))
71
+ script = script .CScript ([pubkey , script .OP_CHECKSIG ])
72
+ blockscript = hexlify (script ).decode ('ascii' )
73
+
74
+ print ('blockscript' , blockscript )
75
+ print ('wif' , wif )
76
+
49
77
# Parent chain args
50
78
for n in range (2 ):
51
79
# We want to test the rpc cookie method so we force the use of a
@@ -62,7 +90,21 @@ def setup_network(self, split=False):
62
90
"-port=" + str (p2p_port (n )),
63
91
"-rpcport=" + str (rpc_port (n ))
64
92
])
65
- else :
93
+ elif self .options .parent_type == 'signet' :
94
+ self .parent_chain = 'signet'
95
+ rpc_u , rpc_p = rpc_auth_pair (n )
96
+ self .extra_args .append ([
97
+ "-printtoconsole=0" ,
98
+ "-signet_blockscript=%s" % blockscript ,
99
+ "-signet_siglen=77" ,
100
+ "-signet_seednode=178.128.221.177" ,
101
+ "-port=" + str (p2p_port (n )),
102
+ "-rpcport=" + str (rpc_port (n )),
103
+ "-addresstype=legacy" , # To make sure bitcoind gives back p2pkh no matter version
104
+ "-deprecatedrpc=validateaddress" ,
105
+ "-fallbackfee=0.00001" ,
106
+ ])
107
+ elif self .options .parent_type == 'elements' :
66
108
self .parent_chain = 'parent'
67
109
self .extra_args .append ([
68
110
"-conf=dummy" ,
@@ -77,8 +119,9 @@ def setup_network(self, split=False):
77
119
if not use_cookie_auth :
78
120
self .extra_args [n ].extend (["-rpcuser=" + rpc_u , "-rpcpassword=" + rpc_p ])
79
121
80
- self .binary = self .options .parent_binpath if self .options .parent_binpath != "" else None
81
122
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 ))
123
+ if self .options .parent_type == 'signet' :
124
+ self .nodes [n ].importprivkey (wif )
82
125
83
126
connect_nodes_bi (self .nodes , 0 , 1 )
84
127
self .parentgenesisblockhash = self .nodes [0 ].getblockhash (0 )
@@ -111,6 +154,14 @@ def setup_network(self, split=False):
111
154
'-con_parent_chain_signblockscript=%s' % parent_chain_signblockscript ,
112
155
'-con_parent_pegged_asset=%s' % parent_pegged_asset ,
113
156
])
157
+ elif self .options .parent_type == 'signet' :
158
+ args .extend ([
159
+ '-con_parent_is_signet=1' ,
160
+ '-con_parent_signet_siglen=77' ,
161
+ '-parentpubkeyprefix=125' ,
162
+ '-parentscriptprefix=87' ,
163
+ '-con_parent_chain_signblockscript=%s' % blockscript ,
164
+ ])
114
165
115
166
if used_cookie_auth :
116
167
# Need to specify where to find parent cookie file
0 commit comments