17
17
send_to_witness ,
18
18
witness_script ,
19
19
)
20
+ from test_framework .descriptors import descsum_create
20
21
from test_framework .messages import (
21
22
COIN ,
22
23
COutPoint ,
48
49
assert_raises_rpc_error ,
49
50
try_rpc ,
50
51
)
51
-
52
52
from test_framework .wallet_util import (
53
53
get_generate_key ,
54
54
)
55
+
55
56
NODE_0 = 0
56
57
NODE_2 = 2
57
58
P2WPKH = 0
@@ -112,7 +113,7 @@ def setup_network(self):
112
113
self .sync_all ()
113
114
114
115
def success_mine (self , node , txid , sign , redeem_script = "" ):
115
- send_to_witness (1 , node , getutxo (txid ), self .pubkey [0 ], False , Decimal ("49 .998" ), sign , redeem_script )
116
+ send_to_witness (1 , node , getutxo (txid ), self .pubkey [0 ], False , Decimal ("199 .998" ), sign , redeem_script )
116
117
block = self .generate (node , 1 )
117
118
assert_equal (len (node .getblock (block [0 ])["tx" ]), 2 )
118
119
self .sync_blocks ()
@@ -126,12 +127,12 @@ def run_test(self):
126
127
self .log .info ("Verify sigops are counted in GBT with pre-BIP141 rules before the fork" )
127
128
txid = self .nodes [0 ].sendtoaddress (self .nodes [0 ].getnewaddress (), 1 )
128
129
tmpl = self .nodes [0 ].getblocktemplate ({'rules' : ['segwit' ]})
129
- assert_equal (tmpl ['sizelimit' ], 100000 )
130
- assert 'weightlimit' not in tmpl
131
- assert_equal (tmpl ['sigoplimit' ], 20000 )
132
- assert_equal (tmpl ['transactions' ][0 ]['hash' ], txid )
133
- assert_equal (tmpl ['transactions' ][0 ]['sigops' ], 2 )
134
- assert '!segwit' not in tmpl ['rules' ]
130
+ assert_equal (tmpl ['sizelimit' ], 400000 )
131
+ # assert 'weightlimit' not in tmpl Commented out because Bitgesell defaults to segwit
132
+ assert_equal (tmpl ['sigoplimit' ], 80000 )
133
+ # assert_equal(tmpl['transactions'][0]['hash'], txid) Commented out because Bitgesell defaults to segwit
134
+ assert_equal (tmpl ['transactions' ][0 ]['sigops' ], 9 )
135
+ # assert '!segwit' not in tmpl['rules'] Commented out because Bitgesell defaults to segwit
135
136
self .generate (self .nodes [0 ], 1 ) # block 162
136
137
137
138
balance_presetup = self .nodes [0 ].getbalance ()
@@ -147,6 +148,31 @@ def run_test(self):
147
148
bip173_ms_addr = self .nodes [i ].createmultisig (1 , [self .pubkey [- 1 ]], 'bech32' )['address' ]
148
149
assert_equal (p2sh_ms_addr , script_to_p2sh_p2wsh (multiscript ))
149
150
assert_equal (bip173_ms_addr , script_to_p2wsh (multiscript ))
151
+
152
+ p2sh_ms_desc = descsum_create (f"sh(wsh(multi(1,{ key .privkey } )))" )
153
+ bip173_ms_desc = descsum_create (f"wsh(multi(1,{ key .privkey } ))" )
154
+ assert_equal (self .nodes [i ].deriveaddresses (p2sh_ms_desc )[0 ], p2sh_ms_addr )
155
+ assert_equal (self .nodes [i ].deriveaddresses (bip173_ms_desc )[0 ], bip173_ms_addr )
156
+
157
+ sh_wpkh_desc = descsum_create (f"sh(wpkh({ key .privkey } ))" )
158
+ wpkh_desc = descsum_create (f"wpkh({ key .privkey } )" )
159
+ assert_equal (self .nodes [i ].deriveaddresses (sh_wpkh_desc )[0 ], key .p2sh_p2wpkh_addr )
160
+ assert_equal (self .nodes [i ].deriveaddresses (wpkh_desc )[0 ], key .p2wpkh_addr )
161
+
162
+ if self .options .descriptors :
163
+ res = self .nodes [i ].importdescriptors ([
164
+ {"desc" : p2sh_ms_desc , "timestamp" : "now" },
165
+ {"desc" : bip173_ms_desc , "timestamp" : "now" },
166
+ {"desc" : sh_wpkh_desc , "timestamp" : "now" },
167
+ {"desc" : wpkh_desc , "timestamp" : "now" },
168
+ ])
169
+ else :
170
+ # The nature of the legacy wallet is that this import results in also adding all of the necessary scripts
171
+ res = self .nodes [i ].importmulti ([
172
+ {"desc" : p2sh_ms_desc , "timestamp" : "now" },
173
+ ])
174
+ assert all ([r ["success" ] for r in res ])
175
+
150
176
p2sh_ids .append ([])
151
177
wit_ids .append ([])
152
178
for _ in range (2 ):
@@ -156,15 +182,15 @@ def run_test(self):
156
182
for _ in range (5 ):
157
183
for n in range (3 ):
158
184
for v in range (2 ):
159
- wit_ids [n ][v ].append (send_to_witness (v , self .nodes [0 ], find_spendable_utxo (self .nodes [0 ], 50 ), self .pubkey [n ], False , Decimal ("49 .999" )))
160
- p2sh_ids [n ][v ].append (send_to_witness (v , self .nodes [0 ], find_spendable_utxo (self .nodes [0 ], 50 ), self .pubkey [n ], True , Decimal ("49 .999" )))
185
+ wit_ids [n ][v ].append (send_to_witness (v , self .nodes [0 ], find_spendable_utxo (self .nodes [0 ], 200 ), self .pubkey [n ], False , Decimal ("199 .999" )))
186
+ p2sh_ids [n ][v ].append (send_to_witness (v , self .nodes [0 ], find_spendable_utxo (self .nodes [0 ], 200 ), self .pubkey [n ], True , Decimal ("199 .999" )))
161
187
162
188
self .generate (self .nodes [0 ], 1 ) # block 163
163
189
164
190
# Make sure all nodes recognize the transactions as theirs
165
- assert_equal (self .nodes [0 ].getbalance (), balance_presetup - 60 * 50 + 20 * Decimal ("49 .999" ) + 50 )
166
- assert_equal (self .nodes [1 ].getbalance (), 20 * Decimal ("49 .999" ))
167
- assert_equal (self .nodes [2 ].getbalance (), 20 * Decimal ("49 .999" ))
191
+ assert_equal (self .nodes [0 ].getbalance (), balance_presetup - 60 * 200 + 20 * Decimal ("199 .999" ) + 200 )
192
+ assert_equal (self .nodes [1 ].getbalance (), 20 * Decimal ("199 .999" ))
193
+ assert_equal (self .nodes [2 ].getbalance (), 20 * Decimal ("199 .999" ))
168
194
169
195
self .log .info ("Verify unsigned p2sh witness txs without a redeem script are invalid" )
170
196
self .fail_accept (self .nodes [2 ], "mandatory-script-verify-flag-failed (Operation not valid with the current stack size)" , p2sh_ids [NODE_2 ][P2WPKH ][1 ], sign = False )
@@ -174,10 +200,10 @@ def run_test(self):
174
200
175
201
self .log .info ("Verify witness txs are mined as soon as segwit activates" )
176
202
177
- send_to_witness (1 , self .nodes [2 ], getutxo (wit_ids [NODE_2 ][P2WPKH ][0 ]), self .pubkey [0 ], encode_p2sh = False , amount = Decimal ("49 .998" ), sign = True )
178
- send_to_witness (1 , self .nodes [2 ], getutxo (wit_ids [NODE_2 ][P2WSH ][0 ]), self .pubkey [0 ], encode_p2sh = False , amount = Decimal ("49 .998" ), sign = True )
179
- send_to_witness (1 , self .nodes [2 ], getutxo (p2sh_ids [NODE_2 ][P2WPKH ][0 ]), self .pubkey [0 ], encode_p2sh = False , amount = Decimal ("49 .998" ), sign = True )
180
- send_to_witness (1 , self .nodes [2 ], getutxo (p2sh_ids [NODE_2 ][P2WSH ][0 ]), self .pubkey [0 ], encode_p2sh = False , amount = Decimal ("49 .998" ), sign = True )
203
+ send_to_witness (1 , self .nodes [2 ], getutxo (wit_ids [NODE_2 ][P2WPKH ][0 ]), self .pubkey [0 ], encode_p2sh = False , amount = Decimal ("199 .998" ), sign = True )
204
+ send_to_witness (1 , self .nodes [2 ], getutxo (wit_ids [NODE_2 ][P2WSH ][0 ]), self .pubkey [0 ], encode_p2sh = False , amount = Decimal ("199 .998" ), sign = True )
205
+ send_to_witness (1 , self .nodes [2 ], getutxo (p2sh_ids [NODE_2 ][P2WPKH ][0 ]), self .pubkey [0 ], encode_p2sh = False , amount = Decimal ("199 .998" ), sign = True )
206
+ send_to_witness (1 , self .nodes [2 ], getutxo (p2sh_ids [NODE_2 ][P2WSH ][0 ]), self .pubkey [0 ], encode_p2sh = False , amount = Decimal ("199 .998" ), sign = True )
181
207
182
208
assert_equal (len (self .nodes [2 ].getrawmempool ()), 4 )
183
209
blockhash = self .generate (self .nodes [2 ], 1 )[0 ] # block 165 (first block with new rules)
@@ -219,8 +245,8 @@ def run_test(self):
219
245
txid = self .nodes [0 ].sendtoaddress (self .nodes [0 ].getnewaddress (), 1 )
220
246
raw_tx = self .nodes [0 ].getrawtransaction (txid , True )
221
247
tmpl = self .nodes [0 ].getblocktemplate ({'rules' : ['segwit' ]})
222
- assert_greater_than_or_equal (tmpl ['sizelimit' ], 3999577 ) # actual maximum size is lower due to minimum mandatory non-witness data
223
- assert_equal (tmpl ['weightlimit' ], 4000000 )
248
+ assert_greater_than_or_equal (tmpl ['sizelimit' ], 399957 ) # actual maximum size is lower due to minimum mandatory non-witness data
249
+ assert_equal (tmpl ['weightlimit' ], 400000 )
224
250
assert_equal (tmpl ['sigoplimit' ], 80000 )
225
251
assert_equal (tmpl ['transactions' ][0 ]['txid' ], txid )
226
252
expected_sigops = 9 if 'txinwitness' in raw_tx ["vin" ][0 ] else 8
@@ -234,7 +260,7 @@ def run_test(self):
234
260
# tx2 (segwit input, paying to a non-segwit output) ->
235
261
# tx3 (non-segwit input, paying to a non-segwit output).
236
262
# tx1 is allowed to appear in the block, but no others.
237
- txid1 = send_to_witness (1 , self .nodes [0 ], find_spendable_utxo (self .nodes [0 ], 50 ), self .pubkey [0 ], False , Decimal ("49 .996" ))
263
+ txid1 = send_to_witness (1 , self .nodes [0 ], find_spendable_utxo (self .nodes [0 ], 200 ), self .pubkey [0 ], False , Decimal ("199 .996" ))
238
264
assert txid1 in self .nodes [0 ].getrawmempool ()
239
265
240
266
tx1_hex = self .nodes [0 ].gettransaction (txid1 )['hex' ]
@@ -250,7 +276,7 @@ def run_test(self):
250
276
# Now create tx2, which will spend from txid1.
251
277
tx = CTransaction ()
252
278
tx .vin .append (CTxIn (COutPoint (int (txid1 , 16 ), 0 ), b'' ))
253
- tx .vout .append (CTxOut (int (49 .99 * COIN ), CScript ([OP_TRUE , OP_DROP ] * 15 + [OP_TRUE ])))
279
+ tx .vout .append (CTxOut (int (199 .99 * COIN ), CScript ([OP_TRUE , OP_DROP ] * 15 + [OP_TRUE ])))
254
280
tx2_hex = self .nodes [0 ].signrawtransactionwithwallet (tx .serialize ().hex ())['hex' ]
255
281
txid2 = self .nodes [0 ].sendrawtransaction (tx2_hex )
256
282
tx = tx_from_hex (tx2_hex )
@@ -305,9 +331,9 @@ def run_test(self):
305
331
306
332
# Import a compressed key and an uncompressed key, generate some multisig addresses
307
333
self .nodes [0 ].importprivkey ("92e6XLo5jVAVwrQKPNTs93oQco8f8sDNBcpv73Dsrs397fQtFQn" )
308
- uncompressed_spendable_address = ["mvozP4UwyGD2mGZU4D2eMvMLPB9WkMmMQu " ]
334
+ uncompressed_spendable_address = ["EwnYZhXmJNXZntpoAuP72GPkvLJsyxUYJH " ]
309
335
self .nodes [0 ].importprivkey ("cNC8eQ5dg3mFAVePDX4ddmPYpPbw41r9bm2jd1nLJT77e6RrzTRR" )
310
- compressed_spendable_address = ["mmWQubrDomqpgSYekvsU7HWEVjLFHAakLe " ]
336
+ compressed_spendable_address = ["EnUy6Eu38tAMi4oysdDvmdYf2tVcYavA2C " ]
311
337
assert not self .nodes [0 ].getaddressinfo (uncompressed_spendable_address [0 ])['iscompressed' ]
312
338
assert self .nodes [0 ].getaddressinfo (compressed_spendable_address [0 ])['iscompressed' ]
313
339
@@ -472,9 +498,9 @@ def run_test(self):
472
498
# Repeat some tests. This time we don't add witness scripts with importaddress
473
499
# Import a compressed key and an uncompressed key, generate some multisig addresses
474
500
self .nodes [0 ].importprivkey ("927pw6RW8ZekycnXqBQ2JS5nPyo1yRfGNN8oq74HeddWSpafDJH" )
475
- uncompressed_spendable_address = ["mguN2vNSCEUh6rJaXoAVwY3YZwZvEmf5xi " ]
501
+ uncompressed_spendable_address = ["EhsvDZRFXLoE8UZueVWxbt5y76jHPyiucv " ]
476
502
self .nodes [0 ].importprivkey ("cMcrXaaUC48ZKpcyydfFo8PxHAjpsYLhdsp6nmtB3E2ER9UUHWnw" )
477
- compressed_spendable_address = ["n1UNmpmbVUJ9ytXYXiurmGPQ3TRrXqPWKL " ]
503
+ compressed_spendable_address = ["F2SvxTpQpach1WnseRGKRcRpacbDmYjDZi " ]
478
504
479
505
self .nodes [0 ].importpubkey (pubkeys [5 ])
480
506
compressed_solvable_address = [key_to_p2pkh (pubkeys [5 ])]
0 commit comments