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

fix: Total Balance/Channel Balance Properly Update After Any Transaction #293

Closed chitowncrispy closed 5 years ago

chitowncrispy commented 5 years ago

Description

I was able to simplify the fix made in PR #285. We already had a signal firing when the "items" of the different "lists" were updated. Those lists included the transactions made on-chain as well as the invoices fulfilled on the Lightning Network. My changes here rip out all the changes I made in the previous PR and simply wrap the self?.balanceService.update() in the updateBalanceOnChange<T>(of items: MutableObservableArray<T>) method so that way the race condition can be satisfied and the call to update the balances happens at the correct time for all transactions be it on-chain or on the Lightning Network.

Motivation and Context

I found an issue with the balance updating when sending an on-chain transaction while testing my changes for PR #285. The behavior was similar to the master branch at the time so I didn't look further into it at the time.

How Has This Been Tested?

While on testnet I ended up sending multiple on-chain transactions as well as created multiple invoices and fulfilled them from a 3rd party website. All of the transactions when submitted/completed showed the correct balance on the wallet page upon the proper state of the transaction.

Screenshots (if appropriate):

Types of changes

Checklist:

codecov-io commented 5 years ago

Codecov Report

Merging #293 into master will increase coverage by 0.15%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #293      +/-   ##
==========================================
+ Coverage   11.25%   11.41%   +0.15%     
==========================================
  Files         230      230              
  Lines        9096     9084      -12     
==========================================
+ Hits         1024     1037      +13     
+ Misses       8072     8047      -25
Impacted Files Coverage Δ
...ning/Services/DataUpdater/InvoiceListUpdater.swift 35.71% <ø> (-14.29%) :arrow_down:
Lightning/Services/LightningService.swift 58.44% <100%> (+5.42%) :arrow_up:
...htning/Services/Misc/BlockChainHeightUpdater.swift 95.83% <0%> (+35.41%) :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 ba0939d...94bb9b0. Read the comment docs.

ottosuess commented 5 years ago

👌👌