@@ -1276,6 +1276,25 @@ def spenders_taproot_nonstandard():
12761276
12771277 return spenders
12781278
1279+ def bip348_csfs_spenders_nonstandard ():
1280+ """Spenders for testing that pre-active CHECKSIGFROMSTACK usage is discouraged but valid"""
1281+
1282+ spenders = []
1283+
1284+ sec = generate_privkey ()
1285+ pub , _ = compute_xonly_pubkey (sec )
1286+ scripts = [
1287+ ("stilltrue" , CScript ([b'' , b'' , b'' , OP_CHECKSIGFROMSTACK ])),
1288+ ("still_opsuccess" , CScript ([OP_RETURN , OP_CHECKSIGFROMSTACK ,])),
1289+ ]
1290+ tap = taproot_construct (pub , scripts )
1291+
1292+ # Valid prior to activation but nonstandard
1293+ add_spender (spenders , "discouraged_csfs/stilltrue" , tap = tap , leaf = "stilltrue" , standard = False )
1294+ add_spender (spenders , "discouraged_csfs/still_opsuccess" , tap = tap , leaf = "still_opsuccess" , standard = False )
1295+
1296+ return spenders
1297+
12791298def bip348_csfs_spenders ():
12801299 secs = [generate_privkey () for _ in range (2 )]
12811300 pubs = [compute_xonly_pubkey (sec )[0 ] for sec in secs ]
@@ -1394,6 +1413,7 @@ def skip_test_if_missing_module(self):
13941413
13951414 def set_test_params (self ):
13961415 self .num_nodes = 1
1416+ self .extra_args = [["-vbparams=checksigfromstack:0:3999999999" ]]
13971417 self .setup_clean_chain = True
13981418
13991419 def block_submit (self , node , txs , msg , err_msg , cb_pubkey = None , fees = 0 , sigops_weight = 0 , witness = False , accept = False ):
@@ -1865,6 +1885,23 @@ def pr(node):
18651885 def run_test (self ):
18661886 self .gen_test_vectors ()
18671887
1888+ self .log .info ("CSFS Pre-activation tests..." )
1889+ assert_equal (self .nodes [0 ].getdeploymentinfo ()["deployments" ]["checksigfromstack" ]["heretical" ]["status" ],"defined" )
1890+ self .generate (self .nodes [0 ], 144 )
1891+ assert_equal (self .nodes [0 ].getdeploymentinfo ()["deployments" ]["checksigfromstack" ]["heretical" ]["status" ],"started" )
1892+ signal_ver = int (self .nodes [0 ].getdeploymentinfo ()["deployments" ]["checksigfromstack" ]["heretical" ]["signal_activate" ], 16 )
1893+
1894+ self .test_spenders (self .nodes [0 ], bip348_csfs_spenders_nonstandard (), input_counts = [1 , 2 ])
1895+
1896+ self .log .info ("Activating CSFS" )
1897+ now = self .nodes [0 ].getblock (self .nodes [0 ].getbestblockhash ())["time" ]
1898+ coinbase_tx = create_coinbase (self .nodes [0 ].getblockcount () + 1 )
1899+ block = create_block (hashprev = int (self .nodes [0 ].getbestblockhash (), 16 ), ntime = now , coinbase = coinbase_tx , version = signal_ver )
1900+ block .solve ()
1901+ res = self .nodes [0 ].submitblock (block .serialize ().hex ())
1902+ self .generate (self .nodes [0 ], 288 )
1903+ assert_equal (self .nodes [0 ].getdeploymentinfo ()["deployments" ]["checksigfromstack" ]["heretical" ]["status" ],"active" )
1904+
18681905 self .log .info ("Post-activation tests..." )
18691906 consensus_spenders = spenders_taproot_active () + bip348_csfs_spenders ()
18701907 self .test_spenders (self .nodes [0 ], consensus_spenders , input_counts = [1 , 2 , 2 , 2 , 2 , 3 ])
0 commit comments