Skip to content

Commit

Permalink
limits: Require 2FA if a fiat limit is present but unusable
Browse files Browse the repository at this point in the history
  • Loading branch information
jgriffiths committed Mar 27, 2023
1 parent 416f89c commit ee988f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
multisig.

### Fixed
- GA_sign_transaction/GA_send_transaction: Fixed exception thrown when a fiat
spending limit is set but cannot be used (for example, because the pricing
source is unavailable). When this occurs, 2FA will be required.
- GA_get_twofactor_config: Fixed exception thrown when a fiat pricing source
is unavailable and a fiat pricing limit is set.
is unavailable and a fiat spending limit is set.
- Singlesig: fix handling of some invalid proxies.

### Removed
Expand Down
16 changes: 14 additions & 2 deletions src/ga_auth_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1741,8 +1741,20 @@ namespace sdk {
m_twofactor_required = m_state == state_type::request_code;

if (!m_net_params.is_liquid() && !m_net_params.is_electrum()) {
const uint64_t limit
= m_twofactor_required ? m_session->get_spending_limits()["satoshi"].get<uint64_t>() : 0;
auto user_limits = m_twofactor_required ? m_session->get_spending_limits() : nlohmann::json({});
amount::value_type limit = 0;
if (user_limits.value("is_fiat", false)) {
try {
user_limits = m_session->convert_amount(user_limits);
} catch (const std::exception& ex) {
// If the fiat limit cannot be converted, require 2FA
GDK_LOG_SEV(log_level::warning) << "2FA limit unavailable: " << ex.what();
user_limits.clear();
}
}
if (user_limits.contains("satoshi")) {
limit = user_limits["satoshi"].get<amount::value_type>();
}
const uint64_t satoshi = m_tx_details.at("satoshi").at("btc");
const uint64_t fee = m_tx_details.at("fee");
const uint32_t change_index = m_tx_details.at("change_index").at("btc");
Expand Down

0 comments on commit ee988f4

Please sign in to comment.