lnrpc: remove oneof from signrpc.KeyDescriptor

This commit is contained in:
Olaoluwa Osuntokun 2018-12-03 21:26:35 -08:00
parent 844698048a
commit 273dee607b
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2
3 changed files with 64 additions and 156 deletions

@ -66,10 +66,14 @@ func (m *KeyLocator) GetKeyIndex() int32 {
}
type KeyDescriptor struct {
// Types that are valid to be assigned to Key:
// *KeyDescriptor_RawKeyBytes
// *KeyDescriptor_KeyLoc
Key isKeyDescriptor_Key `protobuf_oneof:"key"`
// *
// The raw bytes of the key being identified. Either this or the KeyLocator
// must be specified.
RawKeyBytes []byte `protobuf:"bytes,1,opt,name=raw_key_bytes,json=rawKeyBytes,proto3" json:"raw_key_bytes,omitempty"`
// *
// The key locator that identifies which key to use for signing. Either this
// or the raw bytes of the target key must be specified.
KeyLoc *KeyLocator `protobuf:"bytes,2,opt,name=key_loc,json=keyLoc" json:"key_loc,omitempty"`
}
func (m *KeyDescriptor) Reset() { *m = KeyDescriptor{} }
@ -77,111 +81,20 @@ func (m *KeyDescriptor) String() string { return proto.CompactTextStr
func (*KeyDescriptor) ProtoMessage() {}
func (*KeyDescriptor) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
type isKeyDescriptor_Key interface {
isKeyDescriptor_Key()
}
type KeyDescriptor_RawKeyBytes struct {
RawKeyBytes []byte `protobuf:"bytes,1,opt,name=raw_key_bytes,json=rawKeyBytes,proto3,oneof"`
}
type KeyDescriptor_KeyLoc struct {
KeyLoc *KeyLocator `protobuf:"bytes,2,opt,name=key_loc,json=keyLoc,oneof"`
}
func (*KeyDescriptor_RawKeyBytes) isKeyDescriptor_Key() {}
func (*KeyDescriptor_KeyLoc) isKeyDescriptor_Key() {}
func (m *KeyDescriptor) GetKey() isKeyDescriptor_Key {
if m != nil {
return m.Key
}
return nil
}
func (m *KeyDescriptor) GetRawKeyBytes() []byte {
if x, ok := m.GetKey().(*KeyDescriptor_RawKeyBytes); ok {
return x.RawKeyBytes
if m != nil {
return m.RawKeyBytes
}
return nil
}
func (m *KeyDescriptor) GetKeyLoc() *KeyLocator {
if x, ok := m.GetKey().(*KeyDescriptor_KeyLoc); ok {
return x.KeyLoc
if m != nil {
return m.KeyLoc
}
return nil
}
// XXX_OneofFuncs is for the internal use of the proto package.
func (*KeyDescriptor) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
return _KeyDescriptor_OneofMarshaler, _KeyDescriptor_OneofUnmarshaler, _KeyDescriptor_OneofSizer, []interface{}{
(*KeyDescriptor_RawKeyBytes)(nil),
(*KeyDescriptor_KeyLoc)(nil),
}
}
func _KeyDescriptor_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*KeyDescriptor)
// key
switch x := m.Key.(type) {
case *KeyDescriptor_RawKeyBytes:
b.EncodeVarint(1<<3 | proto.WireBytes)
b.EncodeRawBytes(x.RawKeyBytes)
case *KeyDescriptor_KeyLoc:
b.EncodeVarint(2<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.KeyLoc); err != nil {
return err
}
case nil:
default:
return fmt.Errorf("KeyDescriptor.Key has unexpected type %T", x)
}
return nil
}
func _KeyDescriptor_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*KeyDescriptor)
switch tag {
case 1: // key.raw_key_bytes
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Key = &KeyDescriptor_RawKeyBytes{x}
return true, err
case 2: // key.key_loc
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(KeyLocator)
err := b.DecodeMessage(msg)
m.Key = &KeyDescriptor_KeyLoc{msg}
return true, err
default:
return false, nil
}
}
func _KeyDescriptor_OneofSizer(msg proto.Message) (n int) {
m := msg.(*KeyDescriptor)
// key
switch x := m.Key.(type) {
case *KeyDescriptor_RawKeyBytes:
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.RawKeyBytes)))
n += len(x.RawKeyBytes)
case *KeyDescriptor_KeyLoc:
s := proto.Size(x.KeyLoc)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
type TxOut struct {
// / The value of the output being spent.
Value int64 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
@ -551,39 +464,38 @@ var _Signer_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("signrpc/signer.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 536 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xd1, 0x8f, 0xd2, 0x40,
0x10, 0xc6, 0x0f, 0x10, 0xca, 0x4d, 0x5b, 0xd4, 0x95, 0x68, 0xd5, 0x18, 0xb1, 0xf1, 0x0c, 0x4f,
0x18, 0xd1, 0x98, 0xe8, 0x93, 0x39, 0xcd, 0x85, 0x0b, 0x97, 0x5c, 0xb2, 0xf0, 0xde, 0x94, 0xb2,
0xf6, 0x36, 0xe5, 0xda, 0x5e, 0x77, 0x6b, 0xe9, 0x9b, 0xff, 0x83, 0xff, 0xb0, 0x99, 0xdd, 0x05,
0x8a, 0xde, 0x13, 0x7c, 0x5f, 0x67, 0x67, 0x7e, 0x3b, 0x5f, 0x0b, 0x43, 0xc1, 0xe3, 0xb4, 0xc8,
0xa3, 0xf7, 0xf8, 0xcb, 0x8a, 0x49, 0x5e, 0x64, 0x32, 0x23, 0x96, 0x71, 0xfd, 0x19, 0xc0, 0x9c,
0xd5, 0x57, 0x59, 0x14, 0xca, 0xac, 0x20, 0xaf, 0x00, 0x12, 0x56, 0x07, 0x3f, 0xc3, 0x5b, 0xbe,
0xa9, 0xbd, 0xd6, 0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0x5b, 0xa7, 0x61, 0x45, 0x1e, 0x1d, 0x5d, 0x9e, 0xb2, 0xbb, 0x17, 0x8f, 0xff,
0x71, 0x44, 0x4e, 0xbe, 0x01, 0xf9, 0x9e, 0xdd, 0xe6, 0xa5, 0x64, 0xcd, 0xdb, 0xfd, 0x7f, 0xd4,
0xbb, 0x17, 0x86, 0x89, 0x7c, 0xd5, 0x53, 0x9f, 0xef, 0xc7, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff,
0x7b, 0x48, 0x93, 0x2a, 0xd6, 0x03, 0x00, 0x00,
// 526 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x5f, 0x6f, 0xd3, 0x3e,
0x14, 0x55, 0xd7, 0x5f, 0x9b, 0xee, 0x26, 0xd9, 0x0f, 0x4c, 0x05, 0x01, 0x84, 0x28, 0x91, 0x86,
0xfa, 0x80, 0x8a, 0x28, 0x08, 0x09, 0x9e, 0x10, 0xa0, 0x89, 0xa9, 0x93, 0x26, 0xb9, 0x7d, 0x8f,
0xdc, 0xd4, 0x64, 0x56, 0xba, 0xc4, 0x8b, 0x1d, 0xd2, 0xbc, 0xf1, 0x1d, 0xf8, 0xc2, 0xe8, 0xda,
0xee, 0x3f, 0xe0, 0xa9, 0x39, 0xc7, 0xf7, 0xde, 0x73, 0x7c, 0x4f, 0x0d, 0x43, 0x25, 0xb2, 0xa2,
0x92, 0xe9, 0x6b, 0xfc, 0xe5, 0xd5, 0x44, 0x56, 0xa5, 0x2e, 0x89, 0xe7, 0xd8, 0xf8, 0x1b, 0xc0,
0x8c, 0xb7, 0x57, 0x65, 0xca, 0x74, 0x59, 0x91, 0x67, 0x00, 0x39, 0x6f, 0x93, 0xef, 0xec, 0x56,
0xac, 0xdb, 0xa8, 0x33, 0xea, 0x8c, 0x7b, 0xf4, 0x34, 0xe7, 0xed, 0x85, 0x21, 0xc8, 0x53, 0x40,
0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fc, 0xf0, 0x76, 0x7f, 0xb7, 0x46, 0xff, 0x34, 0xc3, 0x95, 0x5c, 0xf6, 0xcd, 0x9b, 0x7d,
0xfb, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xe8, 0x77, 0xc6, 0x62, 0xcb, 0x03, 0x00, 0x00,
}

@ -11,19 +11,17 @@ message KeyLocator {
}
message KeyDescriptor {
oneof key {
/**
The raw bytes of the key being identified. Either this or the KeyLocator
must be specified.
*/
bytes raw_key_bytes = 1;
/**
The raw bytes of the key being identified. Either this or the KeyLocator
must be specified.
*/
bytes raw_key_bytes = 1;
/**
The key locator that identifies which key to use for signing. Either this
or the raw bytes of the target key must be specified.
*/
KeyLocator key_loc = 2;
}
/**
The key locator that identifies which key to use for signing. Either this
or the raw bytes of the target key must be specified.
*/
KeyLocator key_loc = 2;
}
message TxOut {

@ -200,12 +200,11 @@ func (w *WalletKit) DeriveNextKey(ctx context.Context,
}
return &signrpc.KeyDescriptor{
Key: &signrpc.KeyDescriptor_KeyLoc{
KeyLoc: &signrpc.KeyLocator{
KeyFamily: int32(nextKeyDesc.Family),
KeyIndex: int32(nextKeyDesc.Index),
},
KeyLoc: &signrpc.KeyLocator{
KeyFamily: int32(nextKeyDesc.Family),
KeyIndex: int32(nextKeyDesc.Index),
},
RawKeyBytes: nextKeyDesc.PubKey.SerializeCompressed(),
}, nil
}
@ -223,12 +222,11 @@ func (w *WalletKit) DeriveKey(ctx context.Context,
}
return &signrpc.KeyDescriptor{
Key: &signrpc.KeyDescriptor_KeyLoc{
KeyLoc: &signrpc.KeyLocator{
KeyFamily: int32(keyDesc.Family),
KeyIndex: int32(keyDesc.Index),
},
KeyLoc: &signrpc.KeyLocator{
KeyFamily: int32(keyDesc.Family),
KeyIndex: int32(keyDesc.Index),
},
RawKeyBytes: keyDesc.PubKey.SerializeCompressed(),
}, nil
}