Page MenuHomePhabricator

D14187.id.diff
No OneTemporary

D14187.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
@@ -45,6 +45,7 @@
emojis: {
block: '📦',
xecSend: '💸',
+ arrowRight: '➡️',
tokenBurn: '🔥',
tokenGenesis: '🧪',
tokenSend: '🎟',
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
@@ -182,7 +182,7 @@
* { txid, genesisInfo, opReturnInfo }
*/
- const { txid, inputs, outputs, size } = tx;
+ const { txid, inputs, outputs } = tx;
let isTokenTx = false;
let genesisInfo = false;
@@ -335,7 +335,6 @@
// Determine tx fee
const txFee = xecInputAmountSats - xecOutputAmountSats;
- const satsPerByte = txFee / size;
// If this is a token send tx, return token send parsing info and not 'false' for tokenSendInfo
if (tokenSendInfo) {
@@ -359,7 +358,7 @@
txid,
genesisInfo,
opReturnInfo,
- satsPerByte,
+ txFee,
xecSendingOutputScripts,
xecChangeOutputs,
xecReceivingOutputs,
@@ -1110,13 +1109,14 @@
txid,
genesisInfo,
opReturnInfo,
- satsPerByte,
+ txFee,
xecSendingOutputScripts,
xecChangeOutputs,
xecReceivingOutputs,
tokenSendInfo,
tokenBurnInfo,
} = thisParsedTx;
+
if (genesisInfo) {
// The txid of a genesis tx is the tokenId
const tokenId = txid;
@@ -1369,6 +1369,8 @@
coingeckoPrices,
);
+ const displayedTxFee = satsToFormattedValue(txFee, coingeckoPrices);
+
// Clone xecReceivingOutputs so that you don't modify unit test mocks
let xecReceivingAddressOutputs = new Map(xecReceivingOutputs);
@@ -1417,25 +1419,23 @@
changeAmountSats,
coingeckoPrices,
);
- xecSendMsg = `${emojis.xecSend}${xecSenderEmoji}${
+ xecSendMsg = `${emojis.xecSend}<a href="${
+ config.blockExplorer
+ }/tx/${txid}">${displayedChangeAmountXec} for ${displayedTxFee}</a> | ${xecSenderEmoji}${
xecSendingOutputScripts.size
} ${
xecSendingOutputScripts.size > 1 ? 'addresses' : 'address'
- } <a href="${
- config.blockExplorer
- }/tx/${txid}">sent</a> ${displayedChangeAmountXec} to ${
+ } ${config.emojis.arrowRight} ${
xecSendingOutputScripts.size > 1 ? 'themselves' : 'itself'
- }| <code>${satsPerByte.toFixed(2)}</code>`;
+ }`;
} else {
- xecSendMsg = `${
- emojis.xecSend
- }${xecSenderEmoji}${returnAddressPreview(
+ xecSendMsg = `${emojis.xecSend}<a href="${
+ config.blockExplorer
+ }/tx/${txid}">${displayedXecSent} for ${displayedTxFee}</a> | ${xecSenderEmoji}${returnAddressPreview(
cashaddr.encodeOutputScript(
xecSendingOutputScripts.values().next().value,
),
- )} <a href="${
- config.blockExplorer
- }/tx/${txid}">sent</a> ${displayedXecSent} to ${
+ )} ${config.emojis.arrowRight} ${
xecReceivingAddressOutputs.keys().next().value ===
xecSendingOutputScripts.values().next().value
? 'itself'
@@ -1451,7 +1451,7 @@
xecReceivingAddressOutputs.size - 1 > 1 ? 's' : ''
}`
: ''
- } | <code>${satsPerByte.toFixed(2)}</code>`;
+ }`;
}
xecSendTxTgMsgLines.push(xecSendMsg);
@@ -1553,13 +1553,13 @@
// Line break for new section
tgMsg.push('');
- // 1 eCash tx | tx fee in satoshis per byte
+ // 1 eCash tx
// or
- // n eCash txs | tx fee in satoshis per byte
+ // n eCash txs
tgMsg.push(
`${xecSendTxTgMsgLines.length} eCash tx${
xecSendTxTgMsgLines.length > 1 ? `s` : ''
- } | <code>tx fee in satoshis per byte</code>`,
+ }`,
);
tgMsg = tgMsg.concat(xecSendTxTgMsgLines);
diff --git a/apps/ecash-herald/src/utils.js b/apps/ecash-herald/src/utils.js
--- a/apps/ecash-herald/src/utils.js
+++ b/apps/ecash-herald/src/utils.js
@@ -163,13 +163,25 @@
// Get fiat price
let fiatAmount = xecAmount * price;
+ const fiatSymbol = config.fiatReference[fiat];
// Format fiatAmount for different tiers
- if (fiatAmount < 1) {
- // If we're working with less than a dollar, give XEC amounts
- return module.exports.formatXecAmount(xecAmount);
+ let displayedAmount;
+ let localeOptions = { maximumFractionDigits: 0 };
+ let descriptor = '';
+
+ if (fiatAmount === 0) {
+ // Txs that send nothing, e.g. a one-input tx of 5.46 XEC, should keep defaults above
+ } else if (fiatAmount < 0.01) {
+ // enough decimal places to show one significant digit
+ localeOptions = {
+ minimumFractionDigits: -Math.floor(Math.log10(fiatAmount)),
+ };
+ } else if (fiatAmount < 1) {
+ // TODO two decimal places
+ localeOptions = { minimumFractionDigits: 2 };
}
- let displayedAmount, descriptor;
+
if (fiatAmount < 1000) {
displayedAmount = fiatAmount;
descriptor = '';
@@ -186,11 +198,11 @@
displayedAmount = fiatAmount / 1000000000;
descriptor = 'B';
}
- const fiatSymbol = config.fiatReference[fiat];
- return `${fiatSymbol}${displayedAmount.toLocaleString('en-US', {
- maximumFractionDigits: 0,
- })}${descriptor}`;
+ return `${fiatSymbol}${displayedAmount.toLocaleString(
+ 'en-US',
+ localeOptions,
+ )}${descriptor}`;
},
jsonReplacer: function (key, value) {
if (value instanceof Map) {
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
@@ -246,7 +246,7 @@
{ fiat: 'usd', price: 25000, ticker: 'BTC' },
{ fiat: 'usd', price: 1900, ticker: 'ETH' },
],
- msg: 'qrm...r48 airdropped 50 XEC to 4 holders of <a href="https://explorer.e.cash/tx/1c6c9c64d70b285befe733f175d0f384538576876bd280b10587df81279d3f5e">DET</a>',
+ msg: 'qrm...r48 airdropped $0.002 to 4 holders of <a href="https://explorer.e.cash/tx/1c6c9c64d70b285befe733f175d0f384538576876bd280b10587df81279d3f5e">DET</a>',
msgApiFailure:
'qrm...r48 airdropped 50 XEC to 4 holders of <a href="https://explorer.e.cash/tx/1c6c9c64d70b285befe733f175d0f384538576876bd280b10587df81279d3f5e">1c6...f5e</a>',
},
@@ -301,7 +301,7 @@
{ fiat: 'usd', price: 25000, ticker: 'BTC' },
{ fiat: 'usd', price: 1900, ticker: 'ETH' },
],
- msg: 'qq9...fgx sent an encrypted message and 7 XEC to qrm...r48 and 1 other',
+ msg: 'qq9...fgx sent an encrypted message and $0.0002 to qrm...r48 and 1 other',
msgApiFailure:
'qq9...fgx sent an encrypted message and 7 XEC to qrm...r48 and 1 other',
},
diff --git a/apps/ecash-herald/test/mocks/blocks.js b/apps/ecash-herald/test/mocks/blocks.js
--- a/apps/ecash-herald/test/mocks/blocks.js
+++ b/apps/ecash-herald/test/mocks/blocks.js
@@ -508,7 +508,7 @@
"txid": "0167e881fcb359cdfc82af5fc6c0821daf55f40767694eea2f23c0d42a9b1c17",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 1.9135514018691588,
+ "txFee": 1638,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -564,7 +564,7 @@
"txid": "25345b0bf921a2a9080c647768ba440bbe84499f4c7773fba8a1b03e88ae7fe7",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 2.36875,
+ "txFee": 1137,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -632,7 +632,7 @@
"txid": "34cf0f2a51b80dc4c48c8dae9017af6282298f275c7823cb70d3f5b05785456c",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 1.096774193548387,
+ "txFee": 408,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -665,7 +665,7 @@
"txid": "ea54f221be5c17dafc852f581f0e20dea0e72d7f0b3c691b4333fc1577bf0724",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 2.5395348837209304,
+ "txFee": 546,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -1269,38 +1269,6 @@
]
}
],
- [
- "76a9146debf178121d1aac40e40183957e9f74195fb5e888ac",
- {
- "emoji": "",
- "balanceSats": 0,
- "utxos": []
- }
- ],
- [
- "76a914d71b6d842ab10517d93a10341975448f2e358a1788ac",
- {
- "emoji": "",
- "balanceSats": 224200967,
- "utxos": [
- {
- "outputScript": "76a914d71b6d842ab10517d93a10341975448f2e358a1788ac",
- "utxos": [
- {
- "outpoint": {
- "txid": "fee7368b7f228739a21d4e1e2920613cf869fd464b5162a2f20bba97ada4086f",
- "outIdx": 0
- },
- "blockHeight": 792777,
- "isCoinbase": false,
- "value": "224200967",
- "network": "XEC"
- }
- ]
- }
- ]
- }
- ],
[
"76a914dadf34cde9c774fdd6340cd2916a9b9c5d57cf4388ac",
{
@@ -2237,14 +2205,46 @@
}
]
}
+ ],
+ [
+ "76a9146debf178121d1aac40e40183957e9f74195fb5e888ac",
+ {
+ "emoji": "",
+ "balanceSats": 0,
+ "utxos": []
+ }
+ ],
+ [
+ "76a914d71b6d842ab10517d93a10341975448f2e358a1788ac",
+ {
+ "emoji": "",
+ "balanceSats": 224200967,
+ "utxos": [
+ {
+ "outputScript": "76a914d71b6d842ab10517d93a10341975448f2e358a1788ac",
+ "utxos": [
+ {
+ "outpoint": {
+ "txid": "fee7368b7f228739a21d4e1e2920613cf869fd464b5162a2f20bba97ada4086f",
+ "outIdx": 0
+ },
+ "blockHeight": 792777,
+ "isCoinbase": false,
+ "value": "224200967",
+ "network": "XEC"
+ }
+ ]
+ }
+ ]
+ }
]
]
},
"blockSummaryTgMsgs": [
- "📦<a href=\"https://explorer.e.cash/block/000000000000000003a43161c1d963b1df57f639a4621f56d3dbf69d5a8d0561\">782571</a> | 5 txs | ViaBTC, Mined by 600414\n1 XEC = $0.00003514\n1 BTC = $30,583\n1 ETH = $1,923\n\n2 eToken send txs\n🎟1 address <a href=\"https://explorer.e.cash/tx/0167e881fcb359cdfc82af5fc6c0821daf55f40767694eea2f23c0d42a9b1c17\">sent</a> 356.6918 <a href=\"https://explorer.e.cash/tx/7e7dacd72dcdb14e00a03dd3aff47f019ed51a6f1f4e4f532ae50692f62bc4e5\">BUX</a> to itself\n🎟qqw...6v4 <a href=\"https://explorer.e.cash/tx/25345b0bf921a2a9080c647768ba440bbe84499f4c7773fba8a1b03e88ae7fe7\">sent</a> 5,000,000.00 <a href=\"https://explorer.e.cash/tx/fb4233e8a568993976ed38a81c2671587c5ad09552dedefa78760deed6ff87aa\">GRP</a> to qrd...9j0\n\n2 eCash txs | <code>tx fee in satoshis per byte</code>\n💸qpk...pga <a href=\"https://explorer.e.cash/tx/34cf0f2a51b80dc4c48c8dae9017af6282298f275c7823cb70d3f5b05785456c\">sent</a> $37 to qrt...4v7 | <code>1.10</code>\n💸1 address <a href=\"https://explorer.e.cash/tx/ea54f221be5c17dafc852f581f0e20dea0e72d7f0b3c691b4333fc1577bf0724\">sent</a> 0 XEC to itself| <code>2.54</code>"
+ "📦<a href=\"https://explorer.e.cash/block/000000000000000003a43161c1d963b1df57f639a4621f56d3dbf69d5a8d0561\">782571</a> | 5 txs | ViaBTC, Mined by 600414\n1 XEC = $0.00003514\n1 BTC = $30,583\n1 ETH = $1,923\n\n2 eToken send txs\n🎟1 address <a href=\"https://explorer.e.cash/tx/0167e881fcb359cdfc82af5fc6c0821daf55f40767694eea2f23c0d42a9b1c17\">sent</a> 356.6918 <a href=\"https://explorer.e.cash/tx/7e7dacd72dcdb14e00a03dd3aff47f019ed51a6f1f4e4f532ae50692f62bc4e5\">BUX</a> to itself\n🎟qqw...6v4 <a href=\"https://explorer.e.cash/tx/25345b0bf921a2a9080c647768ba440bbe84499f4c7773fba8a1b03e88ae7fe7\">sent</a> 5,000,000.00 <a href=\"https://explorer.e.cash/tx/fb4233e8a568993976ed38a81c2671587c5ad09552dedefa78760deed6ff87aa\">GRP</a> to qrd...9j0\n\n2 eCash txs\n💸<a href=\"https://explorer.e.cash/tx/34cf0f2a51b80dc4c48c8dae9017af6282298f275c7823cb70d3f5b05785456c\">$37 for $0.0001</a> | qpk...pga ➡️ qrt...4v7\n💸<a href=\"https://explorer.e.cash/tx/ea54f221be5c17dafc852f581f0e20dea0e72d7f0b3c691b4333fc1577bf0724\">$0 for $0.0002</a> | 1 address ➡️ itself"
],
"blockSummaryTgMsgsApiFailure": [
- "📦<a href=\"https://explorer.e.cash/block/000000000000000003a43161c1d963b1df57f639a4621f56d3dbf69d5a8d0561\">782571</a> | 5 txs | ViaBTC, Mined by 600414\n\n4 eCash txs | <code>tx fee in satoshis per byte</code>\n💸1 address <a href=\"https://explorer.e.cash/tx/0167e881fcb359cdfc82af5fc6c0821daf55f40767694eea2f23c0d42a9b1c17\">sent</a> 11 XEC to itself| <code>1.91</code>\n💸qqw...6v4 <a href=\"https://explorer.e.cash/tx/25345b0bf921a2a9080c647768ba440bbe84499f4c7773fba8a1b03e88ae7fe7\">sent</a> 5.46 XEC to qrd...9j0 | <code>2.37</code>\n💸qpk...pga <a href=\"https://explorer.e.cash/tx/34cf0f2a51b80dc4c48c8dae9017af6282298f275c7823cb70d3f5b05785456c\">sent</a> 1M XEC to qrt...4v7 | <code>1.10</code>\n💸1 address <a href=\"https://explorer.e.cash/tx/ea54f221be5c17dafc852f581f0e20dea0e72d7f0b3c691b4333fc1577bf0724\">sent</a> 0 XEC to itself| <code>2.54</code>"
+ "📦<a href=\"https://explorer.e.cash/block/000000000000000003a43161c1d963b1df57f639a4621f56d3dbf69d5a8d0561\">782571</a> | 5 txs | ViaBTC, Mined by 600414\n\n4 eCash txs\n💸<a href=\"https://explorer.e.cash/tx/0167e881fcb359cdfc82af5fc6c0821daf55f40767694eea2f23c0d42a9b1c17\">11 XEC for 16 XEC</a> | 1 address ➡️ itself\n💸<a href=\"https://explorer.e.cash/tx/25345b0bf921a2a9080c647768ba440bbe84499f4c7773fba8a1b03e88ae7fe7\">5.46 XEC for 11 XEC</a> | qqw...6v4 ➡️ qrd...9j0\n💸<a href=\"https://explorer.e.cash/tx/34cf0f2a51b80dc4c48c8dae9017af6282298f275c7823cb70d3f5b05785456c\">1M XEC for 4.08 XEC</a> | qpk...pga ➡️ qrt...4v7\n💸<a href=\"https://explorer.e.cash/tx/ea54f221be5c17dafc852f581f0e20dea0e72d7f0b3c691b4333fc1577bf0724\">0 XEC for 5.46 XEC</a> | 1 address ➡️ itself"
],
"blockName": "buxTxs"
},
@@ -2920,7 +2920,7 @@
],
"tokenId": false
},
- "satsPerByte": 1.57439446366782,
+ "txFee": 455,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -2956,7 +2956,7 @@
"txid": "4d6845d856e34b03ef6830313c4cc75f80daee491eee7b8d55f32cdb8c2b72e6",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 5,
+ "txFee": 1120,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -2983,7 +2983,7 @@
"txid": "7b0802223d4376f3bca1a76c9a2deab0c18c2fc5f070d4adb65abdb18d328f08",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 2.019342359767892,
+ "txFee": 1044,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -3023,7 +3023,7 @@
],
"tokenId": false
},
- "satsPerByte": 1.6192170818505338,
+ "txFee": 455,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -3059,7 +3059,7 @@
"txid": "ac4e0acbe7f0e0e25ef3366e2d066ebaa543c0fe8721e998d4cab03fbeb8a5a9",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 5.012406947890819,
+ "txFee": 2020,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -3086,7 +3086,7 @@
"txid": "b4fee092558400fa905336da8c0465e6be857bb6fad758825a20e90a6a12c323",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 5.022421524663677,
+ "txFee": 1120,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -3113,7 +3113,7 @@
"txid": "c04ae7f139eb16023a70d1bb39b1ae8745667edb09833e994a5b4d48976a111d",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 2.373695198329854,
+ "txFee": 1137,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -3181,7 +3181,7 @@
"txid": "c7bfee6cb99bfd021e3d6f38f08391d111463a2872d50b6bc3c5351015707adc",
"genesisInfo": false,
"opReturnInfo": false,
- "satsPerByte": 5.014619883040936,
+ "txFee": 13720,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -3216,7 +3216,7 @@
],
"tokenId": false
},
- "satsPerByte": 1.0178970917225951,
+ "txFee": 455,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -6979,7 +6979,7 @@
}
],
[
- "76a9146bd9330ad46ce1e786864434039b0c15b526bc7088ac",
+ "a91410f3ed6835b5e1a36c6e7e272a08024e45a4f3a087",
{
"emoji": "",
"balanceSats": 0,
@@ -6987,7 +6987,7 @@
}
],
[
- "a91410f3ed6835b5e1a36c6e7e272a08024e45a4f3a087",
+ "76a9146bd9330ad46ce1e786864434039b0c15b526bc7088ac",
{
"emoji": "",
"balanceSats": 0,
@@ -6995,7 +6995,7 @@
}
],
[
- "76a914287a7feec5fdcae526944bb92aa484a32923614e88ac",
+ "76a914ec40fd5c237cb739dafa33ef8a2aa52f41ba269088ac",
{
"emoji": "",
"balanceSats": 0,
@@ -7003,7 +7003,7 @@
}
],
[
- "76a914ec40fd5c237cb739dafa33ef8a2aa52f41ba269088ac",
+ "76a914a4dda233904acfd93ec8e450a52fd488210ce82a88ac",
{
"emoji": "",
"balanceSats": 0,
@@ -7011,7 +7011,7 @@
}
],
[
- "76a914a4dda233904acfd93ec8e450a52fd488210ce82a88ac",
+ "76a914287a7feec5fdcae526944bb92aa484a32923614e88ac",
{
"emoji": "",
"balanceSats": 0,
@@ -7021,10 +7021,10 @@
]
},
"blockSummaryTgMsgs": [
- "📦<a href=\"https://explorer.e.cash/block/00000000000000000609f6bcbbf5169ae25142ad7f119b541adad5789faa28e4\">782774</a> | 10 txs | ViaBTC, Mined by slavm01\n1 XEC = $0.00003514\n1 BTC = $30,583\n1 ETH = $1,923\n\n1 eToken send tx\n🎟qz2...035 <a href=\"https://explorer.e.cash/tx/c04ae7f139eb16023a70d1bb39b1ae8745667edb09833e994a5b4d48976a111d\">sent</a> 2 <a href=\"https://explorer.e.cash/tx/b9877d8f8d2364b983707df905d592f534a3ada18e52aa529a0f72fcc535abf7\">SRM</a> to qp8...gg6\n\nApp txs:\n🖋<a href=\"https://explorer.e.cash/tx/2769041aa0e069610f3050c1a7d6f20e322e216625086d1d9c1f35dd0e85fbe9\">Cashtab Msg:</a> Why not another one, this time with emojis 🤔\n🖋<a href=\"https://explorer.e.cash/tx/a2f704933049b5c5a712a9943ac2e264fbeb1354cd5f2187e31eb68a8f38aa72\">Cashtab Msg:</a> Can't believe already need to test again\n🖋<a href=\"https://explorer.e.cash/tx/d9915ae3c4a7ec176746d3902295c1d2cf8912db589289842c14803a67cfc9d1\">Cashtab Msg:</a> Another Cashtab message to the TG bot. Making it longer to see if spacing is a problem. Is spacing a problem? Is parsing a problem? Who can tell. We will only know after this message appears (or doesn't). \n\n5 eCash txs | <code>tx fee in satoshis per byte</code>\n💸qrw...re7 <a href=\"https://explorer.e.cash/tx/4d6845d856e34b03ef6830313c4cc75f80daee491eee7b8d55f32cdb8c2b72e6\">sent</a> 21 XEC to qza...e7g | <code>5.00</code>\n💸qp4...v8x <a href=\"https://explorer.e.cash/tx/7b0802223d4376f3bca1a76c9a2deab0c18c2fc5f070d4adb65abdb18d328f08\">sent</a> $161 to pqg...tlg and 1 other | <code>2.02</code>\n💸qq5...ck4 <a href=\"https://explorer.e.cash/tx/ac4e0acbe7f0e0e25ef3366e2d066ebaa543c0fe8721e998d4cab03fbeb8a5a9\">sent</a> 10k XEC to qza...e7g | <code>5.01</code>\n💸qzj...u85 <a href=\"https://explorer.e.cash/tx/b4fee092558400fa905336da8c0465e6be857bb6fad758825a20e90a6a12c323\">sent</a> 29 XEC to qza...e7g | <code>5.02</code>\n💸qrk...wcf <a href=\"https://explorer.e.cash/tx/c7bfee6cb99bfd021e3d6f38f08391d111463a2872d50b6bc3c5351015707adc\">sent</a> 8k XEC to qza...e7g | <code>5.01</code>"
+ "📦<a href=\"https://explorer.e.cash/block/00000000000000000609f6bcbbf5169ae25142ad7f119b541adad5789faa28e4\">782774</a> | 10 txs | ViaBTC, Mined by slavm01\n1 XEC = $0.00003514\n1 BTC = $30,583\n1 ETH = $1,923\n\n1 eToken send tx\n🎟qz2...035 <a href=\"https://explorer.e.cash/tx/c04ae7f139eb16023a70d1bb39b1ae8745667edb09833e994a5b4d48976a111d\">sent</a> 2 <a href=\"https://explorer.e.cash/tx/b9877d8f8d2364b983707df905d592f534a3ada18e52aa529a0f72fcc535abf7\">SRM</a> to qp8...gg6\n\nApp txs:\n🖋<a href=\"https://explorer.e.cash/tx/2769041aa0e069610f3050c1a7d6f20e322e216625086d1d9c1f35dd0e85fbe9\">Cashtab Msg:</a> Why not another one, this time with emojis 🤔\n🖋<a href=\"https://explorer.e.cash/tx/a2f704933049b5c5a712a9943ac2e264fbeb1354cd5f2187e31eb68a8f38aa72\">Cashtab Msg:</a> Can't believe already need to test again\n🖋<a href=\"https://explorer.e.cash/tx/d9915ae3c4a7ec176746d3902295c1d2cf8912db589289842c14803a67cfc9d1\">Cashtab Msg:</a> Another Cashtab message to the TG bot. Making it longer to see if spacing is a problem. Is spacing a problem? Is parsing a problem? Who can tell. We will only know after this message appears (or doesn't). \n\n5 eCash txs\n💸<a href=\"https://explorer.e.cash/tx/4d6845d856e34b03ef6830313c4cc75f80daee491eee7b8d55f32cdb8c2b72e6\">$0.0008 for $0.0004</a> | qrw...re7 ➡️ qza...e7g\n💸<a href=\"https://explorer.e.cash/tx/7b0802223d4376f3bca1a76c9a2deab0c18c2fc5f070d4adb65abdb18d328f08\">$161 for $0.0004</a> | qp4...v8x ➡️ pqg...tlg and 1 other\n💸<a href=\"https://explorer.e.cash/tx/ac4e0acbe7f0e0e25ef3366e2d066ebaa543c0fe8721e998d4cab03fbeb8a5a9\">$0.361 for $0.0007</a> | qq5...ck4 ➡️ qza...e7g\n💸<a href=\"https://explorer.e.cash/tx/b4fee092558400fa905336da8c0465e6be857bb6fad758825a20e90a6a12c323\">$0.001 for $0.0004</a> | qzj...u85 ➡️ qza...e7g\n💸<a href=\"https://explorer.e.cash/tx/c7bfee6cb99bfd021e3d6f38f08391d111463a2872d50b6bc3c5351015707adc\">$0.289 for $0.005</a> | qrk...wcf ➡️ qza...e7g"
],
"blockSummaryTgMsgsApiFailure": [
- "📦<a href=\"https://explorer.e.cash/block/00000000000000000609f6bcbbf5169ae25142ad7f119b541adad5789faa28e4\">782774</a> | 10 txs | ViaBTC, Mined by slavm01\n\nApp txs:\n🖋<a href=\"https://explorer.e.cash/tx/2769041aa0e069610f3050c1a7d6f20e322e216625086d1d9c1f35dd0e85fbe9\">Cashtab Msg:</a> Why not another one, this time with emojis 🤔\n🖋<a href=\"https://explorer.e.cash/tx/a2f704933049b5c5a712a9943ac2e264fbeb1354cd5f2187e31eb68a8f38aa72\">Cashtab Msg:</a> Can't believe already need to test again\n🖋<a href=\"https://explorer.e.cash/tx/d9915ae3c4a7ec176746d3902295c1d2cf8912db589289842c14803a67cfc9d1\">Cashtab Msg:</a> Another Cashtab message to the TG bot. Making it longer to see if spacing is a problem. Is spacing a problem? Is parsing a problem? Who can tell. We will only know after this message appears (or doesn't). \n\n6 eCash txs | <code>tx fee in satoshis per byte</code>\n💸qrw...re7 <a href=\"https://explorer.e.cash/tx/4d6845d856e34b03ef6830313c4cc75f80daee491eee7b8d55f32cdb8c2b72e6\">sent</a> 21 XEC to qza...e7g | <code>5.00</code>\n💸qp4...v8x <a href=\"https://explorer.e.cash/tx/7b0802223d4376f3bca1a76c9a2deab0c18c2fc5f070d4adb65abdb18d328f08\">sent</a> 5M XEC to pqg...tlg and 1 other | <code>2.02</code>\n💸qq5...ck4 <a href=\"https://explorer.e.cash/tx/ac4e0acbe7f0e0e25ef3366e2d066ebaa543c0fe8721e998d4cab03fbeb8a5a9\">sent</a> 10k XEC to qza...e7g | <code>5.01</code>\n💸qzj...u85 <a href=\"https://explorer.e.cash/tx/b4fee092558400fa905336da8c0465e6be857bb6fad758825a20e90a6a12c323\">sent</a> 29 XEC to qza...e7g | <code>5.02</code>\n💸qz2...035 <a href=\"https://explorer.e.cash/tx/c04ae7f139eb16023a70d1bb39b1ae8745667edb09833e994a5b4d48976a111d\">sent</a> 5.46 XEC to qp8...gg6 | <code>2.37</code>\n💸qrk...wcf <a href=\"https://explorer.e.cash/tx/c7bfee6cb99bfd021e3d6f38f08391d111463a2872d50b6bc3c5351015707adc\">sent</a> 8k XEC to qza...e7g | <code>5.01</code>"
+ "📦<a href=\"https://explorer.e.cash/block/00000000000000000609f6bcbbf5169ae25142ad7f119b541adad5789faa28e4\">782774</a> | 10 txs | ViaBTC, Mined by slavm01\n\nApp txs:\n🖋<a href=\"https://explorer.e.cash/tx/2769041aa0e069610f3050c1a7d6f20e322e216625086d1d9c1f35dd0e85fbe9\">Cashtab Msg:</a> Why not another one, this time with emojis 🤔\n🖋<a href=\"https://explorer.e.cash/tx/a2f704933049b5c5a712a9943ac2e264fbeb1354cd5f2187e31eb68a8f38aa72\">Cashtab Msg:</a> Can't believe already need to test again\n🖋<a href=\"https://explorer.e.cash/tx/d9915ae3c4a7ec176746d3902295c1d2cf8912db589289842c14803a67cfc9d1\">Cashtab Msg:</a> Another Cashtab message to the TG bot. Making it longer to see if spacing is a problem. Is spacing a problem? Is parsing a problem? Who can tell. We will only know after this message appears (or doesn't). \n\n6 eCash txs\n💸<a href=\"https://explorer.e.cash/tx/4d6845d856e34b03ef6830313c4cc75f80daee491eee7b8d55f32cdb8c2b72e6\">21 XEC for 11 XEC</a> | qrw...re7 ➡️ qza...e7g\n💸<a href=\"https://explorer.e.cash/tx/7b0802223d4376f3bca1a76c9a2deab0c18c2fc5f070d4adb65abdb18d328f08\">5M XEC for 10 XEC</a> | qp4...v8x ➡️ pqg...tlg and 1 other\n💸<a href=\"https://explorer.e.cash/tx/ac4e0acbe7f0e0e25ef3366e2d066ebaa543c0fe8721e998d4cab03fbeb8a5a9\">10k XEC for 20 XEC</a> | qq5...ck4 ➡️ qza...e7g\n💸<a href=\"https://explorer.e.cash/tx/b4fee092558400fa905336da8c0465e6be857bb6fad758825a20e90a6a12c323\">29 XEC for 11 XEC</a> | qzj...u85 ➡️ qza...e7g\n💸<a href=\"https://explorer.e.cash/tx/c04ae7f139eb16023a70d1bb39b1ae8745667edb09833e994a5b4d48976a111d\">5.46 XEC for 11 XEC</a> | qz2...035 ➡️ qp8...gg6\n💸<a href=\"https://explorer.e.cash/tx/c7bfee6cb99bfd021e3d6f38f08391d111463a2872d50b6bc3c5351015707adc\">8k XEC for 137 XEC</a> | qrk...wcf ➡️ qza...e7g"
],
"blockName": "cashtabMsgMulti"
},
@@ -8212,7 +8212,7 @@
],
"tokenId": false
},
- "satsPerByte": 1.0087370929308976,
+ "txFee": 11430,
"xecSendingOutputScripts": {
"dataType": "Set",
"value": [
@@ -8594,14 +8594,6 @@
"outputScriptInfoMap": {
"dataType": "Map",
"value": [
- [
- "76a91412934a7a99b69a60c3b99f991cd79d257104f5a688ac",
- {
- "emoji": "",
- "balanceSats": 0,
- "utxos": []
- }
- ],
[
"76a914d7fc1d156d8ec4384623bb8ceb135df93f2bd93188ac",
{
@@ -8625,6 +8617,14 @@
}
]
}
+ ],
+ [
+ "76a91412934a7a99b69a60c3b99f991cd79d257104f5a688ac",
+ {
+ "emoji": "",
+ "balanceSats": 0,
+ "utxos": []
+ }
]
]
},
diff --git a/apps/ecash-herald/test/utilsTests.js b/apps/ecash-herald/test/utilsTests.js
--- a/apps/ecash-herald/test/utilsTests.js
+++ b/apps/ecash-herald/test/utilsTests.js
@@ -212,10 +212,34 @@
it('formatXecAmount returns a trillions string with no decimal places for max possible XEC amount', async function () {
assert.strictEqual(formatXecAmount(21000000000000), `21T XEC`);
});
- it('satsToFormattedValue returns a formatted XEC amount if total fiat value is less than $1', async function () {
+ it('satsToFormattedValue returns a 6-decimal formatted fiat amount if total fiat value is less than $0.00001', function () {
+ assert.strictEqual(
+ satsToFormattedValue(10, mockCoingeckoPrices),
+ `$0.000003`,
+ );
+ });
+ it('satsToFormattedValue returns a 5-decimal formatted fiat amount if total fiat value is less than $0.0001', function () {
assert.strictEqual(
satsToFormattedValue(100, mockCoingeckoPrices),
- `1 XEC`,
+ `$0.00003`,
+ );
+ });
+ it('satsToFormattedValue returns a 4-decimal formatted fiat amount if total fiat value is less than $0.001', function () {
+ assert.strictEqual(
+ satsToFormattedValue(1000, mockCoingeckoPrices),
+ `$0.0003`,
+ );
+ });
+ it('satsToFormattedValue returns a 3-decimal formatted fiat amount if total fiat value is less than $0.01', function () {
+ assert.strictEqual(
+ satsToFormattedValue(10000, mockCoingeckoPrices),
+ `$0.003`,
+ );
+ });
+ it('satsToFormattedValue returns a 2-decimal formatted fiat amount if total fiat value is less than $1', async function () {
+ assert.strictEqual(
+ satsToFormattedValue(1000000, mockCoingeckoPrices),
+ `$0.30`,
);
});
it('satsToFormattedValue returns a formatted fiat amount if total fiat value is less than $10', async function () {
@@ -273,6 +297,12 @@
'556B XEC',
);
});
+ it('satsToFormattedValue returns a USD amount with 7 decimal places if fiat qty is less than 0.000001', async function () {
+ assert.strictEqual(
+ satsToFormattedValue(1, mockCoingeckoPrices),
+ '$0.0000003',
+ );
+ });
it('jsonReplacer and jsonReviver can encode and decode a Map to and from JSON', async function () {
const map = new Map([
[1, 'one'],

File Metadata

Mime Type
text/plain
Expires
Tue, May 20, 23:38 (28 m, 56 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5866166
Default Alt Text
D14187.id.diff (30 KB)

Event Timeline