Page MenuHomePhabricator

[Cashtab] [pub key fetch from chronik p1] Get recipient public key from chronik instead of bch-api
ClosedPublic

Authored by bytesofman on Oct 7 2022, 22:28.

Details

Summary

T2730

This diff extracts the public key of the intended recipient of an encrypted cashtab message by using chronik instead of bch-api.

For review, this will be implemented as a stacked diff. In part 1, Cashtab is still getting the public key using bch-api and also with chronik, then comparing them.

In part 2 I will remove the bch-api call and the debug logging.

Unfortunately jest is not able to mock some of the more complex chronik calls, which required an optional param to be added to the sendXec function.

Test Plan

Review unit test changes and npm test
npm start
Send a private msg to an address with outgoing txs. Confirm it succeeds. Confirm the pub key determined by chronik matches that determined by bch-api in the dev console.
Send a private msg to an address with no outgoing txs. Confirm the error msg '[chronik] Cannot send an encrypted message to a wallet with no outgoing transactions' appears.

Diff Detail

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

Event Timeline

bytesofman added inline comments.
web/cashtab/src/hooks/useBCH.js
526 ↗(On Diff #35534)

changes planned: you need to make sure that you only get outgoing txs

Extract public key only from an outgoing tx

It seems a bit weird that we just won't send a tx if we can't find an outgoing tx in the last 20 txs. However, I don't think it's worth handling the edge case of someone trying to send a tx to a wallet with 10000s of incoming txs and no outgoing txs. This is mostly a proof of concept feature for Cashtab.

This revision is now accepted and ready to land.Oct 8 2022, 03:22