diff options
author | MacroFake <falke.marco@gmail.com> | 2022-08-10 14:19:11 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-08-10 14:19:17 +0200 |
commit | a6fc293c0a1f27ba1e573bfa16fd76d5f58988b2 (patch) | |
tree | bdf4912877caaf7e22365780180193ddd4494d99 /src/wallet/spend.cpp | |
parent | aac200801b66f1300e618c115a6e3df9b01c9ec3 (diff) | |
parent | 76b3c37fcb93b4bcb047e0500fdaa605160e25d5 (diff) | |
download | bitcoin-a6fc293c0a1f27ba1e573bfa16fd76d5f58988b2.tar.xz |
Merge bitcoin/bitcoin#25656: refactor: wallet: return util::Result from `GetReservedDestination` methods
76b3c37fcb93b4bcb047e0500fdaa605160e25d5 refactor: wallet: return util::Result from `GetReservedDestination` methods (Sebastian Falbesoner)
Pull request description:
This PR is a follow-up to #25218, as suggested in comment https://github.com/bitcoin/bitcoin/pull/25218#discussion_r907710067. The interfaces of the methods `ReserveDestination::GetReservedDestination`, `{Legacy,Descriptor,}ScriptPubKeyMan::GetReservedDestination` are improved by returning `util::Result<CTxDestination>` instead of `bool` in order to get rid of the two `CTxDestination&` and `bilingual_str&` out-parameters.
ACKs for top commit:
furszy:
ACK 76b3c37f
Tree-SHA512: bf15560a88d645bcf8768024013d36012cd65caaa4a613e8a055dfd8f29cb4a219c19084606992bad177920cdca3a732ec168e9b9526f9295491f2cf79cc6815
Diffstat (limited to 'src/wallet/spend.cpp')
-rw-r--r-- | src/wallet/spend.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index b359d3e19b..e266cf6c81 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -814,11 +814,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. |