Currently the exchange rates plugin shows the converted
rate at the time of last user input. If the fx rate
changes the send and receive tabs do not update.
This makes them update. It also means that when enabling
the plugin, if the user had input a BTC amount in the send
or receive, the other fields will refresh. This didn't
used to happen - they stayed blank.
It has long been a minor annoyance that this isn't the
default behaviour. Semantics are as follows:
- Fees are calculated automatically, as usual, and shown
in black
- If the user inputs a fee, it is retained, and shown in
blue to indicate it is user-overridden
- The user can switch back to automatic fee calculation mode
in two ways: press Clear, or blank out the fee field
- User fees are also cleared by do_clear(), for instance when
the payment is sent
I have checked all usage combinations I could think of, including
the ! case, and all work in a sensible and natural fashion.
This also fixes issue #995.
* Fixed all of the update_* functions on the exchange_rate.py plugin to indicate when there are SSL errors, there was a horrorous try-except-pass block that was drowning all the exceptions
* Added get_json_insecure to allow exchange rates over HTTP
Signed-off-by: John Miguel Villar Zavatti <johnvillarzavatti@gmail.com>
Problem:
Using the exchange rate plugin in the send dialog one can start with
entering a fiat amount, e.g. 5 USD, and the BTC amount is updated,
but no fee is calculated.
In this case can get "Invalid fee" error until the BTC amount is
touched manually and fee is calculated. This can cause confusion
when "set transaction fees manually" is disabled.
Reproducing:
* enable exchange rate plugin
* start Electrum
* in send dialog fill out any receive address
* add a value (e.g. 5) into the fiat dialog and see the BTC value filled out
* fee is not filled out, or if disabled the manual transaction fees then directly
get "Invalid Fee" error
Expectation:
* Fees are calculated just as it would be by filling out the BTC field
Fix:
Fixed by triggering a fee setting the same way as it is done when
the BTC field is edited, by calling `textEdited.emit("")` of the relevant
`BTCAmountEdit` element. One problematic thing is that this also triggers
a change on the fiat we just edited, and thus cursor positions need to be saved
and restored. This is not ideal, there should be a way to avoid such cascades
and trigger fee calculation directly instead of by proxy.
Editing the fiat field with these changes is more or less okay, there can be
some strange steps when the decimal point is edited, but IMHO not worse
than the BTC field when the decimal point is edited there.
itbit/coindesk exchange rate requires separate API calls per currency
Moved the calls to when the exchange rate plugin updates and when the
user modifies a selection instead of every time the program needs to
query the current exchange rate
This fixes an issue with slow response time in the send tab with the
exchange rate plugin turned on and set to coindesk or itbit