Page MenuHomePhabricator

[alias-server] Add new database function to lookup registered aliases by address
ClosedPublic

Authored by bytesofman on Jun 26 2023, 23:29.

Details

Summary

T3060

Add a new database function to look up registered aliases by address. This will be used to build an API endpoint.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
alias-from-address-function
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24192
Build 47994: Build Diffalias-server-tests
Build 47993: arc lint + arc unit

Event Timeline

Add unit test for valid ecash address with invalid prefix

emack added inline comments.
apps/alias-server/src/db.js
202

Just double checking - in the event where a dev writes a custom script that sends a registration tx to the payment address for an alias that is already taken, this wouldn't have been registered in the alias-server in the first place right and carries no risk of duplicates flowing through to this function's output?

This revision is now accepted and ready to land.Jun 27 2023, 09:42

(I'm assuming that the code that writes to the db is in charge of rejecting already registered aliases with different addresses)

apps/alias-server/src/db.js
202

Right -- the database collection at config.database.collections.validAliases is initialized with alias as a unique key, i.e. the database cannot accept multiple entries with the same alias

The logic for parsing and determining which is "the" valid alias is handled in alias.js

For this function, it's safe to assume we can't get back more than one registered alias object with the same alias.