Page MenuHomePhabricator

D13414.id38972.diff
No OneTemporary

D13414.id38972.diff

diff --git a/web/alias-server/alias.js b/web/alias-server/alias.js
--- a/web/alias-server/alias.js
+++ b/web/alias-server/alias.js
@@ -32,7 +32,7 @@
// output: {address: 'address', alias: 'alias', txid} if valid
// validate for alias tx
- // Assume P2PKH for now. Add P2SH support in later diff.
+ // P2PKH or P2SH
const inputZeroOutputScript = aliasTx.inputs[0].outputScript;
const registeringAddress = outputScriptToAddress(inputZeroOutputScript);
@@ -80,11 +80,8 @@
return false;
}
} else {
- // Check if output is p2pkh for the alias registration hash160
- if (
- outputScript ===
- `76a914${aliasConstants.registrationHash160}88ac`
- )
+ // Check if this payment went to the alias registration address
+ if (outputScript === aliasConstants.registrationOutputScript)
// If so, then the value here is part of the alias registration fee, aliasFeePaidSats
aliasFeePaidSats += BigInt(value);
}
diff --git a/web/alias-server/config.js b/web/alias-server/config.js
--- a/web/alias-server/config.js
+++ b/web/alias-server/config.js
@@ -20,6 +20,8 @@
express: { port: 5000 },
aliasConstants: {
registrationHash160: '638568e36d0b5d7d49a6e99854caa27d9772b093',
+ registrationOutputScript:
+ '76a914638568e36d0b5d7d49a6e99854caa27d9772b09388ac',
opCodePrefix: '2e786563',
address: 'ecash:qp3c268rd5946l2f5m5es4x25f7ewu4sjvpy52pqa8',
maxLength: 21,
diff --git a/web/alias-server/test/alias.js b/web/alias-server/test/alias.js
--- a/web/alias-server/test/alias.js
+++ b/web/alias-server/test/alias.js
@@ -13,6 +13,7 @@
unprocessedAliases,
testAddressAliasesWithUnconfirmedTxs,
aliases_fake_data,
+ testAliasConstants,
} = require('./mocks/aliasMocks');
describe('alias-server alias.js', function () {
@@ -78,6 +79,14 @@
],
);
});
+ it(`Correctly parses an alias registration tx from a p2sh address`, function () {
+ const { p2shtx, parsedp2shtx } = aliases_fake_data;
+ const { p2shRegistrationAddress } = testAliasConstants;
+ assert.deepEqual(
+ parseAliasTx(p2shtx, p2shRegistrationAddress),
+ parsedp2shtx,
+ );
+ });
it('Returns false for an eToken transaction', function () {
assert.deepEqual(
parseAliasTx(
diff --git a/web/alias-server/test/mocks/aliasMocks.js b/web/alias-server/test/mocks/aliasMocks.js
--- a/web/alias-server/test/mocks/aliasMocks.js
+++ b/web/alias-server/test/mocks/aliasMocks.js
@@ -39108,5 +39108,121 @@
blockheight: 100000000,
},
],
+ p2shtx: {
+ txid: '446c1c3d979deed2b81258d907343c09091bc349352005d3a5804c97c611d19b',
+ version: 2,
+ // overwrite first input's outputscript to be p2sh of ifp address, ecash: prfhcnyqnl5cgrnmlfmms675w93ld7mvvqd0y8lz07
+ // a914d37c4c809fe9840e7bfa77b86bd47163f6fb6c6087
+ // also overwrite output script to be p2sh to test that too
+ inputs: [
+ {
+ prevOut: {
+ txid: '45c838577b52d532c46caa743a0a46edd4876b6f8e9d0d58ca094b9d70afade3',
+ outIdx: 248,
+ },
+ inputScript:
+ '473044022006ee5e5064d9eaef4c56e4a9b578d4a2dff87fae58624ccb6e34d547a3f607f90220674cbd244370f110fc88b49ac983b300c2f1cba3523332dff3486daa49d1efc94121031e9483074a9f0ee7380131a870edbe9403e7b807a4b5611b01540a150f6aa454',
+ outputScript:
+ 'a914d37c4c809fe9840e7bfa77b86bd47163f6fb6c6087',
+ value: '179533',
+ sequenceNo: 4294967295,
+ },
+ ],
+ outputs: [
+ {
+ value: '0',
+ outputScript: '6a042e786563036e6673',
+ },
+ {
+ value: '556',
+ outputScript:
+ 'a914d37c4c809fe9840e7bfa77b86bd47163f6fb6c6087',
+ },
+ {
+ value: '178522',
+ outputScript:
+ '76a9149846b6b38ff713334ac19fe3cf851a1f98c07b0088ac',
+ spentBy: {
+ txid: '20182fb85164e7c0724cb42455ee2758e4c996ee613690d03eb96ba0ab2aebd2',
+ outIdx: 0,
+ },
+ },
+ ],
+ lockTime: 0,
+ block: {
+ height: 771103,
+ hash: '00000000000000000f36aead0613a57660de0a9ca5d587b64b5954e27622c469',
+ timestamp: '1671519222',
+ },
+ timeFirstSeen: '1671518864',
+ size: 244,
+ isCoinbase: false,
+ network: 'XEC',
+ },
+ parsedp2shtx: {
+ address: 'ecash:prfhcnyqnl5cgrnmlfmms675w93ld7mvvqd0y8lz07',
+ alias: 'nfs',
+ blockheight: 771103,
+ txid: '446c1c3d979deed2b81258d907343c09091bc349352005d3a5804c97c611d19b',
+ },
+ },
+ testAliasConstants: {
+ p2shRegistrationAddress: {
+ registrationHash160: 'd37c4c809fe9840e7bfa77b86bd47163f6fb6c60',
+ registrationOutputScript:
+ 'a914d37c4c809fe9840e7bfa77b86bd47163f6fb6c6087',
+ opCodePrefix: '2e786563',
+ address: 'ecash:prfhcnyqnl5cgrnmlfmms675w93ld7mvvqd0y8lz07',
+ maxLength: 21,
+ registrationFeesSats: {
+ 1: 558,
+ 2: 557,
+ 3: 556,
+ 4: 555,
+ 5: 554,
+ 6: 553,
+ 7: 552,
+ 8: 551,
+ 9: 551,
+ 10: 551,
+ 11: 551,
+ 12: 551,
+ 13: 551,
+ 14: 551,
+ 15: 551,
+ 16: 551,
+ 17: 551,
+ 18: 551,
+ 19: 551,
+ 20: 551,
+ 21: 551,
+ },
+ reservedAliases: [
+ 'avalanche',
+ 'electrum',
+ 'electrumabc',
+ 'bitcoin',
+ 'bitcoinabc',
+ 'ecash',
+ 'ecashofficial',
+ 'xec',
+ 'abc',
+ 'cashtab',
+ 'ecashtab',
+ 'cashtabwallet',
+ 'xecwallet',
+ 'gnc',
+ 'etoken',
+ 'token',
+ 'cashfusion',
+ 'coinbase',
+ 'binance',
+ 'ethereum',
+ 'helpdesk',
+ 'admin',
+ 'support',
+ 'official',
+ ],
+ },
},
};

File Metadata

Mime Type
text/plain
Expires
Thu, Feb 6, 16:37 (17 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5082711
Default Alt Text
D13414.id38972.diff (6 KB)

Event Timeline