HomePhabricator

[Cashtab] [Alias] pt 3 - Implement isAliasAvailable function

Description

[Cashtab] [Alias] pt 3 - Implement isAliasAvailable function

Summary:
T2551

Depends on D12898

This diff fleshes out the isAliasAvailable and extractAliasesFromPaymentAddress functions.

extractAliasesFromPaymentAddress in particular is structured as follows:

loop through each inbound txs in alias payment address
    if the txs has an alias rego prefix in output[0] then
        loop through all outputs in that txs
            tally up the payment values across all outputs going to payment address
            if alias <= 50 char and cumulative payment = expected fee then add alias to array
            (I didn't think minFee check was needed since by virtue of a valid rego fee it will always be higher than minFee)
return array of validated registered aliases

Debug statements kept in for this diff so you can see the list of registered aliases in the console log for validation.

[Cashtab] [Alias] pt 1 - Create scaffold for new Identity component
[Cashtab] [Alias] pt 2 - Implement registerNewAlias() to handle alias registration
[Cashtab] [Alias] pt 3 - Implement isAliasAvailable function
[Cashtab] [Alias] pt 4 - Implement isAddressRegistered function
[Cashtab] [Alias] pt 5 - Implement getAddressFromAlias function
[Cashtab] [Alias] pt 6 - Implement isLocalAliasStateLatest function
[Cashtab] [Alias] pt 7 - Enable alias lookup for Send XEC component
[Cashtab] [Alias] pt 8 - Enable alias lookup for Send Token component
[Cashtab] [Alias] pt 9 - Implement pricing mechanism
[Cashtab] [Alias] pt 10 - Server cron job
[Cashtab] [Alias] pt 11 - Upgrade tx history to recognize alias registration txs

Test Plan:

  • npm test
  • npm start
  • comment out the const link = await registerNewAlias... block in Alias.js in order to initially test the alias availability checking logic and avoid spamming the address with test inputs.
  • input your desired alias and click Register Alias. Note the console log of currently registered aliases. If your alias was not in this list, verify console log displays the correct registration fee for this alias, a Progressing to alias registration console log message is displayed and the alias is rendered on the page with '(Pending)' attached.
  • use one of the existing aliases and click Register Alias. Verify an error notification indicating this is taken.
  • send some weird shit to this payment address and verify the availability logic does not fall over and the list of registered aliases in the console log is not updated with the weird shit
  • uncomment the const link = await registerNewAlias... block in Alias.js and test out the end to end registration of new and existing aliases and ensure the existing ones still trigger the error notification with no further progression to onchain registration.

Reviewers: bytesofman, kieran709, #bitcoin_abc

Reviewed By: bytesofman, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D12907

Details

Provenance
emackAuthored on Dec 17 2022, 13:28
emackPushed on Feb 22 2023, 04:05
Reviewer
Restricted Project
Differential Revision
D12907: [Cashtab] [Alias] pt 3 - Implement isAliasAvailable function
Parents
rABC4ad9fa3054f1: [Cashtab] [Alias] pt 2 - Implement registerNewAlias() to handle alias…
Branches
Unknown
Tags
Unknown