|
1 | 1 | #!/usr/bin/env python3 |
2 | | -# Copyright (c) 2020 Daniel Kraft |
| 2 | +# Copyright (c) 2020-2021 Daniel Kraft |
3 | 3 | # Distributed under the MIT/X11 software license, see the accompanying |
4 | 4 | # file COPYING or http://www.opensource.org/licenses/mit-license.php. |
5 | 5 |
|
@@ -28,31 +28,43 @@ def run_test (self): |
28 | 28 | self.sync_blocks () |
29 | 29 | self.checkName (0, "x/name", "value", None, False) |
30 | 30 |
|
31 | | - # fundrawtransaction and friends does not support non-wallet provided |
32 | | - # inputs. Thus we have to first build up the funded transaction without |
33 | | - # the name coins and a slightly higher fee, and then combine it with the |
34 | | - # name input/output to obtain the final raw transaction. |
35 | | - addrPayment = self.nodes[0].getnewaddress () |
36 | | - outs = [{addrPayment: 10}] |
37 | | - options = { |
38 | | - "fee_rate": 100, |
39 | | - } |
40 | | - part1 = self.nodes[1].walletcreatefundedpsbt ([], outs, 0, options)["psbt"] |
| 31 | + # We construct the base transaction first, with just the name input, |
| 32 | + # name output (including the operation) and the payment output. |
| 33 | + # We then apply fundrawtransaction to add the necessary input and change |
| 34 | + # for the payment; this needs solving data for the non-wallet input |
| 35 | + # (the name) to be passed in, which in this case is the pubkey for the |
| 36 | + # name input address. |
41 | 37 |
|
| 38 | + addrPayment = self.nodes[0].getnewaddress () |
42 | 39 | addrNm = self.nodes[1].getnewaddress () |
| 40 | + |
43 | 41 | nmData = self.nodes[0].name_show ("x/name") |
44 | | - part2 = self.nodes[0].createpsbt ([nmData], [{addrNm: 0.01}]) |
| 42 | + addrNmOld = nmData["address"] |
| 43 | + pubKey = self.nodes[0].getaddressinfo (addrNmOld)["pubkey"] |
| 44 | + |
| 45 | + tx = self.nodes[1].createrawtransaction ([nmData], { |
| 46 | + addrPayment: 10, |
| 47 | + addrNm: 0.01, |
| 48 | + }) |
| 49 | + vout = self.rawtxOutputIndex (1, tx, addrNm) |
45 | 50 | nameOp = { |
46 | 51 | "op": "name_update", |
47 | 52 | "name": "x/name", |
48 | 53 | "value": "updated", |
49 | 54 | } |
50 | | - part2 = self.nodes[1].namepsbt (part2, 0, nameOp)["psbt"] |
51 | | - combined = self.nodes[1].joinpsbts ([part1, part2]) |
| 55 | + tx = self.nodes[1].namerawtransaction (tx, vout, nameOp)["hex"] |
| 56 | + |
| 57 | + options = { |
| 58 | + "solving_data": { |
| 59 | + "pubkeys": [pubKey], |
| 60 | + }, |
| 61 | + } |
| 62 | + tx = self.nodes[1].fundrawtransaction (tx, options)["hex"] |
| 63 | + psbt = self.nodes[1].converttopsbt (tx) |
52 | 64 |
|
53 | 65 | # Sign and broadcast the partial tx. |
54 | | - sign1 = self.nodes[0].walletprocesspsbt (combined) |
55 | | - sign2 = self.nodes[1].walletprocesspsbt (combined) |
| 66 | + sign1 = self.nodes[0].walletprocesspsbt (psbt) |
| 67 | + sign2 = self.nodes[1].walletprocesspsbt (psbt) |
56 | 68 | combined = self.nodes[1].combinepsbt ([sign1["psbt"], sign2["psbt"]]) |
57 | 69 | tx = self.nodes[1].finalizepsbt (combined) |
58 | 70 | assert_equal (tx["complete"], True) |
|
0 commit comments