@@ -34,14 +34,14 @@ 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" )
@@ -60,16 +60,35 @@ def setup_network(self, split=False):
60
60
"-addresstype=legacy" , # To make sure bitcoind gives back p2pkh no matter version
61
61
"-deprecatedrpc=validateaddress" ,
62
62
])
63
- else :
63
+ elif self .options .parent_type == 'signet' :
64
+ self .parent_chain = 'signet'
65
+ rpc_u , rpc_p = rpc_auth_pair (n )
66
+ self .extra_args .append ([
67
+ "-printtoconsole=0" ,
68
+ "-signet_blockscript=4104db082f6133b7d9cdb7be60d8384c818ae61233c20485b438e8c1d7772b7f2dbdc04f2f7273d534df0e6a54c8b333994f6275bb921df2438e9a672438e4ed4969ac" ,
69
+ "-signet_siglen=77" ,
70
+ "-signet_seednode=178.128.221.177" ,
71
+ "-port=" + str (p2p_port (n )),
72
+ "-rpcuser=" + rpc_u ,
73
+ "-rpcpassword=" + rpc_p ,
74
+ "-rpcport=" + str (rpc_port (n )),
75
+ "-addresstype=legacy" , # To make sure bitcoind gives back p2pkh no matter version
76
+ "-deprecatedrpc=validateaddress" ,
77
+ "-fallbackfee=0.00001" ,
78
+ ])
79
+ elif self .options .parent_type == 'elements' :
64
80
self .parent_chain = 'parent'
65
81
self .extra_args .append ([
66
82
"-printtoconsole=0" ,
67
83
'-validatepegin=0' ,
68
84
'-anyonecanspendaremine' ,
69
85
'-initialfreecoins=2100000000000000' ,
70
86
])
87
+
71
88
self .binary = self .options .parent_binpath if self .options .parent_binpath != "" else None
72
89
self .nodes .append (start_node (n , self .options .tmpdir , self .extra_args [n ], binary = self .binary , chain = self .parent_chain ))
90
+ if self .options .parent_type == 'signet' :
91
+ self .nodes [n ].importprivkey ('8Hh8jNjkx1aSCgEk3iq9Vo2APZUSDQJVt3rJ2BRpb5Tavqb68vW' )
73
92
74
93
connect_nodes_bi (self .nodes , 0 , 1 )
75
94
self .parentgenesisblockhash = self .nodes [0 ].getblockhash (0 )
@@ -102,6 +121,14 @@ def setup_network(self, split=False):
102
121
'-con_parent_chain_signblockscript=%s' % parent_chain_signblockscript ,
103
122
'-con_parent_pegged_asset=%s' % parent_pegged_asset ,
104
123
])
124
+ elif self .options .parent_type == 'signet' :
125
+ args .extend ([
126
+ '-con_parent_is_signet=1' ,
127
+ '-con_parent_signet_siglen=77' ,
128
+ '-parentpubkeyprefix=125' ,
129
+ '-parentscriptprefix=87' ,
130
+ '-con_parent_chain_signblockscript=4104db082f6133b7d9cdb7be60d8384c818ae61233c20485b438e8c1d7772b7f2dbdc04f2f7273d534df0e6a54c8b333994f6275bb921df2438e9a672438e4ed4969ac' ,
131
+ ])
105
132
self .extra_args .append (args )
106
133
self .nodes .append (start_node (n + 2 , self .options .tmpdir , self .extra_args [n + 2 ], chain = 'sidechain' ))
107
134
@@ -126,13 +153,21 @@ def test_pegout(self, parent_chain_addr, sidechain):
126
153
break
127
154
assert pegout_tested
128
155
156
+ # TODO Remove when signet supports generate
157
+ def parent_generate (self , parent , n_blocks ):
158
+ if self .options .parent_type == 'signet' :
159
+ for i in range (0 , n_blocks ):
160
+ blockhex = parent .getnewblockhex (True )
161
+ else :
162
+ parent .generate (n_blocks )
163
+
129
164
def run_test (self ):
130
165
parent = self .nodes [0 ]
131
166
parent2 = self .nodes [1 ]
132
167
sidechain = self .nodes [2 ]
133
168
sidechain2 = self .nodes [3 ]
134
169
135
- parent . generate ( 101 )
170
+ self . parent_generate ( parent , 101 )
136
171
sidechain .generate (101 )
137
172
138
173
addrs = sidechain .getpeginaddress ()
@@ -141,7 +176,7 @@ def run_test(self):
141
176
print (parent .validateaddress (addr ))
142
177
txid1 = parent .sendtoaddress (addr , 24 )
143
178
# 10+2 confirms required to get into mempool and confirm
144
- parent . generate ( 1 )
179
+ self . parent_generate ( parent , 1 )
145
180
time .sleep (2 )
146
181
proof = parent .gettxoutproof ([txid1 ])
147
182
@@ -158,7 +193,7 @@ def run_test(self):
158
193
assert ("Peg-in Bitcoin transaction needs more confirmations to be sent." in e .error ["message" ])
159
194
160
195
# Second attempt simply doesn't hit mempool bar
161
- parent . generate ( 10 )
196
+ self . parent_generate ( parent , 10 )
162
197
try :
163
198
pegtxid = sidechain .claimpegin (raw , proof )
164
199
raise Exception ("Peg-in should not be mature enough yet, need another block." )
@@ -183,7 +218,7 @@ def run_test(self):
183
218
assert ("Given claim_script does not match the given Bitcoin transaction." in e .error ["message" ])
184
219
185
220
# 12 confirms allows in mempool
186
- parent . generate ( 1 )
221
+ self . parent_generate ( parent , 1 )
187
222
# Should succeed via wallet lookup for address match, and when given
188
223
pegtxid1 = sidechain .claimpegin (raw , proof )
189
224
@@ -234,7 +269,7 @@ def run_test(self):
234
269
for i in range (n_claims ):
235
270
addrs = sidechain .getpeginaddress ()
236
271
txid = parent .sendtoaddress (addrs ["mainchain_address" ], 1 )
237
- parent . generate ( 12 )
272
+ self . parent_generate ( parent , 12 )
238
273
proof = parent .gettxoutproof ([txid ])
239
274
raw = parent .getrawtransaction (txid )
240
275
pegtxs += [sidechain .claimpegin (raw , proof )]
@@ -249,11 +284,13 @@ def run_test(self):
249
284
print ("Test pegout" )
250
285
self .test_pegout (get_new_unconfidential_address (parent ), sidechain )
251
286
252
- print ("Test pegout P2SH" )
253
- parent_chain_addr = get_new_unconfidential_address (parent )
254
- parent_pubkey = parent .validateaddress (parent_chain_addr )["pubkey" ]
255
- parent_chain_p2sh_addr = parent .createmultisig (1 , [parent_pubkey ])["address" ]
256
- self .test_pegout (parent_chain_p2sh_addr , sidechain )
287
+ # TODO Stop skipping this test once signet is rebased on top of 0.17
288
+ if not self .options .parent_type == 'signet' :
289
+ print ("Test pegout P2SH" )
290
+ parent_chain_addr = get_new_unconfidential_address (parent )
291
+ parent_pubkey = parent .validateaddress (parent_chain_addr )["pubkey" ]
292
+ parent_chain_p2sh_addr = parent .createmultisig (1 , [parent_pubkey ])["address" ]
293
+ self .test_pegout (parent_chain_p2sh_addr , sidechain )
257
294
258
295
print ("Test pegout Garbage" )
259
296
parent_chain_addr = "garbage"
@@ -290,7 +327,7 @@ def run_test(self):
290
327
print ("Now test failure to validate peg-ins based on intermittant bitcoind rpc failure" )
291
328
stop_node (self .nodes [1 ], 1 )
292
329
txid = parent .sendtoaddress (addr , 1 )
293
- parent . generate ( 12 )
330
+ self . parent_generate ( parent , 12 )
294
331
proof = parent .gettxoutproof ([txid ])
295
332
raw = parent .getrawtransaction (txid )
296
333
stuck_peg = sidechain .claimpegin (raw , proof )
0 commit comments