HomePhabricator

wallet, refactor: return out-params of CreateTransaction() as optional struct

Description

wallet, refactor: return out-params of CreateTransaction() as optional struct

Summary:

The method CWallet::CreateTransaction currently returns several values in the form of out-parameters:

    the actual newly created transaction (CTransactionRef& tx)
    its required fee (CAmount& nFeeRate)
    the position of the change output (int& nChangePosInOut) -- as the name suggests, this is both an in- and out-param

By returning these values in an optional structure (which returns no value a.k.a. std::nullopt if an error occured), the interfaces is shorter, cleaner (requested change position is now in-param and can be passed by value) and callers don't have to create dummy variables for results that they are not interested in.

Note that the names of the replaced out-variables were kept in CreateTransactionInternal to keep the diff minimal. Also, the fee calculation data (FeeCalculation& fee_calc_out) would be another candidate to put into the structure, but FeeCalculation is currently an opaque data type in the wallet interface and I think it should stay that way.

Backport of core#20640.

Depends on D17953.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Subscribers: PiRK

Differential Revision: https://reviews.bitcoinabc.org/D17954

Details

Provenance
Sebastian Falbesoner <sebastian.falbesoner@gmail.com>Authored on Dec 13 2020, 00:37
FabienCommitted on Mon, Apr 21, 08:10
FabienPushed on Mon, Apr 21, 08:11
Reviewer
Restricted Project
Differential Revision
D17954: wallet, refactor: return out-params of CreateTransaction() as optional struct
Parents
rABCabf469b24e78: [Automated] Update seeds
Branches
Unknown
Tags
Unknown