Page MenuHomePhabricator

[alias-server] Support IFP address for alias registrations
AbandonedPublic

Authored by bytesofman on Mar 28 2023, 22:33.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

T3059

Depends on D13489

This diff makes changes required to accept the IFP address as the designated alias registration address.

Two unique properties of the IFP address require changes to support.

  1. The IFP address receives Coinbase txs
  2. The IFP address is P2SH and not P2PKH

alias-server is refactored so that all chronik calls (which require hash160 and address type) are made with variables instead of 'p2pkh' hardcoded. For simplification, the necessary variables are determined from config.aliasConstants.registrationAddress. This way only a single input is required in config.

This diff is a good example of some of the challenges raised by getting too far ahead of reviews. Some code changes were discovered to be necessary to get tests and test scripts to work as I was working on this diff. Initially I had just planned to make a few quick changes so I could do some local testing. However, since these changes will be needed in the production app, I decided it was worthwhile to push up this diff.

  • Refactoring chronik functions to accept p2sh input required adding support for new input parameters
  • Some parameters chronik requires need to be calculated if they are not hardcoded. They should not be hardcoded, so this diff calculates them
  • Due to quirks in ecashaddrjs which I've put up a task to fix later, it is necesary to add a util function to convert a unit 8 array (returned by cashaddr.decode) to a string (accepted by chronik)
  • Also necessary to apply .toLowerCase() to the type returned by ecashaddrjs, as chronik only accepts lowercase address type
  • Discovered a bug in that the confirmedTxs db was not removed from scripts/generateMocks.js earlier in the stack where it should have been, so removed it here

In short, this is a bad diff. However, it does the minimum necessary to support a P2SH registration address.

Test Plan

npm run live, should take a long time but succeed
npm test and all pass
wipe your ecashAliases db
node index.js
In Cashtab's Ticker.js, change to IFP address. Send some txs. See that they are picked up.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
process-only-unprocessed-txs
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 22798
Build 45216: Build Diff
Build 45215: arc lint + arc unit

Event Timeline

unit tests for new function uint8toString

this should be at the beginning of the stack, not the end

will rebuild

web/alias-server/alias.js
208 ↗(On Diff #39007)

aliasConstants is added as a param here to support unit tests that accept different aliasConstants, i.e. different fees or different registration addresses

web/alias-server/scripts/generateMocks.js
49 ↗(On Diff #39007)

This should have been done in an earlier diff. Required to do here so that npm run generateMocks works

web/alias-server/utils.js
137 ↗(On Diff #39007)

aliasConstants is added as a param here to support unit tests that accept different aliasConstants