|
4 | 4 | # file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
5 | 5 | """Test the fundrawtransaction RPC."""
|
6 | 6 |
|
| 7 | +from decimal import Decimal |
7 | 8 | from test_framework.test_framework import BitcoinTestFramework
|
8 |
| -from test_framework.util import * |
| 9 | +from test_framework.util import ( |
| 10 | + assert_equal, |
| 11 | + assert_fee_amount, |
| 12 | + assert_greater_than, |
| 13 | + assert_greater_than_or_equal, |
| 14 | + assert_raises_rpc_error, |
| 15 | + connect_nodes_bi, |
| 16 | + count_bytes, |
| 17 | + find_vout_for_address, |
| 18 | +) |
9 | 19 |
|
10 | 20 |
|
11 | 21 | def get_unspent(listunspent, amount):
|
@@ -57,6 +67,11 @@ def run_test(self):
|
57 | 67 | watchonly_amount = Decimal(200)
|
58 | 68 | self.nodes[3].importpubkey(watchonly_pubkey, "", True)
|
59 | 69 | watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount)
|
| 70 | + |
| 71 | + # Lock UTXO so nodes[0] doesn't accidentally spend it |
| 72 | + watchonly_vout = find_vout_for_address(self.nodes[0], watchonly_txid, watchonly_address) |
| 73 | + self.nodes[0].lockunspent(False, [{"txid": watchonly_txid, "vout": watchonly_vout}]) |
| 74 | + |
60 | 75 | self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10)
|
61 | 76 |
|
62 | 77 | self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.5)
|
@@ -475,6 +490,9 @@ def run_test(self):
|
475 | 490 | connect_nodes_bi(self.nodes,1,2)
|
476 | 491 | connect_nodes_bi(self.nodes,0,2)
|
477 | 492 | connect_nodes_bi(self.nodes,0,3)
|
| 493 | + # Again lock the watchonly UTXO or nodes[0] may spend it, because |
| 494 | + # lockunspent is memory-only and thus lost on restart |
| 495 | + self.nodes[0].lockunspent(False, [{"txid": watchonly_txid, "vout": watchonly_vout}]) |
478 | 496 | self.sync_all()
|
479 | 497 |
|
480 | 498 | # drain the keypool
|
|
0 commit comments