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

@@ -250,21 +250,21 @@ public:
LOCK(m_wallet->cs_wallet);
return m_wallet->ListLockedCoins(outputs);
}
CTransactionRef createTransaction(const std::vector<CRecipient>& recipients,
BResult<CTransactionRef> createTransaction(const std::vector<CRecipient>& recipients,
const CCoinControl& coin_control,
bool sign,
int& change_pos,
CAmount& fee,
bilingual_str& fail_reason) override
CAmount& fee) override
{
LOCK(m_wallet->cs_wallet);
std::optional<CreatedTransactionResult> txr = CreateTransaction(*m_wallet, recipients, change_pos,
fail_reason, coin_control, sign);
if (!txr) return {};
fee = txr->fee;
change_pos = txr->change_pos;
const auto& res = CreateTransaction(*m_wallet, recipients, change_pos,
coin_control, sign);
if (!res) return res.GetError();
const auto& txr = res.GetObj();
fee = txr.fee;
change_pos = txr.change_pos;
return txr->tx;
return txr.tx;
}
void commitTransaction(CTransactionRef tx,
WalletValueMap value_map,