wallet: use optional for change position as an optional in CreateTransaction
Instead of making -1 a magic number meaning no change or random change position, use an optional to have that meaning.
This commit is contained in:
1 parent
2d39db7aa1
commit
758501b713
7 files changed
+28
-36
No files matched your search
@@ -281,12 +281,12 @@ public:
|
||||
CAmount& fee) override
|
||||
{
|
||||
LOCK(m_wallet->cs_wallet);
|
||||
auto res = CreateTransaction(*m_wallet, recipients, change_pos,
|
||||
auto res = CreateTransaction(*m_wallet, recipients, change_pos == -1 ? std::nullopt : std::make_optional(change_pos),
|
||||
coin_control, sign);
|
||||
if (!res) return util::Error{util::ErrorString(res)};
|
||||
const auto& txr = *res;
|
||||
fee = txr.fee;
|
||||
change_pos = txr.change_pos;
|
||||
change_pos = txr.change_pos ? *txr.change_pos : -1;
|
||||
|
||||
return txr.tx;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user