Label channel closes
This commit is contained in:
parent
4bb23cf0c8
commit
da9834d272
@ -34,7 +34,8 @@ export class AddressLabelsComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleChannel() {
|
handleChannel() {
|
||||||
this.label = `Channel open: ${this.channel.node_left.alias} <> ${this.channel.node_right.alias}`;
|
const type = this.vout ? 'open' : 'close';
|
||||||
|
this.label = `Channel ${type}: ${this.channel.node_left.alias} <> ${this.channel.node_right.alias}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleVin() {
|
handleVin() {
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
{{ vin.prevout.scriptpubkey_type?.toUpperCase() }}
|
{{ vin.prevout.scriptpubkey_type?.toUpperCase() }}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<div>
|
<div>
|
||||||
<app-address-labels [vin]="vin"></app-address-labels>
|
<app-address-labels [vin]="vin" [channel]="channels && channels.inputs[i] || null"></app-address-labels>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@ -172,7 +172,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<div>
|
<div>
|
||||||
<app-address-labels [vout]="vout" [channel]="channels && channels[i] && channels[i].transaction_vout === vindex ? channels[i] : null"></app-address-labels>
|
<app-address-labels [vout]="vout" [channel]="channels && channels.outputs[i] && channels.outputs[i].transaction_vout === vindex ? channels.outputs[i] : null"></app-address-labels>
|
||||||
</div>
|
</div>
|
||||||
<ng-template #scriptpubkey_type>
|
<ng-template #scriptpubkey_type>
|
||||||
<ng-template [ngIf]="vout.pegout" [ngIfElse]="defaultscriptpubkey_type">
|
<ng-template [ngIf]="vout.pegout" [ngIfElse]="defaultscriptpubkey_type">
|
||||||
|
@ -36,7 +36,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
|
|||||||
showDetails$ = new BehaviorSubject<boolean>(false);
|
showDetails$ = new BehaviorSubject<boolean>(false);
|
||||||
outspends: Outspend[][] = [];
|
outspends: Outspend[][] = [];
|
||||||
assetsMinimal: any;
|
assetsMinimal: any;
|
||||||
channels: any[];
|
channels: { inputs: any[], outputs: any[] };
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public stateService: StateService,
|
public stateService: StateService,
|
||||||
|
@ -232,12 +232,12 @@ export class ApiService {
|
|||||||
return this.httpClient.get<RewardStats>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/reward-stats/${blockCount}`);
|
return this.httpClient.get<RewardStats>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/reward-stats/${blockCount}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getChannelByTxIds$(txIds: string[]): Observable<any[]> {
|
getChannelByTxIds$(txIds: string[]): Observable<{ inputs: any[], outputs: any[] }> {
|
||||||
let params = new HttpParams();
|
let params = new HttpParams();
|
||||||
txIds.forEach((txId: string) => {
|
txIds.forEach((txId: string) => {
|
||||||
params = params.append('txId[]', txId);
|
params = params.append('txId[]', txId);
|
||||||
});
|
});
|
||||||
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/lightning/api/v1/channels/txids/', { params });
|
return this.httpClient.get<{ inputs: any[], outputs: any[] }>(this.apiBaseUrl + this.apiBasePath + '/lightning/api/v1/channels/txids/', { params });
|
||||||
}
|
}
|
||||||
|
|
||||||
lightningSearch$(searchText: string): Observable<any[]> {
|
lightningSearch$(searchText: string): Observable<any[]> {
|
||||||
|
@ -74,7 +74,7 @@ class ChannelsApi {
|
|||||||
public async $getChannelsByTransactionId(transactionIds: string[]): Promise<any[]> {
|
public async $getChannelsByTransactionId(transactionIds: string[]): Promise<any[]> {
|
||||||
try {
|
try {
|
||||||
transactionIds = transactionIds.map((id) => '\'' + id + '\'');
|
transactionIds = transactionIds.map((id) => '\'' + id + '\'');
|
||||||
const query = `SELECT n1.alias AS alias_left, n2.alias AS alias_right, channels.* FROM channels LEFT JOIN nodes AS n1 ON n1.public_key = channels.node1_public_key LEFT JOIN nodes AS n2 ON n2.public_key = channels.node2_public_key WHERE channels.transaction_id IN (${transactionIds.join(', ')})`;
|
const query = `SELECT n1.alias AS alias_left, n2.alias AS alias_right, channels.* FROM channels LEFT JOIN nodes AS n1 ON n1.public_key = channels.node1_public_key LEFT JOIN nodes AS n2 ON n2.public_key = channels.node2_public_key WHERE channels.transaction_id IN (${transactionIds.join(', ')}) OR channels.closing_transaction_id IN (${transactionIds.join(', ')})`;
|
||||||
const [rows]: any = await DB.query(query);
|
const [rows]: any = await DB.query(query);
|
||||||
const channels = rows.map((row) => this.convertChannel(row));
|
const channels = rows.map((row) => this.convertChannel(row));
|
||||||
return channels;
|
return channels;
|
||||||
|
@ -67,17 +67,27 @@ class ChannelsRoutes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const channels = await channelsApi.$getChannelsByTransactionId(txIds);
|
const channels = await channelsApi.$getChannelsByTransactionId(txIds);
|
||||||
const result: any[] = [];
|
const inputs: any[] = [];
|
||||||
|
const outputs: any[] = [];
|
||||||
for (const txid of txIds) {
|
for (const txid of txIds) {
|
||||||
const foundChannel = channels.find((channel) => channel.transaction_id === txid);
|
const foundChannelInputs = channels.find((channel) => channel.closing_transaction_id === txid);
|
||||||
if (foundChannel) {
|
if (foundChannelInputs) {
|
||||||
result.push(foundChannel);
|
inputs.push(foundChannelInputs);
|
||||||
} else {
|
} else {
|
||||||
result.push(null);
|
inputs.push(null);
|
||||||
|
}
|
||||||
|
const foundChannelOutputs = channels.find((channel) => channel.transaction_id === txid);
|
||||||
|
if (foundChannelOutputs) {
|
||||||
|
outputs.push(foundChannelOutputs);
|
||||||
|
} else {
|
||||||
|
outputs.push(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json(result);
|
res.json({
|
||||||
|
inputs: inputs,
|
||||||
|
outputs: outputs,
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
res.status(500).send(e instanceof Error ? e.message : e);
|
res.status(500).send(e instanceof Error ? e.message : e);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,8 @@ class DatabaseMigration {
|
|||||||
KEY node2_public_key (node2_public_key),
|
KEY node2_public_key (node2_public_key),
|
||||||
KEY status (status),
|
KEY status (status),
|
||||||
KEY short_id (short_id),
|
KEY short_id (short_id),
|
||||||
KEY transaction_id (transaction_id)
|
KEY transaction_id (transaction_id),
|
||||||
|
KEY closing_transaction_id (closing_transaction_id)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user