send: refactor CreateTransaction flow to return a BResult<CTransactionRef>

This commit is contained in:
furszy
2022-04-08 16:43:10 -03:00
parent 198fcca162
commit 22351725bc
9 changed files with 81 additions and 93 deletions

View File

@@ -519,13 +519,12 @@ public:
CWalletTx& AddTx(CRecipient recipient)
{
CTransactionRef tx;
bilingual_str error;
CCoinControl dummy;
{
constexpr int RANDOM_CHANGE_POSITION = -1;
std::optional<CreatedTransactionResult> txr = CreateTransaction(*wallet, {recipient}, RANDOM_CHANGE_POSITION, error, dummy);
BOOST_CHECK(txr.has_value());
tx = txr->tx;
auto res = CreateTransaction(*wallet, {recipient}, RANDOM_CHANGE_POSITION, dummy);
BOOST_CHECK(res);
tx = res.GetObj().tx;
}
wallet->CommitTransaction(tx, {}, {});
CMutableTransaction blocktx;