diff options
author | Andrew Chow <achow101-github@achow101.com> | 2022-06-01 14:32:26 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-12-08 17:12:19 -0500 |
commit | 758501b71391136c33b525b1a0109b990d4f463e (patch) | |
tree | 37c037c7ab72a684693bc1576b81595e4e4fedf8 /src/wallet/interfaces.cpp | |
parent | 2d39db7aa128a948b6ad11242591ef26a342f5b1 (diff) | |
download | bitcoin-758501b71391136c33b525b1a0109b990d4f463e.tar.xz |
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.
Diffstat (limited to 'src/wallet/interfaces.cpp')
-rw-r--r-- | src/wallet/interfaces.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index 4ca5e29229..d15273dfc9 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -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; } |