aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpc/spend.cpp
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2022-04-08 16:43:10 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2022-07-08 11:18:35 -0300
commit22351725bc4c5eb63ee45f607374bbf2d76e2b8c (patch)
treef070e528309494f0f519be8fd590117c00f1761b /src/wallet/rpc/spend.cpp
parent198fcca162f4d2f877feab485e629ff89818ff56 (diff)
send: refactor CreateTransaction flow to return a BResult<CTransactionRef>
Diffstat (limited to 'src/wallet/rpc/spend.cpp')
-rw-r--r--src/wallet/rpc/spend.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp
index 362e9113fb..22c1f2bdc2 100644
--- a/src/wallet/rpc/spend.cpp
+++ b/src/wallet/rpc/spend.cpp
@@ -156,17 +156,16 @@ UniValue SendMoney(CWallet& wallet, const CCoinControl &coin_control, std::vecto
// Send
constexpr int RANDOM_CHANGE_POSITION = -1;
- bilingual_str error;
- std::optional<CreatedTransactionResult> txr = CreateTransaction(wallet, recipients, RANDOM_CHANGE_POSITION, error, coin_control, true);
- if (!txr) {
- throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, error.original);
+ auto res = CreateTransaction(wallet, recipients, RANDOM_CHANGE_POSITION, coin_control, true);
+ if (!res) {
+ throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, res.GetError().original);
}
- CTransactionRef tx = txr->tx;
+ const CTransactionRef& tx = res.GetObj().tx;
wallet.CommitTransaction(tx, std::move(map_value), {} /* orderForm */);
if (verbose) {
UniValue entry(UniValue::VOBJ);
entry.pushKV("txid", tx->GetHash().GetHex());
- entry.pushKV("fee_reason", StringForFeeReason(txr->fee_calc.reason));
+ entry.pushKV("fee_reason", StringForFeeReason(res.GetObj().fee_calc.reason));
return entry;
}
return tx->GetHash().GetHex();