Add output index to OpenChannelReply

This commit is contained in:
Yaacov Akiba Slama
2019-07-22 15:12:35 +03:00
parent 93eb57364c
commit ab824d1565
3 changed files with 46 additions and 33 deletions

View File

@@ -56,6 +56,7 @@ func (s *server) OpenChannel(ctx context.Context, in *lspdrpc.OpenChannelRequest
return nil, err
}
var txidStr string
var outputIndex uint32
if len(nodeChannels) == 0 && len(pendingChannels) == 0 {
response, err := client.OpenChannelSync(clientCtx, &lnrpc.OpenChannelRequest{
LocalFundingAmount: channelAmount,
@@ -73,14 +74,14 @@ func (s *server) OpenChannel(ctx context.Context, in *lspdrpc.OpenChannelRequest
}
txid, _ := chainhash.NewHash(response.GetFundingTxidBytes())
outputIndex = response.GetOutputIndex()
// don't fail the request in case we can't format the channel id from
// some reason...
if txid != nil {
txidStr = txid.String()
}
}
return &lspdrpc.OpenChannelReply{TxHash: txidStr}, nil
return &lspdrpc.OpenChannelReply{TxHash: txidStr, OutputIndex: outputIndex}, nil
})
if err != nil {