(self)
| 650 | """ |
| 651 | |
| 652 | def run_ca_tests(self): |
| 653 | # Confidential Assets tests |
| 654 | |
| 655 | # Start by sending some coins to a nonconf address |
| 656 | unconf_addr_0 = self.get_address(False, 0) |
| 657 | unconf_addr_1 = self.get_address(False, 0) |
| 658 | unconf_addr_4 = self.get_address(False, 0) |
| 659 | rawtx = self.nodes[0].createrawtransaction([], [{unconf_addr_0:50}, {unconf_addr_1:50}, {unconf_addr_4:50}]) |
| 660 | rawtx = self.nodes[0].fundrawtransaction(rawtx, {"changePosition":3}) # our outputs will be 0, 1, 2 |
| 661 | rawtx = self.nodes[0].blindrawtransaction(rawtx['hex']) |
| 662 | signed_tx = self.nodes[0].signrawtransactionwithwallet(rawtx)['hex'] |
| 663 | txid_nonconf = self.nodes[0].sendrawtransaction(signed_tx) |
| 664 | self.generate(self.nodes[0], 1) |
| 665 | self.sync_all() |
| 666 | |
| 667 | # Now use PSBT to send some coins nonconf->nonconf |
| 668 | unconf_addr_2 = self.get_address(False, 1) |
| 669 | psbt = self.nodes[0].createpsbt([{"txid": txid_nonconf, "vout": 0}], [{unconf_addr_2: 49.999}, {"fee": 0.001}]) |
| 670 | psbt = self.nodes[0].walletprocesspsbt(psbt)["psbt"] |
| 671 | tx_hex = self.nodes[0].finalizepsbt(psbt)['hex'] |
| 672 | self.nodes[0].sendrawtransaction(tx_hex) |
| 673 | self.generate(self.nodes[0], 1) |
| 674 | self.sync_all() |
| 675 | |
| 676 | # Now send nonconf->conf (with two outputs, blinding succeeds) |
| 677 | conf_addr_1 = self.get_address(True, 2) |
| 678 | conf_addr_2 = self.get_address(True, 2) |
| 679 | psbt = self.nodes[0].createpsbt([{"txid": txid_nonconf, "vout": 1}], [{conf_addr_1: 24.999, "blinder_index": 0}, {conf_addr_2: 24.999, "blinder_index": 0}, {"fee": 0.002}]) |
| 680 | psbt = self.nodes[0].walletprocesspsbt(psbt)['psbt'] |
| 681 | hex_tx = self.nodes[0].finalizepsbt(psbt)['hex'] |
| 682 | assert_equal(self.num_blinded_outputs(hex_tx), 2) |
| 683 | txid_conf_2 = self.nodes[0].sendrawtransaction(hex_tx) |
| 684 | self.generate(self.nodes[0], 1) |
| 685 | self.sync_all() |
| 686 | |
| 687 | # Try to send conf->nonconf: This will fail because we can't balance the blinders |
| 688 | unconf_addr_3 = self.get_address(False, 0) |
| 689 | psbt = self.nodes[2].createpsbt([{"txid": txid_conf_2, "vout": 0}], [{unconf_addr_3: 24.998}, {"fee": 0.001}]) |
| 690 | #assert_raises_rpc_error(-25, "Transaction values or blinders are not balanced", self.nodes[2].walletprocesspsbt, psbt) |
| 691 | |
| 692 | # Try to send conf->(nonconf + conf), so we have a conf output to balance blinders |
| 693 | conf_addr_3 = self.get_address(True, 0) |
| 694 | psbt = self.nodes[2].createpsbt([{"txid": txid_conf_2, "vout": 0}], [{unconf_addr_3: 10}, {conf_addr_3: 14.998, "blinder_index": 0}, {"fee": 0.001}]) |
| 695 | psbt = self.nodes[2].walletprocesspsbt(psbt)['psbt'] |
| 696 | hex_tx = self.nodes[2].finalizepsbt(psbt)['hex'] |
| 697 | assert_equal(self.num_blinded_outputs(hex_tx), 1) |
| 698 | self.nodes[2].sendrawtransaction(hex_tx) |
| 699 | self.generate(self.nodes[0], 1) |
| 700 | self.sync_all() |
| 701 | |
| 702 | # Check include_explicit option |
| 703 | psbt = self.nodes[2].walletcreatefundedpsbt([{"txid": txid_conf_2, "vout": 1}], [{self.get_address(True, 0): 24.998, "blinder_index": 0}, {"fee": 0.001}], 0, {"include_explicit": True})["psbt"] |
| 704 | decoded = self.nodes[1].decodepsbt(psbt) |
| 705 | assert "explicit_value" in decoded["inputs"][0] |
| 706 | assert "value_proof" in decoded["inputs"][0] |
| 707 | assert "explicit_asset" in decoded["inputs"][0] |
| 708 | assert "asset_proof" in decoded["inputs"][0] |
| 709 |
no test coverage detected