refactor: wallet: return util::Result from GetReservedDestination methods

This commit is contained in:
Sebastian Falbesoner
2022-07-20 19:06:57 +02:00
parent 006740b6f6
commit 76b3c37fcb
5 changed files with 26 additions and 40 deletions

View File

@@ -812,11 +812,13 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
// Reserve a new key pair from key pool. If it fails, provide a dummy
// destination in case we don't need change.
CTxDestination dest;
bilingual_str dest_err;
if (!reservedest.GetReservedDestination(dest, true, dest_err)) {
error = _("Transaction needs a change address, but we can't generate it.") + Untranslated(" ") + dest_err;
auto op_dest = reservedest.GetReservedDestination(true);
if (!op_dest) {
error = _("Transaction needs a change address, but we can't generate it.") + Untranslated(" ") + util::ErrorString(op_dest);
} else {
dest = *op_dest;
scriptChange = GetScriptForDestination(dest);
}
scriptChange = GetScriptForDestination(dest);
// A valid destination implies a change script (and
// vice-versa). An empty change script will abort later, if the
// change keypool ran out, but change is required.