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

@@ -35,7 +35,7 @@ func (m *ChannelInformationRequest) Reset() { *m = ChannelInformationReq
func (m *ChannelInformationRequest) String() string { return proto.CompactTextString(m) } func (m *ChannelInformationRequest) String() string { return proto.CompactTextString(m) }
func (*ChannelInformationRequest) ProtoMessage() {} func (*ChannelInformationRequest) ProtoMessage() {}
func (*ChannelInformationRequest) Descriptor() ([]byte, []int) { func (*ChannelInformationRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_lspd_c62fb8bb40946759, []int{0} return fileDescriptor_lspd_f6548acf9d60fb70, []int{0}
} }
func (m *ChannelInformationRequest) XXX_Unmarshal(b []byte) error { func (m *ChannelInformationRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ChannelInformationRequest.Unmarshal(m, b) return xxx_messageInfo_ChannelInformationRequest.Unmarshal(m, b)
@@ -94,7 +94,7 @@ func (m *ChannelInformationReply) Reset() { *m = ChannelInformationReply
func (m *ChannelInformationReply) String() string { return proto.CompactTextString(m) } func (m *ChannelInformationReply) String() string { return proto.CompactTextString(m) }
func (*ChannelInformationReply) ProtoMessage() {} func (*ChannelInformationReply) ProtoMessage() {}
func (*ChannelInformationReply) Descriptor() ([]byte, []int) { func (*ChannelInformationReply) Descriptor() ([]byte, []int) {
return fileDescriptor_lspd_c62fb8bb40946759, []int{1} return fileDescriptor_lspd_f6548acf9d60fb70, []int{1}
} }
func (m *ChannelInformationReply) XXX_Unmarshal(b []byte) error { func (m *ChannelInformationReply) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ChannelInformationReply.Unmarshal(m, b) return xxx_messageInfo_ChannelInformationReply.Unmarshal(m, b)
@@ -189,7 +189,7 @@ func (m *OpenChannelRequest) Reset() { *m = OpenChannelRequest{} }
func (m *OpenChannelRequest) String() string { return proto.CompactTextString(m) } func (m *OpenChannelRequest) String() string { return proto.CompactTextString(m) }
func (*OpenChannelRequest) ProtoMessage() {} func (*OpenChannelRequest) ProtoMessage() {}
func (*OpenChannelRequest) Descriptor() ([]byte, []int) { func (*OpenChannelRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_lspd_c62fb8bb40946759, []int{2} return fileDescriptor_lspd_f6548acf9d60fb70, []int{2}
} }
func (m *OpenChannelRequest) XXX_Unmarshal(b []byte) error { func (m *OpenChannelRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_OpenChannelRequest.Unmarshal(m, b) return xxx_messageInfo_OpenChannelRequest.Unmarshal(m, b)
@@ -218,7 +218,9 @@ func (m *OpenChannelRequest) GetPubkey() string {
type OpenChannelReply struct { type OpenChannelReply struct {
// / The transaction hash // / The transaction hash
TxHash string `protobuf:"bytes,1,opt,name=tx_hash,proto3" json:"tx_hash,omitempty"` TxHash string `protobuf:"bytes,1,opt,name=tx_hash,proto3" json:"tx_hash,omitempty"`
// / The output index
OutputIndex uint32 `protobuf:"varint,2,opt,name=output_index,proto3" json:"output_index,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -228,7 +230,7 @@ func (m *OpenChannelReply) Reset() { *m = OpenChannelReply{} }
func (m *OpenChannelReply) String() string { return proto.CompactTextString(m) } func (m *OpenChannelReply) String() string { return proto.CompactTextString(m) }
func (*OpenChannelReply) ProtoMessage() {} func (*OpenChannelReply) ProtoMessage() {}
func (*OpenChannelReply) Descriptor() ([]byte, []int) { func (*OpenChannelReply) Descriptor() ([]byte, []int) {
return fileDescriptor_lspd_c62fb8bb40946759, []int{3} return fileDescriptor_lspd_f6548acf9d60fb70, []int{3}
} }
func (m *OpenChannelReply) XXX_Unmarshal(b []byte) error { func (m *OpenChannelReply) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_OpenChannelReply.Unmarshal(m, b) return xxx_messageInfo_OpenChannelReply.Unmarshal(m, b)
@@ -255,6 +257,13 @@ func (m *OpenChannelReply) GetTxHash() string {
return "" return ""
} }
func (m *OpenChannelReply) GetOutputIndex() uint32 {
if m != nil {
return m.OutputIndex
}
return 0
}
func init() { func init() {
proto.RegisterType((*ChannelInformationRequest)(nil), "lspd.ChannelInformationRequest") proto.RegisterType((*ChannelInformationRequest)(nil), "lspd.ChannelInformationRequest")
proto.RegisterType((*ChannelInformationReply)(nil), "lspd.ChannelInformationReply") proto.RegisterType((*ChannelInformationReply)(nil), "lspd.ChannelInformationReply")
@@ -367,31 +376,32 @@ var _ChannelOpener_serviceDesc = grpc.ServiceDesc{
Metadata: "lspd.proto", Metadata: "lspd.proto",
} }
func init() { proto.RegisterFile("lspd.proto", fileDescriptor_lspd_c62fb8bb40946759) } func init() { proto.RegisterFile("lspd.proto", fileDescriptor_lspd_f6548acf9d60fb70) }
var fileDescriptor_lspd_c62fb8bb40946759 = []byte{ var fileDescriptor_lspd_f6548acf9d60fb70 = []byte{
// 364 bytes of a gzipped FileDescriptorProto // 381 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcf, 0x8a, 0xdb, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xc1, 0x6e, 0xd4, 0x30,
0x10, 0xc6, 0xab, 0xfc, 0xcf, 0x84, 0xd0, 0x20, 0x4a, 0xaa, 0x06, 0x4a, 0x8d, 0xdb, 0x83, 0x29, 0x10, 0xc5, 0xed, 0x76, 0xdb, 0x9d, 0x12, 0x51, 0x8d, 0x50, 0x31, 0x2b, 0x21, 0xa2, 0xc0, 0x21,
0x21, 0x87, 0xe6, 0x09, 0x9a, 0x9e, 0x0a, 0x85, 0x06, 0x1f, 0x7a, 0x15, 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, 0xf4, 0x5d, 0x39, 0x5a, 0x8e, 0xf5, 0xab, 0xe3, 0x02, 0x5b, 0x75, 0xc9,
0xb1, 0xf9, 0x08, 0x6f, 0x52, 0xbd, 0x3a, 0x16, 0x46, 0xd6, 0x88, 0xc5, 0xe2, 0x4f, 0x2a, 0x71, 0x13, 0xfc, 0x08, 0x97, 0x93, 0x77, 0x47, 0x3e, 0xe8, 0x0f, 0x3f, 0x7e, 0x7d, 0xfd, 0xc8, 0x93,
0x33, 0xfe, 0x61, 0xcd, 0x7e, 0xeb, 0x4f, 0x74, 0x4b, 0x76, 0x83, 0xea, 0x56, 0xd7, 0x0f, 0x01, 0xde, 0xe2, 0xf6, 0x0d, 0x3c, 0x2f, 0xcd, 0xe6, 0xae, 0xb1, 0x6a, 0x90, 0x38, 0x6a, 0x7e, 0x94,
0x00, 0x00, 0xff, 0xff, 0xf5, 0x9a, 0xe0, 0xb2, 0xb9, 0x02, 0x00, 0x00, 0x8a, 0x6e, 0x57, 0x5f, 0x9c, 0xcd, 0xb7, 0xa1, 0xc6, 0x5b, 0xb6, 0x5b, 0xf6, 0x7d, 0xbe, 0xf9,
0x1d, 0x00, 0x00, 0xff, 0xff, 0x47, 0xd9, 0x92, 0x62, 0xdd, 0x02, 0x00, 0x00,
} }

View File

@@ -53,4 +53,6 @@ message OpenChannelRequest {
message OpenChannelReply { message OpenChannelReply {
/// The transaction hash /// The transaction hash
string tx_hash = 1 [ json_name = "tx_hash" ]; string tx_hash = 1 [ json_name = "tx_hash" ];
/// The output index
uint32 output_index = 2 [ json_name = "output_index"];
} }

View File

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