lnrpc: making PendingChannels req/resp naming scheme consistent

In this commit we rename the lnrpc.PendingChannelRequest and
lnrpc.PendingChannelResponse to
lnrpc.PendingChannelsRequest/lnrpc.PendingChannelsResponse. We do this
as we strive to ensure that the naming scheme across the RPC interface
is consistent.
This commit is contained in:
Olaoluwa Osuntokun committed 2018-01-04 14:20:31 -06:00
1 parent 445e11db5c
commit 7421584341
7 files changed
+426 -421

No files matched your search

+1 -1
View File
@@ -901,7 +901,7 @@ func pendingChannels(ctx *cli.Context) error {
client, cleanUp := getClient(ctx) client, cleanUp := getClient(ctx)
defer cleanUp() defer cleanUp()
req := &lnrpc.PendingChannelRequest{} req := &lnrpc.PendingChannelsRequest{}
resp, err := client.PendingChannels(ctxb, req) resp, err := client.PendingChannels(ctxb, req)
if err != nil { if err != nil {
return err return err
+10 -10
View File
@@ -211,7 +211,7 @@ func closeChannelAndAssert(ctx context.Context, t *harnessTest,
// If we didn't force close the transaction, at this point, the channel // If we didn't force close the transaction, at this point, the channel
// should now be marked as being in the state of "pending close". // should now be marked as being in the state of "pending close".
if !force { if !force {
pendingChansRequest := &lnrpc.PendingChannelRequest{} pendingChansRequest := &lnrpc.PendingChannelsRequest{}
pendingChanResp, err := node.PendingChannels(ctx, pendingChansRequest) pendingChanResp, err := node.PendingChannels(ctx, pendingChansRequest)
if err != nil { if err != nil {
t.Fatalf("unable to query for pending channels: %v", err) t.Fatalf("unable to query for pending channels: %v", err)
@@ -247,7 +247,7 @@ func closeChannelAndAssert(ctx context.Context, t *harnessTest,
// node's channels that are currently in a pending state (with a broadcast, but // node's channels that are currently in a pending state (with a broadcast, but
// not confirmed funding transaction). // not confirmed funding transaction).
func numOpenChannelsPending(ctxt context.Context, node *lntest.HarnessNode) (int, error) { func numOpenChannelsPending(ctxt context.Context, node *lntest.HarnessNode) (int, error) {
pendingChansRequest := &lnrpc.PendingChannelRequest{} pendingChansRequest := &lnrpc.PendingChannelsRequest{}
resp, err := node.PendingChannels(ctxt, pendingChansRequest) resp, err := node.PendingChannels(ctxt, pendingChansRequest)
if err != nil { if err != nil {
return 0, err return 0, err
@@ -985,11 +985,11 @@ func testChannelBalance(net *lntest.NetworkHarness, t *harnessTest) {
// findForceClosedChannel searches a pending channel response for a particular // findForceClosedChannel searches a pending channel response for a particular
// channel, returning the force closed channel upon success. // channel, returning the force closed channel upon success.
func findForceClosedChannel(t *harnessTest, func findForceClosedChannel(t *harnessTest,
pendingChanResp *lnrpc.PendingChannelResponse, pendingChanResp *lnrpc.PendingChannelsResponse,
op *wire.OutPoint) *lnrpc.PendingChannelResponse_ForceClosedChannel { op *wire.OutPoint) *lnrpc.PendingChannelsResponse_ForceClosedChannel {
var found bool var found bool
var forceClose *lnrpc.PendingChannelResponse_ForceClosedChannel var forceClose *lnrpc.PendingChannelsResponse_ForceClosedChannel
for _, forceClose = range pendingChanResp.PendingForceClosingChannels { for _, forceClose = range pendingChanResp.PendingForceClosingChannels {
if forceClose.Channel.ChannelPoint == op.String() { if forceClose.Channel.ChannelPoint == op.String() {
found = true found = true
@@ -1004,7 +1004,7 @@ func findForceClosedChannel(t *harnessTest,
} }
func assertCommitmentMaturity(t *harnessTest, func assertCommitmentMaturity(t *harnessTest,
forceClose *lnrpc.PendingChannelResponse_ForceClosedChannel, forceClose *lnrpc.PendingChannelsResponse_ForceClosedChannel,
maturityHeight uint32, blocksTilMaturity int32) { maturityHeight uint32, blocksTilMaturity int32) {
if forceClose.MaturityHeight != maturityHeight { if forceClose.MaturityHeight != maturityHeight {
@@ -1022,7 +1022,7 @@ func assertCommitmentMaturity(t *harnessTest,
// assertForceClosedChannelNumHtlcs verifies that a force closed channel has the // assertForceClosedChannelNumHtlcs verifies that a force closed channel has the
// proper number of htlcs. // proper number of htlcs.
func assertPendingChannelNumHtlcs(t *harnessTest, func assertPendingChannelNumHtlcs(t *harnessTest,
forceClose *lnrpc.PendingChannelResponse_ForceClosedChannel, forceClose *lnrpc.PendingChannelsResponse_ForceClosedChannel,
expectedNumHtlcs int) { expectedNumHtlcs int) {
if len(forceClose.PendingHtlcs) != expectedNumHtlcs { if len(forceClose.PendingHtlcs) != expectedNumHtlcs {
@@ -1035,7 +1035,7 @@ func assertPendingChannelNumHtlcs(t *harnessTest,
// assertNumForceClosedChannels checks that a pending channel response has the // assertNumForceClosedChannels checks that a pending channel response has the
// expected number of force closed channels. // expected number of force closed channels.
func assertNumForceClosedChannels(t *harnessTest, func assertNumForceClosedChannels(t *harnessTest,
pendingChanResp *lnrpc.PendingChannelResponse, expectedNumChans int) { pendingChanResp *lnrpc.PendingChannelsResponse, expectedNumChans int) {
if len(pendingChanResp.PendingForceClosingChannels) != expectedNumChans { if len(pendingChanResp.PendingForceClosingChannels) != expectedNumChans {
t.Fatalf("expected to find %d force closed channels, got %d", t.Fatalf("expected to find %d force closed channels, got %d",
@@ -1048,7 +1048,7 @@ func assertNumForceClosedChannels(t *harnessTest,
// belonging to a force closed channel, testing for the expeced stage number, // belonging to a force closed channel, testing for the expeced stage number,
// blocks till maturity, and the maturity height. // blocks till maturity, and the maturity height.
func assertPendingHtlcStageAndMaturity(t *harnessTest, func assertPendingHtlcStageAndMaturity(t *harnessTest,
forceClose *lnrpc.PendingChannelResponse_ForceClosedChannel, forceClose *lnrpc.PendingChannelsResponse_ForceClosedChannel,
stage, maturityHeight uint32, blocksTillMaturity int32) { stage, maturityHeight uint32, blocksTillMaturity int32) {
for _, pendingHtlc := range forceClose.PendingHtlcs { for _, pendingHtlc := range forceClose.PendingHtlcs {
@@ -1213,7 +1213,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
// Now that the channel has been force closed, it should show up in the // Now that the channel has been force closed, it should show up in the
// PendingChannels RPC under the force close section. // PendingChannels RPC under the force close section.
pendingChansRequest := &lnrpc.PendingChannelRequest{} pendingChansRequest := &lnrpc.PendingChannelsRequest{}
pendingChanResp, err := net.Alice.PendingChannels(ctxb, pendingChansRequest) pendingChanResp, err := net.Alice.PendingChannels(ctxb, pendingChansRequest)
if err != nil { if err != nil {
t.Fatalf("unable to query for pending channels: %v", err) t.Fatalf("unable to query for pending channels: %v", err)
+391 -386
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -170,7 +170,7 @@ func request_Lightning_GetInfo_0(ctx context.Context, marshaler runtime.Marshale
} }
func request_Lightning_PendingChannels_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { func request_Lightning_PendingChannels_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq PendingChannelRequest var protoReq PendingChannelsRequest
var metadata runtime.ServerMetadata var metadata runtime.ServerMetadata
msg, err := client.PendingChannels(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) msg, err := client.PendingChannels(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+3 -3
View File
@@ -202,7 +202,7 @@ service Lightning {
workflow and is waiting for confirmations for the funding txn, or is in the workflow and is waiting for confirmations for the funding txn, or is in the
process of closure, either initiated cooperatively or non-cooperatively. process of closure, either initiated cooperatively or non-cooperatively.
*/ */
rpc PendingChannels (PendingChannelRequest) returns (PendingChannelResponse) { rpc PendingChannels (PendingChannelsRequest) returns (PendingChannelsResponse) {
option (google.api.http) = { option (google.api.http) = {
get: "/v1/channels/pending" get: "/v1/channels/pending"
}; };
@@ -913,8 +913,8 @@ message PendingHTLC {
uint32 stage = 6 [ json_name = "stage" ]; uint32 stage = 6 [ json_name = "stage" ];
} }
message PendingChannelRequest {} message PendingChannelsRequest {}
message PendingChannelResponse { message PendingChannelsResponse {
message PendingChannel { message PendingChannel {
string remote_node_pub = 1 [ json_name = "remote_node_pub" ]; string remote_node_pub = 1 [ json_name = "remote_node_pub" ];
string channel_point = 2 [ json_name = "channel_point" ]; string channel_point = 2 [ json_name = "channel_point" ];
+12 -12
View File
@@ -109,7 +109,7 @@
"200": { "200": {
"description": "", "description": "",
"schema": { "schema": {
"$ref": "#/definitions/lnrpcPendingChannelResponse" "$ref": "#/definitions/lnrpcPendingChannelsResponse"
} }
} }
}, },
@@ -696,11 +696,11 @@
} }
}, },
"definitions": { "definitions": {
"PendingChannelResponseClosedChannel": { "PendingChannelsResponseClosedChannel": {
"type": "object", "type": "object",
"properties": { "properties": {
"channel": { "channel": {
"$ref": "#/definitions/PendingChannelResponsePendingChannel", "$ref": "#/definitions/PendingChannelsResponsePendingChannel",
"title": "/ The pending channel to be closed" "title": "/ The pending channel to be closed"
}, },
"closing_txid": { "closing_txid": {
@@ -709,11 +709,11 @@
} }
} }
}, },
"PendingChannelResponseForceClosedChannel": { "PendingChannelsResponseForceClosedChannel": {
"type": "object", "type": "object",
"properties": { "properties": {
"channel": { "channel": {
"$ref": "#/definitions/PendingChannelResponsePendingChannel", "$ref": "#/definitions/PendingChannelsResponsePendingChannel",
"title": "/ The pending channel to be force closed" "title": "/ The pending channel to be force closed"
}, },
"closing_txid": { "closing_txid": {
@@ -748,7 +748,7 @@
} }
} }
}, },
"PendingChannelResponsePendingChannel": { "PendingChannelsResponsePendingChannel": {
"type": "object", "type": "object",
"properties": { "properties": {
"remote_node_pub": { "remote_node_pub": {
@@ -771,11 +771,11 @@
} }
} }
}, },
"PendingChannelResponsePendingOpenChannel": { "PendingChannelsResponsePendingOpenChannel": {
"type": "object", "type": "object",
"properties": { "properties": {
"channel": { "channel": {
"$ref": "#/definitions/PendingChannelResponsePendingChannel", "$ref": "#/definitions/PendingChannelsResponsePendingChannel",
"title": "/ The pending channel" "title": "/ The pending channel"
}, },
"confirmation_height": { "confirmation_height": {
@@ -1746,7 +1746,7 @@
} }
} }
}, },
"lnrpcPendingChannelResponse": { "lnrpcPendingChannelsResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"total_limbo_balance": { "total_limbo_balance": {
@@ -1757,21 +1757,21 @@
"pending_open_channels": { "pending_open_channels": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/PendingChannelResponsePendingOpenChannel" "$ref": "#/definitions/PendingChannelsResponsePendingOpenChannel"
}, },
"title": "/ Channels pending opening" "title": "/ Channels pending opening"
}, },
"pending_closing_channels": { "pending_closing_channels": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/PendingChannelResponseClosedChannel" "$ref": "#/definitions/PendingChannelsResponseClosedChannel"
}, },
"title": "/ Channels pending closing" "title": "/ Channels pending closing"
}, },
"pending_force_closing_channels": { "pending_force_closing_channels": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/PendingChannelResponseForceClosedChannel" "$ref": "#/definitions/PendingChannelsResponseForceClosedChannel"
}, },
"title": "/ Channels pending force closing" "title": "/ Channels pending force closing"
} }
+8 -8
View File
@@ -1257,7 +1257,7 @@ func (r *rpcServer) ChannelBalance(ctx context.Context,
// workflow and is waiting for confirmations for the funding txn, or is in the // workflow and is waiting for confirmations for the funding txn, or is in the
// process of closure, either initiated cooperatively or non-cooperatively. // process of closure, either initiated cooperatively or non-cooperatively.
func (r *rpcServer) PendingChannels(ctx context.Context, func (r *rpcServer) PendingChannels(ctx context.Context,
in *lnrpc.PendingChannelRequest) (*lnrpc.PendingChannelResponse, error) { in *lnrpc.PendingChannelsRequest) (*lnrpc.PendingChannelsResponse, error) {
// Check macaroon to see if this is allowed. // Check macaroon to see if this is allowed.
if r.authSvc != nil { if r.authSvc != nil {
@@ -1274,7 +1274,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
rpcsLog.Debugf("[pendingchannels]") rpcsLog.Debugf("[pendingchannels]")
resp := &lnrpc.PendingChannelResponse{} resp := &lnrpc.PendingChannelsResponse{}
// First, we'll populate the response with all the channels that are // First, we'll populate the response with all the channels that are
// soon to be opened. We can easily fetch this data from the database // soon to be opened. We can easily fetch this data from the database
@@ -1283,7 +1283,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
if err != nil { if err != nil {
return nil, err return nil, err
} }
resp.PendingOpenChannels = make([]*lnrpc.PendingChannelResponse_PendingOpenChannel, resp.PendingOpenChannels = make([]*lnrpc.PendingChannelsResponse_PendingOpenChannel,
len(pendingOpenChannels)) len(pendingOpenChannels))
for i, pendingChan := range pendingOpenChannels { for i, pendingChan := range pendingOpenChannels {
pub := pendingChan.IdentityPub.SerializeCompressed() pub := pendingChan.IdentityPub.SerializeCompressed()
@@ -1302,8 +1302,8 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
targetConfHeight := pendingChan.FundingBroadcastHeight + uint32(pendingChan.NumConfsRequired) targetConfHeight := pendingChan.FundingBroadcastHeight + uint32(pendingChan.NumConfsRequired)
blocksTillOpen := int32(targetConfHeight) - bestHeight blocksTillOpen := int32(targetConfHeight) - bestHeight
resp.PendingOpenChannels[i] = &lnrpc.PendingChannelResponse_PendingOpenChannel{ resp.PendingOpenChannels[i] = &lnrpc.PendingChannelsResponse_PendingOpenChannel{
Channel: &lnrpc.PendingChannelResponse_PendingChannel{ Channel: &lnrpc.PendingChannelsResponse_PendingChannel{
RemoteNodePub: hex.EncodeToString(pub), RemoteNodePub: hex.EncodeToString(pub),
ChannelPoint: pendingChan.FundingOutpoint.String(), ChannelPoint: pendingChan.FundingOutpoint.String(),
Capacity: int64(pendingChan.Capacity), Capacity: int64(pendingChan.Capacity),
@@ -1334,7 +1334,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
// needed regardless of how this channel was closed. // needed regardless of how this channel was closed.
pub := pendingClose.RemotePub.SerializeCompressed() pub := pendingClose.RemotePub.SerializeCompressed()
chanPoint := pendingClose.ChanPoint chanPoint := pendingClose.ChanPoint
channel := &lnrpc.PendingChannelResponse_PendingChannel{ channel := &lnrpc.PendingChannelsResponse_PendingChannel{
RemoteNodePub: hex.EncodeToString(pub), RemoteNodePub: hex.EncodeToString(pub),
ChannelPoint: chanPoint.String(), ChannelPoint: chanPoint.String(),
Capacity: int64(pendingClose.Capacity), Capacity: int64(pendingClose.Capacity),
@@ -1350,7 +1350,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
case channeldb.CooperativeClose: case channeldb.CooperativeClose:
resp.PendingClosingChannels = append( resp.PendingClosingChannels = append(
resp.PendingClosingChannels, resp.PendingClosingChannels,
&lnrpc.PendingChannelResponse_ClosedChannel{ &lnrpc.PendingChannelsResponse_ClosedChannel{
Channel: channel, Channel: channel,
ClosingTxid: closeTXID, ClosingTxid: closeTXID,
}, },
@@ -1361,7 +1361,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
// If the channel was force closed, then we'll need to query // If the channel was force closed, then we'll need to query
// the utxoNursery for additional information. // the utxoNursery for additional information.
case channeldb.ForceClose: case channeldb.ForceClose:
forceClose := &lnrpc.PendingChannelResponse_ForceClosedChannel{ forceClose := &lnrpc.PendingChannelsResponse_ForceClosedChannel{
Channel: channel, Channel: channel,
ClosingTxid: closeTXID, ClosingTxid: closeTXID,
} }