From 2bc1991c0966c3a4aa61565eb35be29351765d01 Mon Sep 17 00:00:00 2001 From: Trinity Date: Fri, 24 Oct 2025 10:32:44 +0700 Subject: [PATCH] feat: new keygen and importkeys for protocol upgrade --- crypto/master_key.go | 3 +- nockchain/nockapp.pb.go | 709 +++++++++++++++++++++++++++++++++++ nockchain/nockapp_grpc.pb.go | 161 ++++++++ nockchain/primitives.pb.go | 305 ++++----------- nockchain/service.pb.go | 365 ++++++++---------- nockchain/service_grpc.pb.go | 40 +- proto/nockapp.proto | 75 ++++ proto/primitives.proto | 17 - proto/service.proto | 40 +- wallet/nockchain_service.go | 52 ++- wallet/service.go | 144 +++++-- wallet/service_test.go | 175 ++++++++- 12 files changed, 1524 insertions(+), 562 deletions(-) create mode 100644 nockchain/nockapp.pb.go create mode 100644 nockchain/nockapp_grpc.pb.go create mode 100644 proto/nockapp.proto diff --git a/crypto/master_key.go b/crypto/master_key.go index 5606061..1634f4f 100644 --- a/crypto/master_key.go +++ b/crypto/master_key.go @@ -191,13 +191,12 @@ func BigIntToT8(data big.Int) [8]uint64 { res := rip(data) return [8]uint64(res) } -func SerializeExtend(chainCode []byte, key []byte, keyType KeyType) []byte { +func SerializeExtend(chainCode []byte, key []byte, ver int, keyType KeyType) []byte { data := []byte{} // dep: depth in chain // idx: index at depth // pf: parent fingerprint // ver: version - ver := 0 depth := 0 idx := []byte{0, 0, 0, 0} pf := []byte{0, 0, 0, 0} diff --git a/nockchain/nockapp.pb.go b/nockchain/nockapp.pb.go new file mode 100644 index 0000000..ac4d7d4 --- /dev/null +++ b/nockchain/nockapp.pb.go @@ -0,0 +1,709 @@ +// nockchain/private/v1/nockapp.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.9 +// protoc v3.20.3 +// source: nockapp.proto + +package nockchain + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AppErrorCode int32 + +const ( + AppErrorCode_ERROR_CODE_UNSPECIFIED AppErrorCode = 0 + AppErrorCode_ERROR_CODE_INVALID_REQUEST AppErrorCode = 1 + AppErrorCode_ERROR_CODE_PEEK_FAILED AppErrorCode = 2 + AppErrorCode_ERROR_CODE_PEEK_RETURNED_NO_DATA AppErrorCode = 3 + AppErrorCode_ERROR_CODE_POKE_FAILED AppErrorCode = 4 + AppErrorCode_ERROR_CODE_NACKAPP_ERROR AppErrorCode = 5 + AppErrorCode_ERROR_CODE_TIMEOUT AppErrorCode = 6 + AppErrorCode_ERROR_CODE_INTERNAL_ERROR AppErrorCode = 7 + AppErrorCode_ERROR_CODE_NOT_FOUND AppErrorCode = 8 + AppErrorCode_ERROR_CODE_PERMISSION_DENIED AppErrorCode = 9 + AppErrorCode_ERROR_CODE_INVALID_WIRE AppErrorCode = 10 + AppErrorCode_ERROR_CODE_KERNEL_ERROR AppErrorCode = 11 +) + +// Enum value maps for AppErrorCode. +var ( + AppErrorCode_name = map[int32]string{ + 0: "ERROR_CODE_UNSPECIFIED", + 1: "ERROR_CODE_INVALID_REQUEST", + 2: "ERROR_CODE_PEEK_FAILED", + 3: "ERROR_CODE_PEEK_RETURNED_NO_DATA", + 4: "ERROR_CODE_POKE_FAILED", + 5: "ERROR_CODE_NACKAPP_ERROR", + 6: "ERROR_CODE_TIMEOUT", + 7: "ERROR_CODE_INTERNAL_ERROR", + 8: "ERROR_CODE_NOT_FOUND", + 9: "ERROR_CODE_PERMISSION_DENIED", + 10: "ERROR_CODE_INVALID_WIRE", + 11: "ERROR_CODE_KERNEL_ERROR", + } + AppErrorCode_value = map[string]int32{ + "ERROR_CODE_UNSPECIFIED": 0, + "ERROR_CODE_INVALID_REQUEST": 1, + "ERROR_CODE_PEEK_FAILED": 2, + "ERROR_CODE_PEEK_RETURNED_NO_DATA": 3, + "ERROR_CODE_POKE_FAILED": 4, + "ERROR_CODE_NACKAPP_ERROR": 5, + "ERROR_CODE_TIMEOUT": 6, + "ERROR_CODE_INTERNAL_ERROR": 7, + "ERROR_CODE_NOT_FOUND": 8, + "ERROR_CODE_PERMISSION_DENIED": 9, + "ERROR_CODE_INVALID_WIRE": 10, + "ERROR_CODE_KERNEL_ERROR": 11, + } +) + +func (x AppErrorCode) Enum() *AppErrorCode { + p := new(AppErrorCode) + *p = x + return p +} + +func (x AppErrorCode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (AppErrorCode) Descriptor() protoreflect.EnumDescriptor { + return file_nockapp_proto_enumTypes[0].Descriptor() +} + +func (AppErrorCode) Type() protoreflect.EnumType { + return &file_nockapp_proto_enumTypes[0] +} + +func (x AppErrorCode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use AppErrorCode.Descriptor instead. +func (AppErrorCode) EnumDescriptor() ([]byte, []int) { + return file_nockapp_proto_rawDescGZIP(), []int{0} +} + +type PeekRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Pid int32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` // process ID for tracking + Path []byte `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` // JAM-encoded nock peek path + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PeekRequest) Reset() { + *x = PeekRequest{} + mi := &file_nockapp_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PeekRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeekRequest) ProtoMessage() {} + +func (x *PeekRequest) ProtoReflect() protoreflect.Message { + mi := &file_nockapp_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PeekRequest.ProtoReflect.Descriptor instead. +func (*PeekRequest) Descriptor() ([]byte, []int) { + return file_nockapp_proto_rawDescGZIP(), []int{0} +} + +func (x *PeekRequest) GetPid() int32 { + if x != nil { + return x.Pid + } + return 0 +} + +func (x *PeekRequest) GetPath() []byte { + if x != nil { + return x.Path + } + return nil +} + +type PeekResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Result: + // + // *PeekResponse_Data + // *PeekResponse_Error + Result isPeekResponse_Result `protobuf_oneof:"result"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PeekResponse) Reset() { + *x = PeekResponse{} + mi := &file_nockapp_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PeekResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeekResponse) ProtoMessage() {} + +func (x *PeekResponse) ProtoReflect() protoreflect.Message { + mi := &file_nockapp_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PeekResponse.ProtoReflect.Descriptor instead. +func (*PeekResponse) Descriptor() ([]byte, []int) { + return file_nockapp_proto_rawDescGZIP(), []int{1} +} + +func (x *PeekResponse) GetResult() isPeekResponse_Result { + if x != nil { + return x.Result + } + return nil +} + +func (x *PeekResponse) GetData() []byte { + if x != nil { + if x, ok := x.Result.(*PeekResponse_Data); ok { + return x.Data + } + } + return nil +} + +func (x *PeekResponse) GetError() *AppErrorStatus { + if x != nil { + if x, ok := x.Result.(*PeekResponse_Error); ok { + return x.Error + } + } + return nil +} + +type isPeekResponse_Result interface { + isPeekResponse_Result() +} + +type PeekResponse_Data struct { + Data []byte `protobuf:"bytes,1,opt,name=data,proto3,oneof"` // JAM-encoded nock data (success case) +} + +type PeekResponse_Error struct { + Error *AppErrorStatus `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +func (*PeekResponse_Data) isPeekResponse_Result() {} + +func (*PeekResponse_Error) isPeekResponse_Result() {} + +type PokeRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Pid int32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` // process ID for tracking + Wire *Wire `protobuf:"bytes,2,opt,name=wire,proto3" json:"wire,omitempty"` // wire routing information + Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` // JAM-encoded nock data + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PokeRequest) Reset() { + *x = PokeRequest{} + mi := &file_nockapp_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PokeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PokeRequest) ProtoMessage() {} + +func (x *PokeRequest) ProtoReflect() protoreflect.Message { + mi := &file_nockapp_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PokeRequest.ProtoReflect.Descriptor instead. +func (*PokeRequest) Descriptor() ([]byte, []int) { + return file_nockapp_proto_rawDescGZIP(), []int{2} +} + +func (x *PokeRequest) GetPid() int32 { + if x != nil { + return x.Pid + } + return 0 +} + +func (x *PokeRequest) GetWire() *Wire { + if x != nil { + return x.Wire + } + return nil +} + +func (x *PokeRequest) GetPayload() []byte { + if x != nil { + return x.Payload + } + return nil +} + +type PokeResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Result: + // + // *PokeResponse_Acknowledged + // *PokeResponse_Error + Result isPokeResponse_Result `protobuf_oneof:"result"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PokeResponse) Reset() { + *x = PokeResponse{} + mi := &file_nockapp_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PokeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PokeResponse) ProtoMessage() {} + +func (x *PokeResponse) ProtoReflect() protoreflect.Message { + mi := &file_nockapp_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PokeResponse.ProtoReflect.Descriptor instead. +func (*PokeResponse) Descriptor() ([]byte, []int) { + return file_nockapp_proto_rawDescGZIP(), []int{3} +} + +func (x *PokeResponse) GetResult() isPokeResponse_Result { + if x != nil { + return x.Result + } + return nil +} + +func (x *PokeResponse) GetAcknowledged() bool { + if x != nil { + if x, ok := x.Result.(*PokeResponse_Acknowledged); ok { + return x.Acknowledged + } + } + return false +} + +func (x *PokeResponse) GetError() *AppErrorStatus { + if x != nil { + if x, ok := x.Result.(*PokeResponse_Error); ok { + return x.Error + } + } + return nil +} + +type isPokeResponse_Result interface { + isPokeResponse_Result() +} + +type PokeResponse_Acknowledged struct { + Acknowledged bool `protobuf:"varint,1,opt,name=acknowledged,proto3,oneof"` // true if successful +} + +type PokeResponse_Error struct { + Error *AppErrorStatus `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +func (*PokeResponse_Acknowledged) isPokeResponse_Result() {} + +func (*PokeResponse_Error) isPokeResponse_Result() {} + +type AppErrorStatus struct { + state protoimpl.MessageState `protogen:"open.v1"` + Code AppErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=nockchain.private.v1.AppErrorCode" json:"code,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + Details *string `protobuf:"bytes,3,opt,name=details,proto3,oneof" json:"details,omitempty"` // additional error context + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AppErrorStatus) Reset() { + *x = AppErrorStatus{} + mi := &file_nockapp_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AppErrorStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AppErrorStatus) ProtoMessage() {} + +func (x *AppErrorStatus) ProtoReflect() protoreflect.Message { + mi := &file_nockapp_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AppErrorStatus.ProtoReflect.Descriptor instead. +func (*AppErrorStatus) Descriptor() ([]byte, []int) { + return file_nockapp_proto_rawDescGZIP(), []int{4} +} + +func (x *AppErrorStatus) GetCode() AppErrorCode { + if x != nil { + return x.Code + } + return AppErrorCode_ERROR_CODE_UNSPECIFIED +} + +func (x *AppErrorStatus) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *AppErrorStatus) GetDetails() string { + if x != nil && x.Details != nil { + return *x.Details + } + return "" +} + +type Wire struct { + state protoimpl.MessageState `protogen:"open.v1"` + Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"` // e.g., "http", "file", "wallet", "grpc" + Version uint64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` // wire format version + Tags []*WireTag `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty"` // operation-specific tags + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Wire) Reset() { + *x = Wire{} + mi := &file_nockapp_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Wire) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Wire) ProtoMessage() {} + +func (x *Wire) ProtoReflect() protoreflect.Message { + mi := &file_nockapp_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Wire.ProtoReflect.Descriptor instead. +func (*Wire) Descriptor() ([]byte, []int) { + return file_nockapp_proto_rawDescGZIP(), []int{5} +} + +func (x *Wire) GetSource() string { + if x != nil { + return x.Source + } + return "" +} + +func (x *Wire) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *Wire) GetTags() []*WireTag { + if x != nil { + return x.Tags + } + return nil +} + +type WireTag struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Value: + // + // *WireTag_Text + // *WireTag_Number + Value isWireTag_Value `protobuf_oneof:"value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WireTag) Reset() { + *x = WireTag{} + mi := &file_nockapp_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WireTag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WireTag) ProtoMessage() {} + +func (x *WireTag) ProtoReflect() protoreflect.Message { + mi := &file_nockapp_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WireTag.ProtoReflect.Descriptor instead. +func (*WireTag) Descriptor() ([]byte, []int) { + return file_nockapp_proto_rawDescGZIP(), []int{6} +} + +func (x *WireTag) GetValue() isWireTag_Value { + if x != nil { + return x.Value + } + return nil +} + +func (x *WireTag) GetText() string { + if x != nil { + if x, ok := x.Value.(*WireTag_Text); ok { + return x.Text + } + } + return "" +} + +func (x *WireTag) GetNumber() uint64 { + if x != nil { + if x, ok := x.Value.(*WireTag_Number); ok { + return x.Number + } + } + return 0 +} + +type isWireTag_Value interface { + isWireTag_Value() +} + +type WireTag_Text struct { + Text string `protobuf:"bytes,1,opt,name=text,proto3,oneof"` +} + +type WireTag_Number struct { + Number uint64 `protobuf:"varint,2,opt,name=number,proto3,oneof"` +} + +func (*WireTag_Text) isWireTag_Value() {} + +func (*WireTag_Number) isWireTag_Value() {} + +var File_nockapp_proto protoreflect.FileDescriptor + +const file_nockapp_proto_rawDesc = "" + + "\n" + + "\rnockapp.proto\x12\x14nockchain.private.v1\"3\n" + + "\vPeekRequest\x12\x10\n" + + "\x03pid\x18\x01 \x01(\x05R\x03pid\x12\x12\n" + + "\x04path\x18\x02 \x01(\fR\x04path\"l\n" + + "\fPeekResponse\x12\x14\n" + + "\x04data\x18\x01 \x01(\fH\x00R\x04data\x12<\n" + + "\x05error\x18\x02 \x01(\v2$.nockchain.private.v1.AppErrorStatusH\x00R\x05errorB\b\n" + + "\x06result\"i\n" + + "\vPokeRequest\x12\x10\n" + + "\x03pid\x18\x01 \x01(\x05R\x03pid\x12.\n" + + "\x04wire\x18\x02 \x01(\v2\x1a.nockchain.private.v1.WireR\x04wire\x12\x18\n" + + "\apayload\x18\x03 \x01(\fR\apayload\"|\n" + + "\fPokeResponse\x12$\n" + + "\facknowledged\x18\x01 \x01(\bH\x00R\facknowledged\x12<\n" + + "\x05error\x18\x02 \x01(\v2$.nockchain.private.v1.AppErrorStatusH\x00R\x05errorB\b\n" + + "\x06result\"\x8d\x01\n" + + "\x0eAppErrorStatus\x126\n" + + "\x04code\x18\x01 \x01(\x0e2\".nockchain.private.v1.AppErrorCodeR\x04code\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage\x12\x1d\n" + + "\adetails\x18\x03 \x01(\tH\x00R\adetails\x88\x01\x01B\n" + + "\n" + + "\b_details\"k\n" + + "\x04Wire\x12\x16\n" + + "\x06source\x18\x01 \x01(\tR\x06source\x12\x18\n" + + "\aversion\x18\x02 \x01(\x04R\aversion\x121\n" + + "\x04tags\x18\x03 \x03(\v2\x1d.nockchain.private.v1.WireTagR\x04tags\"B\n" + + "\aWireTag\x12\x14\n" + + "\x04text\x18\x01 \x01(\tH\x00R\x04text\x12\x18\n" + + "\x06number\x18\x02 \x01(\x04H\x00R\x06numberB\a\n" + + "\x05value*\xf3\x02\n" + + "\fAppErrorCode\x12\x1a\n" + + "\x16ERROR_CODE_UNSPECIFIED\x10\x00\x12\x1e\n" + + "\x1aERROR_CODE_INVALID_REQUEST\x10\x01\x12\x1a\n" + + "\x16ERROR_CODE_PEEK_FAILED\x10\x02\x12$\n" + + " ERROR_CODE_PEEK_RETURNED_NO_DATA\x10\x03\x12\x1a\n" + + "\x16ERROR_CODE_POKE_FAILED\x10\x04\x12\x1c\n" + + "\x18ERROR_CODE_NACKAPP_ERROR\x10\x05\x12\x16\n" + + "\x12ERROR_CODE_TIMEOUT\x10\x06\x12\x1d\n" + + "\x19ERROR_CODE_INTERNAL_ERROR\x10\a\x12\x18\n" + + "\x14ERROR_CODE_NOT_FOUND\x10\b\x12 \n" + + "\x1cERROR_CODE_PERMISSION_DENIED\x10\t\x12\x1b\n" + + "\x17ERROR_CODE_INVALID_WIRE\x10\n" + + "\x12\x1b\n" + + "\x17ERROR_CODE_KERNEL_ERROR\x10\v2\xae\x01\n" + + "\x0eNockAppService\x12M\n" + + "\x04Peek\x12!.nockchain.private.v1.PeekRequest\x1a\".nockchain.private.v1.PeekResponse\x12M\n" + + "\x04Poke\x12!.nockchain.private.v1.PokeRequest\x1a\".nockchain.private.v1.PokeResponseB\x0eZ\f./;nockchainb\x06proto3" + +var ( + file_nockapp_proto_rawDescOnce sync.Once + file_nockapp_proto_rawDescData []byte +) + +func file_nockapp_proto_rawDescGZIP() []byte { + file_nockapp_proto_rawDescOnce.Do(func() { + file_nockapp_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_nockapp_proto_rawDesc), len(file_nockapp_proto_rawDesc))) + }) + return file_nockapp_proto_rawDescData +} + +var file_nockapp_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_nockapp_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_nockapp_proto_goTypes = []any{ + (AppErrorCode)(0), // 0: nockchain.private.v1.AppErrorCode + (*PeekRequest)(nil), // 1: nockchain.private.v1.PeekRequest + (*PeekResponse)(nil), // 2: nockchain.private.v1.PeekResponse + (*PokeRequest)(nil), // 3: nockchain.private.v1.PokeRequest + (*PokeResponse)(nil), // 4: nockchain.private.v1.PokeResponse + (*AppErrorStatus)(nil), // 5: nockchain.private.v1.AppErrorStatus + (*Wire)(nil), // 6: nockchain.private.v1.Wire + (*WireTag)(nil), // 7: nockchain.private.v1.WireTag +} +var file_nockapp_proto_depIdxs = []int32{ + 5, // 0: nockchain.private.v1.PeekResponse.error:type_name -> nockchain.private.v1.AppErrorStatus + 6, // 1: nockchain.private.v1.PokeRequest.wire:type_name -> nockchain.private.v1.Wire + 5, // 2: nockchain.private.v1.PokeResponse.error:type_name -> nockchain.private.v1.AppErrorStatus + 0, // 3: nockchain.private.v1.AppErrorStatus.code:type_name -> nockchain.private.v1.AppErrorCode + 7, // 4: nockchain.private.v1.Wire.tags:type_name -> nockchain.private.v1.WireTag + 1, // 5: nockchain.private.v1.NockAppService.Peek:input_type -> nockchain.private.v1.PeekRequest + 3, // 6: nockchain.private.v1.NockAppService.Poke:input_type -> nockchain.private.v1.PokeRequest + 2, // 7: nockchain.private.v1.NockAppService.Peek:output_type -> nockchain.private.v1.PeekResponse + 4, // 8: nockchain.private.v1.NockAppService.Poke:output_type -> nockchain.private.v1.PokeResponse + 7, // [7:9] is the sub-list for method output_type + 5, // [5:7] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_nockapp_proto_init() } +func file_nockapp_proto_init() { + if File_nockapp_proto != nil { + return + } + file_nockapp_proto_msgTypes[1].OneofWrappers = []any{ + (*PeekResponse_Data)(nil), + (*PeekResponse_Error)(nil), + } + file_nockapp_proto_msgTypes[3].OneofWrappers = []any{ + (*PokeResponse_Acknowledged)(nil), + (*PokeResponse_Error)(nil), + } + file_nockapp_proto_msgTypes[4].OneofWrappers = []any{} + file_nockapp_proto_msgTypes[6].OneofWrappers = []any{ + (*WireTag_Text)(nil), + (*WireTag_Number)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_nockapp_proto_rawDesc), len(file_nockapp_proto_rawDesc)), + NumEnums: 1, + NumMessages: 7, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_nockapp_proto_goTypes, + DependencyIndexes: file_nockapp_proto_depIdxs, + EnumInfos: file_nockapp_proto_enumTypes, + MessageInfos: file_nockapp_proto_msgTypes, + }.Build() + File_nockapp_proto = out.File + file_nockapp_proto_goTypes = nil + file_nockapp_proto_depIdxs = nil +} diff --git a/nockchain/nockapp_grpc.pb.go b/nockchain/nockapp_grpc.pb.go new file mode 100644 index 0000000..0e7f769 --- /dev/null +++ b/nockchain/nockapp_grpc.pb.go @@ -0,0 +1,161 @@ +// nockchain/private/v1/nockapp.proto + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v3.20.3 +// source: nockapp.proto + +package nockchain + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + NockAppService_Peek_FullMethodName = "/nockchain.private.v1.NockAppService/Peek" + NockAppService_Poke_FullMethodName = "/nockchain.private.v1.NockAppService/Poke" +) + +// NockAppServiceClient is the client API for NockAppService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type NockAppServiceClient interface { + Peek(ctx context.Context, in *PeekRequest, opts ...grpc.CallOption) (*PeekResponse, error) + Poke(ctx context.Context, in *PokeRequest, opts ...grpc.CallOption) (*PokeResponse, error) +} + +type nockAppServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewNockAppServiceClient(cc grpc.ClientConnInterface) NockAppServiceClient { + return &nockAppServiceClient{cc} +} + +func (c *nockAppServiceClient) Peek(ctx context.Context, in *PeekRequest, opts ...grpc.CallOption) (*PeekResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(PeekResponse) + err := c.cc.Invoke(ctx, NockAppService_Peek_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *nockAppServiceClient) Poke(ctx context.Context, in *PokeRequest, opts ...grpc.CallOption) (*PokeResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(PokeResponse) + err := c.cc.Invoke(ctx, NockAppService_Poke_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// NockAppServiceServer is the server API for NockAppService service. +// All implementations must embed UnimplementedNockAppServiceServer +// for forward compatibility. +type NockAppServiceServer interface { + Peek(context.Context, *PeekRequest) (*PeekResponse, error) + Poke(context.Context, *PokeRequest) (*PokeResponse, error) + mustEmbedUnimplementedNockAppServiceServer() +} + +// UnimplementedNockAppServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedNockAppServiceServer struct{} + +func (UnimplementedNockAppServiceServer) Peek(context.Context, *PeekRequest) (*PeekResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Peek not implemented") +} +func (UnimplementedNockAppServiceServer) Poke(context.Context, *PokeRequest) (*PokeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Poke not implemented") +} +func (UnimplementedNockAppServiceServer) mustEmbedUnimplementedNockAppServiceServer() {} +func (UnimplementedNockAppServiceServer) testEmbeddedByValue() {} + +// UnsafeNockAppServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to NockAppServiceServer will +// result in compilation errors. +type UnsafeNockAppServiceServer interface { + mustEmbedUnimplementedNockAppServiceServer() +} + +func RegisterNockAppServiceServer(s grpc.ServiceRegistrar, srv NockAppServiceServer) { + // If the following call pancis, it indicates UnimplementedNockAppServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&NockAppService_ServiceDesc, srv) +} + +func _NockAppService_Peek_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PeekRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NockAppServiceServer).Peek(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NockAppService_Peek_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NockAppServiceServer).Peek(ctx, req.(*PeekRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NockAppService_Poke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PokeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NockAppServiceServer).Poke(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NockAppService_Poke_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NockAppServiceServer).Poke(ctx, req.(*PokeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// NockAppService_ServiceDesc is the grpc.ServiceDesc for NockAppService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var NockAppService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "nockchain.private.v1.NockAppService", + HandlerType: (*NockAppServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Peek", + Handler: _NockAppService_Peek_Handler, + }, + { + MethodName: "Poke", + Handler: _NockAppService_Poke_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "nockapp.proto", +} diff --git a/nockchain/primitives.pb.go b/nockchain/primitives.pb.go index 4b9fd9c..9b2c5da 100644 --- a/nockchain/primitives.pb.go +++ b/nockchain/primitives.pb.go @@ -195,148 +195,6 @@ func (*Acknowledged) Descriptor() ([]byte, []int) { return file_primitives_proto_rawDescGZIP(), []int{1} } -type Wire struct { - state protoimpl.MessageState `protogen:"open.v1"` - Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"` // e.g., "http", "file", "wallet", "grpc" - Version uint64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` // wire format version - Tags []*WireTag `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty"` // operation-specific tags - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Wire) Reset() { - *x = Wire{} - mi := &file_primitives_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Wire) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Wire) ProtoMessage() {} - -func (x *Wire) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Wire.ProtoReflect.Descriptor instead. -func (*Wire) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{2} -} - -func (x *Wire) GetSource() string { - if x != nil { - return x.Source - } - return "" -} - -func (x *Wire) GetVersion() uint64 { - if x != nil { - return x.Version - } - return 0 -} - -func (x *Wire) GetTags() []*WireTag { - if x != nil { - return x.Tags - } - return nil -} - -type WireTag struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Value: - // - // *WireTag_Text - // *WireTag_Number - Value isWireTag_Value `protobuf_oneof:"value"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *WireTag) Reset() { - *x = WireTag{} - mi := &file_primitives_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *WireTag) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WireTag) ProtoMessage() {} - -func (x *WireTag) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use WireTag.ProtoReflect.Descriptor instead. -func (*WireTag) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{3} -} - -func (x *WireTag) GetValue() isWireTag_Value { - if x != nil { - return x.Value - } - return nil -} - -func (x *WireTag) GetText() string { - if x != nil { - if x, ok := x.Value.(*WireTag_Text); ok { - return x.Text - } - } - return "" -} - -func (x *WireTag) GetNumber() uint64 { - if x != nil { - if x, ok := x.Value.(*WireTag_Number); ok { - return x.Number - } - } - return 0 -} - -type isWireTag_Value interface { - isWireTag_Value() -} - -type WireTag_Text struct { - Text string `protobuf:"bytes,1,opt,name=text,proto3,oneof"` -} - -type WireTag_Number struct { - Number uint64 `protobuf:"varint,2,opt,name=number,proto3,oneof"` -} - -func (*WireTag_Text) isWireTag_Value() {} - -func (*WireTag_Number) isWireTag_Value() {} - // Note: prefer using raw numeric fields in messages // instead of these wrappers to simplify conversions. // These remain defined for potential future use. @@ -349,7 +207,7 @@ type NoteVersion struct { func (x *NoteVersion) Reset() { *x = NoteVersion{} - mi := &file_primitives_proto_msgTypes[4] + mi := &file_primitives_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -361,7 +219,7 @@ func (x *NoteVersion) String() string { func (*NoteVersion) ProtoMessage() {} func (x *NoteVersion) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[4] + mi := &file_primitives_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -374,7 +232,7 @@ func (x *NoteVersion) ProtoReflect() protoreflect.Message { // Deprecated: Use NoteVersion.ProtoReflect.Descriptor instead. func (*NoteVersion) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{4} + return file_primitives_proto_rawDescGZIP(), []int{2} } func (x *NoteVersion) GetValue() uint32 { @@ -393,7 +251,7 @@ type BlockHeight struct { func (x *BlockHeight) Reset() { *x = BlockHeight{} - mi := &file_primitives_proto_msgTypes[5] + mi := &file_primitives_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -405,7 +263,7 @@ func (x *BlockHeight) String() string { func (*BlockHeight) ProtoMessage() {} func (x *BlockHeight) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[5] + mi := &file_primitives_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -418,7 +276,7 @@ func (x *BlockHeight) ProtoReflect() protoreflect.Message { // Deprecated: Use BlockHeight.ProtoReflect.Descriptor instead. func (*BlockHeight) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{5} + return file_primitives_proto_rawDescGZIP(), []int{3} } func (x *BlockHeight) GetValue() uint64 { @@ -437,7 +295,7 @@ type BlockHeightDelta struct { func (x *BlockHeightDelta) Reset() { *x = BlockHeightDelta{} - mi := &file_primitives_proto_msgTypes[6] + mi := &file_primitives_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -449,7 +307,7 @@ func (x *BlockHeightDelta) String() string { func (*BlockHeightDelta) ProtoMessage() {} func (x *BlockHeightDelta) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[6] + mi := &file_primitives_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -462,7 +320,7 @@ func (x *BlockHeightDelta) ProtoReflect() protoreflect.Message { // Deprecated: Use BlockHeightDelta.ProtoReflect.Descriptor instead. func (*BlockHeightDelta) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{6} + return file_primitives_proto_rawDescGZIP(), []int{4} } func (x *BlockHeightDelta) GetValue() uint64 { @@ -481,7 +339,7 @@ type Nicks struct { func (x *Nicks) Reset() { *x = Nicks{} - mi := &file_primitives_proto_msgTypes[7] + mi := &file_primitives_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -493,7 +351,7 @@ func (x *Nicks) String() string { func (*Nicks) ProtoMessage() {} func (x *Nicks) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[7] + mi := &file_primitives_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -506,7 +364,7 @@ func (x *Nicks) ProtoReflect() protoreflect.Message { // Deprecated: Use Nicks.ProtoReflect.Descriptor instead. func (*Nicks) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{7} + return file_primitives_proto_rawDescGZIP(), []int{5} } func (x *Nicks) GetValue() uint64 { @@ -534,7 +392,7 @@ type EightBelt struct { func (x *EightBelt) Reset() { *x = EightBelt{} - mi := &file_primitives_proto_msgTypes[8] + mi := &file_primitives_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -546,7 +404,7 @@ func (x *EightBelt) String() string { func (*EightBelt) ProtoMessage() {} func (x *EightBelt) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[8] + mi := &file_primitives_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -559,7 +417,7 @@ func (x *EightBelt) ProtoReflect() protoreflect.Message { // Deprecated: Use EightBelt.ProtoReflect.Descriptor instead. func (*EightBelt) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{8} + return file_primitives_proto_rawDescGZIP(), []int{6} } func (x *EightBelt) GetBelt_1() *Belt { @@ -633,7 +491,7 @@ type Hash struct { func (x *Hash) Reset() { *x = Hash{} - mi := &file_primitives_proto_msgTypes[9] + mi := &file_primitives_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -645,7 +503,7 @@ func (x *Hash) String() string { func (*Hash) ProtoMessage() {} func (x *Hash) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[9] + mi := &file_primitives_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -658,7 +516,7 @@ func (x *Hash) ProtoReflect() protoreflect.Message { // Deprecated: Use Hash.ProtoReflect.Descriptor instead. func (*Hash) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{9} + return file_primitives_proto_rawDescGZIP(), []int{7} } func (x *Hash) GetBelt_1() *Belt { @@ -705,7 +563,7 @@ type Base58Hash struct { func (x *Base58Hash) Reset() { *x = Base58Hash{} - mi := &file_primitives_proto_msgTypes[10] + mi := &file_primitives_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -717,7 +575,7 @@ func (x *Base58Hash) String() string { func (*Base58Hash) ProtoMessage() {} func (x *Base58Hash) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[10] + mi := &file_primitives_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -730,7 +588,7 @@ func (x *Base58Hash) ProtoReflect() protoreflect.Message { // Deprecated: Use Base58Hash.ProtoReflect.Descriptor instead. func (*Base58Hash) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{10} + return file_primitives_proto_rawDescGZIP(), []int{8} } func (x *Base58Hash) GetHash() string { @@ -750,7 +608,7 @@ type SchnorrPubkey struct { func (x *SchnorrPubkey) Reset() { *x = SchnorrPubkey{} - mi := &file_primitives_proto_msgTypes[11] + mi := &file_primitives_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -762,7 +620,7 @@ func (x *SchnorrPubkey) String() string { func (*SchnorrPubkey) ProtoMessage() {} func (x *SchnorrPubkey) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[11] + mi := &file_primitives_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -775,7 +633,7 @@ func (x *SchnorrPubkey) ProtoReflect() protoreflect.Message { // Deprecated: Use SchnorrPubkey.ProtoReflect.Descriptor instead. func (*SchnorrPubkey) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{11} + return file_primitives_proto_rawDescGZIP(), []int{9} } func (x *SchnorrPubkey) GetValue() *CheetahPoint { @@ -801,7 +659,7 @@ type CheetahPoint struct { func (x *CheetahPoint) Reset() { *x = CheetahPoint{} - mi := &file_primitives_proto_msgTypes[12] + mi := &file_primitives_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -813,7 +671,7 @@ func (x *CheetahPoint) String() string { func (*CheetahPoint) ProtoMessage() {} func (x *CheetahPoint) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[12] + mi := &file_primitives_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -826,7 +684,7 @@ func (x *CheetahPoint) ProtoReflect() protoreflect.Message { // Deprecated: Use CheetahPoint.ProtoReflect.Descriptor instead. func (*CheetahPoint) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{12} + return file_primitives_proto_rawDescGZIP(), []int{10} } func (x *CheetahPoint) GetX() *SixBelt { @@ -865,7 +723,7 @@ type SixBelt struct { func (x *SixBelt) Reset() { *x = SixBelt{} - mi := &file_primitives_proto_msgTypes[13] + mi := &file_primitives_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -877,7 +735,7 @@ func (x *SixBelt) String() string { func (*SixBelt) ProtoMessage() {} func (x *SixBelt) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[13] + mi := &file_primitives_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -890,7 +748,7 @@ func (x *SixBelt) ProtoReflect() protoreflect.Message { // Deprecated: Use SixBelt.ProtoReflect.Descriptor instead. func (*SixBelt) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{13} + return file_primitives_proto_rawDescGZIP(), []int{11} } func (x *SixBelt) GetBelt_1() *Belt { @@ -945,7 +803,7 @@ type Belt struct { func (x *Belt) Reset() { *x = Belt{} - mi := &file_primitives_proto_msgTypes[14] + mi := &file_primitives_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -957,7 +815,7 @@ func (x *Belt) String() string { func (*Belt) ProtoMessage() {} func (x *Belt) ProtoReflect() protoreflect.Message { - mi := &file_primitives_proto_msgTypes[14] + mi := &file_primitives_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -970,7 +828,7 @@ func (x *Belt) ProtoReflect() protoreflect.Message { // Deprecated: Use Belt.ProtoReflect.Descriptor instead. func (*Belt) Descriptor() ([]byte, []int) { - return file_primitives_proto_rawDescGZIP(), []int{14} + return file_primitives_proto_rawDescGZIP(), []int{12} } func (x *Belt) GetValue() uint64 { @@ -991,15 +849,7 @@ const file_primitives_proto_rawDesc = "" + "\adetails\x18\x03 \x01(\tH\x00R\adetails\x88\x01\x01B\n" + "\n" + "\b_details\"\x0e\n" + - "\fAcknowledged\"j\n" + - "\x04Wire\x12\x16\n" + - "\x06source\x18\x01 \x01(\tR\x06source\x12\x18\n" + - "\aversion\x18\x02 \x01(\x04R\aversion\x120\n" + - "\x04tags\x18\x03 \x03(\v2\x1c.nockchain.public.v1.WireTagR\x04tags\"B\n" + - "\aWireTag\x12\x14\n" + - "\x04text\x18\x01 \x01(\tH\x00R\x04text\x12\x18\n" + - "\x06number\x18\x02 \x01(\x04H\x00R\x06numberB\a\n" + - "\x05value\"#\n" + + "\fAcknowledged\"#\n" + "\vNoteVersion\x12\x14\n" + "\x05value\x18\x01 \x01(\rR\x05value\"#\n" + "\vBlockHeight\x12\x14\n" + @@ -1069,55 +919,52 @@ func file_primitives_proto_rawDescGZIP() []byte { } var file_primitives_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_primitives_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_primitives_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_primitives_proto_goTypes = []any{ (ErrorCode)(0), // 0: nockchain.public.v1.ErrorCode (*ErrorStatus)(nil), // 1: nockchain.public.v1.ErrorStatus (*Acknowledged)(nil), // 2: nockchain.public.v1.Acknowledged - (*Wire)(nil), // 3: nockchain.public.v1.Wire - (*WireTag)(nil), // 4: nockchain.public.v1.WireTag - (*NoteVersion)(nil), // 5: nockchain.public.v1.NoteVersion - (*BlockHeight)(nil), // 6: nockchain.public.v1.BlockHeight - (*BlockHeightDelta)(nil), // 7: nockchain.public.v1.BlockHeightDelta - (*Nicks)(nil), // 8: nockchain.public.v1.Nicks - (*EightBelt)(nil), // 9: nockchain.public.v1.EightBelt - (*Hash)(nil), // 10: nockchain.public.v1.Hash - (*Base58Hash)(nil), // 11: nockchain.public.v1.Base58Hash - (*SchnorrPubkey)(nil), // 12: nockchain.public.v1.SchnorrPubkey - (*CheetahPoint)(nil), // 13: nockchain.public.v1.CheetahPoint - (*SixBelt)(nil), // 14: nockchain.public.v1.SixBelt - (*Belt)(nil), // 15: nockchain.public.v1.Belt + (*NoteVersion)(nil), // 3: nockchain.public.v1.NoteVersion + (*BlockHeight)(nil), // 4: nockchain.public.v1.BlockHeight + (*BlockHeightDelta)(nil), // 5: nockchain.public.v1.BlockHeightDelta + (*Nicks)(nil), // 6: nockchain.public.v1.Nicks + (*EightBelt)(nil), // 7: nockchain.public.v1.EightBelt + (*Hash)(nil), // 8: nockchain.public.v1.Hash + (*Base58Hash)(nil), // 9: nockchain.public.v1.Base58Hash + (*SchnorrPubkey)(nil), // 10: nockchain.public.v1.SchnorrPubkey + (*CheetahPoint)(nil), // 11: nockchain.public.v1.CheetahPoint + (*SixBelt)(nil), // 12: nockchain.public.v1.SixBelt + (*Belt)(nil), // 13: nockchain.public.v1.Belt } var file_primitives_proto_depIdxs = []int32{ 0, // 0: nockchain.public.v1.ErrorStatus.code:type_name -> nockchain.public.v1.ErrorCode - 4, // 1: nockchain.public.v1.Wire.tags:type_name -> nockchain.public.v1.WireTag - 15, // 2: nockchain.public.v1.EightBelt.belt_1:type_name -> nockchain.public.v1.Belt - 15, // 3: nockchain.public.v1.EightBelt.belt_2:type_name -> nockchain.public.v1.Belt - 15, // 4: nockchain.public.v1.EightBelt.belt_3:type_name -> nockchain.public.v1.Belt - 15, // 5: nockchain.public.v1.EightBelt.belt_4:type_name -> nockchain.public.v1.Belt - 15, // 6: nockchain.public.v1.EightBelt.belt_5:type_name -> nockchain.public.v1.Belt - 15, // 7: nockchain.public.v1.EightBelt.belt_6:type_name -> nockchain.public.v1.Belt - 15, // 8: nockchain.public.v1.EightBelt.belt_7:type_name -> nockchain.public.v1.Belt - 15, // 9: nockchain.public.v1.EightBelt.belt_8:type_name -> nockchain.public.v1.Belt - 15, // 10: nockchain.public.v1.Hash.belt_1:type_name -> nockchain.public.v1.Belt - 15, // 11: nockchain.public.v1.Hash.belt_2:type_name -> nockchain.public.v1.Belt - 15, // 12: nockchain.public.v1.Hash.belt_3:type_name -> nockchain.public.v1.Belt - 15, // 13: nockchain.public.v1.Hash.belt_4:type_name -> nockchain.public.v1.Belt - 15, // 14: nockchain.public.v1.Hash.belt_5:type_name -> nockchain.public.v1.Belt - 13, // 15: nockchain.public.v1.SchnorrPubkey.value:type_name -> nockchain.public.v1.CheetahPoint - 14, // 16: nockchain.public.v1.CheetahPoint.x:type_name -> nockchain.public.v1.SixBelt - 14, // 17: nockchain.public.v1.CheetahPoint.y:type_name -> nockchain.public.v1.SixBelt - 15, // 18: nockchain.public.v1.SixBelt.belt_1:type_name -> nockchain.public.v1.Belt - 15, // 19: nockchain.public.v1.SixBelt.belt_2:type_name -> nockchain.public.v1.Belt - 15, // 20: nockchain.public.v1.SixBelt.belt_3:type_name -> nockchain.public.v1.Belt - 15, // 21: nockchain.public.v1.SixBelt.belt_4:type_name -> nockchain.public.v1.Belt - 15, // 22: nockchain.public.v1.SixBelt.belt_5:type_name -> nockchain.public.v1.Belt - 15, // 23: nockchain.public.v1.SixBelt.belt_6:type_name -> nockchain.public.v1.Belt - 24, // [24:24] is the sub-list for method output_type - 24, // [24:24] is the sub-list for method input_type - 24, // [24:24] is the sub-list for extension type_name - 24, // [24:24] is the sub-list for extension extendee - 0, // [0:24] is the sub-list for field type_name + 13, // 1: nockchain.public.v1.EightBelt.belt_1:type_name -> nockchain.public.v1.Belt + 13, // 2: nockchain.public.v1.EightBelt.belt_2:type_name -> nockchain.public.v1.Belt + 13, // 3: nockchain.public.v1.EightBelt.belt_3:type_name -> nockchain.public.v1.Belt + 13, // 4: nockchain.public.v1.EightBelt.belt_4:type_name -> nockchain.public.v1.Belt + 13, // 5: nockchain.public.v1.EightBelt.belt_5:type_name -> nockchain.public.v1.Belt + 13, // 6: nockchain.public.v1.EightBelt.belt_6:type_name -> nockchain.public.v1.Belt + 13, // 7: nockchain.public.v1.EightBelt.belt_7:type_name -> nockchain.public.v1.Belt + 13, // 8: nockchain.public.v1.EightBelt.belt_8:type_name -> nockchain.public.v1.Belt + 13, // 9: nockchain.public.v1.Hash.belt_1:type_name -> nockchain.public.v1.Belt + 13, // 10: nockchain.public.v1.Hash.belt_2:type_name -> nockchain.public.v1.Belt + 13, // 11: nockchain.public.v1.Hash.belt_3:type_name -> nockchain.public.v1.Belt + 13, // 12: nockchain.public.v1.Hash.belt_4:type_name -> nockchain.public.v1.Belt + 13, // 13: nockchain.public.v1.Hash.belt_5:type_name -> nockchain.public.v1.Belt + 11, // 14: nockchain.public.v1.SchnorrPubkey.value:type_name -> nockchain.public.v1.CheetahPoint + 12, // 15: nockchain.public.v1.CheetahPoint.x:type_name -> nockchain.public.v1.SixBelt + 12, // 16: nockchain.public.v1.CheetahPoint.y:type_name -> nockchain.public.v1.SixBelt + 13, // 17: nockchain.public.v1.SixBelt.belt_1:type_name -> nockchain.public.v1.Belt + 13, // 18: nockchain.public.v1.SixBelt.belt_2:type_name -> nockchain.public.v1.Belt + 13, // 19: nockchain.public.v1.SixBelt.belt_3:type_name -> nockchain.public.v1.Belt + 13, // 20: nockchain.public.v1.SixBelt.belt_4:type_name -> nockchain.public.v1.Belt + 13, // 21: nockchain.public.v1.SixBelt.belt_5:type_name -> nockchain.public.v1.Belt + 13, // 22: nockchain.public.v1.SixBelt.belt_6:type_name -> nockchain.public.v1.Belt + 23, // [23:23] is the sub-list for method output_type + 23, // [23:23] is the sub-list for method input_type + 23, // [23:23] is the sub-list for extension type_name + 23, // [23:23] is the sub-list for extension extendee + 0, // [0:23] is the sub-list for field type_name } func init() { file_primitives_proto_init() } @@ -1126,17 +973,13 @@ func file_primitives_proto_init() { return } file_primitives_proto_msgTypes[0].OneofWrappers = []any{} - file_primitives_proto_msgTypes[3].OneofWrappers = []any{ - (*WireTag_Text)(nil), - (*WireTag_Number)(nil), - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_primitives_proto_rawDesc), len(file_primitives_proto_rawDesc)), NumEnums: 1, - NumMessages: 15, + NumMessages: 13, NumExtensions: 0, NumServices: 0, }, diff --git a/nockchain/service.pb.go b/nockchain/service.pb.go index 6f6ef70..040a2bd 100644 --- a/nockchain/service.pb.go +++ b/nockchain/service.pb.go @@ -23,6 +23,7 @@ const ( type KeygenRequest struct { state protoimpl.MessageState `protogen:"open.v1"` + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -57,14 +58,22 @@ func (*KeygenRequest) Descriptor() ([]byte, []int) { return file_service_proto_rawDescGZIP(), []int{0} } +func (x *KeygenRequest) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + type KeygenResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` Seed string `protobuf:"bytes,3,opt,name=seed,proto3" json:"seed,omitempty"` ChainCode string `protobuf:"bytes,4,opt,name=chain_code,json=chainCode,proto3" json:"chain_code,omitempty"` ImportPrivateKey string `protobuf:"bytes,5,opt,name=import_private_key,json=importPrivateKey,proto3" json:"import_private_key,omitempty"` ImportPublicKey string `protobuf:"bytes,6,opt,name=import_public_key,json=importPublicKey,proto3" json:"import_public_key,omitempty"` + Version uint64 `protobuf:"varint,7,opt,name=version,proto3" json:"version,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -99,9 +108,9 @@ func (*KeygenResponse) Descriptor() ([]byte, []int) { return file_service_proto_rawDescGZIP(), []int{1} } -func (x *KeygenResponse) GetPublicKey() string { +func (x *KeygenResponse) GetAddress() string { if x != nil { - return x.PublicKey + return x.Address } return "" } @@ -141,10 +150,18 @@ func (x *KeygenResponse) GetImportPublicKey() string { return "" } +func (x *KeygenResponse) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + type ImportKeysRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - ImportType ImportType `protobuf:"varint,2,opt,name=import_type,json=importType,proto3,enum=nockchain.public.v1.ImportType" json:"import_type,omitempty"` + Version uint64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` + ImportType ImportType `protobuf:"varint,3,opt,name=import_type,json=importType,proto3,enum=nockchain.public.v1.ImportType" json:"import_type,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -186,6 +203,13 @@ func (x *ImportKeysRequest) GetKey() string { return "" } +func (x *ImportKeysRequest) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + func (x *ImportKeysRequest) GetImportType() ImportType { if x != nil { return x.ImportType @@ -195,12 +219,13 @@ func (x *ImportKeysRequest) GetImportType() ImportType { type ImportKeysResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` Seed string `protobuf:"bytes,3,opt,name=seed,proto3" json:"seed,omitempty"` ChainCode string `protobuf:"bytes,4,opt,name=chain_code,json=chainCode,proto3" json:"chain_code,omitempty"` ImportPrivateKey string `protobuf:"bytes,5,opt,name=import_private_key,json=importPrivateKey,proto3" json:"import_private_key,omitempty"` ImportPublicKey string `protobuf:"bytes,6,opt,name=import_public_key,json=importPublicKey,proto3" json:"import_public_key,omitempty"` + Version uint64 `protobuf:"varint,7,opt,name=version,proto3" json:"version,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -235,9 +260,9 @@ func (*ImportKeysResponse) Descriptor() ([]byte, []int) { return file_service_proto_rawDescGZIP(), []int{3} } -func (x *ImportKeysResponse) GetPublicKey() string { +func (x *ImportKeysResponse) GetAddress() string { if x != nil { - return x.PublicKey + return x.Address } return "" } @@ -277,11 +302,19 @@ func (x *ImportKeysResponse) GetImportPublicKey() string { return "" } +func (x *ImportKeysResponse) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + type DeriveChildRequest struct { state protoimpl.MessageState `protogen:"open.v1"` ImportedKey string `protobuf:"bytes,1,opt,name=imported_key,json=importedKey,proto3" json:"imported_key,omitempty"` Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` Hardened bool `protobuf:"varint,3,opt,name=hardened,proto3" json:"hardened,omitempty"` + Version uint64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -337,11 +370,19 @@ func (x *DeriveChildRequest) GetHardened() bool { return false } +func (x *DeriveChildRequest) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + type DeriveChildResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` ChainCode string `protobuf:"bytes,3,opt,name=chain_code,json=chainCode,proto3" json:"chain_code,omitempty"` + Version uint64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -376,9 +417,9 @@ func (*DeriveChildResponse) Descriptor() ([]byte, []int) { return file_service_proto_rawDescGZIP(), []int{5} } -func (x *DeriveChildResponse) GetPublicKey() string { +func (x *DeriveChildResponse) GetAddress() string { if x != nil { - return x.PublicKey + return x.Address } return "" } @@ -397,6 +438,13 @@ func (x *DeriveChildResponse) GetChainCode() string { return "" } +func (x *DeriveChildResponse) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + type CreateTxRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Names string `protobuf:"bytes,1,opt,name=names,proto3" json:"names,omitempty"` @@ -408,7 +456,8 @@ type CreateTxRequest struct { ChainCode string `protobuf:"bytes,7,opt,name=chain_code,json=chainCode,proto3" json:"chain_code,omitempty"` Index uint64 `protobuf:"varint,8,opt,name=index,proto3" json:"index,omitempty"` Hardened bool `protobuf:"varint,9,opt,name=hardened,proto3" json:"hardened,omitempty"` - TimelockIntent *TimelockIntent `protobuf:"bytes,10,opt,name=timelock_intent,json=timelockIntent,proto3" json:"timelock_intent,omitempty"` + Version uint64 `protobuf:"varint,10,opt,name=version,proto3" json:"version,omitempty"` + TimelockIntent *TimelockIntent `protobuf:"bytes,11,opt,name=timelock_intent,json=timelockIntent,proto3" json:"timelock_intent,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -506,6 +555,13 @@ func (x *CreateTxRequest) GetHardened() bool { return false } +func (x *CreateTxRequest) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + func (x *CreateTxRequest) GetTimelockIntent() *TimelockIntent { if x != nil { return x.TimelockIntent @@ -557,118 +613,6 @@ func (x *CreateTxResponse) GetRawTx() *RawTx { return nil } -type SignTxRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - UnsignedTx string `protobuf:"bytes,1,opt,name=unsigned_tx,json=unsignedTx,proto3" json:"unsigned_tx,omitempty"` - Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` - Hardened bool `protobuf:"varint,3,opt,name=hardened,proto3" json:"hardened,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SignTxRequest) Reset() { - *x = SignTxRequest{} - mi := &file_service_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SignTxRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SignTxRequest) ProtoMessage() {} - -func (x *SignTxRequest) ProtoReflect() protoreflect.Message { - mi := &file_service_proto_msgTypes[8] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SignTxRequest.ProtoReflect.Descriptor instead. -func (*SignTxRequest) Descriptor() ([]byte, []int) { - return file_service_proto_rawDescGZIP(), []int{8} -} - -func (x *SignTxRequest) GetUnsignedTx() string { - if x != nil { - return x.UnsignedTx - } - return "" -} - -func (x *SignTxRequest) GetIndex() uint64 { - if x != nil { - return x.Index - } - return 0 -} - -func (x *SignTxRequest) GetHardened() bool { - if x != nil { - return x.Hardened - } - return false -} - -type SignTxResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - SignedTx string `protobuf:"bytes,1,opt,name=signed_tx,json=signedTx,proto3" json:"signed_tx,omitempty"` - Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SignTxResponse) Reset() { - *x = SignTxResponse{} - mi := &file_service_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SignTxResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SignTxResponse) ProtoMessage() {} - -func (x *SignTxResponse) ProtoReflect() protoreflect.Message { - mi := &file_service_proto_msgTypes[9] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SignTxResponse.ProtoReflect.Descriptor instead. -func (*SignTxResponse) Descriptor() ([]byte, []int) { - return file_service_proto_rawDescGZIP(), []int{9} -} - -func (x *SignTxResponse) GetSignedTx() string { - if x != nil { - return x.SignedTx - } - return "" -} - -func (x *SignTxResponse) GetError() string { - if x != nil { - return x.Error - } - return "" -} - type ScanRequest struct { state protoimpl.MessageState `protogen:"open.v1"` MasterPubkey string `protobuf:"bytes,1,opt,name=master_pubkey,json=masterPubkey,proto3" json:"master_pubkey,omitempty"` @@ -682,7 +626,7 @@ type ScanRequest struct { func (x *ScanRequest) Reset() { *x = ScanRequest{} - mi := &file_service_proto_msgTypes[10] + mi := &file_service_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -694,7 +638,7 @@ func (x *ScanRequest) String() string { func (*ScanRequest) ProtoMessage() {} func (x *ScanRequest) ProtoReflect() protoreflect.Message { - mi := &file_service_proto_msgTypes[10] + mi := &file_service_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -707,7 +651,7 @@ func (x *ScanRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ScanRequest.ProtoReflect.Descriptor instead. func (*ScanRequest) Descriptor() ([]byte, []int) { - return file_service_proto_rawDescGZIP(), []int{10} + return file_service_proto_rawDescGZIP(), []int{8} } func (x *ScanRequest) GetMasterPubkey() string { @@ -754,7 +698,7 @@ type ScanResponse struct { func (x *ScanResponse) Reset() { *x = ScanResponse{} - mi := &file_service_proto_msgTypes[11] + mi := &file_service_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -766,7 +710,7 @@ func (x *ScanResponse) String() string { func (*ScanResponse) ProtoMessage() {} func (x *ScanResponse) ProtoReflect() protoreflect.Message { - mi := &file_service_proto_msgTypes[11] + mi := &file_service_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -779,7 +723,7 @@ func (x *ScanResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ScanResponse.ProtoReflect.Descriptor instead. func (*ScanResponse) Descriptor() ([]byte, []int) { - return file_service_proto_rawDescGZIP(), []int{11} + return file_service_proto_rawDescGZIP(), []int{9} } func (x *ScanResponse) GetScanData() []*ScanData { @@ -798,7 +742,7 @@ type GetBalanceRequest struct { func (x *GetBalanceRequest) Reset() { *x = GetBalanceRequest{} - mi := &file_service_proto_msgTypes[12] + mi := &file_service_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -810,7 +754,7 @@ func (x *GetBalanceRequest) String() string { func (*GetBalanceRequest) ProtoMessage() {} func (x *GetBalanceRequest) ProtoReflect() protoreflect.Message { - mi := &file_service_proto_msgTypes[12] + mi := &file_service_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -823,7 +767,7 @@ func (x *GetBalanceRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBalanceRequest.ProtoReflect.Descriptor instead. func (*GetBalanceRequest) Descriptor() ([]byte, []int) { - return file_service_proto_rawDescGZIP(), []int{12} + return file_service_proto_rawDescGZIP(), []int{10} } func (x *GetBalanceRequest) GetAddress() string { @@ -842,7 +786,7 @@ type GetBalanceResponse struct { func (x *GetBalanceResponse) Reset() { *x = GetBalanceResponse{} - mi := &file_service_proto_msgTypes[13] + mi := &file_service_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -854,7 +798,7 @@ func (x *GetBalanceResponse) String() string { func (*GetBalanceResponse) ProtoMessage() {} func (x *GetBalanceResponse) ProtoReflect() protoreflect.Message { - mi := &file_service_proto_msgTypes[13] + mi := &file_service_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -867,7 +811,7 @@ func (x *GetBalanceResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBalanceResponse.ProtoReflect.Descriptor instead. func (*GetBalanceResponse) Descriptor() ([]byte, []int) { - return file_service_proto_rawDescGZIP(), []int{13} + return file_service_proto_rawDescGZIP(), []int{11} } func (x *GetBalanceResponse) GetData() *WalletBalanceData { @@ -886,7 +830,7 @@ type SendTransactionRequest struct { func (x *SendTransactionRequest) Reset() { *x = SendTransactionRequest{} - mi := &file_service_proto_msgTypes[14] + mi := &file_service_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -898,7 +842,7 @@ func (x *SendTransactionRequest) String() string { func (*SendTransactionRequest) ProtoMessage() {} func (x *SendTransactionRequest) ProtoReflect() protoreflect.Message { - mi := &file_service_proto_msgTypes[14] + mi := &file_service_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -911,7 +855,7 @@ func (x *SendTransactionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SendTransactionRequest.ProtoReflect.Descriptor instead. func (*SendTransactionRequest) Descriptor() ([]byte, []int) { - return file_service_proto_rawDescGZIP(), []int{14} + return file_service_proto_rawDescGZIP(), []int{12} } func (x *SendTransactionRequest) GetRawTx() *RawTx { @@ -930,7 +874,7 @@ type SendTransactionResponse struct { func (x *SendTransactionResponse) Reset() { *x = SendTransactionResponse{} - mi := &file_service_proto_msgTypes[15] + mi := &file_service_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -942,7 +886,7 @@ func (x *SendTransactionResponse) String() string { func (*SendTransactionResponse) ProtoMessage() {} func (x *SendTransactionResponse) ProtoReflect() protoreflect.Message { - mi := &file_service_proto_msgTypes[15] + mi := &file_service_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -955,7 +899,7 @@ func (x *SendTransactionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SendTransactionResponse.ProtoReflect.Descriptor instead. func (*SendTransactionResponse) Descriptor() ([]byte, []int) { - return file_service_proto_rawDescGZIP(), []int{15} + return file_service_proto_rawDescGZIP(), []int{13} } func (x *SendTransactionResponse) GetResponse() *WalletSendTransactionResponse { @@ -969,43 +913,46 @@ var File_service_proto protoreflect.FileDescriptor const file_service_proto_rawDesc = "" + "\n" + - "\rservice.proto\x12\x13nockchain.public.v1\x1a\vtypes.proto\x1a\x10blockchain.proto\x1a\x0fnockchain.proto\"\x0f\n" + - "\rKeygenRequest\"\xdd\x01\n" + - "\x0eKeygenResponse\x12\x1d\n" + - "\n" + - "public_key\x18\x01 \x01(\tR\tpublicKey\x12\x1f\n" + + "\rservice.proto\x12\x13nockchain.public.v1\x1a\vtypes.proto\x1a\x10blockchain.proto\x1a\x0fnockchain.proto\")\n" + + "\rKeygenRequest\x12\x18\n" + + "\aversion\x18\x01 \x01(\x04R\aversion\"\xf2\x01\n" + + "\x0eKeygenResponse\x12\x18\n" + + "\aaddress\x18\x01 \x01(\tR\aaddress\x12\x1f\n" + "\vprivate_key\x18\x02 \x01(\tR\n" + "privateKey\x12\x12\n" + "\x04seed\x18\x03 \x01(\tR\x04seed\x12\x1d\n" + "\n" + "chain_code\x18\x04 \x01(\tR\tchainCode\x12,\n" + "\x12import_private_key\x18\x05 \x01(\tR\x10importPrivateKey\x12*\n" + - "\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\"g\n" + + "\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\x12\x18\n" + + "\aversion\x18\a \x01(\x04R\aversion\"\x81\x01\n" + "\x11ImportKeysRequest\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12@\n" + - "\vimport_type\x18\x02 \x01(\x0e2\x1f.nockchain.public.v1.ImportTypeR\n" + - "importType\"\xe1\x01\n" + - "\x12ImportKeysResponse\x12\x1d\n" + - "\n" + - "public_key\x18\x01 \x01(\tR\tpublicKey\x12\x1f\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x18\n" + + "\aversion\x18\x02 \x01(\x04R\aversion\x12@\n" + + "\vimport_type\x18\x03 \x01(\x0e2\x1f.nockchain.public.v1.ImportTypeR\n" + + "importType\"\xf6\x01\n" + + "\x12ImportKeysResponse\x12\x18\n" + + "\aaddress\x18\x01 \x01(\tR\aaddress\x12\x1f\n" + "\vprivate_key\x18\x02 \x01(\tR\n" + "privateKey\x12\x12\n" + "\x04seed\x18\x03 \x01(\tR\x04seed\x12\x1d\n" + "\n" + "chain_code\x18\x04 \x01(\tR\tchainCode\x12,\n" + "\x12import_private_key\x18\x05 \x01(\tR\x10importPrivateKey\x12*\n" + - "\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\"i\n" + + "\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\x12\x18\n" + + "\aversion\x18\a \x01(\x04R\aversion\"\x83\x01\n" + "\x12DeriveChildRequest\x12!\n" + "\fimported_key\x18\x01 \x01(\tR\vimportedKey\x12\x14\n" + "\x05index\x18\x02 \x01(\x04R\x05index\x12\x1a\n" + - "\bhardened\x18\x03 \x01(\bR\bhardened\"t\n" + - "\x13DeriveChildResponse\x12\x1d\n" + - "\n" + - "public_key\x18\x01 \x01(\tR\tpublicKey\x12\x1f\n" + + "\bhardened\x18\x03 \x01(\bR\bhardened\x12\x18\n" + + "\aversion\x18\x04 \x01(\x04R\aversion\"\x89\x01\n" + + "\x13DeriveChildResponse\x12\x18\n" + + "\aaddress\x18\x01 \x01(\tR\aaddress\x12\x1f\n" + "\vprivate_key\x18\x02 \x01(\tR\n" + "privateKey\x12\x1d\n" + "\n" + - "chain_code\x18\x03 \x01(\tR\tchainCode\"\xc4\x02\n" + + "chain_code\x18\x03 \x01(\tR\tchainCode\x12\x18\n" + + "\aversion\x18\x04 \x01(\x04R\aversion\"\xde\x02\n" + "\x0fCreateTxRequest\x12\x14\n" + "\x05names\x18\x01 \x01(\tR\x05names\x12\x1e\n" + "\n" + @@ -1018,19 +965,12 @@ const file_service_proto_rawDesc = "" + "\n" + "chain_code\x18\a \x01(\tR\tchainCode\x12\x14\n" + "\x05index\x18\b \x01(\x04R\x05index\x12\x1a\n" + - "\bhardened\x18\t \x01(\bR\bhardened\x12L\n" + - "\x0ftimelock_intent\x18\n" + - " \x01(\v2#.nockchain.public.v1.TimelockIntentR\x0etimelockIntent\"D\n" + + "\bhardened\x18\t \x01(\bR\bhardened\x12\x18\n" + + "\aversion\x18\n" + + " \x01(\x04R\aversion\x12L\n" + + "\x0ftimelock_intent\x18\v \x01(\v2#.nockchain.public.v1.TimelockIntentR\x0etimelockIntent\"D\n" + "\x10CreateTxResponse\x120\n" + - "\x05rawTx\x18\x01 \x01(\v2\x1a.nockchain.public.v1.RawTxR\x05rawTx\"b\n" + - "\rSignTxRequest\x12\x1f\n" + - "\vunsigned_tx\x18\x01 \x01(\tR\n" + - "unsignedTx\x12\x14\n" + - "\x05index\x18\x02 \x01(\x04R\x05index\x12\x1a\n" + - "\bhardened\x18\x03 \x01(\bR\bhardened\"C\n" + - "\x0eSignTxResponse\x12\x1b\n" + - "\tsigned_tx\x18\x01 \x01(\tR\bsignedTx\x12\x14\n" + - "\x05error\x18\x02 \x01(\tR\x05error\"\xcc\x01\n" + + "\x05rawTx\x18\x01 \x01(\v2\x1a.nockchain.public.v1.RawTxR\x05rawTx\"\xcc\x01\n" + "\vScanRequest\x12#\n" + "\rmaster_pubkey\x18\x01 \x01(\tR\fmasterPubkey\x12\x1d\n" + "\n" + @@ -1047,14 +987,13 @@ const file_service_proto_rawDesc = "" + "\x16SendTransactionRequest\x121\n" + "\x06raw_tx\x18\x01 \x01(\v2\x1a.nockchain.public.v1.RawTxR\x05rawTx\"i\n" + "\x17SendTransactionResponse\x12N\n" + - "\bresponse\x18\x01 \x01(\v22.nockchain.public.v1.WalletSendTransactionResponseR\bresponse2\xef\x06\n" + + "\bresponse\x18\x01 \x01(\v22.nockchain.public.v1.WalletSendTransactionResponseR\bresponse2\x9c\x06\n" + "\rWalletService\x12Q\n" + "\x06Keygen\x12\".nockchain.public.v1.KeygenRequest\x1a#.nockchain.public.v1.KeygenResponse\x12]\n" + "\n" + "ImportKeys\x12&.nockchain.public.v1.ImportKeysRequest\x1a'.nockchain.public.v1.ImportKeysResponse\x12`\n" + "\vDeriveChild\x12'.nockchain.public.v1.DeriveChildRequest\x1a(.nockchain.public.v1.DeriveChildResponse\x12W\n" + - "\bCreateTx\x12$.nockchain.public.v1.CreateTxRequest\x1a%.nockchain.public.v1.CreateTxResponse\x12Q\n" + - "\x06SignTx\x12\".nockchain.public.v1.SignTxRequest\x1a#.nockchain.public.v1.SignTxResponse\x12K\n" + + "\bCreateTx\x12$.nockchain.public.v1.CreateTxRequest\x1a%.nockchain.public.v1.CreateTxResponse\x12K\n" + "\x04Scan\x12 .nockchain.public.v1.ScanRequest\x1a!.nockchain.public.v1.ScanResponse\x12c\n" + "\x10WalletGetBalance\x12&.nockchain.public.v1.GetBalanceRequest\x1a'.nockchain.public.v1.GetBalanceResponse\x12r\n" + "\x15WalletSendTransaction\x12+.nockchain.public.v1.SendTransactionRequest\x1a,.nockchain.public.v1.SendTransactionResponse\x12x\n" + @@ -1072,7 +1011,7 @@ func file_service_proto_rawDescGZIP() []byte { return file_service_proto_rawDescData } -var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_service_proto_goTypes = []any{ (*KeygenRequest)(nil), // 0: nockchain.public.v1.KeygenRequest (*KeygenResponse)(nil), // 1: nockchain.public.v1.KeygenResponse @@ -1082,51 +1021,47 @@ var file_service_proto_goTypes = []any{ (*DeriveChildResponse)(nil), // 5: nockchain.public.v1.DeriveChildResponse (*CreateTxRequest)(nil), // 6: nockchain.public.v1.CreateTxRequest (*CreateTxResponse)(nil), // 7: nockchain.public.v1.CreateTxResponse - (*SignTxRequest)(nil), // 8: nockchain.public.v1.SignTxRequest - (*SignTxResponse)(nil), // 9: nockchain.public.v1.SignTxResponse - (*ScanRequest)(nil), // 10: nockchain.public.v1.ScanRequest - (*ScanResponse)(nil), // 11: nockchain.public.v1.ScanResponse - (*GetBalanceRequest)(nil), // 12: nockchain.public.v1.GetBalanceRequest - (*GetBalanceResponse)(nil), // 13: nockchain.public.v1.GetBalanceResponse - (*SendTransactionRequest)(nil), // 14: nockchain.public.v1.SendTransactionRequest - (*SendTransactionResponse)(nil), // 15: nockchain.public.v1.SendTransactionResponse - (ImportType)(0), // 16: nockchain.public.v1.ImportType - (*TimelockIntent)(nil), // 17: nockchain.public.v1.TimelockIntent - (*RawTx)(nil), // 18: nockchain.public.v1.RawTx - (*ScanData)(nil), // 19: nockchain.public.v1.ScanData - (*WalletBalanceData)(nil), // 20: nockchain.public.v1.WalletBalanceData - (*WalletSendTransactionResponse)(nil), // 21: nockchain.public.v1.WalletSendTransactionResponse - (*TransactionAcceptedRequest)(nil), // 22: nockchain.public.v1.TransactionAcceptedRequest - (*TransactionAcceptedResponse)(nil), // 23: nockchain.public.v1.TransactionAcceptedResponse + (*ScanRequest)(nil), // 8: nockchain.public.v1.ScanRequest + (*ScanResponse)(nil), // 9: nockchain.public.v1.ScanResponse + (*GetBalanceRequest)(nil), // 10: nockchain.public.v1.GetBalanceRequest + (*GetBalanceResponse)(nil), // 11: nockchain.public.v1.GetBalanceResponse + (*SendTransactionRequest)(nil), // 12: nockchain.public.v1.SendTransactionRequest + (*SendTransactionResponse)(nil), // 13: nockchain.public.v1.SendTransactionResponse + (ImportType)(0), // 14: nockchain.public.v1.ImportType + (*TimelockIntent)(nil), // 15: nockchain.public.v1.TimelockIntent + (*RawTx)(nil), // 16: nockchain.public.v1.RawTx + (*ScanData)(nil), // 17: nockchain.public.v1.ScanData + (*WalletBalanceData)(nil), // 18: nockchain.public.v1.WalletBalanceData + (*WalletSendTransactionResponse)(nil), // 19: nockchain.public.v1.WalletSendTransactionResponse + (*TransactionAcceptedRequest)(nil), // 20: nockchain.public.v1.TransactionAcceptedRequest + (*TransactionAcceptedResponse)(nil), // 21: nockchain.public.v1.TransactionAcceptedResponse } var file_service_proto_depIdxs = []int32{ - 16, // 0: nockchain.public.v1.ImportKeysRequest.import_type:type_name -> nockchain.public.v1.ImportType - 17, // 1: nockchain.public.v1.CreateTxRequest.timelock_intent:type_name -> nockchain.public.v1.TimelockIntent - 18, // 2: nockchain.public.v1.CreateTxResponse.rawTx:type_name -> nockchain.public.v1.RawTx - 19, // 3: nockchain.public.v1.ScanResponse.scan_data:type_name -> nockchain.public.v1.ScanData - 20, // 4: nockchain.public.v1.GetBalanceResponse.data:type_name -> nockchain.public.v1.WalletBalanceData - 18, // 5: nockchain.public.v1.SendTransactionRequest.raw_tx:type_name -> nockchain.public.v1.RawTx - 21, // 6: nockchain.public.v1.SendTransactionResponse.response:type_name -> nockchain.public.v1.WalletSendTransactionResponse + 14, // 0: nockchain.public.v1.ImportKeysRequest.import_type:type_name -> nockchain.public.v1.ImportType + 15, // 1: nockchain.public.v1.CreateTxRequest.timelock_intent:type_name -> nockchain.public.v1.TimelockIntent + 16, // 2: nockchain.public.v1.CreateTxResponse.rawTx:type_name -> nockchain.public.v1.RawTx + 17, // 3: nockchain.public.v1.ScanResponse.scan_data:type_name -> nockchain.public.v1.ScanData + 18, // 4: nockchain.public.v1.GetBalanceResponse.data:type_name -> nockchain.public.v1.WalletBalanceData + 16, // 5: nockchain.public.v1.SendTransactionRequest.raw_tx:type_name -> nockchain.public.v1.RawTx + 19, // 6: nockchain.public.v1.SendTransactionResponse.response:type_name -> nockchain.public.v1.WalletSendTransactionResponse 0, // 7: nockchain.public.v1.WalletService.Keygen:input_type -> nockchain.public.v1.KeygenRequest 2, // 8: nockchain.public.v1.WalletService.ImportKeys:input_type -> nockchain.public.v1.ImportKeysRequest 4, // 9: nockchain.public.v1.WalletService.DeriveChild:input_type -> nockchain.public.v1.DeriveChildRequest 6, // 10: nockchain.public.v1.WalletService.CreateTx:input_type -> nockchain.public.v1.CreateTxRequest - 8, // 11: nockchain.public.v1.WalletService.SignTx:input_type -> nockchain.public.v1.SignTxRequest - 10, // 12: nockchain.public.v1.WalletService.Scan:input_type -> nockchain.public.v1.ScanRequest - 12, // 13: nockchain.public.v1.WalletService.WalletGetBalance:input_type -> nockchain.public.v1.GetBalanceRequest - 14, // 14: nockchain.public.v1.WalletService.WalletSendTransaction:input_type -> nockchain.public.v1.SendTransactionRequest - 22, // 15: nockchain.public.v1.WalletService.TransactionAccepted:input_type -> nockchain.public.v1.TransactionAcceptedRequest - 1, // 16: nockchain.public.v1.WalletService.Keygen:output_type -> nockchain.public.v1.KeygenResponse - 3, // 17: nockchain.public.v1.WalletService.ImportKeys:output_type -> nockchain.public.v1.ImportKeysResponse - 5, // 18: nockchain.public.v1.WalletService.DeriveChild:output_type -> nockchain.public.v1.DeriveChildResponse - 7, // 19: nockchain.public.v1.WalletService.CreateTx:output_type -> nockchain.public.v1.CreateTxResponse - 9, // 20: nockchain.public.v1.WalletService.SignTx:output_type -> nockchain.public.v1.SignTxResponse - 11, // 21: nockchain.public.v1.WalletService.Scan:output_type -> nockchain.public.v1.ScanResponse - 13, // 22: nockchain.public.v1.WalletService.WalletGetBalance:output_type -> nockchain.public.v1.GetBalanceResponse - 15, // 23: nockchain.public.v1.WalletService.WalletSendTransaction:output_type -> nockchain.public.v1.SendTransactionResponse - 23, // 24: nockchain.public.v1.WalletService.TransactionAccepted:output_type -> nockchain.public.v1.TransactionAcceptedResponse - 16, // [16:25] is the sub-list for method output_type - 7, // [7:16] is the sub-list for method input_type + 8, // 11: nockchain.public.v1.WalletService.Scan:input_type -> nockchain.public.v1.ScanRequest + 10, // 12: nockchain.public.v1.WalletService.WalletGetBalance:input_type -> nockchain.public.v1.GetBalanceRequest + 12, // 13: nockchain.public.v1.WalletService.WalletSendTransaction:input_type -> nockchain.public.v1.SendTransactionRequest + 20, // 14: nockchain.public.v1.WalletService.TransactionAccepted:input_type -> nockchain.public.v1.TransactionAcceptedRequest + 1, // 15: nockchain.public.v1.WalletService.Keygen:output_type -> nockchain.public.v1.KeygenResponse + 3, // 16: nockchain.public.v1.WalletService.ImportKeys:output_type -> nockchain.public.v1.ImportKeysResponse + 5, // 17: nockchain.public.v1.WalletService.DeriveChild:output_type -> nockchain.public.v1.DeriveChildResponse + 7, // 18: nockchain.public.v1.WalletService.CreateTx:output_type -> nockchain.public.v1.CreateTxResponse + 9, // 19: nockchain.public.v1.WalletService.Scan:output_type -> nockchain.public.v1.ScanResponse + 11, // 20: nockchain.public.v1.WalletService.WalletGetBalance:output_type -> nockchain.public.v1.GetBalanceResponse + 13, // 21: nockchain.public.v1.WalletService.WalletSendTransaction:output_type -> nockchain.public.v1.SendTransactionResponse + 21, // 22: nockchain.public.v1.WalletService.TransactionAccepted:output_type -> nockchain.public.v1.TransactionAcceptedResponse + 15, // [15:23] is the sub-list for method output_type + 7, // [7:15] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name 7, // [7:7] is the sub-list for extension extendee 0, // [0:7] is the sub-list for field type_name @@ -1146,7 +1081,7 @@ func file_service_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_service_proto_rawDesc), len(file_service_proto_rawDesc)), NumEnums: 0, - NumMessages: 16, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, diff --git a/nockchain/service_grpc.pb.go b/nockchain/service_grpc.pb.go index a8f205e..73b8665 100644 --- a/nockchain/service_grpc.pb.go +++ b/nockchain/service_grpc.pb.go @@ -23,7 +23,6 @@ const ( WalletService_ImportKeys_FullMethodName = "/nockchain.public.v1.WalletService/ImportKeys" WalletService_DeriveChild_FullMethodName = "/nockchain.public.v1.WalletService/DeriveChild" WalletService_CreateTx_FullMethodName = "/nockchain.public.v1.WalletService/CreateTx" - WalletService_SignTx_FullMethodName = "/nockchain.public.v1.WalletService/SignTx" WalletService_Scan_FullMethodName = "/nockchain.public.v1.WalletService/Scan" WalletService_WalletGetBalance_FullMethodName = "/nockchain.public.v1.WalletService/WalletGetBalance" WalletService_WalletSendTransaction_FullMethodName = "/nockchain.public.v1.WalletService/WalletSendTransaction" @@ -38,7 +37,7 @@ type WalletServiceClient interface { ImportKeys(ctx context.Context, in *ImportKeysRequest, opts ...grpc.CallOption) (*ImportKeysResponse, error) DeriveChild(ctx context.Context, in *DeriveChildRequest, opts ...grpc.CallOption) (*DeriveChildResponse, error) CreateTx(ctx context.Context, in *CreateTxRequest, opts ...grpc.CallOption) (*CreateTxResponse, error) - SignTx(ctx context.Context, in *SignTxRequest, opts ...grpc.CallOption) (*SignTxResponse, error) + // rpc SignTx(SignTxRequest) returns (SignTxResponse); Scan(ctx context.Context, in *ScanRequest, opts ...grpc.CallOption) (*ScanResponse, error) WalletGetBalance(ctx context.Context, in *GetBalanceRequest, opts ...grpc.CallOption) (*GetBalanceResponse, error) WalletSendTransaction(ctx context.Context, in *SendTransactionRequest, opts ...grpc.CallOption) (*SendTransactionResponse, error) @@ -93,16 +92,6 @@ func (c *walletServiceClient) CreateTx(ctx context.Context, in *CreateTxRequest, return out, nil } -func (c *walletServiceClient) SignTx(ctx context.Context, in *SignTxRequest, opts ...grpc.CallOption) (*SignTxResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(SignTxResponse) - err := c.cc.Invoke(ctx, WalletService_SignTx_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *walletServiceClient) Scan(ctx context.Context, in *ScanRequest, opts ...grpc.CallOption) (*ScanResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ScanResponse) @@ -151,7 +140,7 @@ type WalletServiceServer interface { ImportKeys(context.Context, *ImportKeysRequest) (*ImportKeysResponse, error) DeriveChild(context.Context, *DeriveChildRequest) (*DeriveChildResponse, error) CreateTx(context.Context, *CreateTxRequest) (*CreateTxResponse, error) - SignTx(context.Context, *SignTxRequest) (*SignTxResponse, error) + // rpc SignTx(SignTxRequest) returns (SignTxResponse); Scan(context.Context, *ScanRequest) (*ScanResponse, error) WalletGetBalance(context.Context, *GetBalanceRequest) (*GetBalanceResponse, error) WalletSendTransaction(context.Context, *SendTransactionRequest) (*SendTransactionResponse, error) @@ -178,9 +167,6 @@ func (UnimplementedWalletServiceServer) DeriveChild(context.Context, *DeriveChil func (UnimplementedWalletServiceServer) CreateTx(context.Context, *CreateTxRequest) (*CreateTxResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateTx not implemented") } -func (UnimplementedWalletServiceServer) SignTx(context.Context, *SignTxRequest) (*SignTxResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SignTx not implemented") -} func (UnimplementedWalletServiceServer) Scan(context.Context, *ScanRequest) (*ScanResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Scan not implemented") } @@ -286,24 +272,6 @@ func _WalletService_CreateTx_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _WalletService_SignTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SignTxRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(WalletServiceServer).SignTx(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: WalletService_SignTx_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WalletServiceServer).SignTx(ctx, req.(*SignTxRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _WalletService_Scan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ScanRequest) if err := dec(in); err != nil { @@ -399,10 +367,6 @@ var WalletService_ServiceDesc = grpc.ServiceDesc{ MethodName: "CreateTx", Handler: _WalletService_CreateTx_Handler, }, - { - MethodName: "SignTx", - Handler: _WalletService_SignTx_Handler, - }, { MethodName: "Scan", Handler: _WalletService_Scan_Handler, diff --git a/proto/nockapp.proto b/proto/nockapp.proto new file mode 100644 index 0000000..3c0bb98 --- /dev/null +++ b/proto/nockapp.proto @@ -0,0 +1,75 @@ +// nockchain/private/v1/nockapp.proto + +syntax = "proto3"; + +package nockchain.private.v1; +option go_package = "./;nockchain"; + +service NockAppService { + rpc Peek(PeekRequest) returns (PeekResponse); + rpc Poke(PokeRequest) returns (PokeResponse); +} + +message PeekRequest { + int32 pid = 1; // process ID for tracking + bytes path = 2; // JAM-encoded nock peek path +} + +message PeekResponse { + oneof result { + bytes data = 1; // JAM-encoded nock data (success case) + AppErrorStatus error = 2; + } +} + +message PokeRequest { + int32 pid = 1; // process ID for tracking + Wire wire = 2; // wire routing information + bytes payload = 3; // JAM-encoded nock data +} + +message PokeResponse { + oneof result { + bool acknowledged = 1; // true if successful + AppErrorStatus error = 2; + } +} + + +message AppErrorStatus { + AppErrorCode code = 1; + string message = 2; + optional string details = 3; // additional error context +} + +enum AppErrorCode { + ERROR_CODE_UNSPECIFIED = 0; + ERROR_CODE_INVALID_REQUEST = 1; + ERROR_CODE_PEEK_FAILED = 2; + ERROR_CODE_PEEK_RETURNED_NO_DATA = 3; + ERROR_CODE_POKE_FAILED = 4; + ERROR_CODE_NACKAPP_ERROR = 5; + ERROR_CODE_TIMEOUT = 6; + ERROR_CODE_INTERNAL_ERROR = 7; + ERROR_CODE_NOT_FOUND = 8; + ERROR_CODE_PERMISSION_DENIED = 9; + ERROR_CODE_INVALID_WIRE = 10; + ERROR_CODE_KERNEL_ERROR = 11; +} + +// =================================================================== +// Wire types for NockApp pokes +// =================================================================== + +message Wire { + string source = 1; // e.g., "http", "file", "wallet", "grpc" + uint64 version = 2; // wire format version + repeated WireTag tags = 3; // operation-specific tags +} + +message WireTag { + oneof value { + string text = 1; + uint64 number = 2; + } +} diff --git a/proto/primitives.proto b/proto/primitives.proto index 47625ab..ececfe7 100644 --- a/proto/primitives.proto +++ b/proto/primitives.proto @@ -28,23 +28,6 @@ enum ErrorCode { ERROR_CODE_KERNEL_ERROR = 11; } -// =================================================================== -// Wire types for NockApp pokes -// =================================================================== - -message Wire { - string source = 1; // e.g., "http", "file", "wallet", "grpc" - uint64 version = 2; // wire format version - repeated WireTag tags = 3; // operation-specific tags -} - -message WireTag { - oneof value { - string text = 1; - uint64 number = 2; - } -} - // Note: prefer using raw numeric fields in messages // instead of these wrappers to simplify conversions. // These remain defined for potential future use. diff --git a/proto/service.proto b/proto/service.proto index d37aad1..e5839d6 100644 --- a/proto/service.proto +++ b/proto/service.proto @@ -11,7 +11,7 @@ service WalletService { rpc ImportKeys(ImportKeysRequest) returns (ImportKeysResponse); rpc DeriveChild(DeriveChildRequest) returns (DeriveChildResponse); rpc CreateTx(CreateTxRequest) returns (CreateTxResponse); - rpc SignTx(SignTxRequest) returns (SignTxResponse); + // rpc SignTx(SignTxRequest) returns (SignTxResponse); rpc Scan(ScanRequest) returns (ScanResponse); rpc WalletGetBalance(GetBalanceRequest) returns (GetBalanceResponse); @@ -21,41 +21,48 @@ service WalletService { returns (TransactionAcceptedResponse); } -message KeygenRequest {} +message KeygenRequest { + uint64 version = 1; +} message KeygenResponse { - string public_key = 1; + string address = 1; string private_key = 2; string seed = 3; string chain_code = 4; string import_private_key = 5; string import_public_key = 6; + uint64 version = 7; } message ImportKeysRequest { string key = 1; - ImportType import_type = 2; + uint64 version = 2; + ImportType import_type = 3; } message ImportKeysResponse { - string public_key = 1; + string address = 1; string private_key = 2; string seed = 3; string chain_code = 4; string import_private_key = 5; string import_public_key = 6; + uint64 version = 7; } message DeriveChildRequest { string imported_key = 1; uint64 index = 2; bool hardened = 3; + uint64 version = 4; } message DeriveChildResponse { - string public_key = 1; + string address = 1; string private_key = 2; string chain_code = 3; + uint64 version = 4; } message CreateTxRequest { @@ -68,23 +75,24 @@ message CreateTxRequest { string chain_code = 7; uint64 index = 8; bool hardened = 9; - TimelockIntent timelock_intent = 10; + uint64 version = 10; + TimelockIntent timelock_intent = 11; } message CreateTxResponse { RawTx rawTx = 1; } -message SignTxRequest { - string unsigned_tx = 1; - uint64 index = 2; - bool hardened = 3; -} +// message SignTxRequest { +// string unsigned_tx = 1; +// uint64 index = 2; +// bool hardened = 3; +// } -message SignTxResponse { - string signed_tx = 1; - string error = 2; -} +// message SignTxResponse { +// string signed_tx = 1; +// string error = 2; +// } message ScanRequest { string master_pubkey = 1; diff --git a/wallet/nockchain_service.go b/wallet/nockchain_service.go index dac0a74..f4e4fd4 100644 --- a/wallet/nockchain_service.go +++ b/wallet/nockchain_service.go @@ -10,8 +10,9 @@ import ( ) type NockchainClient struct { - conn *grpc.ClientConn - client nockchain.NockchainServiceClient + conn *grpc.ClientConn + client nockchain.NockchainServiceClient + appClient nockchain.NockAppServiceClient } // NewNockchainClient creates a new gRPC client connection @@ -27,10 +28,12 @@ func NewNockchainClient(address string) (*NockchainClient, error) { } client := nockchain.NewNockchainServiceClient(conn) + appClient := nockchain.NewNockAppServiceClient(conn) return &NockchainClient{ - conn: conn, - client: client, + conn: conn, + client: client, + appClient: appClient, }, nil } @@ -150,3 +153,44 @@ func (nc *NockchainClient) WalletSendTransaction(tx *nockchain.RawTx) (*nockchai return nil, fmt.Errorf("invalid result type") } } + +func (nc *NockchainClient) Peek(pid int32, path []byte) ([]byte, error) { + req := nockchain.PeekRequest{ + Pid: pid, + Path: path, + } + + resp, err := nc.appClient.Peek(context.Background(), &req) + if err != nil { + return nil, err + } + switch resp.Result.(type) { + case *nockchain.PeekResponse_Data: + return resp.GetData(), nil + case *nockchain.PeekResponse_Error: + return nil, fmt.Errorf("error: %s", resp.GetError().Message) + default: + return nil, fmt.Errorf("invalid result type") + } +} + +func (nc *NockchainClient) Poke(pid int32, wire *nockchain.Wire, payload []byte) (bool, error) { + req := nockchain.PokeRequest{ + Pid: pid, + Wire: wire, + Payload: payload, + } + + resp, err := nc.appClient.Poke(context.Background(), &req) + if err != nil { + return false, err + } + switch resp.Result.(type) { + case *nockchain.PokeResponse_Acknowledged: + return resp.GetAcknowledged(), nil + case *nockchain.PokeResponse_Error: + return false, fmt.Errorf("error: %s", resp.GetError().Message) + default: + return false, fmt.Errorf("invalid result type") + } +} diff --git a/wallet/service.go b/wallet/service.go index 1c0dfc9..a3e0275 100644 --- a/wallet/service.go +++ b/wallet/service.go @@ -49,13 +49,26 @@ func (h *GprcHandler) Keygen(ctx context.Context, req *nockchain.KeygenRequest) return nil, err } privBytes := append([]byte{0x00}, masterKey.PrivateKey...) + + address := "" + if req.Version == 0 { + address = base58.Encode(masterKey.PublicKey) + } else { + pkPoint, err := crypto.CheetaPointFromBytes(masterKey.PublicKey) + if err != nil { + return nil, err + } + pkHash := HashPubkey(pkPoint) + address = crypto.Tip5HashToBase58(pkHash) + } return &nockchain.KeygenResponse{ Seed: mnemonic, PrivateKey: base58.Encode(masterKey.PrivateKey), - PublicKey: base58.Encode(masterKey.PublicKey), + Address: address, ChainCode: base58.Encode(masterKey.ChainCode), - ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE)), - ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC)), + ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, 0, crypto.KeyType_PRIVATE)), + ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, 0, crypto.KeyType_PUBLIC)), + Version: req.Version, }, nil } @@ -88,13 +101,26 @@ func (h *GprcHandler) ImportKeys(ctx context.Context, req *nockchain.ImportKeysR return nil, err } privBytes := append([]byte{0x00}, masterKey.PrivateKey...) + + address := "" + if req.Version == 0 { + address = base58.Encode(masterKey.PublicKey) + } else { + pkPoint, err := crypto.CheetaPointFromBytes(masterKey.PublicKey) + if err != nil { + return nil, err + } + pkHash := HashPubkey(pkPoint) + address = crypto.Tip5HashToBase58(pkHash) + } return &nockchain.ImportKeysResponse{ Seed: "", PrivateKey: base58.Encode(masterKey.PrivateKey), - PublicKey: base58.Encode(masterKey.PublicKey), + Address: address, ChainCode: base58.Encode(masterKey.ChainCode), - ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE)), - ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC)), + ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, 0, crypto.KeyType_PRIVATE)), + ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, 0, crypto.KeyType_PUBLIC)), + Version: req.Version, }, nil case strings.HasPrefix(req.Key, "zpub"): if len(data) != 147 { @@ -111,13 +137,26 @@ func (h *GprcHandler) ImportKeys(ctx context.Context, req *nockchain.ImportKeysR copy(chainCode, data[14:46]) publicKey := make([]byte, 97) copy(publicKey, data[46:143]) + + address := "" + if req.Version == 0 { + address = base58.Encode(publicKey) + } else { + pkPoint, err := crypto.CheetaPointFromBytes(publicKey) + if err != nil { + return nil, err + } + pkHash := HashPubkey(pkPoint) + address = crypto.Tip5HashToBase58(pkHash) + } return &nockchain.ImportKeysResponse{ Seed: "", PrivateKey: "", - PublicKey: base58.Encode(publicKey), + Address: address, ChainCode: base58.Encode(chainCode), ImportPrivateKey: "", - ImportPublicKey: base58.Encode(crypto.SerializeExtend(chainCode, publicKey, crypto.KeyType_PUBLIC)), + ImportPublicKey: base58.Encode(crypto.SerializeExtend(chainCode, publicKey, 0, crypto.KeyType_PUBLIC)), + Version: req.Version, }, nil default: return nil, fmt.Errorf("invalid extended key") @@ -140,13 +179,26 @@ func (h *GprcHandler) ImportKeys(ctx context.Context, req *nockchain.ImportKeysR return nil, err } privBytes := append([]byte{0x00}, masterKey.PrivateKey...) + + address := "" + if req.Version == 0 { + address = base58.Encode(masterKey.PublicKey) + } else { + pkPoint, err := crypto.CheetaPointFromBytes(masterKey.PublicKey) + if err != nil { + return nil, err + } + pkHash := HashPubkey(pkPoint) + address = crypto.Tip5HashToBase58(pkHash) + } return &nockchain.ImportKeysResponse{ Seed: "", PrivateKey: base58.Encode(masterKey.PrivateKey), - PublicKey: base58.Encode(masterKey.PublicKey), + Address: address, ChainCode: base58.Encode(masterKey.ChainCode), - ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE)), - ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC)), + ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, 0, crypto.KeyType_PRIVATE)), + ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, 0, crypto.KeyType_PUBLIC)), + Version: req.Version, }, nil case nockchain.ImportType_SEEDPHRASE: masterKey, err := crypto.MasterKeyFromSeed(req.Key) @@ -154,23 +206,49 @@ func (h *GprcHandler) ImportKeys(ctx context.Context, req *nockchain.ImportKeysR return nil, err } privBytes := append([]byte{0x00}, masterKey.PrivateKey...) + + address := "" + if req.Version == 0 { + address = base58.Encode(masterKey.PublicKey) + } else { + pkPoint, err := crypto.CheetaPointFromBytes(masterKey.PublicKey) + if err != nil { + return nil, err + } + pkHash := HashPubkey(pkPoint) + address = crypto.Tip5HashToBase58(pkHash) + } return &nockchain.ImportKeysResponse{ Seed: "", PrivateKey: base58.Encode(masterKey.PrivateKey), - PublicKey: base58.Encode(masterKey.PublicKey), + Address: address, ChainCode: base58.Encode(masterKey.ChainCode), - ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE)), - ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC)), + ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, 0, crypto.KeyType_PRIVATE)), + ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, 0, crypto.KeyType_PUBLIC)), + Version: req.Version, }, nil case nockchain.ImportType_WATCH_ONLY: - pubKey := base58.Decode(req.Key) + pubkey := base58.Decode(req.Key) + + address := "" + if req.Version == 0 { + address = base58.Encode(pubkey) + } else { + pkPoint, err := crypto.CheetaPointFromBytes(pubkey) + if err != nil { + return nil, err + } + pkHash := HashPubkey(pkPoint) + address = crypto.Tip5HashToBase58(pkHash) + } return &nockchain.ImportKeysResponse{ Seed: "", PrivateKey: "", - PublicKey: base58.Encode(pubKey), + Address: address, ChainCode: "", ImportPrivateKey: "", ImportPublicKey: "", + Version: req.Version, }, nil default: return nil, fmt.Errorf("invalid import type") @@ -212,10 +290,23 @@ func (h *GprcHandler) DeriveChild(ctx context.Context, req *nockchain.DeriveChil if err != nil { return nil, err } + + address := "" + if req.Version == 0 { + address = base58.Encode(childKey.PublicKey) + } else { + pkPoint, err := crypto.CheetaPointFromBytes(childKey.PublicKey) + if err != nil { + return nil, err + } + pkHash := HashPubkey(pkPoint) + address = crypto.Tip5HashToBase58(pkHash) + } return &nockchain.DeriveChildResponse{ - PublicKey: base58.Encode(childKey.PublicKey), + Address: address, PrivateKey: base58.Encode(childKey.PrivateKey), ChainCode: base58.Encode(childKey.ChainCode), + Version: req.Version, }, nil case strings.HasPrefix(req.ImportedKey, "zpub"): @@ -243,10 +334,23 @@ func (h *GprcHandler) DeriveChild(ctx context.Context, req *nockchain.DeriveChil if err != nil { return nil, err } + + address := "" + if req.Version == 0 { + address = base58.Encode(childKey.PublicKey) + } else { + pkPoint, err := crypto.CheetaPointFromBytes(childKey.PublicKey) + if err != nil { + return nil, err + } + pkHash := HashPubkey(pkPoint) + address = crypto.Tip5HashToBase58(pkHash) + } return &nockchain.DeriveChildResponse{ - PublicKey: base58.Encode(childKey.PublicKey), + Address: address, PrivateKey: "", ChainCode: base58.Encode(childKey.ChainCode), + Version: req.Version, }, nil default: return nil, fmt.Errorf("invalid extended key") @@ -590,7 +694,3 @@ func (h *GprcHandler) WalletSendTransaction(_ context.Context, req *nockchain.Se func (h *GprcHandler) TransactionAccepted(_ context.Context, req *nockchain.TransactionAcceptedRequest) (*nockchain.TransactionAcceptedResponse, error) { return h.client.TxAccepted(req.TxId.Hash) } - -func (h *GprcHandler) SignTx(context.Context, *nockchain.SignTxRequest) (*nockchain.SignTxResponse, error) { - return nil, nil -} diff --git a/wallet/service_test.go b/wallet/service_test.go index 3be7eff..b96e027 100644 --- a/wallet/service_test.go +++ b/wallet/service_test.go @@ -16,7 +16,7 @@ import ( ) // The entropy, salt and result is taken from "nockchain-wallet keygen" command -func TestKeyGen(t *testing.T) { +func TestKeyGenV0(t *testing.T) { entropyBigInt, isOk := new(big.Int).SetString("37133536588676344913489312523941366110857274548479981512263368615793750653450", 10) assert.True(t, isOk) @@ -38,6 +38,10 @@ func TestKeyGen(t *testing.T) { masterKey, err := crypto.MasterKeyFromSeed(mnemonic) assert.NoError(t, err) + pkPoint, err := crypto.CheetaPointFromBytes(masterKey.PublicKey) + assert.NoError(t, err) + + fmt.Println(crypto.Tip5HashToBase58(wallet.HashPubkey(pkPoint))) assert.Equal(t, base58.Encode(masterKey.PublicKey), "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", @@ -53,9 +57,9 @@ func TestKeyGen(t *testing.T) { // assert import priv/pubkey privBytes := append([]byte{0x00}, masterKey.PrivateKey...) - importPrivKey := crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE) + importPrivKey := crypto.SerializeExtend(masterKey.ChainCode, privBytes, 0, crypto.KeyType_PRIVATE) assert.Len(t, importPrivKey, 83) - importPubKey := crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC) + importPubKey := crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, 0, crypto.KeyType_PUBLIC) assert.Len(t, importPubKey, 147) assert.Equal(t, @@ -68,6 +72,51 @@ func TestKeyGen(t *testing.T) { ) } +func TestKeyGenV1(t *testing.T) { + entropyBigInt, isOk := new(big.Int).SetString("90486886833626125109893864286343887304289963452245361030406651820586141463911", 10) + assert.True(t, isOk) + + entropy := entropyBigInt.Bytes() + assert.Len(t, entropy, 32) + + saltBigInt, isOk := new(big.Int).SetString("200764822674693794811396222039518854030", 10) + assert.True(t, isOk) + + salt := saltBigInt.Bytes() + assert.Len(t, salt, 16) + + argonBytes := crypto.DeriveKey(0, entropy[:], salt[:], nil, nil, 6, 786432, 4, 32) + slices.Reverse(argonBytes) + mnemonic, err := bip39.NewMnemonic(argonBytes) + assert.NoError(t, err) + assert.Equal(t, mnemonic, "holiday wage fan orange humble erode thought across boring cereal brass believe window drill until dry dish basket mean all banana tribe antenna engage") + + masterKey, err := crypto.MasterKeyFromSeed(mnemonic) + assert.NoError(t, err) + + pkPoint, err := crypto.CheetaPointFromBytes(masterKey.PublicKey) + assert.NoError(t, err) + assert.Equal(t, + crypto.Tip5HashToBase58(wallet.HashPubkey(pkPoint)), + "6DGFW4qAgCDx1AnP9fkhENwaPUeVWHEDB5WuJPiN1bZBjW2igMgU7N8", + ) + + // assert import priv/pubkey + privBytes := append([]byte{0x00}, masterKey.PrivateKey...) + importPrivKey := crypto.SerializeExtend(masterKey.ChainCode, privBytes, 0, crypto.KeyType_PRIVATE) + assert.Len(t, importPrivKey, 83) + importPubKey := crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, 0, crypto.KeyType_PUBLIC) + assert.Len(t, importPubKey, 147) + + assert.Equal(t, + base58.Encode(importPrivKey), + "zprvLpf3WSvYWmHRd4ifBMKZTDRa4s5sNBZo7cLx7PhFsYvdCEwv6WdHnDFYHFFvd4sKy1DcSpU4xAohfutPqVpsKGsyCdwLgZDpVH7sHSM382d6", + ) + assert.Equal(t, + base58.Encode(importPubKey), + "zpub2jgndknkQprVYB9YTkv6VAteaXtW1rQcGMVtNEsuKUJay8MkBm5VW5LyFLYhpQyE1hChW2ZkCiN6BCcTF2wBNiVeCzu7sFP4kaV5DVHZDY3BsdYXimDjQ8GCw6o1qWH8w6kTZrMwkA8o7BSLZ6vk1BHHASi6P2qNSeDBw2No6fAHAr5xvEnUY7Xqa63m4jXYcgFD", + ) +} func TestImportKey(t *testing.T) { type Input struct { req *nockchain.ImportKeysRequest @@ -90,27 +139,47 @@ func TestImportKey(t *testing.T) { copy(invalidImportPubkeyChecksum[:], correctImportPubkey) copy(invalidImportPubkeyChecksum[143:], []byte{1, 2, 3, 4}) - response := &nockchain.ImportKeysResponse{ - PublicKey: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", + responseV0 := &nockchain.ImportKeysResponse{ + Address: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", PrivateKey: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8", ImportPrivateKey: base58.Encode(correctImportPrivKey), ImportPublicKey: base58.Encode(correctImportPubkey), + Version: 0, + } + responseV1 := &nockchain.ImportKeysResponse{ + Address: "BAmYAxgpVrJeFqqPnKAZHVZZdmVfzrgu7bBqcRBNca8HpxQofzUZG8Q", + PrivateKey: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", + ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8", + ImportPrivateKey: base58.Encode(correctImportPrivKey), + ImportPublicKey: base58.Encode(correctImportPubkey), + Version: 1, } - responseReadOnly := &nockchain.ImportKeysResponse{ - PublicKey: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", + responseV0ReadOnly := &nockchain.ImportKeysResponse{ + Address: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", PrivateKey: "", ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8", ImportPrivateKey: "", ImportPublicKey: base58.Encode(correctImportPubkey), + Version: 0, } + responseV1ReadOnly := &nockchain.ImportKeysResponse{ + Address: "BAmYAxgpVrJeFqqPnKAZHVZZdmVfzrgu7bBqcRBNca8HpxQofzUZG8Q", + PrivateKey: "", + ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8", + ImportPrivateKey: "", + ImportPublicKey: base58.Encode(correctImportPubkey), + Version: 1, + } + inputs := []Input{ // case invalid type { req: &nockchain.ImportKeysRequest{ Key: "", ImportType: nockchain.ImportType_UNDEFINED, + Version: 0, }, expectResp: nil, isErr: true, @@ -121,6 +190,7 @@ func TestImportKey(t *testing.T) { req: &nockchain.ImportKeysRequest{ Key: "some wrong string", ImportType: nockchain.ImportType_EXTENDED_KEY, + Version: 0, }, expectResp: nil, isErr: true, @@ -130,6 +200,7 @@ func TestImportKey(t *testing.T) { req: &nockchain.ImportKeysRequest{ Key: "zprv wrong priv import key length", ImportType: nockchain.ImportType_EXTENDED_KEY, + Version: 0, }, expectResp: nil, isErr: true, @@ -139,6 +210,7 @@ func TestImportKey(t *testing.T) { req: &nockchain.ImportKeysRequest{ Key: base58.Encode(invalidImportPrivKeyPrefix), ImportType: nockchain.ImportType_EXTENDED_KEY, + Version: 0, }, expectResp: nil, isErr: true, @@ -153,13 +225,25 @@ func TestImportKey(t *testing.T) { isErr: true, errStr: "invalid checksum", }, - // case success import priv key + // case success import priv key v0 { req: &nockchain.ImportKeysRequest{ Key: base58.Encode(correctImportPrivKey), ImportType: nockchain.ImportType_EXTENDED_KEY, + Version: 0, }, - expectResp: response, + expectResp: responseV0, + isErr: false, + errStr: "", + }, + // case success import priv key v1 + { + req: &nockchain.ImportKeysRequest{ + Key: base58.Encode(correctImportPrivKey), + ImportType: nockchain.ImportType_EXTENDED_KEY, + Version: 1, + }, + expectResp: responseV1, isErr: false, errStr: "", }, @@ -168,6 +252,7 @@ func TestImportKey(t *testing.T) { req: &nockchain.ImportKeysRequest{ Key: "zpub wrong public import key length", ImportType: nockchain.ImportType_EXTENDED_KEY, + Version: 0, }, expectResp: nil, isErr: true, @@ -177,18 +262,31 @@ func TestImportKey(t *testing.T) { req: &nockchain.ImportKeysRequest{ Key: base58.Encode(invalidImportPubkeyChecksum), ImportType: nockchain.ImportType_EXTENDED_KEY, + Version: 0, }, expectResp: nil, isErr: true, errStr: "invalid checksum", }, - // case success import pub key + // case success import pub key v0 { req: &nockchain.ImportKeysRequest{ Key: base58.Encode(correctImportPubkey), ImportType: nockchain.ImportType_EXTENDED_KEY, + Version: 0, }, - expectResp: responseReadOnly, + expectResp: responseV0ReadOnly, + isErr: false, + errStr: "", + }, + // case success import pub key v1 + { + req: &nockchain.ImportKeysRequest{ + Key: base58.Encode(correctImportPubkey), + ImportType: nockchain.ImportType_EXTENDED_KEY, + Version: 1, + }, + expectResp: responseV1ReadOnly, isErr: false, errStr: "", }, @@ -197,6 +295,7 @@ func TestImportKey(t *testing.T) { req: &nockchain.ImportKeysRequest{ Key: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", ImportType: nockchain.ImportType_MASTER_PRIVKEY, + Version: 0, }, expectResp: nil, isErr: true, @@ -207,6 +306,7 @@ func TestImportKey(t *testing.T) { req: &nockchain.ImportKeysRequest{ Key: "abcdxyz,3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", ImportType: nockchain.ImportType_MASTER_PRIVKEY, + Version: 0, }, expectResp: nil, isErr: true, @@ -216,39 +316,80 @@ func TestImportKey(t *testing.T) { req: &nockchain.ImportKeysRequest{ Key: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8,abcdxyz", ImportType: nockchain.ImportType_MASTER_PRIVKEY, + Version: 0, }, expectResp: nil, isErr: true, errStr: "invalid priv key length", }, - // case success import master privkey + // case success import master privkey v0 { req: &nockchain.ImportKeysRequest{ Key: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8,3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", ImportType: nockchain.ImportType_MASTER_PRIVKEY, + Version: 0, }, - expectResp: response, + expectResp: responseV0, isErr: false, errStr: "", }, - // case success import seed + // case success import master privkey v1 + { + req: &nockchain.ImportKeysRequest{ + Key: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8,3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", + ImportType: nockchain.ImportType_MASTER_PRIVKEY, + Version: 1, + }, + expectResp: responseV1, + isErr: false, + errStr: "", + }, + // case success import seed v0 { req: &nockchain.ImportKeysRequest{ Key: "include lounge salad chicken trumpet embrace grace mercy pulp submit alter weapon plastic welcome funny female palm satoshi open file knock sun fade match", ImportType: nockchain.ImportType_SEEDPHRASE, + Version: 0, }, - expectResp: response, + expectResp: responseV0, isErr: false, errStr: "", }, - // case sucess import pubkey + // case success import seed v1 + { + req: &nockchain.ImportKeysRequest{ + Key: "include lounge salad chicken trumpet embrace grace mercy pulp submit alter weapon plastic welcome funny female palm satoshi open file knock sun fade match", + ImportType: nockchain.ImportType_SEEDPHRASE, + Version: 1, + }, + expectResp: responseV1, + isErr: false, + errStr: "", + }, + // case sucess import pubkey v0 { req: &nockchain.ImportKeysRequest{ Key: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", ImportType: nockchain.ImportType_WATCH_ONLY, + Version: 0, }, expectResp: &nockchain.ImportKeysResponse{ - PublicKey: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", + Address: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", + Version: 0, + }, + isErr: false, + errStr: "", + }, + // case sucess import pubkey v1 + { + req: &nockchain.ImportKeysRequest{ + Key: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", + ImportType: nockchain.ImportType_WATCH_ONLY, + Version: 1, + }, + expectResp: &nockchain.ImportKeysResponse{ + Address: "BAmYAxgpVrJeFqqPnKAZHVZZdmVfzrgu7bBqcRBNca8HpxQofzUZG8Q", + Version: 1, }, isErr: false, errStr: "",