mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
[wallet] CreateTransaction: simplify change address check
This commit is contained in:
parent
5efc25f963
commit
709f8685ac
@ -2630,18 +2630,11 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
|
|||||||
// post-backup change.
|
// post-backup change.
|
||||||
|
|
||||||
// Reserve a new key pair from key pool
|
// Reserve a new key pair from key pool
|
||||||
if (!CanGetAddresses(true)) {
|
|
||||||
strFailReason = _("Can't generate a change-address key. No keys in the internal keypool and can't generate any keys.").translated;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
CTxDestination dest;
|
CTxDestination dest;
|
||||||
bool ret = reservedest.GetReservedDestination(dest, true);
|
if (!reservedest.GetReservedDestination(dest, true)) {
|
||||||
if (!ret)
|
strFailReason = _("Can't generate a change-address key. Please call keypoolrefill first.").translated;
|
||||||
{
|
|
||||||
strFailReason = _("Keypool ran out, please call keypoolrefill first").translated;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptChange = GetScriptForDestination(dest);
|
scriptChange = GetScriptForDestination(dest);
|
||||||
}
|
}
|
||||||
CTxOut change_prototype_txout(0, scriptChange);
|
CTxOut change_prototype_txout(0, scriptChange);
|
||||||
|
@ -504,7 +504,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
rawtx = self.nodes[1].createrawtransaction(inputs, outputs)
|
rawtx = self.nodes[1].createrawtransaction(inputs, outputs)
|
||||||
# fund a transaction that requires a new key for the change output
|
# fund a transaction that requires a new key for the change output
|
||||||
# creating the key must be impossible because the wallet is locked
|
# creating the key must be impossible because the wallet is locked
|
||||||
assert_raises_rpc_error(-4, "Keypool ran out, please call keypoolrefill first", self.nodes[1].fundrawtransaction, rawtx)
|
assert_raises_rpc_error(-4, "Can't generate a change-address key. Please call keypoolrefill first.", self.nodes[1].fundrawtransaction, rawtx)
|
||||||
|
|
||||||
# Refill the keypool.
|
# Refill the keypool.
|
||||||
self.nodes[1].walletpassphrase("test", 100)
|
self.nodes[1].walletpassphrase("test", 100)
|
||||||
|
Loading…
Reference in New Issue
Block a user