Page MenuHomePhabricator

[Cashtab] Do not throw API error utxo with null isValid
ClosedPublic

Authored by bytesofman on Oct 19 2021, 20:41.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC36697e1790bb: [Cashtab] Do not throw API error utxo with null isValid
Summary

T1920 related

Recently dev work has been going on to send and parse OP_RETURN transactions with Cashtab. However, during this work, we've learned that bch-api (through SLPDB) is confused by transactions with OP_RETURN msgs that are not eToken txs. Specifically, the validation function will return null.

Because SLPDB will also return isValid: null when the backend is rate limited, the old behavior of Cashtab threw an error that would change the API or lock the app until the API was not rate limited. However, in this case the issue is not a rate limit. So, if a user has a utxo with a normal OP_RETURN msg in it...Cashtab will perpetually throw a rate limit error.

This diff corrects this behavior. Cashtab already filters out isValid: null utxos from the utxo set (lines 434 and 443 of useBCH.js).

Future diffs will parse these utxos appropriately. However, since neither SLPDB nor bch-api do this, will be a bit complicated; probably screening OP_RETURN fields for SLP prefixes.

Test Plan

arc patch d10363 and npm start to run a branch of cashtab that will allow you to send yourself an OP_RETURN tx (alt: send your cashtab wallet an OP_RETURN msg tx)
Note that the wallet throws an API error and never recovers
arc patch D10368 and npm start
Note that wallet recovers, though the null utxo is logged to console

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested changes to this revision.Oct 20 2021, 06:50
Fabien added a subscriber: Fabien.

As far as I can tell this is only a linter update, you might have submitted the wrong branch

This revision now requires changes to proceed.Oct 20 2021, 06:50

As far as I can tell this is only a linter update, you might have submitted the wrong branch

The key update is line 429, removal of the throw error statement.

111.PNG (152×1 px, 15 KB)

reverting to previous prettier version

Fabien requested changes to this revision.Oct 21 2021, 07:47

What happens now when a API error occurs ?

web/cashtab/src/hooks/useBCH.js
424 ↗(On Diff #30611)

Remove, this is now duplicated.

This revision now requires changes to proceed.Oct 21 2021, 07:48

Remove duplicate console.log statement

This revision is now accepted and ready to land.Oct 22 2021, 12:40