Adding channel id in addition to short id

This commit is contained in:
softsimon 2022-05-03 20:55:34 +04:00
parent 7e1c2f4f40
commit b0b73e6c70
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
5 changed files with 36 additions and 4 deletions

View File

@ -13,6 +13,7 @@
"@types/node": "^16.11.41", "@types/node": "^16.11.41",
"axios": "~0.27.2", "axios": "~0.27.2",
"bitcoinjs-lib": "6.0.1", "bitcoinjs-lib": "6.0.1",
"bolt07": "^1.8.1",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"express": "^4.18.0", "express": "^4.18.0",
"mysql2": "2.3.3", "mysql2": "2.3.3",
@ -798,6 +799,11 @@
"node": ">=8.0.0" "node": ">=8.0.0"
} }
}, },
"node_modules/bn.js": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz",
"integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw=="
},
"node_modules/body-parser": { "node_modules/body-parser": {
"version": "1.20.0", "version": "1.20.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.0.tgz", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.0.tgz",
@ -821,6 +827,14 @@
"npm": "1.2.8000 || >= 1.4.16" "npm": "1.2.8000 || >= 1.4.16"
} }
}, },
"node_modules/bolt07": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/bolt07/-/bolt07-1.8.1.tgz",
"integrity": "sha512-vgh796VOdJBunZZZX0YuW1DmkS9SbW93rCLPOmWPsAHS/mStEs4+5d0KM1bYX6QBHshY9ecg4kgJaB18jrZsIA==",
"dependencies": {
"bn.js": "5.2.0"
}
},
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@ -3397,6 +3411,11 @@
"wif": "^2.0.1" "wif": "^2.0.1"
} }
}, },
"bn.js": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz",
"integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw=="
},
"body-parser": { "body-parser": {
"version": "1.20.0", "version": "1.20.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.0.tgz", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.0.tgz",
@ -3416,6 +3435,14 @@
"unpipe": "1.0.0" "unpipe": "1.0.0"
} }
}, },
"bolt07": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/bolt07/-/bolt07-1.8.1.tgz",
"integrity": "sha512-vgh796VOdJBunZZZX0YuW1DmkS9SbW93rCLPOmWPsAHS/mStEs4+5d0KM1bYX6QBHshY9ecg4kgJaB18jrZsIA==",
"requires": {
"bn.js": "5.2.0"
}
},
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",

View File

@ -34,6 +34,7 @@
"@types/node": "^16.11.41", "@types/node": "^16.11.41",
"axios": "~0.27.2", "axios": "~0.27.2",
"bitcoinjs-lib": "6.0.1", "bitcoinjs-lib": "6.0.1",
"bolt07": "^1.8.1",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"express": "^4.18.0", "express": "^4.18.0",
"mysql2": "2.3.3", "mysql2": "2.3.3",

View File

@ -1,6 +1,6 @@
<div class="container-xl" *ngIf="(channel$ | async) as channel"> <div class="container-xl" *ngIf="(channel$ | async) as channel">
<div class="mb-2"> <div class="mb-2">
<h1 i18n="shared.address" class="mb-0">Channel <a [routerLink]="['/lightning/channel' | relativeUrl, channel.id]">{{ channel.id }}</a> <app-clipboard [text]="channel.id"></app-clipboard></h1> <h1 i18n="shared.address" class="mb-0">Channel <a [routerLink]="['/lightning/channel' | relativeUrl, channel.id]">{{ channel.short_id }}</a> <app-clipboard [text]="channel.id"></app-clipboard></h1>
<div class="badges"> <div class="badges">
<span class="badge rounded-pill badge-secondary" *ngIf="channel.status === 0">Inactive</span> <span class="badge rounded-pill badge-secondary" *ngIf="channel.status === 0">Inactive</span>
<span class="badge rounded-pill badge-success" *ngIf="channel.status === 1">Active</span> <span class="badge rounded-pill badge-success" *ngIf="channel.status === 1">Active</span>

View File

@ -53,7 +53,7 @@
<app-amount [satoshis]="channel.capacity" digitsInfo="1.2-2"></app-amount> <app-amount [satoshis]="channel.capacity" digitsInfo="1.2-2"></app-amount>
</td> </td>
<td class="capacity text-right"> <td class="capacity text-right">
<a [routerLink]="['/lightning/channel' | relativeUrl, channel.id]">{{ channel.id }}</a> <a [routerLink]="['/lightning/channel' | relativeUrl, channel.id]">{{ channel.short_id }}</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -1,4 +1,4 @@
import { chanNumber } from 'bolt07';
import DB from '../database'; import DB from '../database';
import logger from '../logger'; import logger from '../logger';
import lightningApi from '../api/lightning/lightning-api-factory'; import lightningApi from '../api/lightning/lightning-api-factory';
@ -71,11 +71,14 @@ class NodeSyncService {
} }
private async $saveChannel(channel: ILightningApi.Channel): Promise<void> { private async $saveChannel(channel: ILightningApi.Channel): Promise<void> {
const fromChannel = chanNumber({ channel: channel.id }).number;
try { try {
const d = new Date(Date.parse(channel.updated_at)); const d = new Date(Date.parse(channel.updated_at));
const query = `INSERT INTO channels const query = `INSERT INTO channels
( (
id, id,
short_id,
capacity, capacity,
transaction_id, transaction_id,
transaction_vout, transaction_vout,
@ -98,7 +101,7 @@ class NodeSyncService {
node2_min_htlc_mtokens, node2_min_htlc_mtokens,
node2_updated_at node2_updated_at
) )
VALUES (?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
capacity = ?, capacity = ?,
updated_at = ?, updated_at = ?,
@ -122,6 +125,7 @@ class NodeSyncService {
;`; ;`;
await DB.query(query, [ await DB.query(query, [
fromChannel,
channel.id, channel.id,
channel.capacity, channel.capacity,
channel.transaction_id, channel.transaction_id,