|
10 | 10 | get_datadir_path, |
11 | 11 | rpc_port, |
12 | 12 | p2p_port, |
| 13 | + assert_raises_rpc_error, |
| 14 | + assert_equal, |
13 | 15 | ) |
14 | 16 | from decimal import Decimal |
15 | 17 |
|
@@ -53,9 +55,10 @@ def setup_network(self, split=False): |
53 | 55 | else: |
54 | 56 | extra_args.extend([ |
55 | 57 | "-validatepegin=0", |
56 | | - "-initialfreecoins=2100000000000000", |
| 58 | + "-initialfreecoins=0", |
57 | 59 | "-anyonecanspendaremine", |
58 | 60 | "-signblockscript=51", # OP_TRUE |
| 61 | + '-con_blocksubsidy=5000000000', |
59 | 62 | ]) |
60 | 63 |
|
61 | 64 | self.add_nodes(1, [extra_args], chain=[parent_chain], binary=parent_binary) |
@@ -390,7 +393,38 @@ def run_test(self): |
390 | 393 | # Make sure balance went down |
391 | 394 | assert(bal_2 + 1 < bal_1) |
392 | 395 |
|
393 | | - sidechain.sendtomainchain(some_btc_addr, bal_2, True) |
| 396 | + # Have bitcoin output go directly into a claim output |
| 397 | + pegin_info = sidechain.getpeginaddress() |
| 398 | + mainchain_addr = pegin_info["mainchain_address"] |
| 399 | + claim_script = pegin_info["claim_script"] |
| 400 | + # Watch the address so we can get tx without txindex |
| 401 | + parent.importaddress(mainchain_addr) |
| 402 | + claim_block = parent.generatetoaddress(50, mainchain_addr)[0] |
| 403 | + block_coinbase = parent.getblock(claim_block, 2)["tx"][0] |
| 404 | + claim_txid = block_coinbase["txid"] |
| 405 | + claim_tx = block_coinbase["hex"] |
| 406 | + claim_proof = parent.gettxoutproof([claim_txid], claim_block) |
| 407 | + |
| 408 | + # Can't claim something even though it has 50 confirms since it's coinbase |
| 409 | + assert_raises_rpc_error(-8, "Peg-in Bitcoin transaction needs more confirmations to be sent.", sidechain.claimpegin, claim_tx, claim_proof) |
| 410 | + # If done via raw API, still doesn't work |
| 411 | + coinbase_pegin = sidechain.createrawpegin(claim_tx, claim_proof) |
| 412 | + assert_equal(coinbase_pegin["mature"], False) |
| 413 | + signed_pegin = sidechain.signrawtransactionwithwallet(coinbase_pegin["hex"])["hex"] |
| 414 | + assert_raises_rpc_error(-26, "bad-pegin-witness, Needs more confirmations.", sidechain.sendrawtransaction, signed_pegin) |
| 415 | + |
| 416 | + # 50 more blocks to allow wallet to make it succeed by relay and consensus |
| 417 | + parent.generatetoaddress(50, parent.getnewaddress()) |
| 418 | + # Wallet still doesn't want to for 2 more confirms |
| 419 | + assert_equal(sidechain.createrawpegin(claim_tx, claim_proof)["mature"], False) |
| 420 | + # But we can just shoot it off |
| 421 | + claim_txid = sidechain.sendrawtransaction(signed_pegin) |
| 422 | + sidechain.generatetoaddress(1, sidechain.getnewaddress()) |
| 423 | + assert_equal(sidechain.gettransaction(claim_txid)["confirmations"], 1) |
| 424 | + |
| 425 | + |
| 426 | + # Send rest of coins using subtractfee from output arg |
| 427 | + sidechain.sendtomainchain(some_btc_addr, sidechain.getwalletinfo()["balance"]['bitcoin'], True) |
394 | 428 |
|
395 | 429 | assert(sidechain.getwalletinfo()["balance"]['bitcoin'] == 0) |
396 | 430 |
|
|
0 commit comments