LN-Zap / zap-iOS

Zap Wallet - Native iOS lightning wallet focused on user experience and ease of use ⚡️
http://zaphq.io
MIT License
181 stars 47 forks source link

Error messaging for send amount too small #297

Closed chitowncrispy closed 4 years ago

chitowncrispy commented 5 years ago

Description

I added some error messaging to the UI when the user is trying to send an amount that is too small for the fee estimation service to estimate the fee.

I needed to allow the fee estimation completion block to return a result set that contained both the success and failure scenarios. This allows us to respond to both scenarios all the way down to the UI level in the LoadingAmountView. In this view, I look for a specific error message (not ideal) and then based upon that I tailor a more user-friendly message to display to the user.

I think I may have found a potential error in either our code or in the LND API where they are not properly returning errors back in the response. As far as I can tell the errors are all Code=1 and in the localizedDescription they all come through as code = Unknown. This may be something we should report back to the LND team so they can better pass that through to the apps for error handling.

Motivation and Context

As I have been testing the app I have been seeing that when I have a small number of sats I want to send the fee estimate was "-". This didn't make much sense to me and until I dug into the error that the API was returning I wasn't sure why that was happening. Thus, I put up this PR to make it a bit more user and noob friendly.

How Has This Been Tested?

On testnet I was opening the send view and then typing in a small number of sats (<150 sats). I would type it out, delete it, type it again, etc... All of which would show the error string. I would then put in an amount large enough to trigger a fee estimate (>1000 sats) and the estimate would show.

Screenshots (if appropriate):

Screen Shot 2019-10-21 at 8 49 30 PM Screen Shot 2019-10-21 at 8 49 35 PM

Types of changes

Checklist:

codecov-io commented 5 years ago

Codecov Report

Merging #297 into master will decrease coverage by 0.04%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #297      +/-   ##
==========================================
- Coverage   11.01%   10.97%   -0.05%     
==========================================
  Files         234      234              
  Lines        9330     9369      +39     
==========================================
  Hits         1028     1028              
- Misses       8302     8341      +39
Impacted Files Coverage Δ
Library/Generated/strings.swift 6.97% <ø> (ø) :arrow_up:
Lightning/Services/TransactionService.swift 18.75% <0%> (-1.94%) :arrow_down:
...ry/Scenes/ModalDetail/Send/LoadingAmountView.swift 0% <0%> (ø) :arrow_up:
...ibrary/Scenes/ModalDetail/Send/SendViewModel.swift 0% <0%> (ø) :arrow_up:
Library/Views/OnChainFeeView/OnChainFeeView.swift 0% <0%> (ø) :arrow_up:
Library/Scenes/LndLog/LndLogViewController.swift 0% <0%> (ø) :arrow_up:
...y/Scenes/Background/BackgroundViewController.swift 0% <0%> (ø) :arrow_up:
...cenes/ManageWallets/WalletConfigurationStore.swift 0% <0%> (ø) :arrow_up:
Library/Scenes/Node/NodeHeaderView.swift 0% <0%> (ø) :arrow_up:
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8320cf8...a04e48d. Read the comment docs.

ottosuess commented 5 years ago

sorry i broke your pr: https://github.com/LN-Zap/zap-iOS/commit/e8b5799125292e420846914eb43618dc71c52ff4

lnd's routes endpoint now only returns a single route. I changed that in our api to make it more obvious. A rebase should be very simple though.

ottosuess commented 5 years ago

when i enter an amount bigger than my on chain funds i get some sort of error indication at the top:

Simulator Screen Shot - iPhone 11 - 2019-10-22 at 15 29 38

maybe when the funds are below the dust limit we should display the error on the top too. just to be consistent? (because it's not specific to fee estimation but to sending funds in general)

any thoughts? @sohomang @JimmyMow @ole1220

sohomang commented 5 years ago

@ole1220 Agreed! It'd also provide feedback before clicking Send so it's a good thing

What about handling it the same way we handle a channel opening ? i.e. updating the On-chain balance: X sats label to Minimum sending amount: X sats as the user types his chosen amount.

chitowncrispy commented 5 years ago
Screen Shot 2019-10-23 at 8 44 50 PM Screen Shot 2019-10-23 at 8 44 55 PM Screen Shot 2019-10-23 at 8 45 00 PM Screen Shot 2019-10-23 at 8 45 05 PM
chitowncrispy commented 5 years ago

@sohomang there isn't a way for me to tell what the minimum amount of sats that we can send is. Since that is the case I added some more UI tweaks in the screenshots above based upon the state. Let me know how these look now.

@ottosuess do you know of a way to get the minimum amount of sats that we can send?

sohomang commented 5 years ago

@chitowncrispy looks 🎇! Could we make it so when no amount is typed yet, no error message appears? Like:

chitowncrispy commented 5 years ago

@sohomang

Screen Shot 2019-10-24 at 8 23 02 PM
JimmyMow commented 5 years ago

So where did we settle on this @chitowncrispy @ottosuess @sohomang? No error in the fee estimation, rather the following for the amount input?

ottosuess commented 5 years ago

yeah, imo the error at the top is enough.

chitowncrispy commented 5 years ago

Ok, so we don't want the error in the fee estimate label? Only up top where we have the subtitle for the amount entered?

JimmyMow commented 5 years ago

Yeah @chitowncrispy that seems to be the consensus. I personally like that UX as well

chitowncrispy commented 5 years ago
Screen Shot 2019-10-30 at 11 00 34 PM Screen Shot 2019-10-30 at 11 00 42 PM Screen Shot 2019-10-30 at 11 00 47 PM Screen Shot 2019-10-30 at 11 00 54 PM
chitowncrispy commented 5 years ago

@ottosuess @JimmyMow @sohomang I've updated the code for the desired behavior and attached the screenshots of each state.

ottosuess commented 4 years ago

merged in 7dace9e2532da36faa84ee2aeb3ca1e8eda42d00