litecoin-foundation / litewallet-ios

iOS version of Litewallet , official SPV Wallet from the Litecoin Foundation. Maintained by the Litewallet Team & Charlie Lee (Creator of Litecoin)
MIT License
26 stars 15 forks source link

#207 resolve core update issue missing labels #211

Closed kcw-grunt closed 1 year ago

kcw-grunt commented 1 year ago

Problem

When updating the loafwallet-core module / library the address is failing a UnsafeUnmutablePointer when the opening the history of transactions.

As a result, the sent and receive addresses are showing as normal if they are LNgqTxjWxmjsULeugZd7ee6wwVFsVGkz4js but ltc1qrledc2grd0lvluvcn388szkjhxllqmtyzr37rxn or M or ltc1 addresses are not showing.

The issue is the standard of UnsafeUnmutablePointers has changed over the few years so the way to properly handle has changed.

Positives

Snapshot

Sample History with Labels (DEBUG-UPDATE-ADDRESS)
Simulator Screenshot - iPhone 14 Pro - 2023-05-30 at 08 56 49
Correct Addresses
test-addresses

Goal

Fix the unwrapping so the addresses can be shown. Most of my investigation is around the Transaction.swift class line 174

kcw-grunt commented 1 year ago

Hey @majestic84!

Maybe you can spot the issue here? Basically, iOS was working fine for years and we merged the loafwallet-core to have both Android and iOS use the same commit.

When trying to migrate, the tx filtering fails as the structure of the addresses are different and so any segwit addresses are not found.

I'm not savvy enough on BRCore to understand why the filtering fails. Ironically enough, the addresses are found but it doesn't make sense that they worked fine (for years) and now they are violating the filter

Do you have a cycle or 2 to take a look? I'm stumped here.

Thanks if you can!

kcw-grunt commented 1 year ago

This PR is the best argument to write tests. Note: Check out this commit f200ecc

cc: @josikie @Iferencak

kcw-grunt commented 11 months ago

Bounty Distribution

Thanks for the bounty 21Ł Thanks to the Lite.Space and Indigo Nakamoto Please visit Lite.Space to learn and learn more about other bounties!

Note the distribution for this effort:

Developer Percentage Amount
Lead Developer 75% 15.75Ł
PR Review 20% 4.2Ł
Litewallet Operations 5% 1.05Ł
kcw-grunt commented 11 months ago

Cool! Thanks @kcw-grunt

On this code:

addressText = String(format: transaction.direction.addressTextFormat, transaction.toAddress ?? "DEBUG-UPDATED-ADDRESS")

Why there are two questions mark?

@josikie in Swift there is syntax where an object could be nil and in swift ?? says " if it could be nil, put in something that is live and valid" This is referred to an Optional. This was added to Swift to properly manage memory leaks. That is it forces the developer to retire objects more pristinely. Its one of the biggest improvements in Swift over Obj-C

josikie commented 11 months ago

that's a cool syntax, thank you for the explanation @kcw-grunt