Page MenuHomePhabricator

D14209.id.diff
No OneTemporary

D14209.id.diff

diff --git a/apps/ecash-herald/config.js b/apps/ecash-herald/config.js
--- a/apps/ecash-herald/config.js
+++ b/apps/ecash-herald/config.js
@@ -44,6 +44,7 @@
shrimp: 0,
},
emojis: {
+ alias: '👾',
block: '📦',
xecSend: '💸',
arrowRight: '➡️',
diff --git a/apps/ecash-herald/constants/op_return.js b/apps/ecash-herald/constants/op_return.js
--- a/apps/ecash-herald/constants/op_return.js
+++ b/apps/ecash-herald/constants/op_return.js
@@ -23,6 +23,7 @@
fusion: { prefix: '46555a00', app: 'Cash Fusion' },
fusionLegacy: { prefix: '5920070', app: 'Cash Fusion' },
slp2: { prefix: '534c5032', app: 'SLP v2' },
+ alias: { prefix: '2e786563', app: 'Alias (beta)' },
},
memo: {
'prefix': '6d',
diff --git a/apps/ecash-herald/src/parse.js b/apps/ecash-herald/src/parse.js
--- a/apps/ecash-herald/src/parse.js
+++ b/apps/ecash-herald/src/parse.js
@@ -423,6 +423,26 @@
// Spec https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/chronik/bitcoinsuite-slp/src/empp/mod.rs
return module.exports.parseMultipushStack(stackArray);
}
+ case opReturn.knownApps.alias.prefix: {
+ app = opReturn.knownApps.alias.app;
+ /*
+ For now, parse and render alias txs by going through OP_RETURN
+ When aliases are live, refactor to use alias-server for validation
+ <protocolIdentifier> <version> <alias> <address type + hash>
+
+ Only parse the msg if the tx is constructed correctly
+ */
+ msg =
+ stackArray.length === 4 && stackArray[1] === '00'
+ ? prepareStringForTelegramHTML(
+ Buffer.from(stackArray[2], 'hex').toString(
+ 'utf8',
+ ),
+ )
+ : 'Invalid alias registration';
+
+ break;
+ }
case opReturn.knownApps.airdrop.prefix: {
app = opReturn.knownApps.airdrop.app;
@@ -1141,6 +1161,10 @@
appEmoji = emojis.memo;
break;
}
+ case opReturn.knownApps.alias.app: {
+ appEmoji = emojis.alias;
+ break;
+ }
case opReturn.knownApps.cashtabMsg.app: {
appEmoji = emojis.cashtabMsg;
break;
diff --git a/apps/ecash-herald/test/mocks/appTxSamples.js b/apps/ecash-herald/test/mocks/appTxSamples.js
--- a/apps/ecash-herald/test/mocks/appTxSamples.js
+++ b/apps/ecash-herald/test/mocks/appTxSamples.js
@@ -378,4 +378,65 @@
msg: `${opReturn.knownApps.slp2.app}:Unknown token type|SEND|Unknown App:\u0004\u0000tab(From Freexec, thank you for your support`,
},
],
+ aliasRegistrations: [
+ {
+ txid: 'dafea3b4ace4d56aec6aed106c6a654d7a1b0bc2f5bfa0599f679da77825e165',
+ hex: '042e78656300046c616d6215000b7d35fda03544a08e65464d54cfae4257eb6db7',
+ stackArray: [
+ '2e786563',
+ '00',
+ '6c616d62',
+ '000b7d35fda03544a08e65464d54cfae4257eb6db7',
+ ],
+ msg: 'lamb',
+ },
+ {
+ txid: '79372d596c1dd14189720b5dc205350d46edfd0fffb108c717b9d0afbcf5869f',
+ hex: '042e78656300046d6f6f6e15000b7d35fda03544a08e65464d54cfae4257eb6db7',
+ stackArray: [
+ '2e786563',
+ '00',
+ '6d6f6f6e',
+ '000b7d35fda03544a08e65464d54cfae4257eb6db7',
+ ],
+ msg: 'moon',
+ },
+ {
+ txid: '65c6afcf8a90d8b69729a0f048d736fda1a40451c3e83867c5a5f5a4c5226694',
+ hex: '042e786563000670616e67616915000b7d35fda03544a08e65464d54cfae4257eb6db7',
+ stackArray: [
+ '2e786563',
+ '00',
+ '70616e676169',
+ '000b7d35fda03544a08e65464d54cfae4257eb6db7',
+ ],
+ msg: 'pangai',
+ },
+ // Invalid alias tx with correct protocol identifier but incomplete stack
+ {
+ txid: 'N/A',
+ hex: '042e78656305426f6f6d21',
+ stackArray: ['2e786563', '426f6f6d21'],
+ msg: 'Invalid alias registration',
+ },
+ // Invalid alias tx with correct protocol identifier but empty stack after protocol identifier
+ {
+ txid: 'N/A',
+ hex: '042e786563',
+ stackArray: ['2e786563'],
+ msg: 'Invalid alias registration',
+ },
+ // Different version # for whatever reason
+ {
+ txid: 'N/A',
+ hex: '042e78656301010670616e67616915000b7d35fda03544a08e65464d54cfae4257eb6db7',
+ stackArray: [
+ '2e786563',
+ '01',
+ '70616e676169',
+ '000b7d35fda03544a08e65464d54cfae4257eb6db7',
+ ],
+ msg: 'Invalid alias registration',
+ },
+ ],
};
diff --git a/apps/ecash-herald/test/parseTests.js b/apps/ecash-herald/test/parseTests.js
--- a/apps/ecash-herald/test/parseTests.js
+++ b/apps/ecash-herald/test/parseTests.js
@@ -32,6 +32,7 @@
encryptedCashtabMsgs,
slp2PushVectors,
slp2TxVectors,
+ aliasRegistrations,
} = require('./mocks/appTxSamples');
describe('parse.js functions', function () {
@@ -76,6 +77,17 @@
assert.strictEqual(result, msg);
}
});
+ it('parseOpReturn handles alias registration txs', function () {
+ for (let i = 0; i < aliasRegistrations.length; i += 1) {
+ const { hex, stackArray, msg } = aliasRegistrations[i];
+ assert.deepEqual(parseOpReturn(hex), {
+ app: opReturn.knownApps.alias.app,
+ msg,
+ stackArray,
+ tokenId: false,
+ });
+ }
+ });
it('parseOpReturn handles airdrop txs with and without a cashtab msg', function () {
for (let i = 0; i < airdrops.length; i += 1) {
const { hex, stackArray, tokenId } = airdrops[i];

File Metadata

Mime Type
text/plain
Expires
Tue, May 20, 21:41 (17 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5865990
Default Alt Text
D14209.id.diff (6 KB)

Event Timeline