diff --git a/common/constant/node.go b/common/constant/node.go new file mode 100644 index 000000000..616b577a9 --- /dev/null +++ b/common/constant/node.go @@ -0,0 +1,6 @@ +package constant + +var ( + // ProofOfOwnershipExpiration number of blocks after a proof of ownership message 'expires' (is considered invalid) + ProofOfOwnershipExpiration uint32 = 100 +) diff --git a/common/crypto/signature.go b/common/crypto/signature.go index f4d8a7901..7913e1c67 100644 --- a/common/crypto/signature.go +++ b/common/crypto/signature.go @@ -8,7 +8,7 @@ import ( type ( SignatureInterface interface { Sign(payload []byte, accountType uint32, accountAddress, seed string) []byte - SignBlock(payload []byte, nodeSeed string) []byte + SignByNode(payload []byte, nodeSeed string) []byte VerifySignature(payload, signature []byte, accountType uint32, accountAddress string) bool } @@ -37,8 +37,8 @@ func (sig *Signature) Sign(payload []byte, accountType uint32, accountAddress, s } } -// SignBlock special method for signing block only, there will be no multiple signature options -func (*Signature) SignBlock(payload []byte, nodeSeed string) []byte { +// SignByNode special method for signing block only, there will be no multiple signature options +func (*Signature) SignByNode(payload []byte, nodeSeed string) []byte { nodePrivateKey := ed25519GetPrivateKeyFromSeed(nodeSeed) return ed25519.Sign(nodePrivateKey, payload) } diff --git a/common/crypto/signature_test.go b/common/crypto/signature_test.go index d670f47fb..e66023e17 100644 --- a/common/crypto/signature_test.go +++ b/common/crypto/signature_test.go @@ -83,7 +83,7 @@ func TestSignature_SignBlock(t *testing.T) { want []byte }{ { - name: "SignBlock:success", + name: "SignByNode:success", args: args{ payload: []byte{12, 43, 65, 65, 12, 123, 43, 12, 1, 24, 5, 5, 12, 54}, nodeSeed: "concur vocalist rotten busload gap quote stinging undiluted surfer goofiness deviation starved", @@ -96,8 +96,8 @@ func TestSignature_SignBlock(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &Signature{} - if got := s.SignBlock(tt.args.payload, tt.args.nodeSeed); !reflect.DeepEqual(got, tt.want) { - t.Errorf("Signature.SignBlock() = %v, want %v", got, tt.want) + if got := s.SignByNode(tt.args.payload, tt.args.nodeSeed); !reflect.DeepEqual(got, tt.want) { + t.Errorf("Signature.SignByNode() = %v, want %v", got, tt.want) } }) } diff --git a/common/model/host.pb.go b/common/model/host.pb.go index 4567e3324..13a54397b 100644 --- a/common/model/host.pb.go +++ b/common/model/host.pb.go @@ -20,7 +20,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package -// Host represent node and listed peers information +// Host represent data sructure node and listed peers in node it's self type Host struct { Info *Node `protobuf:"bytes,1,opt,name=Info,proto3" json:"Info,omitempty"` ResolvedPeers map[string]*Peer `protobuf:"bytes,2,rep,name=ResolvedPeers,proto3" json:"ResolvedPeers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` diff --git a/common/model/nodeRegistration.pb.go b/common/model/nodeRegistration.pb.go index 5fab73821..23626762e 100644 --- a/common/model/nodeRegistration.pb.go +++ b/common/model/nodeRegistration.pb.go @@ -1,11 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: model/nodeRegistration.proto -package model // import "github.com/zoobc/zoobc-core/common/model" +package model -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -16,7 +18,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type NodeRegistration struct { NodePublicKey []byte `protobuf:"bytes,1,opt,name=NodePublicKey,proto3" json:"NodePublicKey,omitempty"` @@ -36,16 +38,17 @@ func (m *NodeRegistration) Reset() { *m = NodeRegistration{} } func (m *NodeRegistration) String() string { return proto.CompactTextString(m) } func (*NodeRegistration) ProtoMessage() {} func (*NodeRegistration) Descriptor() ([]byte, []int) { - return fileDescriptor_nodeRegistration_4567bc509a0bbb5d, []int{0} + return fileDescriptor_df1af0ec89e31788, []int{0} } + func (m *NodeRegistration) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_NodeRegistration.Unmarshal(m, b) } func (m *NodeRegistration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_NodeRegistration.Marshal(b, m, deterministic) } -func (dst *NodeRegistration) XXX_Merge(src proto.Message) { - xxx_messageInfo_NodeRegistration.Merge(dst, src) +func (m *NodeRegistration) XXX_Merge(src proto.Message) { + xxx_messageInfo_NodeRegistration.Merge(m, src) } func (m *NodeRegistration) XXX_Size() int { return xxx_messageInfo_NodeRegistration.Size(m) @@ -127,16 +130,17 @@ func (m *GetNodeRegistrationsRequest) Reset() { *m = GetNodeRegistration func (m *GetNodeRegistrationsRequest) String() string { return proto.CompactTextString(m) } func (*GetNodeRegistrationsRequest) ProtoMessage() {} func (*GetNodeRegistrationsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_nodeRegistration_4567bc509a0bbb5d, []int{1} + return fileDescriptor_df1af0ec89e31788, []int{1} } + func (m *GetNodeRegistrationsRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetNodeRegistrationsRequest.Unmarshal(m, b) } func (m *GetNodeRegistrationsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_GetNodeRegistrationsRequest.Marshal(b, m, deterministic) } -func (dst *GetNodeRegistrationsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetNodeRegistrationsRequest.Merge(dst, src) +func (m *GetNodeRegistrationsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetNodeRegistrationsRequest.Merge(m, src) } func (m *GetNodeRegistrationsRequest) XXX_Size() int { return xxx_messageInfo_GetNodeRegistrationsRequest.Size(m) @@ -191,16 +195,17 @@ func (m *GetNodeRegistrationRequest) Reset() { *m = GetNodeRegistrationR func (m *GetNodeRegistrationRequest) String() string { return proto.CompactTextString(m) } func (*GetNodeRegistrationRequest) ProtoMessage() {} func (*GetNodeRegistrationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_nodeRegistration_4567bc509a0bbb5d, []int{2} + return fileDescriptor_df1af0ec89e31788, []int{2} } + func (m *GetNodeRegistrationRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetNodeRegistrationRequest.Unmarshal(m, b) } func (m *GetNodeRegistrationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_GetNodeRegistrationRequest.Marshal(b, m, deterministic) } -func (dst *GetNodeRegistrationRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetNodeRegistrationRequest.Merge(dst, src) +func (m *GetNodeRegistrationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetNodeRegistrationRequest.Merge(m, src) } func (m *GetNodeRegistrationRequest) XXX_Size() int { return xxx_messageInfo_GetNodeRegistrationRequest.Size(m) @@ -262,16 +267,17 @@ func (m *GetNodeRegistrationsResponse) Reset() { *m = GetNodeRegistratio func (m *GetNodeRegistrationsResponse) String() string { return proto.CompactTextString(m) } func (*GetNodeRegistrationsResponse) ProtoMessage() {} func (*GetNodeRegistrationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_nodeRegistration_4567bc509a0bbb5d, []int{3} + return fileDescriptor_df1af0ec89e31788, []int{3} } + func (m *GetNodeRegistrationsResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetNodeRegistrationsResponse.Unmarshal(m, b) } func (m *GetNodeRegistrationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_GetNodeRegistrationsResponse.Marshal(b, m, deterministic) } -func (dst *GetNodeRegistrationsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetNodeRegistrationsResponse.Merge(dst, src) +func (m *GetNodeRegistrationsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetNodeRegistrationsResponse.Merge(m, src) } func (m *GetNodeRegistrationsResponse) XXX_Size() int { return xxx_messageInfo_GetNodeRegistrationsResponse.Size(m) @@ -331,11 +337,9 @@ func init() { proto.RegisterType((*GetNodeRegistrationsResponse)(nil), "model.GetNodeRegistrationsResponse") } -func init() { - proto.RegisterFile("model/nodeRegistration.proto", fileDescriptor_nodeRegistration_4567bc509a0bbb5d) -} +func init() { proto.RegisterFile("model/nodeRegistration.proto", fileDescriptor_df1af0ec89e31788) } -var fileDescriptor_nodeRegistration_4567bc509a0bbb5d = []byte{ +var fileDescriptor_df1af0ec89e31788 = []byte{ // 347 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x93, 0xdf, 0x4a, 0xc3, 0x30, 0x18, 0xc5, 0xc9, 0xfe, 0xd4, 0x2d, 0x73, 0x22, 0xb9, 0x90, 0xa2, 0xbb, 0x08, 0x45, 0xa4, 0x08, diff --git a/common/model/transaction.pb.go b/common/model/transaction.pb.go index 218ef7851..466bb8190 100644 --- a/common/model/transaction.pb.go +++ b/common/model/transaction.pb.go @@ -1,11 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: model/transaction.proto -package model // import "github.com/zoobc/zoobc-core/common/model" +package model -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -16,7 +18,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Transaction represent the transaction data structure stored in the database type Transaction struct { @@ -51,16 +53,17 @@ func (m *Transaction) Reset() { *m = Transaction{} } func (m *Transaction) String() string { return proto.CompactTextString(m) } func (*Transaction) ProtoMessage() {} func (*Transaction) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{0} + return fileDescriptor_8333001f09b34082, []int{0} } + func (m *Transaction) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Transaction.Unmarshal(m, b) } func (m *Transaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Transaction.Marshal(b, m, deterministic) } -func (dst *Transaction) XXX_Merge(src proto.Message) { - xxx_messageInfo_Transaction.Merge(dst, src) +func (m *Transaction) XXX_Merge(src proto.Message) { + xxx_messageInfo_Transaction.Merge(m, src) } func (m *Transaction) XXX_Size() int { return xxx_messageInfo_Transaction.Size(m) @@ -226,99 +229,15 @@ func (m *Transaction) GetSignature() []byte { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*Transaction) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _Transaction_OneofMarshaler, _Transaction_OneofUnmarshaler, _Transaction_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Transaction) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*Transaction_EmptyTransactionBody)(nil), (*Transaction_SendMoneyTransactionBody)(nil), (*Transaction_NodeRegistrationTransactionBody)(nil), } } -func _Transaction_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*Transaction) - // TransactionBody - switch x := m.TransactionBody.(type) { - case *Transaction_EmptyTransactionBody: - b.EncodeVarint(15<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.EmptyTransactionBody); err != nil { - return err - } - case *Transaction_SendMoneyTransactionBody: - b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SendMoneyTransactionBody); err != nil { - return err - } - case *Transaction_NodeRegistrationTransactionBody: - b.EncodeVarint(17<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.NodeRegistrationTransactionBody); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("Transaction.TransactionBody has unexpected type %T", x) - } - return nil -} - -func _Transaction_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*Transaction) - switch tag { - case 15: // TransactionBody.emptyTransactionBody - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(EmptyTransactionBody) - err := b.DecodeMessage(msg) - m.TransactionBody = &Transaction_EmptyTransactionBody{msg} - return true, err - case 16: // TransactionBody.sendMoneyTransactionBody - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(SendMoneyTransactionBody) - err := b.DecodeMessage(msg) - m.TransactionBody = &Transaction_SendMoneyTransactionBody{msg} - return true, err - case 17: // TransactionBody.nodeRegistrationTransactionBody - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(NodeRegistrationTransactionBody) - err := b.DecodeMessage(msg) - m.TransactionBody = &Transaction_NodeRegistrationTransactionBody{msg} - return true, err - default: - return false, nil - } -} - -func _Transaction_OneofSizer(msg proto.Message) (n int) { - m := msg.(*Transaction) - // TransactionBody - switch x := m.TransactionBody.(type) { - case *Transaction_EmptyTransactionBody: - s := proto.Size(x.EmptyTransactionBody) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *Transaction_SendMoneyTransactionBody: - s := proto.Size(x.SendMoneyTransactionBody) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *Transaction_NodeRegistrationTransactionBody: - s := proto.Size(x.NodeRegistrationTransactionBody) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type EmptyTransactionBody struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -329,16 +248,17 @@ func (m *EmptyTransactionBody) Reset() { *m = EmptyTransactionBody{} } func (m *EmptyTransactionBody) String() string { return proto.CompactTextString(m) } func (*EmptyTransactionBody) ProtoMessage() {} func (*EmptyTransactionBody) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{1} + return fileDescriptor_8333001f09b34082, []int{1} } + func (m *EmptyTransactionBody) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_EmptyTransactionBody.Unmarshal(m, b) } func (m *EmptyTransactionBody) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_EmptyTransactionBody.Marshal(b, m, deterministic) } -func (dst *EmptyTransactionBody) XXX_Merge(src proto.Message) { - xxx_messageInfo_EmptyTransactionBody.Merge(dst, src) +func (m *EmptyTransactionBody) XXX_Merge(src proto.Message) { + xxx_messageInfo_EmptyTransactionBody.Merge(m, src) } func (m *EmptyTransactionBody) XXX_Size() int { return xxx_messageInfo_EmptyTransactionBody.Size(m) @@ -360,16 +280,17 @@ func (m *SendMoneyTransactionBody) Reset() { *m = SendMoneyTransactionBo func (m *SendMoneyTransactionBody) String() string { return proto.CompactTextString(m) } func (*SendMoneyTransactionBody) ProtoMessage() {} func (*SendMoneyTransactionBody) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{2} + return fileDescriptor_8333001f09b34082, []int{2} } + func (m *SendMoneyTransactionBody) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SendMoneyTransactionBody.Unmarshal(m, b) } func (m *SendMoneyTransactionBody) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_SendMoneyTransactionBody.Marshal(b, m, deterministic) } -func (dst *SendMoneyTransactionBody) XXX_Merge(src proto.Message) { - xxx_messageInfo_SendMoneyTransactionBody.Merge(dst, src) +func (m *SendMoneyTransactionBody) XXX_Merge(src proto.Message) { + xxx_messageInfo_SendMoneyTransactionBody.Merge(m, src) } func (m *SendMoneyTransactionBody) XXX_Size() int { return xxx_messageInfo_SendMoneyTransactionBody.Size(m) @@ -405,16 +326,17 @@ func (m *NodeRegistrationTransactionBody) Reset() { *m = NodeRegistratio func (m *NodeRegistrationTransactionBody) String() string { return proto.CompactTextString(m) } func (*NodeRegistrationTransactionBody) ProtoMessage() {} func (*NodeRegistrationTransactionBody) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{3} + return fileDescriptor_8333001f09b34082, []int{3} } + func (m *NodeRegistrationTransactionBody) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_NodeRegistrationTransactionBody.Unmarshal(m, b) } func (m *NodeRegistrationTransactionBody) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_NodeRegistrationTransactionBody.Marshal(b, m, deterministic) } -func (dst *NodeRegistrationTransactionBody) XXX_Merge(src proto.Message) { - xxx_messageInfo_NodeRegistrationTransactionBody.Merge(dst, src) +func (m *NodeRegistrationTransactionBody) XXX_Merge(src proto.Message) { + xxx_messageInfo_NodeRegistrationTransactionBody.Merge(m, src) } func (m *NodeRegistrationTransactionBody) XXX_Size() int { return xxx_messageInfo_NodeRegistrationTransactionBody.Size(m) @@ -481,13 +403,10 @@ func (m *NodeRegistrationTransactionBody) GetPoown() *ProofOfOwnership { return nil } -// TODO: shall we move this to a different file? +//TODO: shall we move this to a different file? type ProofOfOwnership struct { - AccountType uint32 `protobuf:"varint,1,opt,name=AccountType,proto3" json:"AccountType,omitempty"` - AccountAddress string `protobuf:"bytes,2,opt,name=AccountAddress,proto3" json:"AccountAddress,omitempty"` - BlockHash []byte `protobuf:"bytes,3,opt,name=blockHash,proto3" json:"blockHash,omitempty"` - BlockHeight uint32 `protobuf:"varint,4,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"` - Signature []byte `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` + MessageBytes []byte `protobuf:"bytes,1,opt,name=MessageBytes,proto3" json:"MessageBytes,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=Signature,proto3" json:"Signature,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -497,16 +416,17 @@ func (m *ProofOfOwnership) Reset() { *m = ProofOfOwnership{} } func (m *ProofOfOwnership) String() string { return proto.CompactTextString(m) } func (*ProofOfOwnership) ProtoMessage() {} func (*ProofOfOwnership) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{4} + return fileDescriptor_8333001f09b34082, []int{4} } + func (m *ProofOfOwnership) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ProofOfOwnership.Unmarshal(m, b) } func (m *ProofOfOwnership) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_ProofOfOwnership.Marshal(b, m, deterministic) } -func (dst *ProofOfOwnership) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProofOfOwnership.Merge(dst, src) +func (m *ProofOfOwnership) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProofOfOwnership.Merge(m, src) } func (m *ProofOfOwnership) XXX_Size() int { return xxx_messageInfo_ProofOfOwnership.Size(m) @@ -517,41 +437,84 @@ func (m *ProofOfOwnership) XXX_DiscardUnknown() { var xxx_messageInfo_ProofOfOwnership proto.InternalMessageInfo -func (m *ProofOfOwnership) GetAccountType() uint32 { +func (m *ProofOfOwnership) GetMessageBytes() []byte { + if m != nil { + return m.MessageBytes + } + return nil +} + +func (m *ProofOfOwnership) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +//TODO: shall we move this to a different file? +type ProofOfOwnershipMessage struct { + AccountType uint32 `protobuf:"varint,1,opt,name=AccountType,proto3" json:"AccountType,omitempty"` + AccountAddress string `protobuf:"bytes,2,opt,name=AccountAddress,proto3" json:"AccountAddress,omitempty"` + BlockHash []byte `protobuf:"bytes,3,opt,name=BlockHash,proto3" json:"BlockHash,omitempty"` + BlockHeight uint32 `protobuf:"varint,4,opt,name=BlockHeight,proto3" json:"BlockHeight,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ProofOfOwnershipMessage) Reset() { *m = ProofOfOwnershipMessage{} } +func (m *ProofOfOwnershipMessage) String() string { return proto.CompactTextString(m) } +func (*ProofOfOwnershipMessage) ProtoMessage() {} +func (*ProofOfOwnershipMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_8333001f09b34082, []int{5} +} + +func (m *ProofOfOwnershipMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ProofOfOwnershipMessage.Unmarshal(m, b) +} +func (m *ProofOfOwnershipMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ProofOfOwnershipMessage.Marshal(b, m, deterministic) +} +func (m *ProofOfOwnershipMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProofOfOwnershipMessage.Merge(m, src) +} +func (m *ProofOfOwnershipMessage) XXX_Size() int { + return xxx_messageInfo_ProofOfOwnershipMessage.Size(m) +} +func (m *ProofOfOwnershipMessage) XXX_DiscardUnknown() { + xxx_messageInfo_ProofOfOwnershipMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_ProofOfOwnershipMessage proto.InternalMessageInfo + +func (m *ProofOfOwnershipMessage) GetAccountType() uint32 { if m != nil { return m.AccountType } return 0 } -func (m *ProofOfOwnership) GetAccountAddress() string { +func (m *ProofOfOwnershipMessage) GetAccountAddress() string { if m != nil { return m.AccountAddress } return "" } -func (m *ProofOfOwnership) GetBlockHash() []byte { +func (m *ProofOfOwnershipMessage) GetBlockHash() []byte { if m != nil { return m.BlockHash } return nil } -func (m *ProofOfOwnership) GetBlockHeight() uint32 { +func (m *ProofOfOwnershipMessage) GetBlockHeight() uint32 { if m != nil { return m.BlockHeight } return 0 } -func (m *ProofOfOwnership) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - type GetTransactionRequest struct { // Fetch Transaction by its ID ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` @@ -564,16 +527,17 @@ func (m *GetTransactionRequest) Reset() { *m = GetTransactionRequest{} } func (m *GetTransactionRequest) String() string { return proto.CompactTextString(m) } func (*GetTransactionRequest) ProtoMessage() {} func (*GetTransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{5} + return fileDescriptor_8333001f09b34082, []int{6} } + func (m *GetTransactionRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetTransactionRequest.Unmarshal(m, b) } func (m *GetTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_GetTransactionRequest.Marshal(b, m, deterministic) } -func (dst *GetTransactionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetTransactionRequest.Merge(dst, src) +func (m *GetTransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTransactionRequest.Merge(m, src) } func (m *GetTransactionRequest) XXX_Size() int { return xxx_messageInfo_GetTransactionRequest.Size(m) @@ -605,16 +569,17 @@ func (m *GetTransactionsRequest) Reset() { *m = GetTransactionsRequest{} func (m *GetTransactionsRequest) String() string { return proto.CompactTextString(m) } func (*GetTransactionsRequest) ProtoMessage() {} func (*GetTransactionsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{6} + return fileDescriptor_8333001f09b34082, []int{7} } + func (m *GetTransactionsRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetTransactionsRequest.Unmarshal(m, b) } func (m *GetTransactionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_GetTransactionsRequest.Marshal(b, m, deterministic) } -func (dst *GetTransactionsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetTransactionsRequest.Merge(dst, src) +func (m *GetTransactionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTransactionsRequest.Merge(m, src) } func (m *GetTransactionsRequest) XXX_Size() int { return xxx_messageInfo_GetTransactionsRequest.Size(m) @@ -651,16 +616,17 @@ func (m *PostTransactionRequest) Reset() { *m = PostTransactionRequest{} func (m *PostTransactionRequest) String() string { return proto.CompactTextString(m) } func (*PostTransactionRequest) ProtoMessage() {} func (*PostTransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{7} + return fileDescriptor_8333001f09b34082, []int{8} } + func (m *PostTransactionRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PostTransactionRequest.Unmarshal(m, b) } func (m *PostTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_PostTransactionRequest.Marshal(b, m, deterministic) } -func (dst *PostTransactionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PostTransactionRequest.Merge(dst, src) +func (m *PostTransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_PostTransactionRequest.Merge(m, src) } func (m *PostTransactionRequest) XXX_Size() int { return xxx_messageInfo_PostTransactionRequest.Size(m) @@ -689,16 +655,17 @@ func (m *PostTransactionResponse) Reset() { *m = PostTransactionResponse func (m *PostTransactionResponse) String() string { return proto.CompactTextString(m) } func (*PostTransactionResponse) ProtoMessage() {} func (*PostTransactionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{8} + return fileDescriptor_8333001f09b34082, []int{9} } + func (m *PostTransactionResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PostTransactionResponse.Unmarshal(m, b) } func (m *PostTransactionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_PostTransactionResponse.Marshal(b, m, deterministic) } -func (dst *PostTransactionResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PostTransactionResponse.Merge(dst, src) +func (m *PostTransactionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PostTransactionResponse.Merge(m, src) } func (m *PostTransactionResponse) XXX_Size() int { return xxx_messageInfo_PostTransactionResponse.Size(m) @@ -732,16 +699,17 @@ func (m *GetTransactionsResponse) Reset() { *m = GetTransactionsResponse func (m *GetTransactionsResponse) String() string { return proto.CompactTextString(m) } func (*GetTransactionsResponse) ProtoMessage() {} func (*GetTransactionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{9} + return fileDescriptor_8333001f09b34082, []int{10} } + func (m *GetTransactionsResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetTransactionsResponse.Unmarshal(m, b) } func (m *GetTransactionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_GetTransactionsResponse.Marshal(b, m, deterministic) } -func (dst *GetTransactionsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetTransactionsResponse.Merge(dst, src) +func (m *GetTransactionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTransactionsResponse.Merge(m, src) } func (m *GetTransactionsResponse) XXX_Size() int { return xxx_messageInfo_GetTransactionsResponse.Size(m) @@ -785,16 +753,17 @@ func (m *SendTransactionRequest) Reset() { *m = SendTransactionRequest{} func (m *SendTransactionRequest) String() string { return proto.CompactTextString(m) } func (*SendTransactionRequest) ProtoMessage() {} func (*SendTransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{10} + return fileDescriptor_8333001f09b34082, []int{11} } + func (m *SendTransactionRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SendTransactionRequest.Unmarshal(m, b) } func (m *SendTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_SendTransactionRequest.Marshal(b, m, deterministic) } -func (dst *SendTransactionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SendTransactionRequest.Merge(dst, src) +func (m *SendTransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SendTransactionRequest.Merge(m, src) } func (m *SendTransactionRequest) XXX_Size() int { return xxx_messageInfo_SendTransactionRequest.Size(m) @@ -826,16 +795,17 @@ func (m *PostUnconfirmedTransactionRequest) Reset() { *m = PostUnconfirm func (m *PostUnconfirmedTransactionRequest) String() string { return proto.CompactTextString(m) } func (*PostUnconfirmedTransactionRequest) ProtoMessage() {} func (*PostUnconfirmedTransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_transaction_2fccaf44500e9457, []int{11} + return fileDescriptor_8333001f09b34082, []int{12} } + func (m *PostUnconfirmedTransactionRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PostUnconfirmedTransactionRequest.Unmarshal(m, b) } func (m *PostUnconfirmedTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_PostUnconfirmedTransactionRequest.Marshal(b, m, deterministic) } -func (dst *PostUnconfirmedTransactionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PostUnconfirmedTransactionRequest.Merge(dst, src) +func (m *PostUnconfirmedTransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_PostUnconfirmedTransactionRequest.Merge(m, src) } func (m *PostUnconfirmedTransactionRequest) XXX_Size() int { return xxx_messageInfo_PostUnconfirmedTransactionRequest.Size(m) @@ -873,6 +843,7 @@ func init() { proto.RegisterType((*SendMoneyTransactionBody)(nil), "model.SendMoneyTransactionBody") proto.RegisterType((*NodeRegistrationTransactionBody)(nil), "model.NodeRegistrationTransactionBody") proto.RegisterType((*ProofOfOwnership)(nil), "model.ProofOfOwnership") + proto.RegisterType((*ProofOfOwnershipMessage)(nil), "model.ProofOfOwnershipMessage") proto.RegisterType((*GetTransactionRequest)(nil), "model.GetTransactionRequest") proto.RegisterType((*GetTransactionsRequest)(nil), "model.GetTransactionsRequest") proto.RegisterType((*PostTransactionRequest)(nil), "model.PostTransactionRequest") @@ -882,62 +853,61 @@ func init() { proto.RegisterType((*PostUnconfirmedTransactionRequest)(nil), "model.PostUnconfirmedTransactionRequest") } -func init() { - proto.RegisterFile("model/transaction.proto", fileDescriptor_transaction_2fccaf44500e9457) -} - -var fileDescriptor_transaction_2fccaf44500e9457 = []byte{ - // 825 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xef, 0x6e, 0xe3, 0x44, - 0x10, 0xaf, 0xe3, 0xa6, 0x47, 0x27, 0x6d, 0xaf, 0x5d, 0xe5, 0x9a, 0x95, 0x38, 0xd1, 0x60, 0xa1, - 0x23, 0x3a, 0x71, 0x89, 0x14, 0x4e, 0x88, 0xaf, 0x09, 0xa1, 0xa4, 0xa2, 0x90, 0xb0, 0x0d, 0x7c, - 0x40, 0xe2, 0x83, 0x63, 0x4f, 0x12, 0xeb, 0xe2, 0xdd, 0xe0, 0xdd, 0x70, 0x0a, 0x12, 0x8f, 0xc3, - 0x4b, 0xf0, 0x40, 0x3c, 0x06, 0x42, 0xbb, 0x76, 0x9a, 0xb5, 0xe3, 0x70, 0x08, 0xbe, 0x54, 0x9d, - 0xdf, 0xcc, 0xfc, 0xe6, 0xcf, 0xce, 0x4c, 0x0c, 0x8d, 0x58, 0x84, 0xb8, 0xec, 0xa8, 0xc4, 0xe7, - 0xd2, 0x0f, 0x54, 0x24, 0x78, 0x7b, 0x95, 0x08, 0x25, 0x48, 0xd5, 0x28, 0xbc, 0xbf, 0x4e, 0xa0, - 0x36, 0xd9, 0x29, 0x09, 0x85, 0x27, 0x3f, 0x60, 0x22, 0x23, 0xc1, 0xa9, 0xd3, 0x74, 0x5a, 0xe7, - 0x6c, 0x2b, 0x92, 0x0b, 0xa8, 0xdc, 0x0d, 0x68, 0xa5, 0xe9, 0xb4, 0x5c, 0x56, 0xb9, 0x1b, 0x68, - 0xcb, 0xfe, 0x52, 0x04, 0x6f, 0xee, 0x06, 0xd4, 0x35, 0xe0, 0x56, 0x24, 0xd7, 0x70, 0x32, 0xc4, - 0x68, 0xbe, 0x50, 0xf4, 0xd8, 0x50, 0x64, 0x12, 0xf9, 0x04, 0xae, 0x1e, 0x90, 0x87, 0x98, 0xf4, - 0x82, 0x40, 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, 0xba, 0x2b, 0x7a, 0xc1, 0xff, 0x67, 0x57, 0x7e, 0x77, 0xe0, 0x43, 0xdd, 0x96, 0xef, - 0x79, 0x20, 0xf8, 0x2c, 0x4a, 0x62, 0x2c, 0x63, 0xfc, 0x4f, 0x0d, 0xd2, 0x79, 0xf4, 0x92, 0x24, - 0xfa, 0xc5, 0x5f, 0xee, 0x7e, 0xaa, 0xd2, 0xd2, 0xf7, 0x70, 0xf2, 0x01, 0xc0, 0x2d, 0xe2, 0x18, - 0x13, 0x9d, 0x56, 0xf6, 0x41, 0x60, 0x21, 0xfd, 0x97, 0x3f, 0xb6, 0xe6, 0x91, 0x5a, 0xac, 0xa7, - 0xed, 0x40, 0xc4, 0x9d, 0x5f, 0x85, 0x98, 0x06, 0xe9, 0xdf, 0x57, 0x81, 0x48, 0xb0, 0x13, 0x88, - 0x38, 0x16, 0xbc, 0x63, 0x12, 0x9a, 0x9e, 0x98, 0x2f, 0x94, 0x4f, 0xff, 0x0e, 0x00, 0x00, 0xff, - 0xff, 0xf5, 0x62, 0xd7, 0x26, 0xbc, 0x08, 0x00, 0x00, +func init() { proto.RegisterFile("model/transaction.proto", fileDescriptor_8333001f09b34082) } + +var fileDescriptor_8333001f09b34082 = []byte{ + // 838 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x5f, 0x6f, 0xe3, 0x44, + 0x10, 0xaf, 0xe3, 0xa6, 0x47, 0x27, 0x69, 0xaf, 0x5d, 0xe5, 0x9a, 0x95, 0x38, 0xd1, 0x60, 0xa1, + 0x23, 0x3a, 0x71, 0xa9, 0x14, 0x4e, 0x88, 0xd7, 0x86, 0x52, 0x52, 0xd1, 0xa3, 0x61, 0x1b, 0x78, + 0x40, 0xe2, 0xc1, 0xb5, 0x27, 0x89, 0x75, 0xf1, 0x6e, 0xf0, 0x6e, 0x38, 0x05, 0x89, 0x4f, 0x83, + 0xf8,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 0xa7, 0x89, 0x9a, 0x2d, 0x1f, 0x7a, 0x91, 0x48, 0x2f, + 0x7e, 0x11, 0xe2, 0x21, 0xca, 0x7f, 0x5f, 0x45, 0x22, 0xc3, 0x8b, 0x48, 0xa4, 0xa9, 0xe0, 0x17, + 0x26, 0xa0, 0x87, 0x03, 0xf3, 0x81, 0xf3, 0xe9, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x18, 0xc1, + 0x98, 0x32, 0xfb, 0x08, 0x00, 0x00, } diff --git a/common/schema b/common/schema index b7b68e538..f6b5ee61f 160000 --- a/common/schema +++ b/common/schema @@ -1 +1 @@ -Subproject commit b7b68e538eaca1b4f4e33543afe0e8182cf43f9c +Subproject commit f6b5ee61f98a26c1b022a088342f62b6720eee3b diff --git a/common/service/transaction.pb.go b/common/service/transaction.pb.go index 0077b3ca8..d0d0201f5 100644 --- a/common/service/transaction.pb.go +++ b/common/service/transaction.pb.go @@ -1,17 +1,18 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: service/transaction.proto -package service // import "github.com/zoobc/zoobc-core/common/service" - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" -import model "github.com/zoobc/zoobc-core/common/model" -import _ "google.golang.org/genproto/googleapis/api/annotations" +package service import ( - context "golang.org/x/net/context" + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + model "github.com/zoobc/zoobc-core/common/model" + _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. @@ -23,7 +24,29 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("service/transaction.proto", fileDescriptor_e672968ede58c6fc) } + +var fileDescriptor_e672968ede58c6fc = []byte{ + // 245 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x4e, 0x2d, 0x2a, + 0xcb, 0x4c, 0x4e, 0xd5, 0x2f, 0x29, 0x4a, 0xcc, 0x2b, 0x4e, 0x4c, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x4a, 0x49, 0x89, 0xe7, 0xe6, 0xa7, 0xa4, 0xe6, + 0x60, 0xaa, 0x90, 0x92, 0x49, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x4f, 0x2c, 0xc8, 0xd4, 0x4f, + 0xcc, 0xcb, 0xcb, 0x2f, 0x49, 0x04, 0x49, 0x16, 0x43, 0x64, 0x8d, 0xbe, 0x31, 0x71, 0x09, 0x85, + 0x20, 0xf4, 0x04, 0x43, 0x4c, 0x13, 0xaa, 0xe4, 0xe2, 0x77, 0x4f, 0x2d, 0x41, 0x92, 0x28, 0x16, + 0x92, 0xd5, 0x03, 0xdb, 0xa0, 0x87, 0x26, 0x1e, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0x22, 0x25, + 0x87, 0x4b, 0xba, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0x49, 0xbd, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, + 0x8a, 0x42, 0xf2, 0xfa, 0x65, 0x86, 0xc8, 0xae, 0xd4, 0x47, 0xb7, 0x27, 0x8b, 0x8b, 0x0f, 0x55, + 0x48, 0x48, 0x06, 0xab, 0xd1, 0x30, 0x8b, 0x85, 0xa0, 0xb2, 0x48, 0x52, 0x4a, 0x6a, 0x60, 0xcb, + 0x14, 0x84, 0xe4, 0xf0, 0x5b, 0x06, 0xf2, 0x66, 0x40, 0x7e, 0x31, 0x8a, 0x10, 0xcc, 0x9b, 0x68, + 0xe2, 0xe8, 0xde, 0xc4, 0x90, 0x46, 0xf5, 0xa6, 0x12, 0x86, 0x37, 0xd1, 0x34, 0x38, 0xe9, 0x44, + 0x69, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x57, 0xe5, 0xe7, 0x27, + 0x25, 0x43, 0x48, 0xdd, 0xe4, 0xfc, 0xa2, 0x54, 0xfd, 0xe4, 0xfc, 0xdc, 0xdc, 0xfc, 0x3c, 0x7d, + 0x68, 0xec, 0x26, 0xb1, 0x81, 0x63, 0xcb, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x9a, 0x04, 0xcf, + 0x12, 0x0a, 0x02, 0x00, 0x00, +} // Reference imports to suppress errors if they are not otherwise used. var _ context.Context @@ -84,6 +107,20 @@ type TransactionServiceServer interface { PostTransaction(context.Context, *model.PostTransactionRequest) (*model.PostTransactionResponse, error) } +// UnimplementedTransactionServiceServer can be embedded to have forward compatible implementations. +type UnimplementedTransactionServiceServer struct { +} + +func (*UnimplementedTransactionServiceServer) GetTransactions(ctx context.Context, req *model.GetTransactionsRequest) (*model.GetTransactionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTransactions not implemented") +} +func (*UnimplementedTransactionServiceServer) GetTransaction(ctx context.Context, req *model.GetTransactionRequest) (*model.Transaction, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTransaction not implemented") +} +func (*UnimplementedTransactionServiceServer) PostTransaction(ctx context.Context, req *model.PostTransactionRequest) (*model.PostTransactionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PostTransaction not implemented") +} + func RegisterTransactionServiceServer(s *grpc.Server, srv TransactionServiceServer) { s.RegisterService(&_TransactionService_serviceDesc, srv) } @@ -162,27 +199,3 @@ var _TransactionService_serviceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "service/transaction.proto", } - -func init() { - proto.RegisterFile("service/transaction.proto", fileDescriptor_transaction_0e75a8e7f913159d) -} - -var fileDescriptor_transaction_0e75a8e7f913159d = []byte{ - // 245 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x4e, 0x2d, 0x2a, - 0xcb, 0x4c, 0x4e, 0xd5, 0x2f, 0x29, 0x4a, 0xcc, 0x2b, 0x4e, 0x4c, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x4a, 0x49, 0x89, 0xe7, 0xe6, 0xa7, 0xa4, 0xe6, - 0x60, 0xaa, 0x90, 0x92, 0x49, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x4f, 0x2c, 0xc8, 0xd4, 0x4f, - 0xcc, 0xcb, 0xcb, 0x2f, 0x49, 0x04, 0x49, 0x16, 0x43, 0x64, 0x8d, 0xbe, 0x31, 0x71, 0x09, 0x85, - 0x20, 0xf4, 0x04, 0x43, 0x4c, 0x13, 0xaa, 0xe4, 0xe2, 0x77, 0x4f, 0x2d, 0x41, 0x92, 0x28, 0x16, - 0x92, 0xd5, 0x03, 0xdb, 0xa0, 0x87, 0x26, 0x1e, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0x22, 0x25, - 0x87, 0x4b, 0xba, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0x49, 0xbd, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, - 0x8a, 0x42, 0xf2, 0xfa, 0x65, 0x86, 0xc8, 0xae, 0xd4, 0x47, 0xb7, 0x27, 0x8b, 0x8b, 0x0f, 0x55, - 0x48, 0x48, 0x06, 0xab, 0xd1, 0x30, 0x8b, 0x85, 0xa0, 0xb2, 0x48, 0x52, 0x4a, 0x6a, 0x60, 0xcb, - 0x14, 0x84, 0xe4, 0xf0, 0x5b, 0x06, 0xf2, 0x66, 0x40, 0x7e, 0x31, 0x8a, 0x10, 0xcc, 0x9b, 0x68, - 0xe2, 0xe8, 0xde, 0xc4, 0x90, 0x46, 0xf5, 0xa6, 0x12, 0x86, 0x37, 0xd1, 0x34, 0x38, 0xe9, 0x44, - 0x69, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x57, 0xe5, 0xe7, 0x27, - 0x25, 0x43, 0x48, 0xdd, 0xe4, 0xfc, 0xa2, 0x54, 0xfd, 0xe4, 0xfc, 0xdc, 0xdc, 0xfc, 0x3c, 0x7d, - 0x68, 0xec, 0x26, 0xb1, 0x81, 0x63, 0xcb, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x9a, 0x04, 0xcf, - 0x12, 0x0a, 0x02, 0x00, 0x00, -} diff --git a/common/service/transaction.pb.gw.go b/common/service/transaction.pb.gw.go index 8a96103c1..31cce4ea4 100644 --- a/common/service/transaction.pb.gw.go +++ b/common/service/transaction.pb.gw.go @@ -37,7 +37,10 @@ func request_TransactionService_GetTransactions_0(ctx context.Context, marshaler var protoReq model.GetTransactionsRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_TransactionService_GetTransactions_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TransactionService_GetTransactions_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -54,7 +57,10 @@ func request_TransactionService_GetTransaction_0(ctx context.Context, marshaler var protoReq model.GetTransactionRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_TransactionService_GetTransaction_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TransactionService_GetTransaction_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -71,7 +77,10 @@ func request_TransactionService_PostTransaction_0(ctx context.Context, marshaler var protoReq model.PostTransactionRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_TransactionService_PostTransaction_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TransactionService_PostTransaction_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -182,11 +191,11 @@ func RegisterTransactionServiceHandlerClient(ctx context.Context, mux *runtime.S } var ( - pattern_TransactionService_GetTransactions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "transaction", "GetTransactions"}, "")) + pattern_TransactionService_GetTransactions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "transaction", "GetTransactions"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_TransactionService_GetTransaction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "transaction", "GetTransaction"}, "")) + pattern_TransactionService_GetTransaction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "transaction", "GetTransaction"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_TransactionService_PostTransaction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "transaction", "PostTransaction"}, "")) + pattern_TransactionService_PostTransaction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "transaction", "PostTransaction"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/common/transaction/nodeRegistration.go b/common/transaction/nodeRegistration.go index 09d241b4c..74d0ba789 100644 --- a/common/transaction/nodeRegistration.go +++ b/common/transaction/nodeRegistration.go @@ -167,10 +167,10 @@ func (tx *NodeRegistration) GetAmount() int64 { func (tx *NodeRegistration) GetSize() uint32 { nodePublicKey := 32 - accountType := 2 + accountType := 4 //TODO: this is valid for account type = 0 accountAddress := 44 - nodeAddressLength := 1 + nodeAddressLength := 4 nodeAddress := len([]byte(tx.Body.NodeAddress)) lockedBalance := 8 return uint32(nodePublicKey + accountType + nodeAddressLength + accountAddress + nodeAddress + lockedBalance) diff --git a/common/transaction/nodeRegistration_test.go b/common/transaction/nodeRegistration_test.go index 4d2a38942..fe8d5a4e9 100644 --- a/common/transaction/nodeRegistration_test.go +++ b/common/transaction/nodeRegistration_test.go @@ -645,7 +645,7 @@ func TestNodeRegistration_GetSize(t *testing.T) { NodeAddress: "127.0.0.1", }, }, - want: 96, + want: 101, }, } for _, tt := range tests { diff --git a/core/service/blockCoreService.go b/core/service/blockCoreService.go index 797c71e07..9ea773be3 100644 --- a/core/service/blockCoreService.go +++ b/core/service/blockCoreService.go @@ -41,6 +41,7 @@ type ( ) (*model.Block, error) PushBlock(previousBlock, block *model.Block) error GetLastBlock() (*model.Block, error) + GetBlockByHeight(height uint32) (*model.Block, error) GetBlocks() ([]*model.Block, error) GetGenesisBlock() (*model.Block, error) RemoveMempoolTransactions(transactions []*model.Transaction) error @@ -121,7 +122,7 @@ func (bs *BlockService) NewBlock( PayloadLength: payloadLength, } blockUnsignedByte, _ := coreUtil.GetBlockByte(block, false) - block.BlockSignature = bs.Signature.SignBlock(blockUnsignedByte, secretPhrase) + block.BlockSignature = bs.Signature.SignByNode(blockUnsignedByte, secretPhrase) return block } @@ -253,6 +254,30 @@ func (bs *BlockService) GetLastBlock() (*model.Block, error) { } +// GetLastBlock return the last pushed block +func (bs *BlockService) GetBlockByHeight(height uint32) (*model.Block, error) { + rows, err := bs.QueryExecutor.ExecuteSelect(bs.BlockQuery.GetBlockByHeight(height)) + defer func() { + if rows != nil { + _ = rows.Close() + } + }() + if err != nil { + return &model.Block{ + ID: -1, + }, err + } + var blocks []*model.Block + blocks = bs.BlockQuery.BuildModel(blocks, rows) + if len(blocks) > 0 { + return blocks[0], nil + } + return &model.Block{ + ID: -1, + }, errors.New("BlockNotFound") + +} + // GetGenesis return the last pushed block func (bs *BlockService) GetGenesisBlock() (*model.Block, error) { rows, err := bs.QueryExecutor.ExecuteSelect(bs.BlockQuery.GetGenesisBlock()) diff --git a/core/service/blockCoreService_test.go b/core/service/blockCoreService_test.go index ed863541f..6de56b0b4 100644 --- a/core/service/blockCoreService_test.go +++ b/core/service/blockCoreService_test.go @@ -57,7 +57,7 @@ func (*mockTypeActionSuccess) GetTransactionType(tx *model.Transaction) transact } // mockSignature -func (*mockSignature) SignBlock(payload []byte, nodeSeed string) []byte { +func (*mockSignature) SignByNode(payload []byte, nodeSeed string) []byte { return []byte{} } func (*mockSignature) VerifySignature( @@ -116,6 +116,13 @@ func (*mockQueryExecutorSuccess) ExecuteSelect(qe string, args ...interface{}) ( db, mock, _ := sqlmock.New() defer db.Close() switch qe { + case "SELECT id, previous_block_hash, height, timestamp, block_seed, block_signature, cumulative_difficulty, smith_scale, " + + "payload_length, payload_hash, blocksmith_id, total_amount, total_fee, total_coinbase, version FROM main_block WHERE height = 0": + mock.ExpectQuery(regexp.QuoteMeta(qe)).WillReturnRows(sqlmock.NewRows([]string{ + "ID", "PreviousBlockHash", "Height", "Timestamp", "BlockSeed", "BlockSignature", "CumulativeDifficulty", + "SmithScale", "PayloadLength", "PayloadHash", "BlocksmithID", "TotalAmount", "TotalFee", "TotalCoinBase", + "Version"}, + ).AddRow(1, []byte{}, 1, 10000, []byte{}, []byte{}, "", 1, 2, []byte{}, []byte{}, 0, 0, 0, 1)) case "SELECT id, previous_block_hash, height, timestamp, block_seed, block_signature, cumulative_difficulty, smith_scale, " + "payload_length, payload_hash, blocksmith_id, total_amount, total_fee, total_coinbase, version FROM main_block ORDER BY " + "height DESC LIMIT 1": @@ -1596,3 +1603,91 @@ func TestBlockService_ReceivedBlockListener(t *testing.T) { func testOnNotify(fn observer.OnNotify, block *model.Block) { fn(block, nil) } + +func TestBlockService_GetBlockByHeight(t *testing.T) { + type fields struct { + Chaintype contract.ChainType + QueryExecutor query.ExecutorInterface + BlockQuery query.BlockQueryInterface + MempoolQuery query.MempoolQueryInterface + TransactionQuery query.TransactionQueryInterface + Signature crypto.SignatureInterface + MempoolService MempoolServiceInterface + ActionTypeSwitcher transaction.TypeActionSwitcher + AccountBalanceQuery query.AccountBalanceQueryInterface + Observer *observer.Observer + } + type args struct { + height uint32 + } + tests := []struct { + name string + fields fields + args args + want *model.Block + wantErr bool + }{ + { + name: "GetBlockByHeight:Success", // All is good + fields: fields{ + Chaintype: &chaintype.MainChain{}, + QueryExecutor: &mockQueryExecutorSuccess{}, + BlockQuery: query.NewBlockQuery(&chaintype.MainChain{}), + }, + want: &model.Block{ + ID: 1, + PreviousBlockHash: []byte{}, + Height: 1, + Timestamp: 10000, + BlockSeed: []byte{}, + BlockSignature: []byte{}, + CumulativeDifficulty: "", + SmithScale: 1, + PayloadLength: 2, + PayloadHash: []byte{}, + BlocksmithID: []byte{}, + TotalAmount: 0, + TotalFee: 0, + TotalCoinBase: 0, + Version: 1, + }, + wantErr: false, + }, + { + name: "GetBlockByHeight:FailNoEntryFound", // All is good + fields: fields{ + Chaintype: &chaintype.MainChain{}, + QueryExecutor: &mockQueryExecutorFail{}, + BlockQuery: query.NewBlockQuery(&chaintype.MainChain{}), + }, + want: &model.Block{ + ID: -1, + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + bs := &BlockService{ + Chaintype: tt.fields.Chaintype, + QueryExecutor: tt.fields.QueryExecutor, + BlockQuery: tt.fields.BlockQuery, + MempoolQuery: tt.fields.MempoolQuery, + TransactionQuery: tt.fields.TransactionQuery, + Signature: tt.fields.Signature, + MempoolService: tt.fields.MempoolService, + ActionTypeSwitcher: tt.fields.ActionTypeSwitcher, + AccountBalanceQuery: tt.fields.AccountBalanceQuery, + Observer: tt.fields.Observer, + } + got, err := bs.GetBlockByHeight(tt.args.height) + if (err != nil) != tt.wantErr { + t.Errorf("BlockService.GetBlockByHeight() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("BlockService.GetBlockByHeight() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/core/service/nodeAdminCoreService.go b/core/service/nodeAdminCoreService.go new file mode 100644 index 000000000..2d0140a36 --- /dev/null +++ b/core/service/nodeAdminCoreService.go @@ -0,0 +1,160 @@ +package service + +import ( + "bytes" + "errors" + + proto "github.com/golang/protobuf/proto" + log "github.com/sirupsen/logrus" + "github.com/spf13/viper" + "github.com/zoobc/zoobc-core/common/constant" + "github.com/zoobc/zoobc-core/common/crypto" + "github.com/zoobc/zoobc-core/common/model" + "github.com/zoobc/zoobc-core/common/query" + "github.com/zoobc/zoobc-core/core/util" +) + +type ( + // NodeAdminServiceInterface represents interface for NodeAdminService + NodeAdminServiceInterface interface { + GenerateProofOfOwnership(accountType uint32, accountAddress string, signature []byte) (*model.ProofOfOwnership, error) + ValidateProofOfOwnership(poown *model.ProofOfOwnership, nodePublicKey []byte) + } + + // NodeAdminServiceHelpersInterface mockable service methods + NodeAdminServiceHelpersInterface interface { + GetBytesFromMessage(poown *model.ProofOfOwnershipMessage) ([]byte, error) + ParseMessageBytes(messageBytes []byte) (*model.ProofOfOwnershipMessage, error) + // TODO: to be implemented: method to validate a request for a new proof of ownership, coming from the client + // ValidateProofOfOwnershipRequest(accountType uint32, accountAddress string, signature []byte) bool + } + + NodeAdminService struct { + QueryExecutor query.ExecutorInterface + BlockQuery query.BlockQueryInterface + AccountQuery query.AccountQueryInterface + Signature crypto.SignatureInterface + Helpers NodeAdminServiceHelpersInterface + BlockService BlockServiceInterface + } +) + +func NewNodeAdminService( + queryExecutor query.ExecutorInterface, + blockQuery query.BlockQueryInterface, + accountQuery query.AccountQueryInterface, + signature crypto.SignatureInterface, + helpers NodeAdminServiceHelpersInterface, + blockService BlockServiceInterface) *NodeAdminService { + return &NodeAdminService{ + queryExecutor, + blockQuery, + accountQuery, + signature, + helpers, + blockService, + } +} + +// GetMessageSize return the message size in bytes +// note: it can be used to validate a message +func (*NodeAdminService) GetMessageSize() uint32 { + accountType := 4 + //TODO: this is valid for account type = 0 + accountAddress := 44 + blockHash := 64 + blockHeight := 4 + return uint32(accountType + accountAddress + blockHash + blockHeight) +} + +// GetBytesFromMessage wrapper around proto.marshal function. returns the message's bytes +func (*NodeAdminService) GetBytesFromMessage(poown *model.ProofOfOwnershipMessage) ([]byte, error) { + b, err := proto.Marshal(poown) + if err != nil { + return nil, errors.New("InvalidPoownMessage") + } + return b, nil +} + +// GetBytesFromMessage wrapper around proto.marshal function. returns the message's bytes +func (nas *NodeAdminService) ParseMessageBytes(messageBytes []byte) (*model.ProofOfOwnershipMessage, error) { + message := new(model.ProofOfOwnershipMessage) + if err := proto.Unmarshal(messageBytes, message); err != nil { + return nil, errors.New("InvalidPoownMessageBytes") + } + return message, nil +} + +// generate proof of ownership +func (nas *NodeAdminService) GenerateProofOfOwnership(accountType uint32, + accountAddress string) (*model.ProofOfOwnership, error) { + + ownerAccountType := viper.GetUint32("ownerAccountType") + ownerAccountAddress := viper.GetString("ownerAccountAddress") + if ownerAccountAddress != accountAddress && ownerAccountType != accountType { + return nil, errors.New("PoownAccountNotNodeOwner") + } + + lastBlock, err := nas.BlockService.GetLastBlock() + if err != nil { + return nil, err + } + lastBlockHash, err := util.GetBlockHash(lastBlock) + if err != nil { + return nil, err + } + + poownMessage := &model.ProofOfOwnershipMessage{ + AccountType: accountType, + AccountAddress: accountAddress, + BlockHash: lastBlockHash, + BlockHeight: lastBlock.Height, + } + messageBytes, err := nas.Helpers.GetBytesFromMessage(poownMessage) + log.Println(messageBytes) + if err != nil { + return nil, err + } + nodeSecretPhrase := viper.GetString("nodeSecretPhrase") + poownSignature := crypto.NewSignature().SignByNode(messageBytes, nodeSecretPhrase) + return &model.ProofOfOwnership{ + MessageBytes: messageBytes, + Signature: poownSignature, + }, nil +} + +// ValidateProofOfOwnership validates a proof of ownership message +func (nas *NodeAdminService) ValidateProofOfOwnership(poown *model.ProofOfOwnership, nodePublicKey []byte) error { + + if !crypto.NewSignature().VerifyNodeSignature(poown.MessageBytes, poown.Signature, nodePublicKey) { + return errors.New("InvalidSignature") + } + + message, err := nas.Helpers.ParseMessageBytes(poown.MessageBytes) + if err != nil { + return err + } + + lastBlock, err := nas.BlockService.GetLastBlock() + if err != nil { + return err + } + + // Expiration, in number of blocks, of a proof of ownership message + if lastBlock.Height-message.BlockHeight > constant.ProofOfOwnershipExpiration { + return errors.New("ProofOfOwnershipExpired") + } + + poownBlockRef, err := nas.BlockService.GetBlockByHeight(message.BlockHeight) + if err != nil { + return err + } + poownBlockHashRef, err := util.GetBlockHash(poownBlockRef) + if err != nil { + return err + } + if !bytes.Equal(poownBlockHashRef, message.BlockHash) { + return errors.New("InvalidProofOfOwnershipBlockHash") + } + return nil +} diff --git a/core/service/nodeAdminCoreService_test.go b/core/service/nodeAdminCoreService_test.go new file mode 100644 index 000000000..cdc2e385c --- /dev/null +++ b/core/service/nodeAdminCoreService_test.go @@ -0,0 +1,137 @@ +package service + +import ( + "reflect" + "testing" + + "github.com/zoobc/zoobc-core/common/model" + commonUtil "github.com/zoobc/zoobc-core/common/util" +) + +type ( + spyNodeAdminCoreServiceHelper struct { + NodeAdminService + } + blockServiceMocked struct { + BlockService + } +) + +func (*blockServiceMocked) GetLastBlock() (*model.Block, error) { + return new(model.Block), nil +} + +func (*blockServiceMocked) GetBlockByHeight(height uint32) (*model.Block, error) { + return new(model.Block), nil +} + +func TestNodeAdminService_GenerateProofOfOwnership(t *testing.T) { + if err := commonUtil.LoadConfig("./resource", "config", "toml"); err != nil { + panic(err) + } + type fields struct { + Helpers NodeAdminServiceHelpersInterface + BlockService BlockServiceInterface + } + type args struct { + accountType uint32 + accountAddress string + } + tests := []struct { + name string + fields fields + args args + want *model.ProofOfOwnership + wantErr bool + }{ + { + name: "GenerateProofOfOwnership:Success", + fields: fields{ + Helpers: &spyNodeAdminCoreServiceHelper{}, + BlockService: &blockServiceMocked{}, + }, + args: args{ + accountType: 1, + accountAddress: "BCZEGOb3WNx3fDOVf9ZS4EjvOIv_UeW4TVBQJ_6tHKlE", + }, + want: &model.ProofOfOwnership{ + MessageBytes: []byte{8, 1, 18, 44, 66, 67, 90, 69, 71, 79, 98, 51, 87, 78, 120, 51, 102, 68, 79, 86, 102, 57, 90, 83, 52, 69, + 106, 118, 79, 73, 118, 95, 85, 101, 87, 52, 84, 86, 66, 81, 74, 95, 54, 116, 72, 75, 108, 69, 26, 64, 166, 159, 115, 204, + 162, 58, 154, 197, 200, 181, 103, 220, 24, 90, 117, 110, 151, 201, 130, 22, 79, 226, 88, 89, 224, 209, 220, 193, 71, 92, 128, + 166, 21, 178, 18, 58, 241, 245, 249, 76, 17, 227, 233, 64, 44, 58, 197, 88, 245, 0, 25, 157, 149, 182, 211, 227, 1, 117, 133, + 134, 40, 29, 205, 38}, + Signature: []byte{156, 114, 29, 63, 218, 45, 128, 0, 15, 148, 102, 248, 215, 237, 93, 241, 87, 188, 65, 94, 74, + 181, 85, 195, 131, 214, 109, 192, 81, 171, 210, 24, 14, 200, 53, 58, 193, 24, 252, 225, 149, 135, 223, 66, 122, 125, 147, + 213, 223, 105, 100, 83, 102, 46, 106, 144, 116, 58, 228, 191, 53, 225, 215, 15}, + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + nas := &NodeAdminService{ + Helpers: tt.fields.Helpers, + BlockService: tt.fields.BlockService, + } + got, err := nas.GenerateProofOfOwnership(tt.args.accountType, tt.args.accountAddress) + if (err != nil) != tt.wantErr { + t.Errorf("NodeAdminService.GenerateProofOfOwnership() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("NodeAdminService.GenerateProofOfOwnership() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestNodeAdminService_ValidateProofOfOwnership(t *testing.T) { + type fields struct { + Helpers NodeAdminServiceHelpersInterface + BlockService BlockServiceInterface + } + type args struct { + poown *model.ProofOfOwnership + nodePublicKey []byte + } + tests := []struct { + name string + fields fields + args args + wantErr bool + }{ + { + name: "ValidateProofOfOwnership:Success", + fields: fields{ + Helpers: &spyNodeAdminCoreServiceHelper{}, + BlockService: &blockServiceMocked{}, + }, + args: args{ + poown: &model.ProofOfOwnership{ + MessageBytes: []byte{8, 1, 18, 44, 66, 67, 90, 69, 71, 79, 98, 51, 87, 78, 120, 51, 102, 68, 79, 86, 102, 57, 90, 83, 52, 69, + 106, 118, 79, 73, 118, 95, 85, 101, 87, 52, 84, 86, 66, 81, 74, 95, 54, 116, 72, 75, 108, 69, 26, 64, 166, 159, 115, 204, + 162, 58, 154, 197, 200, 181, 103, 220, 24, 90, 117, 110, 151, 201, 130, 22, 79, 226, 88, 89, 224, 209, 220, 193, 71, 92, 128, + 166, 21, 178, 18, 58, 241, 245, 249, 76, 17, 227, 233, 64, 44, 58, 197, 88, 245, 0, 25, 157, 149, 182, 211, 227, 1, 117, 133, + 134, 40, 29, 205, 38}, + Signature: []byte{156, 114, 29, 63, 218, 45, 128, 0, 15, 148, 102, 248, 215, 237, 93, 241, 87, 188, 65, 94, 74, + 181, 85, 195, 131, 214, 109, 192, 81, 171, 210, 24, 14, 200, 53, 58, 193, 24, 252, 225, 149, 135, 223, 66, 122, 125, 147, + 213, 223, 105, 100, 83, 102, 46, 106, 144, 116, 58, 228, 191, 53, 225, 215, 15}, + }, + nodePublicKey: []byte{153, 58, 50, 200, 7, 61, 108, 229, 204, 48, 199, 145, 21, 99, 125, 75, 49, 45, 118, 97, 219, 80, 242, + 244, 100, 134, 144, 246, 37, 144, 213, 135}, + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + nas := &NodeAdminService{ + Helpers: tt.fields.Helpers, + BlockService: tt.fields.BlockService, + } + if err := nas.ValidateProofOfOwnership(tt.args.poown, tt.args.nodePublicKey); (err != nil) != tt.wantErr { + t.Errorf("NodeAdminService.ValidateProofOfOwnership() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/core/util/blockUtil.go b/core/util/blockUtil.go index bb34b63d7..85bb91206 100644 --- a/core/util/blockUtil.go +++ b/core/util/blockUtil.go @@ -84,10 +84,7 @@ func CalculateSmithScale(previousBlock, block *model.Block, smithingDelayTime in // return the assigned ID if assigned func GetBlockID(block *model.Block) int64 { if block.ID == 0 { - digest := sha3.New512() - blockByte, _ := GetBlockByte(block, true) - _, _ = digest.Write(blockByte) - hash := digest.Sum([]byte{}) + hash, _ := GetBlockHash(block) res := new(big.Int) block.ID = res.SetBytes([]byte{ hash[7], @@ -103,6 +100,18 @@ func GetBlockID(block *model.Block) int64 { return block.ID } +// GetBlockHash return the block's bytes hash. +// note: the block must be signed, otherwise this function returns an error +func GetBlockHash(block *model.Block) ([]byte, error) { + digest := sha3.New512() + blockByte, _ := GetBlockByte(block, true) + _, err := digest.Write(blockByte) + if err != nil { + return nil, err + } + return digest.Sum([]byte{}), nil +} + // GetBlockByte generate value for `Bytes` field if not assigned yet // return .`Bytes` if value assigned func GetBlockByte(block *model.Block, signed bool) ([]byte, error) { diff --git a/resource/config.toml b/resource/config.toml index b41d65fa5..a06ce1802 100644 --- a/resource/config.toml +++ b/resource/config.toml @@ -8,4 +8,6 @@ wellknownPeers=["127.0.0.1:8002"] apiRPCPort=3001 apiHTTPPort=3031 -nodeSecretPhrase = "concur vocalist rotten busload gap quote stinging undiluted surfer goofiness deviation starved" +nodeSecretPhrase = "sprinkled sneak species pork outpost thrift unwind cheesy vexingly dizzy neurology neatness" +ownerAccountType = 0 +ownerAccountAddress = "BCZEGOb3WNx3fDOVf9ZS4EjvOIv_UeW4TVBQJ_6tHKlE" diff --git a/resource/config2.toml b/resource/config2.toml index cb04f8f48..9ab1358e5 100644 --- a/resource/config2.toml +++ b/resource/config2.toml @@ -8,3 +8,6 @@ wellknownPeers=["127.0.0.1:8003"] apiRPCPort=3002 apiHTTPPort=3032 +nodeSecretPhrase = "demanding unlined hazard neuter condone anime asleep ascent capitol sitter marathon armband" +ownerAccountType = 0 +ownerAccountAddress = "BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN" diff --git a/resource/config3.toml b/resource/config3.toml index 65861550d..f432daa94 100644 --- a/resource/config3.toml +++ b/resource/config3.toml @@ -8,3 +8,6 @@ wellknownPeers=["127.0.0.1:8002"] apiRPCPort=3003 apiHTTPPort=3033 +nodeSecretPhrase = "street roast immovable escalator stinger nervy provider debug flavoring hubcap creature remix" +ownerAccountType = 0 +ownerAccountAddress = "BCZKLvgUYZ1KKx-jtF9KoJskjVPvB9jpIjfzzI6zDW0J" diff --git a/resource/config4.toml b/resource/config4.toml index bf7a433cc..dd8f36ca1 100644 --- a/resource/config4.toml +++ b/resource/config4.toml @@ -8,3 +8,6 @@ wellknownPeers=["127.0.0.1:8002"] apiRPCPort=3004 apiHTTPPort=3034 +nodeSecretPhrase = "spree uplifted stapling quotable disfigure lair deduct untying timothy maggot cryptic unrigged" +ownerAccountType = 0 +ownerAccountAddress = "BCZD_VxfO2S9aziIL3cn_cXW7uPDVPOrnXuP98GEAUC7" \ No newline at end of file