limit nlocktime change only tx announcements

This commit is contained in:
Alex Bosworth 2023-05-15 09:43:40 -07:00
parent 25ee496e56
commit c859f77e39
No known key found for this signature in database
GPG key ID: E80D2F3F311FD87E
4 changed files with 691 additions and 310 deletions

View file

@ -1,5 +1,9 @@
# Versions
## 15.7.2
- `telegram`: Ignore re-received chain txs where only the locktime is changed
## 15.7.1
- `reconnect`: Fix reconnection when there is a disconnected closing out peer

967
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -10,6 +10,7 @@
"url": "https://github.com/alexbosworth/balanceofsatoshis/issues"
},
"dependencies": {
"@alexbosworth/blockchain": "1.1.0",
"@alexbosworth/caporal": "1.4.4",
"@alexbosworth/fiat": "1.0.4",
"@alexbosworth/html2unicode": "1.1.5",
@ -24,7 +25,7 @@
"bolt01": "1.2.6",
"bolt03": "1.2.15",
"bolt07": "1.8.3",
"cbor": "8.1.0",
"cbor": "9.0.0",
"colorette": "2.0.20",
"crypto-js": "4.1.1",
"csv-parse": "5.3.10",
@ -34,9 +35,9 @@
"hot-formula-parser": "4.0.0",
"import-lazy": "4.0.0",
"ini": "4.1.0",
"inquirer": "9.2.2",
"inquirer": "9.2.3",
"ln-accounting": "7.0.1",
"ln-service": "56.3.0",
"ln-service": "56.3.1",
"ln-sync": "5.2.0",
"ln-telegram": "4.6.1",
"moment": "2.29.4",
@ -83,5 +84,5 @@
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis -t alexbosworth/balanceofsatoshis:$npm_package_version --push .",
"test": "tap --branches=1 --functions=1 --lines=1 --statements=1 -t 60 test/arrays/*.js test/balances/*.js test/chain/*.js test/display/*.js test/encryption/*.js test/lnd/*.js test/network/*.js test/nodes/*.js test/peers/*.js test/responses/*.js test/routing/*.js test/services/*.js test/swaps/*.js test/tags/*.js test/telegram/*.js test/wallets/*.js"
},
"version": "15.7.1"
"version": "15.7.2"
}

View file

@ -28,6 +28,7 @@ const {handleStopCommand} = require('ln-telegram');
const {handleVersionCommand} = require('ln-telegram');
const {InputFile} = require('grammy');
const {isMessageReplyAction} = require('ln-telegram');
const {noLocktimeIdForTransaction} = require('@alexbosworth/blockchain');
const {notifyOfForwards} = require('ln-telegram');
const {postChainTransaction} = require('ln-telegram');
const {postClosedMessage} = require('ln-telegram');
@ -58,6 +59,7 @@ const {version} = require('./../package');
const fileAsDoc = file => new InputFile(file.source, file.filename);
const fromName = node => `${node.alias} ${node.public_key.substring(0, 8)}`;
const getLnds = (x, y, z) => getNodeDetails({logger: x, names: y, nodes: z});
const hexAsBuffer = hex => Buffer.from(hex, 'hex');
const {isArray} = Array;
const isHash = n => /^[0-9A-F]{64}$/i.test(n);
let isBotInit = false;
@ -947,6 +949,7 @@ module.exports = (args, cbk) => {
let isFinished = false;
return asyncEach(getNodes, ({from, lnd}, cbk) => {
const noLocktimeIds = [];
const sub = subscribeToTransactions({lnd});
const transactions = [];
@ -962,6 +965,24 @@ module.exports = (args, cbk) => {
transactions.push(id);
// Check the transaction uniqueness against a locktime-absent hash
if (!!transaction.transaction) {
try {
const buffer = hexAsBuffer(transaction.transaction);
const noLocktimeId = noLocktimeIdForTransaction({buffer}).id;
// Exit early when a similar transaction has already been seen
if (noLocktimeIds.includes(noLocktimeId)) {
return;
}
noLocktimeIds.push(noLocktimeId);
} catch (err) {
args.logger.error({err});
}
}
try {
const record = await getTransactionRecord({lnd, id});