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

Total Balance/Channel Balance Properly Update After Receiving Payment #285

Closed chitowncrispy closed 5 years ago

chitowncrispy commented 5 years ago

Description

The meat of the change was adding a Signal and Observer to InvoiceListUpdater. The Signal will fire whenever an invoice is settled upon while the app is open. On the other end, the LightningService observes this Signal and tells the balanceService to update. There seems to be a slight race condition within LND though and I had to delay the call to balanceService.update() in order for the correct values to be displayed within the UI. I also made a few minor naming changes throughout the code and added a few distinctUntilChanged calls so that the UI doesn't update as often. I noticed a lot of LND calls are made and many of them were resulting in UI refreshes so I toned those down a bit.

Motivation and Context

This was an open issue #266.

How Has This Been Tested?

I spent a lot of time on testnet creating invoices and getting an outside service to pay those invoices I was creating. All I needed to do was ask the outside service to fulfill the invoice and watch the UI in the app to see if it was updating properly or not. At the beginning of testing, I also noticed that the channels page was not updating the balances as well. With the final fix not only will the main total balance accurately be reflected but so will all the channels on the channels page. I also did a few tests with simulated poor connections. I used the network link conditioner to perform these invoice fulfilments over 3G and EDGE connections.

Types of changes

Checklist:

codecov-io commented 5 years ago

Codecov Report

Merging #285 into master will increase coverage by 0.07%. The diff coverage is 50%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #285      +/-   ##
========================================
+ Coverage    7.53%   7.6%   +0.07%     
========================================
  Files         219    219              
  Lines        8694   8713      +19     
========================================
+ Hits          655    663       +8     
- Misses       8039   8050      +11
Impacted Files Coverage Δ
Library/Scenes/Wallet/WalletViewModel.swift 0% <0%> (ø) :arrow_up:
Library/Scenes/Wallet/WalletViewController.swift 0% <0%> (ø) :arrow_up:
Lightning/Services/LightningService.swift 53.01% <55.55%> (-3.16%) :arrow_down:
...ning/Services/DataUpdater/InvoiceListUpdater.swift 50% <85.71%> (+14.28%) :arrow_up:

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 52a8c41...75c47fa. Read the comment docs.

ottosuess commented 5 years ago

❤️