Skip to content

Commit c2711e4

Browse files
committed
Avoid dumpprivkey in wallet_listsinceblock.py
Generate a privkey in the test framework instead of using dumpprivkey so that descriptor wallets work in this test.
1 parent 553dbf9 commit c2711e4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

test/functional/wallet_listsinceblock.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test the listsinceblock RPC."""
66

7+
from test_framework.address import key_to_p2wpkh
8+
from test_framework.key import ECKey
79
from test_framework.test_framework import BitcoinTestFramework
810
from test_framework.messages import BIP125_SEQUENCE_NUMBER
911
from test_framework.util import (
1012
assert_array_result,
1113
assert_equal,
1214
assert_raises_rpc_error,
1315
)
16+
from test_framework.wallet_util import bytes_to_wif
1417

1518
from decimal import Decimal
1619

@@ -181,15 +184,21 @@ def test_double_spend(self):
181184

182185
self.sync_all()
183186

184-
# Split network into two
185-
self.split_network()
186-
187187
# share utxo between nodes[1] and nodes[2]
188+
eckey = ECKey()
189+
eckey.generate()
190+
privkey = bytes_to_wif(eckey.get_bytes())
191+
address = key_to_p2wpkh(eckey.get_pubkey().get_bytes())
192+
self.nodes[2].sendtoaddress(address, 10)
193+
self.nodes[2].generate(6)
194+
self.nodes[2].importprivkey(privkey)
188195
utxos = self.nodes[2].listunspent()
189-
utxo = utxos[0]
190-
privkey = self.nodes[2].dumpprivkey(utxo['address'])
196+
utxo = [u for u in utxos if u["address"] == address][0]
191197
self.nodes[1].importprivkey(privkey)
192198

199+
# Split network into two
200+
self.split_network()
201+
193202
# send from nodes[1] using utxo to nodes[0]
194203
change = '%.8f' % (float(utxo['amount']) - 1.0003)
195204
recipient_dict = {

0 commit comments

Comments
 (0)