Skip to content

Commit 709f868

Browse files
committed
[wallet] CreateTransaction: simplify change address check
1 parent 5efc25f commit 709f868

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,18 +2630,11 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
26302630
// post-backup change.
26312631

26322632
// Reserve a new key pair from key pool
2633-
if (!CanGetAddresses(true)) {
2634-
strFailReason = _("Can't generate a change-address key. No keys in the internal keypool and can't generate any keys.").translated;
2635-
return false;
2636-
}
26372633
CTxDestination dest;
2638-
bool ret = reservedest.GetReservedDestination(dest, true);
2639-
if (!ret)
2640-
{
2641-
strFailReason = _("Keypool ran out, please call keypoolrefill first").translated;
2634+
if (!reservedest.GetReservedDestination(dest, true)) {
2635+
strFailReason = _("Can't generate a change-address key. Please call keypoolrefill first.").translated;
26422636
return false;
26432637
}
2644-
26452638
scriptChange = GetScriptForDestination(dest);
26462639
}
26472640
CTxOut change_prototype_txout(0, scriptChange);

test/functional/rpc_fundrawtransaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def test_locked_wallet(self):
504504
rawtx = self.nodes[1].createrawtransaction(inputs, outputs)
505505
# fund a transaction that requires a new key for the change output
506506
# creating the key must be impossible because the wallet is locked
507-
assert_raises_rpc_error(-4, "Keypool ran out, please call keypoolrefill first", self.nodes[1].fundrawtransaction, rawtx)
507+
assert_raises_rpc_error(-4, "Can't generate a change-address key. Please call keypoolrefill first.", self.nodes[1].fundrawtransaction, rawtx)
508508

509509
# Refill the keypool.
510510
self.nodes[1].walletpassphrase("test", 100)

0 commit comments

Comments
 (0)