From 48e8f941e9a585910ab9fe8dd258d26bc34b5263 Mon Sep 17 00:00:00 2001 From: Krr Prr <24500376+krrprr@users.noreply.github.com> Date: Sun, 25 Aug 2019 10:40:34 +0000 Subject: [PATCH] refactor(rpc): rename channelbalance to balance --- docs/api.md | 112 +++++++------- .../{channelbalance.ts => balance.ts} | 24 +-- lib/grpc/GrpcService.ts | 16 +- lib/proto/xudrpc.swagger.json | 96 ++++++------ lib/proto/xudrpc_grpc_pb.d.ts | 28 ++-- lib/proto/xudrpc_grpc_pb.js | 62 ++++---- lib/proto/xudrpc_pb.d.ts | 46 +++--- lib/proto/xudrpc_pb.js | 144 +++++++++--------- lib/service/Service.ts | 4 +- proto/xudrpc.proto | 18 +-- 10 files changed, 275 insertions(+), 275 deletions(-) rename lib/cli/commands/{channelbalance.ts => balance.ts} (51%) diff --git a/docs/api.md b/docs/api.md index b89e95b5a..30c8eda2b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -8,13 +8,10 @@ - [AddCurrencyResponse](#xudrpc.AddCurrencyResponse) - [AddPairRequest](#xudrpc.AddPairRequest) - [AddPairResponse](#xudrpc.AddPairResponse) + - [Balance](#xudrpc.Balance) - [BanRequest](#xudrpc.BanRequest) - [BanResponse](#xudrpc.BanResponse) - [Chain](#xudrpc.Chain) - - [ChannelBalance](#xudrpc.ChannelBalance) - - [ChannelBalanceRequest](#xudrpc.ChannelBalanceRequest) - - [ChannelBalanceResponse](#xudrpc.ChannelBalanceResponse) - - [ChannelBalanceResponse.BalancesEntry](#xudrpc.ChannelBalanceResponse.BalancesEntry) - [ConnectRequest](#xudrpc.ConnectRequest) - [ConnectResponse](#xudrpc.ConnectResponse) - [CreateNodeRequest](#xudrpc.CreateNodeRequest) @@ -22,6 +19,9 @@ - [DiscoverNodesRequest](#xudrpc.DiscoverNodesRequest) - [DiscoverNodesResponse](#xudrpc.DiscoverNodesResponse) - [ExecuteSwapRequest](#xudrpc.ExecuteSwapRequest) + - [GetBalanceRequest](#xudrpc.GetBalanceRequest) + - [GetBalanceResponse](#xudrpc.GetBalanceResponse) + - [GetBalanceResponse.BalancesEntry](#xudrpc.GetBalanceResponse.BalancesEntry) - [GetInfoRequest](#xudrpc.GetInfoRequest) - [GetInfoResponse](#xudrpc.GetInfoResponse) - [GetInfoResponse.LndEntry](#xudrpc.GetInfoResponse.LndEntry) @@ -145,6 +145,22 @@ + + +### Balance + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| balance | [uint64](#uint64) | | Total balance denominated in satoshis. | +| pending_open_balance | [uint64](#uint64) | | Sum of pending channel balances denominated in satoshis. | + + + + + + ### BanRequest @@ -186,167 +202,151 @@ - + -### ChannelBalance +### ConnectRequest | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| balance | [uint64](#uint64) | | Sum of channel balances denominated in satoshis. | -| pending_open_balance | [uint64](#uint64) | | Sum of pending channel balances denominated in satoshis. | - - +| node_uri | [string](#string) | | The uri of the node to connect to in "[nodePubKey]@[host]:[port]" format. | - -### ChannelBalanceRequest + +### ConnectResponse -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| currency | [string](#string) | | The ticker symbol of the currency to query for, if unspecified then balances for all supported currencies are queried. | - + -### ChannelBalanceResponse +### CreateNodeRequest | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| balances | [ChannelBalanceResponse.BalancesEntry](#xudrpc.ChannelBalanceResponse.BalancesEntry) | repeated | A map between currency ticker symbols and their channel balances. | +| password | [string](#string) | | The password in utf-8 with which to encrypt the new xud node key as well as underlying client wallets such as lnd. | - + -### ChannelBalanceResponse.BalancesEntry +### CreateNodeResponse | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| key | [string](#string) | | | -| value | [ChannelBalance](#xudrpc.ChannelBalance) | | | +| seed_mnemonic | [string](#string) | repeated | | +| initialized_lnds | [string](#string) | repeated | The list of lnd clients that were initialized. | +| initialized_raiden | [bool](#bool) | | Whether raiden was initialized. | - + -### ConnectRequest +### DiscoverNodesRequest | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| node_uri | [string](#string) | | The uri of the node to connect to in "[nodePubKey]@[host]:[port]" format. | - - - - - - - - -### ConnectResponse - +| peer_pub_key | [string](#string) | | The node pub key of the peer to discover nodes from. | - + -### CreateNodeRequest +### DiscoverNodesResponse | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| password | [string](#string) | | The password in utf-8 with which to encrypt the new xud node key as well as underlying client wallets such as lnd. | +| num_nodes | [uint32](#uint32) | | | - + -### CreateNodeResponse +### ExecuteSwapRequest | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| seed_mnemonic | [string](#string) | repeated | | -| initialized_lnds | [string](#string) | repeated | The list of lnd clients that were initialized. | -| initialized_raiden | [bool](#bool) | | Whether raiden was initialized. | +| order_id | [string](#string) | | The order id of the maker order. | +| pair_id | [string](#string) | | The trading pair of the swap orders. | +| peer_pub_key | [string](#string) | | The node pub key of the peer which owns the maker order. This is optional but helps locate the order more quickly. | +| quantity | [uint64](#uint64) | | The quantity to swap denominated in satoshis. The whole order will be swapped if unspecified. | - + -### DiscoverNodesRequest +### GetBalanceRequest | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| peer_pub_key | [string](#string) | | The node pub key of the peer to discover nodes from. | +| currency | [string](#string) | | The ticker symbol of the currency to query for, if unspecified then balances for all supported currencies are queried. | - + -### DiscoverNodesResponse +### GetBalanceResponse | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| num_nodes | [uint32](#uint32) | | | +| balances | [GetBalanceResponse.BalancesEntry](#xudrpc.GetBalanceResponse.BalancesEntry) | repeated | A map between currency ticker symbols and their balances. | - + -### ExecuteSwapRequest +### GetBalanceResponse.BalancesEntry | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| order_id | [string](#string) | | The order id of the maker order. | -| pair_id | [string](#string) | | The trading pair of the swap orders. | -| peer_pub_key | [string](#string) | | The node pub key of the peer which owns the maker order. This is optional but helps locate the order more quickly. | -| quantity | [uint64](#uint64) | | The quantity to swap denominated in satoshis. The whole order will be swapped if unspecified. | +| key | [string](#string) | | | +| value | [Balance](#xudrpc.Balance) | | | @@ -1157,7 +1157,7 @@ | AddCurrency | [AddCurrencyRequest](#xudrpc.AddCurrencyRequest) | [AddCurrencyResponse](#xudrpc.AddCurrencyResponse) | Adds a currency to the list of supported currencies. Once added, the currency may be used for new trading pairs. | | AddPair | [AddPairRequest](#xudrpc.AddPairRequest) | [AddPairResponse](#xudrpc.AddPairResponse) | Adds a trading pair to the list of supported trading pairs. The newly supported pair is advertised to peers so they may begin sending orders for it. | | RemoveOrder | [RemoveOrderRequest](#xudrpc.RemoveOrderRequest) | [RemoveOrderResponse](#xudrpc.RemoveOrderResponse) | Removes an order from the order book by its local id. This should be called when an order is canceled or filled outside of xud. Removed orders become immediately unavailable for swaps, and peers are notified that the order is no longer valid. Any portion of the order that is on hold due to ongoing swaps will not be removed until after the swap attempts complete. | -| ChannelBalance | [ChannelBalanceRequest](#xudrpc.ChannelBalanceRequest) | [ChannelBalanceResponse](#xudrpc.ChannelBalanceResponse) | Gets the total balance available across all payment channels for one or all currencies. | +| GetBalance | [GetBalanceRequest](#xudrpc.GetBalanceRequest) | [GetBalanceResponse](#xudrpc.GetBalanceResponse) | Gets the total balance available across all payment channels and wallets for one or all currencies. | | OpenChannel | [OpenChannelRequest](#xudrpc.OpenChannelRequest) | [OpenChannelResponse](#xudrpc.OpenChannelResponse) | Opens a payment channel to a peer with the given node pub key for the specified amount and currency. | | Connect | [ConnectRequest](#xudrpc.ConnectRequest) | [ConnectResponse](#xudrpc.ConnectResponse) | Attempts to connect to a node. Once connected, the node is added to the list of peers and becomes available for swaps and trading. A handshake exchanges information about the peer's supported trading and swap clients. Orders will be shared with the peer upon connection and upon new order placements. | | Ban | [BanRequest](#xudrpc.BanRequest) | [BanResponse](#xudrpc.BanResponse) | Bans a node and immediately disconnects from it. This can be used to prevent any connections to a specific node. | diff --git a/lib/cli/commands/channelbalance.ts b/lib/cli/commands/balance.ts similarity index 51% rename from lib/cli/commands/channelbalance.ts rename to lib/cli/commands/balance.ts index a40bad66e..baafe42f6 100644 --- a/lib/cli/commands/channelbalance.ts +++ b/lib/cli/commands/balance.ts @@ -1,6 +1,6 @@ import { callback, loadXudClient } from '../command'; import { Arguments } from 'yargs'; -import { ChannelBalanceRequest, ChannelBalanceResponse } from '../../proto/xudrpc_pb'; +import { GetBalanceRequest, GetBalanceResponse } from '../../proto/xudrpc_pb'; import { satsToCoinsStr } from '../utils'; import Table, { HorizontalTable } from 'cli-table3'; import colors from 'colors/safe'; @@ -11,11 +11,11 @@ const HEADERS = [ colors.blue('Pending Balance'), ]; -const formatChannels = (channels: ChannelBalanceResponse.AsObject) => { +const formatBalances = (balances: GetBalanceResponse.AsObject) => { const formatted: any[] = []; - channels.balancesMap.forEach((channel) => { + balances.balancesMap.forEach((balance) => { const element = []; - element.push(channel[0], `${satsToCoinsStr(channel[1].balance)}`, `${satsToCoinsStr(channel[1].pendingOpenBalance)}`); + element.push(balance[0], `${satsToCoinsStr(balance[1].balance)}`, `${satsToCoinsStr(balance[1].pendingOpenBalance)}`); formatted.push(element); }); return formatted; @@ -28,17 +28,17 @@ const createTable = () => { return table; }; -const displayChannels = (channels: ChannelBalanceResponse.AsObject) => { +const displayBalances = (balances: GetBalanceResponse.AsObject) => { const table = createTable(); - const formatted = formatChannels(channels); - formatted.forEach(channel => table.push(channel)); - console.log(colors.underline(colors.bold('\nChannel balance:'))); + const formatted = formatBalances(balances); + formatted.forEach(balance => table.push(balance)); + console.log(colors.underline(colors.bold('\nBalance:'))); console.log(table.toString()); }; -export const command = 'channelbalance [currency]'; +export const command = 'balance [currency]'; -export const describe = 'get total channel balance for a given currency'; +export const describe = 'get total balance for a given currency'; export const builder = { currency: { @@ -48,9 +48,9 @@ export const builder = { }; export const handler = (argv: Arguments) => { - const request = new ChannelBalanceRequest(); + const request = new GetBalanceRequest(); if (argv.currency) { request.setCurrency(argv.currency.toUpperCase()); } - loadXudClient(argv).channelBalance(request, callback(argv, displayChannels)); + loadXudClient(argv).getBalance(request, callback(argv, displayBalances)); }; diff --git a/lib/grpc/GrpcService.ts b/lib/grpc/GrpcService.ts index e3b50f040..26d2907a1 100644 --- a/lib/grpc/GrpcService.ts +++ b/lib/grpc/GrpcService.ts @@ -267,17 +267,17 @@ class GrpcService { } /** - * See [[Service.channelBalance]] + * See [[Service.getBalance]] */ - public channelBalance: grpc.handleUnaryCall = async (call, callback) => { + public getBalance: grpc.handleUnaryCall = async (call, callback) => { try { - const channelBalanceResponse = await this.service.channelBalance(call.request.toObject()); - const response = new xudrpc.ChannelBalanceResponse(); + const balanceResponse = await this.service.getBalance(call.request.toObject()); + const response = new xudrpc.GetBalanceResponse(); const balancesMap = response.getBalancesMap(); - channelBalanceResponse.forEach((channelBalance, currency) => { - const balance = new xudrpc.ChannelBalance(); - balance.setBalance(channelBalance.balance); - balance.setPendingOpenBalance(channelBalance.pendingOpenBalance); + balanceResponse.forEach((balanceObj, currency) => { + const balance = new xudrpc.Balance(); + balance.setBalance(balanceObj.balance); + balance.setPendingOpenBalance(balanceObj.pendingOpenBalance); balancesMap.set(currency, balance); }); callback(null, response); diff --git a/lib/proto/xudrpc.swagger.json b/lib/proto/xudrpc.swagger.json index b8334716d..a52dc3a1d 100644 --- a/lib/proto/xudrpc.swagger.json +++ b/lib/proto/xudrpc.swagger.json @@ -69,26 +69,25 @@ ] } }, - "/v1/ban": { - "post": { - "summary": "Bans a node and immediately disconnects from it. This can be used to prevent any connections\nto a specific node.", - "operationId": "Ban", + "/v1/balance": { + "get": { + "summary": "Gets the total balance available across all payment channels and wallets for one or all currencies.", + "operationId": "GetBalance", "responses": { "200": { "description": "", "schema": { - "$ref": "#/definitions/xudrpcBanResponse" + "$ref": "#/definitions/xudrpcGetBalanceResponse" } } }, "parameters": [ { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/xudrpcBanRequest" - } + "name": "currency", + "description": "The ticker symbol of the currency to query for, if unspecified then balances for all supported\ncurrencies are queried.", + "in": "query", + "required": false, + "type": "string" } ], "tags": [ @@ -96,25 +95,26 @@ ] } }, - "/v1/channelbalance": { - "get": { - "summary": "Gets the total balance available across all payment channels for one or all currencies.", - "operationId": "ChannelBalance", + "/v1/ban": { + "post": { + "summary": "Bans a node and immediately disconnects from it. This can be used to prevent any connections\nto a specific node.", + "operationId": "Ban", "responses": { "200": { "description": "", "schema": { - "$ref": "#/definitions/xudrpcChannelBalanceResponse" + "$ref": "#/definitions/xudrpcBanResponse" } } }, "parameters": [ { - "name": "currency", - "description": "The ticker symbol of the currency to query for, if unspecified then balances for all supported\ncurrencies are queried.", - "in": "query", - "required": false, - "type": "string" + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/xudrpcBanRequest" + } } ], "tags": [ @@ -711,6 +711,21 @@ "xudrpcAddPairResponse": { "type": "object" }, + "xudrpcBalance": { + "type": "object", + "properties": { + "balance": { + "type": "string", + "format": "uint64", + "description": "Total balance denominated in satoshis." + }, + "pending_open_balance": { + "type": "string", + "format": "uint64", + "description": "Sum of pending channel balances denominated in satoshis." + } + } + }, "xudrpcBanRequest": { "type": "object", "properties": { @@ -736,33 +751,6 @@ } } }, - "xudrpcChannelBalance": { - "type": "object", - "properties": { - "balance": { - "type": "string", - "format": "uint64", - "description": "Sum of channel balances denominated in satoshis." - }, - "pending_open_balance": { - "type": "string", - "format": "uint64", - "description": "Sum of pending channel balances denominated in satoshis." - } - } - }, - "xudrpcChannelBalanceResponse": { - "type": "object", - "properties": { - "balances": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/xudrpcChannelBalance" - }, - "description": "A map between currency ticker symbols and their channel balances." - } - } - }, "xudrpcConnectRequest": { "type": "object", "properties": { @@ -838,6 +826,18 @@ } } }, + "xudrpcGetBalanceResponse": { + "type": "object", + "properties": { + "balances": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/xudrpcBalance" + }, + "description": "A map between currency ticker symbols and their balances." + } + } + }, "xudrpcGetInfoResponse": { "type": "object", "properties": { diff --git a/lib/proto/xudrpc_grpc_pb.d.ts b/lib/proto/xudrpc_grpc_pb.d.ts index b6cde0964..da41f8d74 100644 --- a/lib/proto/xudrpc_grpc_pb.d.ts +++ b/lib/proto/xudrpc_grpc_pb.d.ts @@ -61,7 +61,7 @@ interface IXudService extends grpc.ServiceDefinition; responseDeserialize: grpc.deserialize; } -interface IXudService_IChannelBalance extends grpc.MethodDefinition { - path: string; // "/xudrpc.Xud/ChannelBalance" +interface IXudService_IGetBalance extends grpc.MethodDefinition { + path: string; // "/xudrpc.Xud/GetBalance" requestStream: boolean; // false responseStream: boolean; // false - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; } interface IXudService_IOpenChannel extends grpc.MethodDefinition { path: string; // "/xudrpc.Xud/OpenChannel" @@ -317,7 +317,7 @@ export interface IXudServer { addCurrency: grpc.handleUnaryCall; addPair: grpc.handleUnaryCall; removeOrder: grpc.handleUnaryCall; - channelBalance: grpc.handleUnaryCall; + getBalance: grpc.handleUnaryCall; openChannel: grpc.handleUnaryCall; connect: grpc.handleUnaryCall; ban: grpc.handleUnaryCall; @@ -351,9 +351,9 @@ export interface IXudClient { removeOrder(request: xudrpc_pb.RemoveOrderRequest, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.RemoveOrderResponse) => void): grpc.ClientUnaryCall; removeOrder(request: xudrpc_pb.RemoveOrderRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.RemoveOrderResponse) => void): grpc.ClientUnaryCall; removeOrder(request: xudrpc_pb.RemoveOrderRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.RemoveOrderResponse) => void): grpc.ClientUnaryCall; - channelBalance(request: xudrpc_pb.ChannelBalanceRequest, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.ChannelBalanceResponse) => void): grpc.ClientUnaryCall; - channelBalance(request: xudrpc_pb.ChannelBalanceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.ChannelBalanceResponse) => void): grpc.ClientUnaryCall; - channelBalance(request: xudrpc_pb.ChannelBalanceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.ChannelBalanceResponse) => void): grpc.ClientUnaryCall; + getBalance(request: xudrpc_pb.GetBalanceRequest, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.GetBalanceResponse) => void): grpc.ClientUnaryCall; + getBalance(request: xudrpc_pb.GetBalanceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.GetBalanceResponse) => void): grpc.ClientUnaryCall; + getBalance(request: xudrpc_pb.GetBalanceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.GetBalanceResponse) => void): grpc.ClientUnaryCall; openChannel(request: xudrpc_pb.OpenChannelRequest, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.OpenChannelResponse) => void): grpc.ClientUnaryCall; openChannel(request: xudrpc_pb.OpenChannelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.OpenChannelResponse) => void): grpc.ClientUnaryCall; openChannel(request: xudrpc_pb.OpenChannelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.OpenChannelResponse) => void): grpc.ClientUnaryCall; @@ -426,9 +426,9 @@ export class XudClient extends grpc.Client implements IXudClient { public removeOrder(request: xudrpc_pb.RemoveOrderRequest, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.RemoveOrderResponse) => void): grpc.ClientUnaryCall; public removeOrder(request: xudrpc_pb.RemoveOrderRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.RemoveOrderResponse) => void): grpc.ClientUnaryCall; public removeOrder(request: xudrpc_pb.RemoveOrderRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.RemoveOrderResponse) => void): grpc.ClientUnaryCall; - public channelBalance(request: xudrpc_pb.ChannelBalanceRequest, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.ChannelBalanceResponse) => void): grpc.ClientUnaryCall; - public channelBalance(request: xudrpc_pb.ChannelBalanceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.ChannelBalanceResponse) => void): grpc.ClientUnaryCall; - public channelBalance(request: xudrpc_pb.ChannelBalanceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.ChannelBalanceResponse) => void): grpc.ClientUnaryCall; + public getBalance(request: xudrpc_pb.GetBalanceRequest, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.GetBalanceResponse) => void): grpc.ClientUnaryCall; + public getBalance(request: xudrpc_pb.GetBalanceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.GetBalanceResponse) => void): grpc.ClientUnaryCall; + public getBalance(request: xudrpc_pb.GetBalanceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.GetBalanceResponse) => void): grpc.ClientUnaryCall; public openChannel(request: xudrpc_pb.OpenChannelRequest, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.OpenChannelResponse) => void): grpc.ClientUnaryCall; public openChannel(request: xudrpc_pb.OpenChannelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.OpenChannelResponse) => void): grpc.ClientUnaryCall; public openChannel(request: xudrpc_pb.OpenChannelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: xudrpc_pb.OpenChannelResponse) => void): grpc.ClientUnaryCall; diff --git a/lib/proto/xudrpc_grpc_pb.js b/lib/proto/xudrpc_grpc_pb.js index 3d92fe566..5b6345afb 100644 --- a/lib/proto/xudrpc_grpc_pb.js +++ b/lib/proto/xudrpc_grpc_pb.js @@ -92,28 +92,6 @@ function deserialize_xudrpc_BanResponse(buffer_arg) { return xudrpc_pb.BanResponse.deserializeBinary(new Uint8Array(buffer_arg)); } -function serialize_xudrpc_ChannelBalanceRequest(arg) { - if (!(arg instanceof xudrpc_pb.ChannelBalanceRequest)) { - throw new Error('Expected argument of type xudrpc.ChannelBalanceRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_xudrpc_ChannelBalanceRequest(buffer_arg) { - return xudrpc_pb.ChannelBalanceRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_xudrpc_ChannelBalanceResponse(arg) { - if (!(arg instanceof xudrpc_pb.ChannelBalanceResponse)) { - throw new Error('Expected argument of type xudrpc.ChannelBalanceResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_xudrpc_ChannelBalanceResponse(buffer_arg) { - return xudrpc_pb.ChannelBalanceResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - function serialize_xudrpc_ConnectRequest(arg) { if (!(arg instanceof xudrpc_pb.ConnectRequest)) { throw new Error('Expected argument of type xudrpc.ConnectRequest'); @@ -191,6 +169,28 @@ function deserialize_xudrpc_ExecuteSwapRequest(buffer_arg) { return xudrpc_pb.ExecuteSwapRequest.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_xudrpc_GetBalanceRequest(arg) { + if (!(arg instanceof xudrpc_pb.GetBalanceRequest)) { + throw new Error('Expected argument of type xudrpc.GetBalanceRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_xudrpc_GetBalanceRequest(buffer_arg) { + return xudrpc_pb.GetBalanceRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_xudrpc_GetBalanceResponse(arg) { + if (!(arg instanceof xudrpc_pb.GetBalanceResponse)) { + throw new Error('Expected argument of type xudrpc.GetBalanceResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_xudrpc_GetBalanceResponse(buffer_arg) { + return xudrpc_pb.GetBalanceResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_xudrpc_GetInfoRequest(arg) { if (!(arg instanceof xudrpc_pb.GetInfoRequest)) { throw new Error('Expected argument of type xudrpc.GetInfoRequest'); @@ -656,17 +656,17 @@ var XudService = exports.XudService = { responseSerialize: serialize_xudrpc_RemoveOrderResponse, responseDeserialize: deserialize_xudrpc_RemoveOrderResponse, }, - // Gets the total balance available across all payment channels for one or all currencies. - channelBalance: { - path: '/xudrpc.Xud/ChannelBalance', + // Gets the total balance available across all payment channels and wallets for one or all currencies. + getBalance: { + path: '/xudrpc.Xud/GetBalance', requestStream: false, responseStream: false, - requestType: xudrpc_pb.ChannelBalanceRequest, - responseType: xudrpc_pb.ChannelBalanceResponse, - requestSerialize: serialize_xudrpc_ChannelBalanceRequest, - requestDeserialize: deserialize_xudrpc_ChannelBalanceRequest, - responseSerialize: serialize_xudrpc_ChannelBalanceResponse, - responseDeserialize: deserialize_xudrpc_ChannelBalanceResponse, + requestType: xudrpc_pb.GetBalanceRequest, + responseType: xudrpc_pb.GetBalanceResponse, + requestSerialize: serialize_xudrpc_GetBalanceRequest, + requestDeserialize: deserialize_xudrpc_GetBalanceRequest, + responseSerialize: serialize_xudrpc_GetBalanceResponse, + responseDeserialize: deserialize_xudrpc_GetBalanceResponse, }, // Opens a payment channel to a peer with the given node pub key for the specified amount and currency. openChannel: { diff --git a/lib/proto/xudrpc_pb.d.ts b/lib/proto/xudrpc_pb.d.ts index 205672850..7f0e5e5e1 100644 --- a/lib/proto/xudrpc_pb.d.ts +++ b/lib/proto/xudrpc_pb.d.ts @@ -269,7 +269,7 @@ export namespace Chain { } } -export class ChannelBalance extends jspb.Message { +export class Balance extends jspb.Message { getBalance(): number; setBalance(value: number): void; @@ -278,63 +278,63 @@ export class ChannelBalance extends jspb.Message { serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ChannelBalance.AsObject; - static toObject(includeInstance: boolean, msg: ChannelBalance): ChannelBalance.AsObject; + toObject(includeInstance?: boolean): Balance.AsObject; + static toObject(includeInstance: boolean, msg: Balance): Balance.AsObject; static extensions: {[key: number]: jspb.ExtensionFieldInfo}; static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ChannelBalance, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ChannelBalance; - static deserializeBinaryFromReader(message: ChannelBalance, reader: jspb.BinaryReader): ChannelBalance; + static serializeBinaryToWriter(message: Balance, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Balance; + static deserializeBinaryFromReader(message: Balance, reader: jspb.BinaryReader): Balance; } -export namespace ChannelBalance { +export namespace Balance { export type AsObject = { balance: number, pendingOpenBalance: number, } } -export class ChannelBalanceRequest extends jspb.Message { +export class GetBalanceRequest extends jspb.Message { getCurrency(): string; setCurrency(value: string): void; serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ChannelBalanceRequest.AsObject; - static toObject(includeInstance: boolean, msg: ChannelBalanceRequest): ChannelBalanceRequest.AsObject; + toObject(includeInstance?: boolean): GetBalanceRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetBalanceRequest): GetBalanceRequest.AsObject; static extensions: {[key: number]: jspb.ExtensionFieldInfo}; static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ChannelBalanceRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ChannelBalanceRequest; - static deserializeBinaryFromReader(message: ChannelBalanceRequest, reader: jspb.BinaryReader): ChannelBalanceRequest; + static serializeBinaryToWriter(message: GetBalanceRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetBalanceRequest; + static deserializeBinaryFromReader(message: GetBalanceRequest, reader: jspb.BinaryReader): GetBalanceRequest; } -export namespace ChannelBalanceRequest { +export namespace GetBalanceRequest { export type AsObject = { currency: string, } } -export class ChannelBalanceResponse extends jspb.Message { +export class GetBalanceResponse extends jspb.Message { - getBalancesMap(): jspb.Map; + getBalancesMap(): jspb.Map; clearBalancesMap(): void; serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ChannelBalanceResponse.AsObject; - static toObject(includeInstance: boolean, msg: ChannelBalanceResponse): ChannelBalanceResponse.AsObject; + toObject(includeInstance?: boolean): GetBalanceResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetBalanceResponse): GetBalanceResponse.AsObject; static extensions: {[key: number]: jspb.ExtensionFieldInfo}; static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ChannelBalanceResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ChannelBalanceResponse; - static deserializeBinaryFromReader(message: ChannelBalanceResponse, reader: jspb.BinaryReader): ChannelBalanceResponse; + static serializeBinaryToWriter(message: GetBalanceResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetBalanceResponse; + static deserializeBinaryFromReader(message: GetBalanceResponse, reader: jspb.BinaryReader): GetBalanceResponse; } -export namespace ChannelBalanceResponse { +export namespace GetBalanceResponse { export type AsObject = { - balancesMap: Array<[string, ChannelBalance.AsObject]>, + balancesMap: Array<[string, Balance.AsObject]>, } } diff --git a/lib/proto/xudrpc_pb.js b/lib/proto/xudrpc_pb.js index a262a482f..6004fad3c 100644 --- a/lib/proto/xudrpc_pb.js +++ b/lib/proto/xudrpc_pb.js @@ -17,12 +17,10 @@ goog.exportSymbol('proto.xudrpc.AddCurrencyRequest.SwapClient', null, global); goog.exportSymbol('proto.xudrpc.AddCurrencyResponse', null, global); goog.exportSymbol('proto.xudrpc.AddPairRequest', null, global); goog.exportSymbol('proto.xudrpc.AddPairResponse', null, global); +goog.exportSymbol('proto.xudrpc.Balance', null, global); goog.exportSymbol('proto.xudrpc.BanRequest', null, global); goog.exportSymbol('proto.xudrpc.BanResponse', null, global); goog.exportSymbol('proto.xudrpc.Chain', null, global); -goog.exportSymbol('proto.xudrpc.ChannelBalance', null, global); -goog.exportSymbol('proto.xudrpc.ChannelBalanceRequest', null, global); -goog.exportSymbol('proto.xudrpc.ChannelBalanceResponse', null, global); goog.exportSymbol('proto.xudrpc.ConnectRequest', null, global); goog.exportSymbol('proto.xudrpc.ConnectResponse', null, global); goog.exportSymbol('proto.xudrpc.CreateNodeRequest', null, global); @@ -30,6 +28,8 @@ goog.exportSymbol('proto.xudrpc.CreateNodeResponse', null, global); goog.exportSymbol('proto.xudrpc.DiscoverNodesRequest', null, global); goog.exportSymbol('proto.xudrpc.DiscoverNodesResponse', null, global); goog.exportSymbol('proto.xudrpc.ExecuteSwapRequest', null, global); +goog.exportSymbol('proto.xudrpc.GetBalanceRequest', null, global); +goog.exportSymbol('proto.xudrpc.GetBalanceResponse', null, global); goog.exportSymbol('proto.xudrpc.GetInfoRequest', null, global); goog.exportSymbol('proto.xudrpc.GetInfoResponse', null, global); goog.exportSymbol('proto.xudrpc.GetNodeInfoRequest', null, global); @@ -1856,12 +1856,12 @@ proto.xudrpc.Chain.prototype.setNetwork = function(value) { * @extends {jspb.Message} * @constructor */ -proto.xudrpc.ChannelBalance = function(opt_data) { +proto.xudrpc.Balance = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; -goog.inherits(proto.xudrpc.ChannelBalance, jspb.Message); +goog.inherits(proto.xudrpc.Balance, jspb.Message); if (goog.DEBUG && !COMPILED) { - proto.xudrpc.ChannelBalance.displayName = 'proto.xudrpc.ChannelBalance'; + proto.xudrpc.Balance.displayName = 'proto.xudrpc.Balance'; } @@ -1876,8 +1876,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * for transitional soy proto support: http://goto/soy-param-migration * @return {!Object} */ -proto.xudrpc.ChannelBalance.prototype.toObject = function(opt_includeInstance) { - return proto.xudrpc.ChannelBalance.toObject(opt_includeInstance, this); +proto.xudrpc.Balance.prototype.toObject = function(opt_includeInstance) { + return proto.xudrpc.Balance.toObject(opt_includeInstance, this); }; @@ -1886,11 +1886,11 @@ proto.xudrpc.ChannelBalance.prototype.toObject = function(opt_includeInstance) { * @param {boolean|undefined} includeInstance Whether to include the JSPB * instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.xudrpc.ChannelBalance} msg The msg instance to transform. + * @param {!proto.xudrpc.Balance} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.xudrpc.ChannelBalance.toObject = function(includeInstance, msg) { +proto.xudrpc.Balance.toObject = function(includeInstance, msg) { var f, obj = { balance: jspb.Message.getFieldWithDefault(msg, 1, 0), pendingOpenBalance: jspb.Message.getFieldWithDefault(msg, 2, 0) @@ -1907,23 +1907,23 @@ proto.xudrpc.ChannelBalance.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.xudrpc.ChannelBalance} + * @return {!proto.xudrpc.Balance} */ -proto.xudrpc.ChannelBalance.deserializeBinary = function(bytes) { +proto.xudrpc.Balance.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.xudrpc.ChannelBalance; - return proto.xudrpc.ChannelBalance.deserializeBinaryFromReader(msg, reader); + var msg = new proto.xudrpc.Balance; + return proto.xudrpc.Balance.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.xudrpc.ChannelBalance} msg The message object to deserialize into. + * @param {!proto.xudrpc.Balance} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.xudrpc.ChannelBalance} + * @return {!proto.xudrpc.Balance} */ -proto.xudrpc.ChannelBalance.deserializeBinaryFromReader = function(msg, reader) { +proto.xudrpc.Balance.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -1951,9 +1951,9 @@ proto.xudrpc.ChannelBalance.deserializeBinaryFromReader = function(msg, reader) * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.xudrpc.ChannelBalance.prototype.serializeBinary = function() { +proto.xudrpc.Balance.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.xudrpc.ChannelBalance.serializeBinaryToWriter(this, writer); + proto.xudrpc.Balance.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -1961,11 +1961,11 @@ proto.xudrpc.ChannelBalance.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.xudrpc.ChannelBalance} message + * @param {!proto.xudrpc.Balance} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.xudrpc.ChannelBalance.serializeBinaryToWriter = function(message, writer) { +proto.xudrpc.Balance.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getBalance(); if (f !== 0) { @@ -1988,13 +1988,13 @@ proto.xudrpc.ChannelBalance.serializeBinaryToWriter = function(message, writer) * optional uint64 balance = 1; * @return {number} */ -proto.xudrpc.ChannelBalance.prototype.getBalance = function() { +proto.xudrpc.Balance.prototype.getBalance = function() { return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** @param {number} value */ -proto.xudrpc.ChannelBalance.prototype.setBalance = function(value) { +proto.xudrpc.Balance.prototype.setBalance = function(value) { jspb.Message.setField(this, 1, value); }; @@ -2003,13 +2003,13 @@ proto.xudrpc.ChannelBalance.prototype.setBalance = function(value) { * optional uint64 pending_open_balance = 2; * @return {number} */ -proto.xudrpc.ChannelBalance.prototype.getPendingOpenBalance = function() { +proto.xudrpc.Balance.prototype.getPendingOpenBalance = function() { return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** @param {number} value */ -proto.xudrpc.ChannelBalance.prototype.setPendingOpenBalance = function(value) { +proto.xudrpc.Balance.prototype.setPendingOpenBalance = function(value) { jspb.Message.setField(this, 2, value); }; @@ -2025,12 +2025,12 @@ proto.xudrpc.ChannelBalance.prototype.setPendingOpenBalance = function(value) { * @extends {jspb.Message} * @constructor */ -proto.xudrpc.ChannelBalanceRequest = function(opt_data) { +proto.xudrpc.GetBalanceRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; -goog.inherits(proto.xudrpc.ChannelBalanceRequest, jspb.Message); +goog.inherits(proto.xudrpc.GetBalanceRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { - proto.xudrpc.ChannelBalanceRequest.displayName = 'proto.xudrpc.ChannelBalanceRequest'; + proto.xudrpc.GetBalanceRequest.displayName = 'proto.xudrpc.GetBalanceRequest'; } @@ -2045,8 +2045,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * for transitional soy proto support: http://goto/soy-param-migration * @return {!Object} */ -proto.xudrpc.ChannelBalanceRequest.prototype.toObject = function(opt_includeInstance) { - return proto.xudrpc.ChannelBalanceRequest.toObject(opt_includeInstance, this); +proto.xudrpc.GetBalanceRequest.prototype.toObject = function(opt_includeInstance) { + return proto.xudrpc.GetBalanceRequest.toObject(opt_includeInstance, this); }; @@ -2055,11 +2055,11 @@ proto.xudrpc.ChannelBalanceRequest.prototype.toObject = function(opt_includeInst * @param {boolean|undefined} includeInstance Whether to include the JSPB * instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.xudrpc.ChannelBalanceRequest} msg The msg instance to transform. + * @param {!proto.xudrpc.GetBalanceRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.xudrpc.ChannelBalanceRequest.toObject = function(includeInstance, msg) { +proto.xudrpc.GetBalanceRequest.toObject = function(includeInstance, msg) { var f, obj = { currency: jspb.Message.getFieldWithDefault(msg, 1, "") }; @@ -2075,23 +2075,23 @@ proto.xudrpc.ChannelBalanceRequest.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.xudrpc.ChannelBalanceRequest} + * @return {!proto.xudrpc.GetBalanceRequest} */ -proto.xudrpc.ChannelBalanceRequest.deserializeBinary = function(bytes) { +proto.xudrpc.GetBalanceRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.xudrpc.ChannelBalanceRequest; - return proto.xudrpc.ChannelBalanceRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.xudrpc.GetBalanceRequest; + return proto.xudrpc.GetBalanceRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.xudrpc.ChannelBalanceRequest} msg The message object to deserialize into. + * @param {!proto.xudrpc.GetBalanceRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.xudrpc.ChannelBalanceRequest} + * @return {!proto.xudrpc.GetBalanceRequest} */ -proto.xudrpc.ChannelBalanceRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.xudrpc.GetBalanceRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -2115,9 +2115,9 @@ proto.xudrpc.ChannelBalanceRequest.deserializeBinaryFromReader = function(msg, r * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.xudrpc.ChannelBalanceRequest.prototype.serializeBinary = function() { +proto.xudrpc.GetBalanceRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.xudrpc.ChannelBalanceRequest.serializeBinaryToWriter(this, writer); + proto.xudrpc.GetBalanceRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -2125,11 +2125,11 @@ proto.xudrpc.ChannelBalanceRequest.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.xudrpc.ChannelBalanceRequest} message + * @param {!proto.xudrpc.GetBalanceRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.xudrpc.ChannelBalanceRequest.serializeBinaryToWriter = function(message, writer) { +proto.xudrpc.GetBalanceRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getCurrency(); if (f.length > 0) { @@ -2145,13 +2145,13 @@ proto.xudrpc.ChannelBalanceRequest.serializeBinaryToWriter = function(message, w * optional string currency = 1; * @return {string} */ -proto.xudrpc.ChannelBalanceRequest.prototype.getCurrency = function() { +proto.xudrpc.GetBalanceRequest.prototype.getCurrency = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** @param {string} value */ -proto.xudrpc.ChannelBalanceRequest.prototype.setCurrency = function(value) { +proto.xudrpc.GetBalanceRequest.prototype.setCurrency = function(value) { jspb.Message.setField(this, 1, value); }; @@ -2167,12 +2167,12 @@ proto.xudrpc.ChannelBalanceRequest.prototype.setCurrency = function(value) { * @extends {jspb.Message} * @constructor */ -proto.xudrpc.ChannelBalanceResponse = function(opt_data) { +proto.xudrpc.GetBalanceResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; -goog.inherits(proto.xudrpc.ChannelBalanceResponse, jspb.Message); +goog.inherits(proto.xudrpc.GetBalanceResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { - proto.xudrpc.ChannelBalanceResponse.displayName = 'proto.xudrpc.ChannelBalanceResponse'; + proto.xudrpc.GetBalanceResponse.displayName = 'proto.xudrpc.GetBalanceResponse'; } @@ -2187,8 +2187,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * for transitional soy proto support: http://goto/soy-param-migration * @return {!Object} */ -proto.xudrpc.ChannelBalanceResponse.prototype.toObject = function(opt_includeInstance) { - return proto.xudrpc.ChannelBalanceResponse.toObject(opt_includeInstance, this); +proto.xudrpc.GetBalanceResponse.prototype.toObject = function(opt_includeInstance) { + return proto.xudrpc.GetBalanceResponse.toObject(opt_includeInstance, this); }; @@ -2197,13 +2197,13 @@ proto.xudrpc.ChannelBalanceResponse.prototype.toObject = function(opt_includeIns * @param {boolean|undefined} includeInstance Whether to include the JSPB * instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.xudrpc.ChannelBalanceResponse} msg The msg instance to transform. + * @param {!proto.xudrpc.GetBalanceResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.xudrpc.ChannelBalanceResponse.toObject = function(includeInstance, msg) { +proto.xudrpc.GetBalanceResponse.toObject = function(includeInstance, msg) { var f, obj = { - balancesMap: (f = msg.getBalancesMap()) ? f.toObject(includeInstance, proto.xudrpc.ChannelBalance.toObject) : [] + balancesMap: (f = msg.getBalancesMap()) ? f.toObject(includeInstance, proto.xudrpc.Balance.toObject) : [] }; if (includeInstance) { @@ -2217,23 +2217,23 @@ proto.xudrpc.ChannelBalanceResponse.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.xudrpc.ChannelBalanceResponse} + * @return {!proto.xudrpc.GetBalanceResponse} */ -proto.xudrpc.ChannelBalanceResponse.deserializeBinary = function(bytes) { +proto.xudrpc.GetBalanceResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.xudrpc.ChannelBalanceResponse; - return proto.xudrpc.ChannelBalanceResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.xudrpc.GetBalanceResponse; + return proto.xudrpc.GetBalanceResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.xudrpc.ChannelBalanceResponse} msg The message object to deserialize into. + * @param {!proto.xudrpc.GetBalanceResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.xudrpc.ChannelBalanceResponse} + * @return {!proto.xudrpc.GetBalanceResponse} */ -proto.xudrpc.ChannelBalanceResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.xudrpc.GetBalanceResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -2243,7 +2243,7 @@ proto.xudrpc.ChannelBalanceResponse.deserializeBinaryFromReader = function(msg, case 1: var value = msg.getBalancesMap(); reader.readMessage(value, function(message, reader) { - jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.xudrpc.ChannelBalance.deserializeBinaryFromReader); + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.xudrpc.Balance.deserializeBinaryFromReader); }); break; default: @@ -2259,9 +2259,9 @@ proto.xudrpc.ChannelBalanceResponse.deserializeBinaryFromReader = function(msg, * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.xudrpc.ChannelBalanceResponse.prototype.serializeBinary = function() { +proto.xudrpc.GetBalanceResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.xudrpc.ChannelBalanceResponse.serializeBinaryToWriter(this, writer); + proto.xudrpc.GetBalanceResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -2269,33 +2269,33 @@ proto.xudrpc.ChannelBalanceResponse.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.xudrpc.ChannelBalanceResponse} message + * @param {!proto.xudrpc.GetBalanceResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.xudrpc.ChannelBalanceResponse.serializeBinaryToWriter = function(message, writer) { +proto.xudrpc.GetBalanceResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getBalancesMap(true); if (f && f.getLength() > 0) { - f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.xudrpc.ChannelBalance.serializeBinaryToWriter); + f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.xudrpc.Balance.serializeBinaryToWriter); } }; /** - * map balances = 1; + * map balances = 1; * @param {boolean=} opt_noLazyCreate Do not create the map if * empty, instead returning `undefined` - * @return {!jspb.Map} + * @return {!jspb.Map} */ -proto.xudrpc.ChannelBalanceResponse.prototype.getBalancesMap = function(opt_noLazyCreate) { - return /** @type {!jspb.Map} */ ( +proto.xudrpc.GetBalanceResponse.prototype.getBalancesMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( jspb.Message.getMapField(this, 1, opt_noLazyCreate, - proto.xudrpc.ChannelBalance)); + proto.xudrpc.Balance)); }; -proto.xudrpc.ChannelBalanceResponse.prototype.clearBalancesMap = function() { +proto.xudrpc.GetBalanceResponse.prototype.clearBalancesMap = function() { this.getBalancesMap().clear(); }; diff --git a/lib/service/Service.ts b/lib/service/Service.ts index 1903c3fb4..f6f36b599 100644 --- a/lib/service/Service.ts +++ b/lib/service/Service.ts @@ -116,8 +116,8 @@ class Service { return this.orderBook.removeOwnOrderByLocalId(orderId, quantity); } - /** Gets the total lightning network channel balance for a given currency. */ - public channelBalance = async (args: { currency: string }) => { + /** Gets the total lightning network balance for a given currency. */ + public getBalance = async (args: { currency: string }) => { const { currency } = args; const balances = new Map(); diff --git a/proto/xudrpc.proto b/proto/xudrpc.proto index df043079e..63498196a 100644 --- a/proto/xudrpc.proto +++ b/proto/xudrpc.proto @@ -85,10 +85,10 @@ service Xud { }; } - /* Gets the total balance available across all payment channels for one or all currencies. */ - rpc ChannelBalance(ChannelBalanceRequest) returns (ChannelBalanceResponse) { + /* Gets the total balance available across all payment channels and wallets for one or all currencies. */ + rpc GetBalance(GetBalanceRequest) returns (GetBalanceResponse) { option (google.api.http) = { - get: "/v1/channelbalance" + get: "/v1/balance" }; } @@ -319,21 +319,21 @@ message Chain { string network = 2 [json_name = "network"]; } -message ChannelBalance { - // Sum of channel balances denominated in satoshis. +message Balance { + // Total balance denominated in satoshis. uint64 balance = 1 [json_name = "balance"]; // Sum of pending channel balances denominated in satoshis. uint64 pending_open_balance = 2 [json_name = "pending_open_balance"]; } -message ChannelBalanceRequest { +message GetBalanceRequest { // The ticker symbol of the currency to query for, if unspecified then balances for all supported // currencies are queried. string currency = 1 [json_name = "currency"]; } -message ChannelBalanceResponse { - // A map between currency ticker symbols and their channel balances. - map balances = 1 [json_name = "orders"]; +message GetBalanceResponse { + // A map between currency ticker symbols and their balances. + map balances = 1 [json_name = "orders"]; } message OpenChannelRequest {