Page MenuHomePhabricator

[token-server] Add new function to determine if a given tx involves an address receiving a given tokenId
ClosedPublic

Authored by bytesofman on Mar 5 2024, 22:58.

Details

Summary

Add tested function addressReceivedToken, returning true if any output in a tx has a given tokenId at a given address

Test Plan

npm test

Diff Detail

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

Event Timeline

bytesofman published this revision for review.Mar 5 2024, 23:09
emack requested changes to this revision.Mar 6 2024, 00:41
emack added a subscriber: emack.

Just so I'm clear on the underlying use case here, will this be used to parse through all tx history of the address to figure out whether the address has received this token at least once in its entire history, or is it to determine the user is currently holding a balance of this tokenId? If it's the latter then you can just use the etoken-list lib can't you?

This revision now requires changes to proceed.Mar 6 2024, 00:41

Just so I'm clear on the underlying use case here, will this be used to parse through all tx history of the address to figure out whether the address has received this token at least once in its entire history, or is it to determine the user is currently holding a balance of this tokenId? If it's the latter then you can just use the etoken-list lib can't you?

Overall goal here will be MVP for token rewards every 24 hrs for Cashtab users

You can see the "eligibility check" function these build up to here: D15599

So, for this case, we will only be interested in the tx history for a certain time window. Getting txs from "only this window" is the most complicated part of the function.

I can see the helper functions introduced here being used in other applications as well.

in-node chronik-client has much better methods than etoken-list for getting a list of token holders and balance. will be implementing these in cashtab and deprecating etoken-list after in-node chronik-client is implemented.

This revision is now accepted and ready to land.Mar 6 2024, 00:54