Skip to content

Commit 1a6eacb

Browse files
committed
[QA] add fundrawtransaction test on a locked wallet with empty keypool
1 parent c24a4f5 commit 1a6eacb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

qa/rpc-tests/fundrawtransaction.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,23 @@ def run_test(self):
484484
self.is_network_split=False
485485
self.sync_all()
486486

487+
# drain the keypool
488+
self.nodes[1].getnewaddress()
489+
inputs = []
490+
outputs = {self.nodes[0].getnewaddress():1.1}
491+
rawTx = self.nodes[1].createrawtransaction(inputs, outputs)
492+
# fund a transaction that requires a new key for the change output
493+
# creating the key must be impossible because the wallet is locked
494+
try:
495+
fundedTx = self.nodes[1].fundrawtransaction(rawTx)
496+
raise AssertionError("Wallet unlocked without passphrase")
497+
except JSONRPCException as e:
498+
assert('Keypool ran out' in e.error['message'])
499+
500+
#refill the keypool
501+
self.nodes[1].walletpassphrase("test", 100)
502+
self.nodes[1].walletlock()
503+
487504
try:
488505
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2)
489506
raise AssertionError("Wallet unlocked without passphrase")

0 commit comments

Comments
 (0)