From 5c56dd51c72f80aaa53278bbadb3c2b33b19818b Mon Sep 17 00:00:00 2001 From: AP Date: Thu, 21 Nov 2019 06:49:43 +0100 Subject: [PATCH] chore: small changes --- src/schemaTypes/query/info/channels.ts | 2 +- src/schemaTypes/query/info/pendingChannels.ts | 45 +++++-------------- src/schemas/query/channels/channels.ts | 4 +- src/schemas/query/channels/pendingChannels.ts | 23 ++++++++-- 4 files changed, 34 insertions(+), 40 deletions(-) diff --git a/src/schemaTypes/query/info/channels.ts b/src/schemaTypes/query/info/channels.ts index 07860c59..9dd52fc4 100644 --- a/src/schemaTypes/query/info/channels.ts +++ b/src/schemaTypes/query/info/channels.ts @@ -31,7 +31,7 @@ export const ChannelType = new GraphQLObjectType({ localBalance: { type: GraphQLInt }, localReserve: { type: GraphQLInt }, partnerPublicKey: { type: GraphQLString }, - recieved: { type: GraphQLInt }, + received: { type: GraphQLInt }, remoteBalance: { type: GraphQLInt }, remoteReserve: { type: GraphQLInt }, sent: { type: GraphQLInt }, diff --git a/src/schemaTypes/query/info/pendingChannels.ts b/src/schemaTypes/query/info/pendingChannels.ts index 363d9d35..d837697f 100644 --- a/src/schemaTypes/query/info/pendingChannels.ts +++ b/src/schemaTypes/query/info/pendingChannels.ts @@ -5,45 +5,24 @@ import { GraphQLList } from "graphql"; import { GraphQLInt } from "graphql"; +import { PartnerNodeType } from "./channels"; // TODO: INCOMPLETE TYPE export const PendingChannelType = new GraphQLObjectType({ name: "pendingChannelType", fields: () => { return { - closeTransactionId: { - type: GraphQLString - }, - isActive: { - type: GraphQLBoolean - }, - isClosing: { - type: GraphQLBoolean - }, - isOpening: { - type: GraphQLBoolean - }, - localBalance: { - type: GraphQLInt - }, - localReserve: { - type: GraphQLInt - }, - partnerPublicKey: { - type: GraphQLString - }, - received: { - type: GraphQLInt - }, - remoteBalance: { - type: GraphQLInt - }, - remoteReserve: { - type: GraphQLInt - }, - sent: { - type: GraphQLInt - } + isActive: { type: GraphQLBoolean }, + isClosing: { type: GraphQLBoolean }, + isOpening: { type: GraphQLBoolean }, + localBalance: { type: GraphQLInt }, + localReserve: { type: GraphQLInt }, + partnerPublicKey: { type: GraphQLString }, + received: { type: GraphQLInt }, + remoteBalance: { type: GraphQLInt }, + remoteReserve: { type: GraphQLInt }, + sent: { type: GraphQLInt }, + partnerNodeInfo: { type: PartnerNodeType } }; } }); diff --git a/src/schemas/query/channels/channels.ts b/src/schemas/query/channels/channels.ts index 30e3ee31..21dc3c8e 100644 --- a/src/schemas/query/channels/channels.ts +++ b/src/schemas/query/channels/channels.ts @@ -60,13 +60,13 @@ export const getChannels = { isActive: channel.is_active, isClosing: channel.is_closing, isOpening: channel.is_opening, - isPartnerInitiated: channel.is_partner_initiated, + isPartnerInitiated: !channel.is_partner_initiated, isPrivate: channel.is_private, isStaticRemoteKey: channel.is_static_remote_key, localBalance: channel.local_balance, localReserve: channel.local_reserve, partnerPublicKey: channel.partner_public_key, - recieved: channel.received, + received: channel.received, remoteBalance: channel.remote_balance, remoteReserve: channel.remote_reserve, sent: channel.sent, diff --git a/src/schemas/query/channels/pendingChannels.ts b/src/schemas/query/channels/pendingChannels.ts index 0a252631..bee7b882 100644 --- a/src/schemas/query/channels/pendingChannels.ts +++ b/src/schemas/query/channels/pendingChannels.ts @@ -1,4 +1,7 @@ -import { getPendingChannels as getLnPendingChannels } from "ln-service"; +import { + getPendingChannels as getLnPendingChannels, + getNode +} from "ln-service"; import { logger } from "../../../helpers/logger"; import { PendingChannelType } from "../../../schemaTypes/query/info/pendingChannels"; import { GraphQLList } from "graphql"; @@ -35,9 +38,14 @@ export const getPendingChannels = { } ); - const channels = pendingChannels.pending_channels.map(channel => { + const channels = pendingChannels.pending_channels.map(async channel => { + const nodeInfo = await getNode({ + lnd, + is_omitting_channels: true, + public_key: channel.partner_public_key + }); + return { - closeTransactionId: channel.close_transaction_id, isActive: channel.is_active, isClosing: channel.is_closing, isOpening: channel.is_opening, @@ -47,7 +55,14 @@ export const getPendingChannels = { received: channel.received, remoteBalance: channel.remote_balance, remoteReserve: channel.remote_reserve, - sent: channel.sent + sent: channel.sent, + partnerNodeInfo: { + alias: nodeInfo.alias, + capacity: nodeInfo.capacity, + channelCount: nodeInfo.channel_count, + color: nodeInfo.color, + lastUpdate: nodeInfo.updated_at + } }; }); return channels;