Electric-Coin-Company / zcash-android-wallet-sdk

Native Android SDK for Zcash
MIT License
5 stars 7 forks source link

SDK does not distinguish "failed to communicate with lightwalletd" from "lightwalletd returned an error" #1516

Open str4d opened 1 week ago

str4d commented 1 week ago

See https://github.com/Electric-Coin-Company/zashi-android/issues/1422 as an example:

CompactBlockProcessor.emit(): Syncing process starts for batch: BlockBatch(order=1, range=BlockHeight(value=419201)..BlockHeight(value=419300), blocks=null)
                            main                           CompactBlockProcessor.fetchTreeStateForHeight$zcash_android_sdk_2_1_2_release(): Starting to fetch tree state for height 419200
app_time_stats: avg=3437.46ms min=3437.46ms max=3437.46ms count=1
Networking error: UNKNOWN: zcashd did not return treestate
                            main                           CompactBlockProcessor.fetchTreeStateForHeight$zcash_android_sdk_2_1_2_release(): Tree state fetch failed (Ask Gemini)
java.lang.Throwable: Communication failure with details: 2: zcashd did not return treestate

zcashd did not return treestate is an error that lightwalletd can return from the GetTreeState method: https://github.com/zcash/lightwalletd/blob/6e3816b5834583c492c37ce05b0faaf9fe12c87f/frontend/service.go#L288-L290

If this error is received, it means we successfully communicated with lightwalletd, i.e. there was no networking error.

The SDK should have a separate error type for lightwalletd errors, so that downstream SDK users are not misled into thinking this is an issue with the client phone's networking.