mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 16:24:48 +02:00
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:
@@ -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