Compare commits
6 Commits
main
...
minh/addre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9fe28d5ea | ||
|
|
3ab2b57835 | ||
|
|
3a9d132f8d | ||
|
|
898b542e54 | ||
|
|
bade30ba1a | ||
|
|
2bc1991c09 |
@ -17,11 +17,13 @@ var (
|
||||
PublicKeyStart = []byte{12, 14, 187, 9}
|
||||
MagicDyckForPoint = []uint64{0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1}
|
||||
MagicDyckForT8 = []uint64{0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}
|
||||
MagicDyckForSeed = []uint64{0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}
|
||||
MagicDyckForSeed = []uint64{0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}
|
||||
MagicDyckForName = []uint64{0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1}
|
||||
Tip5Zero = [5]uint64{1730770831742798981, 2676322185709933211, 8329210750824781744, 16756092452590401876, 3547445316740171466}
|
||||
Tip5One = [5]uint64{6727110957294540849, 15606243244732609007, 11887284596344881785, 10646863421881571398, 8146872807338919620}
|
||||
Tip5ZeroZero = [5]uint64{4372149332062030091, 17876920912185183887, 13348798570422431948, 8872865212694716527, 3385176510443841516}
|
||||
LockTagTip5Hash = [5]uint64{14842882926452000379, 13014485748050717591, 1400056310629901848, 12454303796926623552, 932704623874458879}
|
||||
PkhTagTip5Hash = [5]uint64{10156173885239003330, 10977325146168166962, 5009593872749405377, 3760122916894980618, 174876511384150447}
|
||||
)
|
||||
|
||||
type MasterKey struct {
|
||||
@ -192,13 +194,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}
|
||||
|
||||
@ -144,6 +144,14 @@ var (
|
||||
INIT_SPONGE_FIX = [16]uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295}
|
||||
)
|
||||
|
||||
func Tip5HashLeaf(leaf uint64) [5]uint64 {
|
||||
belts := []Belt{
|
||||
{Value: 1},
|
||||
{Value: leaf},
|
||||
}
|
||||
return Tip5HashBelts(belts)
|
||||
}
|
||||
|
||||
func Tip5HashBelts(input []Belt) [5]uint64 {
|
||||
inputLen := len(input)
|
||||
q := inputLen / RATE
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
709
nockchain/nockapp.pb.go
Normal file
709
nockchain/nockapp.pb.go
Normal file
@ -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
|
||||
}
|
||||
161
nockchain/nockapp_grpc.pb.go
Normal file
161
nockchain/nockapp_grpc.pb.go
Normal file
@ -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",
|
||||
}
|
||||
@ -26,12 +26,17 @@ const (
|
||||
type WalletGetBalanceRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// pubkey cheetah point; specific address, or current wallet
|
||||
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
|
||||
//
|
||||
// Types that are valid to be assigned to Selector:
|
||||
//
|
||||
// *WalletGetBalanceRequest_Address
|
||||
// *WalletGetBalanceRequest_FirstName
|
||||
Selector isWalletGetBalanceRequest_Selector `protobuf_oneof:"selector"`
|
||||
// Pagination parameters. The server enforces limits and may return fewer
|
||||
// entries than requested to respect message size and policy. For consistent
|
||||
// paging across a stable snapshot, pass along the returned page_token from
|
||||
// the previous response without modification.
|
||||
Page *PageRequest `protobuf:"bytes,2,opt,name=page,proto3" json:"page,omitempty"`
|
||||
Page *PageRequest `protobuf:"bytes,3,opt,name=page,proto3" json:"page,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -66,11 +71,29 @@ func (*WalletGetBalanceRequest) Descriptor() ([]byte, []int) {
|
||||
return file_nockchain_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *WalletGetBalanceRequest) GetAddress() string {
|
||||
func (x *WalletGetBalanceRequest) GetSelector() isWalletGetBalanceRequest_Selector {
|
||||
if x != nil {
|
||||
return x.Address
|
||||
return x.Selector
|
||||
}
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *WalletGetBalanceRequest) GetAddress() *Base58Pubkey {
|
||||
if x != nil {
|
||||
if x, ok := x.Selector.(*WalletGetBalanceRequest_Address); ok {
|
||||
return x.Address
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *WalletGetBalanceRequest) GetFirstName() *Base58Hash {
|
||||
if x != nil {
|
||||
if x, ok := x.Selector.(*WalletGetBalanceRequest_FirstName); ok {
|
||||
return x.FirstName
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *WalletGetBalanceRequest) GetPage() *PageRequest {
|
||||
@ -80,6 +103,22 @@ func (x *WalletGetBalanceRequest) GetPage() *PageRequest {
|
||||
return nil
|
||||
}
|
||||
|
||||
type isWalletGetBalanceRequest_Selector interface {
|
||||
isWalletGetBalanceRequest_Selector()
|
||||
}
|
||||
|
||||
type WalletGetBalanceRequest_Address struct {
|
||||
Address *Base58Pubkey `protobuf:"bytes,1,opt,name=address,proto3,oneof"`
|
||||
}
|
||||
|
||||
type WalletGetBalanceRequest_FirstName struct {
|
||||
FirstName *Base58Hash `protobuf:"bytes,2,opt,name=first_name,json=firstName,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*WalletGetBalanceRequest_Address) isWalletGetBalanceRequest_Selector() {}
|
||||
|
||||
func (*WalletGetBalanceRequest_FirstName) isWalletGetBalanceRequest_Selector() {}
|
||||
|
||||
type WalletGetBalanceResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Result:
|
||||
@ -128,7 +167,7 @@ func (x *WalletGetBalanceResponse) GetResult() isWalletGetBalanceResponse_Result
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *WalletGetBalanceResponse) GetBalance() *WalletBalanceData {
|
||||
func (x *WalletGetBalanceResponse) GetBalance() *Balance {
|
||||
if x != nil {
|
||||
if x, ok := x.Result.(*WalletGetBalanceResponse_Balance); ok {
|
||||
return x.Balance
|
||||
@ -155,7 +194,7 @@ type WalletGetBalanceResponse_Balance struct {
|
||||
// Continue paging using `balance.page.next_page_token` until empty. Clients
|
||||
// should treat the page token as opaque; it may encode snapshot identity
|
||||
// and the last returned key.
|
||||
Balance *WalletBalanceData `protobuf:"bytes,1,opt,name=balance,proto3,oneof"`
|
||||
Balance *Balance `protobuf:"bytes,1,opt,name=balance,proto3,oneof"`
|
||||
}
|
||||
|
||||
type WalletGetBalanceResponse_Error struct {
|
||||
@ -437,31 +476,35 @@ var File_nockchain_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_nockchain_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x0fnockchain.proto\x12\x13nockchain.public.v1\x1a\x10blockchain.proto\x1a\x10primitives.proto\x1a\x10pagination.proto\"i\n" +
|
||||
"\x17WalletGetBalanceRequest\x12\x18\n" +
|
||||
"\aaddress\x18\x01 \x01(\tR\aaddress\x124\n" +
|
||||
"\x04page\x18\x02 \x01(\v2 .nockchain.public.v1.PageRequestR\x04page\"\xa2\x01\n" +
|
||||
"\x18WalletGetBalanceResponse\x12B\n" +
|
||||
"\abalance\x18\x01 \x01(\v2&.nockchain.public.v1.WalletBalanceDataH\x00R\abalance\x128\n" +
|
||||
"\x05error\x18\x02 \x01(\v2 .nockchain.public.v1.ErrorStatusH\x00R\x05errorB\b\n" +
|
||||
"\x0fnockchain.proto\x12\x13nockchain.public.v2\x1a\x10blockchain.proto\x1a\x10primitives.proto\x1a\x10pagination.proto\"\xdc\x01\n" +
|
||||
"\x17WalletGetBalanceRequest\x12=\n" +
|
||||
"\aaddress\x18\x01 \x01(\v2!.nockchain.public.v2.Base58PubkeyH\x00R\aaddress\x12@\n" +
|
||||
"\n" +
|
||||
"first_name\x18\x02 \x01(\v2\x1f.nockchain.public.v2.Base58HashH\x00R\tfirstName\x124\n" +
|
||||
"\x04page\x18\x03 \x01(\v2 .nockchain.public.v2.PageRequestR\x04pageB\n" +
|
||||
"\n" +
|
||||
"\bselector\"\x98\x01\n" +
|
||||
"\x18WalletGetBalanceResponse\x128\n" +
|
||||
"\abalance\x18\x01 \x01(\v2\x1c.nockchain.public.v2.BalanceH\x00R\abalance\x128\n" +
|
||||
"\x05error\x18\x02 \x01(\v2 .nockchain.public.v2.ErrorStatusH\x00R\x05errorB\b\n" +
|
||||
"\x06result\"\x8a\x01\n" +
|
||||
"\x1cWalletSendTransactionRequest\x12.\n" +
|
||||
"\x05tx_id\x18\x01 \x01(\v2\x19.nockchain.public.v1.HashR\x04txId\x12:\n" +
|
||||
"\x06raw_tx\x18\x02 \x01(\v2#.nockchain.public.v1.RawTransactionR\x05rawTx\"\x9a\x01\n" +
|
||||
"\x05tx_id\x18\x01 \x01(\v2\x19.nockchain.public.v2.HashR\x04txId\x12:\n" +
|
||||
"\x06raw_tx\x18\x02 \x01(\v2#.nockchain.public.v2.RawTransactionR\x05rawTx\"\x9a\x01\n" +
|
||||
"\x1dWalletSendTransactionResponse\x125\n" +
|
||||
"\x03ack\x18\x01 \x01(\v2!.nockchain.public.v1.AcknowledgedH\x00R\x03ack\x128\n" +
|
||||
"\x05error\x18\x02 \x01(\v2 .nockchain.public.v1.ErrorStatusH\x00R\x05errorB\b\n" +
|
||||
"\x03ack\x18\x01 \x01(\v2!.nockchain.public.v2.AcknowledgedH\x00R\x03ack\x128\n" +
|
||||
"\x05error\x18\x02 \x01(\v2 .nockchain.public.v2.ErrorStatusH\x00R\x05errorB\b\n" +
|
||||
"\x06result\"R\n" +
|
||||
"\x1aTransactionAcceptedRequest\x124\n" +
|
||||
"\x05tx_id\x18\x01 \x01(\v2\x1f.nockchain.public.v1.Base58HashR\x04txId\"\x7f\n" +
|
||||
"\x05tx_id\x18\x01 \x01(\v2\x1f.nockchain.public.v2.Base58HashR\x04txId\"\x7f\n" +
|
||||
"\x1bTransactionAcceptedResponse\x12\x1c\n" +
|
||||
"\baccepted\x18\x01 \x01(\bH\x00R\baccepted\x128\n" +
|
||||
"\x05error\x18\x02 \x01(\v2 .nockchain.public.v1.ErrorStatusH\x00R\x05errorB\b\n" +
|
||||
"\x05error\x18\x02 \x01(\v2 .nockchain.public.v2.ErrorStatusH\x00R\x05errorB\b\n" +
|
||||
"\x06result2\xfd\x02\n" +
|
||||
"\x10NockchainService\x12o\n" +
|
||||
"\x10WalletGetBalance\x12,.nockchain.public.v1.WalletGetBalanceRequest\x1a-.nockchain.public.v1.WalletGetBalanceResponse\x12~\n" +
|
||||
"\x15WalletSendTransaction\x121.nockchain.public.v1.WalletSendTransactionRequest\x1a2.nockchain.public.v1.WalletSendTransactionResponse\x12x\n" +
|
||||
"\x13TransactionAccepted\x12/.nockchain.public.v1.TransactionAcceptedRequest\x1a0.nockchain.public.v1.TransactionAcceptedResponseB\x0eZ\f./;nockchainb\x06proto3"
|
||||
"\x10WalletGetBalance\x12,.nockchain.public.v2.WalletGetBalanceRequest\x1a-.nockchain.public.v2.WalletGetBalanceResponse\x12~\n" +
|
||||
"\x15WalletSendTransaction\x121.nockchain.public.v2.WalletSendTransactionRequest\x1a2.nockchain.public.v2.WalletSendTransactionResponse\x12x\n" +
|
||||
"\x13TransactionAccepted\x12/.nockchain.public.v2.TransactionAcceptedRequest\x1a0.nockchain.public.v2.TransactionAcceptedResponseB\x0eZ\f./;nockchainb\x06proto3"
|
||||
|
||||
var (
|
||||
file_nockchain_proto_rawDescOnce sync.Once
|
||||
@ -477,41 +520,44 @@ func file_nockchain_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_nockchain_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_nockchain_proto_goTypes = []any{
|
||||
(*WalletGetBalanceRequest)(nil), // 0: nockchain.public.v1.WalletGetBalanceRequest
|
||||
(*WalletGetBalanceResponse)(nil), // 1: nockchain.public.v1.WalletGetBalanceResponse
|
||||
(*WalletSendTransactionRequest)(nil), // 2: nockchain.public.v1.WalletSendTransactionRequest
|
||||
(*WalletSendTransactionResponse)(nil), // 3: nockchain.public.v1.WalletSendTransactionResponse
|
||||
(*TransactionAcceptedRequest)(nil), // 4: nockchain.public.v1.TransactionAcceptedRequest
|
||||
(*TransactionAcceptedResponse)(nil), // 5: nockchain.public.v1.TransactionAcceptedResponse
|
||||
(*PageRequest)(nil), // 6: nockchain.public.v1.PageRequest
|
||||
(*WalletBalanceData)(nil), // 7: nockchain.public.v1.WalletBalanceData
|
||||
(*ErrorStatus)(nil), // 8: nockchain.public.v1.ErrorStatus
|
||||
(*Hash)(nil), // 9: nockchain.public.v1.Hash
|
||||
(*RawTransaction)(nil), // 10: nockchain.public.v1.RawTransaction
|
||||
(*Acknowledged)(nil), // 11: nockchain.public.v1.Acknowledged
|
||||
(*Base58Hash)(nil), // 12: nockchain.public.v1.Base58Hash
|
||||
(*WalletGetBalanceRequest)(nil), // 0: nockchain.public.v2.WalletGetBalanceRequest
|
||||
(*WalletGetBalanceResponse)(nil), // 1: nockchain.public.v2.WalletGetBalanceResponse
|
||||
(*WalletSendTransactionRequest)(nil), // 2: nockchain.public.v2.WalletSendTransactionRequest
|
||||
(*WalletSendTransactionResponse)(nil), // 3: nockchain.public.v2.WalletSendTransactionResponse
|
||||
(*TransactionAcceptedRequest)(nil), // 4: nockchain.public.v2.TransactionAcceptedRequest
|
||||
(*TransactionAcceptedResponse)(nil), // 5: nockchain.public.v2.TransactionAcceptedResponse
|
||||
(*Base58Pubkey)(nil), // 6: nockchain.public.v2.Base58Pubkey
|
||||
(*Base58Hash)(nil), // 7: nockchain.public.v2.Base58Hash
|
||||
(*PageRequest)(nil), // 8: nockchain.public.v2.PageRequest
|
||||
(*Balance)(nil), // 9: nockchain.public.v2.Balance
|
||||
(*ErrorStatus)(nil), // 10: nockchain.public.v2.ErrorStatus
|
||||
(*Hash)(nil), // 11: nockchain.public.v2.Hash
|
||||
(*RawTransaction)(nil), // 12: nockchain.public.v2.RawTransaction
|
||||
(*Acknowledged)(nil), // 13: nockchain.public.v2.Acknowledged
|
||||
}
|
||||
var file_nockchain_proto_depIdxs = []int32{
|
||||
6, // 0: nockchain.public.v1.WalletGetBalanceRequest.page:type_name -> nockchain.public.v1.PageRequest
|
||||
7, // 1: nockchain.public.v1.WalletGetBalanceResponse.balance:type_name -> nockchain.public.v1.WalletBalanceData
|
||||
8, // 2: nockchain.public.v1.WalletGetBalanceResponse.error:type_name -> nockchain.public.v1.ErrorStatus
|
||||
9, // 3: nockchain.public.v1.WalletSendTransactionRequest.tx_id:type_name -> nockchain.public.v1.Hash
|
||||
10, // 4: nockchain.public.v1.WalletSendTransactionRequest.raw_tx:type_name -> nockchain.public.v1.RawTransaction
|
||||
11, // 5: nockchain.public.v1.WalletSendTransactionResponse.ack:type_name -> nockchain.public.v1.Acknowledged
|
||||
8, // 6: nockchain.public.v1.WalletSendTransactionResponse.error:type_name -> nockchain.public.v1.ErrorStatus
|
||||
12, // 7: nockchain.public.v1.TransactionAcceptedRequest.tx_id:type_name -> nockchain.public.v1.Base58Hash
|
||||
8, // 8: nockchain.public.v1.TransactionAcceptedResponse.error:type_name -> nockchain.public.v1.ErrorStatus
|
||||
0, // 9: nockchain.public.v1.NockchainService.WalletGetBalance:input_type -> nockchain.public.v1.WalletGetBalanceRequest
|
||||
2, // 10: nockchain.public.v1.NockchainService.WalletSendTransaction:input_type -> nockchain.public.v1.WalletSendTransactionRequest
|
||||
4, // 11: nockchain.public.v1.NockchainService.TransactionAccepted:input_type -> nockchain.public.v1.TransactionAcceptedRequest
|
||||
1, // 12: nockchain.public.v1.NockchainService.WalletGetBalance:output_type -> nockchain.public.v1.WalletGetBalanceResponse
|
||||
3, // 13: nockchain.public.v1.NockchainService.WalletSendTransaction:output_type -> nockchain.public.v1.WalletSendTransactionResponse
|
||||
5, // 14: nockchain.public.v1.NockchainService.TransactionAccepted:output_type -> nockchain.public.v1.TransactionAcceptedResponse
|
||||
12, // [12:15] is the sub-list for method output_type
|
||||
9, // [9:12] is the sub-list for method input_type
|
||||
9, // [9:9] is the sub-list for extension type_name
|
||||
9, // [9:9] is the sub-list for extension extendee
|
||||
0, // [0:9] is the sub-list for field type_name
|
||||
6, // 0: nockchain.public.v2.WalletGetBalanceRequest.address:type_name -> nockchain.public.v2.Base58Pubkey
|
||||
7, // 1: nockchain.public.v2.WalletGetBalanceRequest.first_name:type_name -> nockchain.public.v2.Base58Hash
|
||||
8, // 2: nockchain.public.v2.WalletGetBalanceRequest.page:type_name -> nockchain.public.v2.PageRequest
|
||||
9, // 3: nockchain.public.v2.WalletGetBalanceResponse.balance:type_name -> nockchain.public.v2.Balance
|
||||
10, // 4: nockchain.public.v2.WalletGetBalanceResponse.error:type_name -> nockchain.public.v2.ErrorStatus
|
||||
11, // 5: nockchain.public.v2.WalletSendTransactionRequest.tx_id:type_name -> nockchain.public.v2.Hash
|
||||
12, // 6: nockchain.public.v2.WalletSendTransactionRequest.raw_tx:type_name -> nockchain.public.v2.RawTransaction
|
||||
13, // 7: nockchain.public.v2.WalletSendTransactionResponse.ack:type_name -> nockchain.public.v2.Acknowledged
|
||||
10, // 8: nockchain.public.v2.WalletSendTransactionResponse.error:type_name -> nockchain.public.v2.ErrorStatus
|
||||
7, // 9: nockchain.public.v2.TransactionAcceptedRequest.tx_id:type_name -> nockchain.public.v2.Base58Hash
|
||||
10, // 10: nockchain.public.v2.TransactionAcceptedResponse.error:type_name -> nockchain.public.v2.ErrorStatus
|
||||
0, // 11: nockchain.public.v2.NockchainService.WalletGetBalance:input_type -> nockchain.public.v2.WalletGetBalanceRequest
|
||||
2, // 12: nockchain.public.v2.NockchainService.WalletSendTransaction:input_type -> nockchain.public.v2.WalletSendTransactionRequest
|
||||
4, // 13: nockchain.public.v2.NockchainService.TransactionAccepted:input_type -> nockchain.public.v2.TransactionAcceptedRequest
|
||||
1, // 14: nockchain.public.v2.NockchainService.WalletGetBalance:output_type -> nockchain.public.v2.WalletGetBalanceResponse
|
||||
3, // 15: nockchain.public.v2.NockchainService.WalletSendTransaction:output_type -> nockchain.public.v2.WalletSendTransactionResponse
|
||||
5, // 16: nockchain.public.v2.NockchainService.TransactionAccepted:output_type -> nockchain.public.v2.TransactionAcceptedResponse
|
||||
14, // [14:17] is the sub-list for method output_type
|
||||
11, // [11:14] is the sub-list for method input_type
|
||||
11, // [11:11] is the sub-list for extension type_name
|
||||
11, // [11:11] is the sub-list for extension extendee
|
||||
0, // [0:11] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_nockchain_proto_init() }
|
||||
@ -522,6 +568,10 @@ func file_nockchain_proto_init() {
|
||||
file_blockchain_proto_init()
|
||||
file_primitives_proto_init()
|
||||
file_pagination_proto_init()
|
||||
file_nockchain_proto_msgTypes[0].OneofWrappers = []any{
|
||||
(*WalletGetBalanceRequest_Address)(nil),
|
||||
(*WalletGetBalanceRequest_FirstName)(nil),
|
||||
}
|
||||
file_nockchain_proto_msgTypes[1].OneofWrappers = []any{
|
||||
(*WalletGetBalanceResponse_Balance)(nil),
|
||||
(*WalletGetBalanceResponse_Error)(nil),
|
||||
|
||||
@ -21,9 +21,9 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
NockchainService_WalletGetBalance_FullMethodName = "/nockchain.public.v1.NockchainService/WalletGetBalance"
|
||||
NockchainService_WalletSendTransaction_FullMethodName = "/nockchain.public.v1.NockchainService/WalletSendTransaction"
|
||||
NockchainService_TransactionAccepted_FullMethodName = "/nockchain.public.v1.NockchainService/TransactionAccepted"
|
||||
NockchainService_WalletGetBalance_FullMethodName = "/nockchain.public.v2.NockchainService/WalletGetBalance"
|
||||
NockchainService_WalletSendTransaction_FullMethodName = "/nockchain.public.v2.NockchainService/WalletSendTransaction"
|
||||
NockchainService_TransactionAccepted_FullMethodName = "/nockchain.public.v2.NockchainService/TransactionAccepted"
|
||||
)
|
||||
|
||||
// NockchainServiceClient is the client API for NockchainService service.
|
||||
@ -178,7 +178,7 @@ func _NockchainService_TransactionAccepted_Handler(srv interface{}, ctx context.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var NockchainService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "nockchain.public.v1.NockchainService",
|
||||
ServiceName: "nockchain.public.v2.NockchainService",
|
||||
HandlerType: (*NockchainServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
|
||||
@ -152,7 +152,7 @@ var File_pagination_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_pagination_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x10pagination.proto\x12\x13nockchain.public.v1\"\x80\x01\n" +
|
||||
"\x10pagination.proto\x12\x13nockchain.public.v2\"\x80\x01\n" +
|
||||
"\vPageRequest\x125\n" +
|
||||
"\x17client_page_items_limit\x18\x01 \x01(\rR\x14clientPageItemsLimit\x12\x1d\n" +
|
||||
"\n" +
|
||||
@ -175,8 +175,8 @@ func file_pagination_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_pagination_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_pagination_proto_goTypes = []any{
|
||||
(*PageRequest)(nil), // 0: nockchain.public.v1.PageRequest
|
||||
(*PageResponse)(nil), // 1: nockchain.public.v1.PageResponse
|
||||
(*PageRequest)(nil), // 0: nockchain.public.v2.PageRequest
|
||||
(*PageResponse)(nil), // 1: nockchain.public.v2.PageResponse
|
||||
}
|
||||
var file_pagination_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
|
||||
@ -101,7 +101,7 @@ func (ErrorCode) EnumDescriptor() ([]byte, []int) {
|
||||
|
||||
type ErrorStatus struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=nockchain.public.v1.ErrorCode" json:"code,omitempty"`
|
||||
Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=nockchain.public.v2.ErrorCode" 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
|
||||
@ -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 {
|
||||
@ -740,6 +598,50 @@ func (x *Base58Hash) GetHash() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type Base58Pubkey struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Base58Pubkey) Reset() {
|
||||
*x = Base58Pubkey{}
|
||||
mi := &file_primitives_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Base58Pubkey) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Base58Pubkey) ProtoMessage() {}
|
||||
|
||||
func (x *Base58Pubkey) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_primitives_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 Base58Pubkey.ProtoReflect.Descriptor instead.
|
||||
func (*Base58Pubkey) Descriptor() ([]byte, []int) {
|
||||
return file_primitives_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *Base58Pubkey) GetKey() string {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// pub struct SchnorrPubkey(pub CheetahPoint);
|
||||
type SchnorrPubkey struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
@ -750,7 +652,7 @@ type SchnorrPubkey struct {
|
||||
|
||||
func (x *SchnorrPubkey) Reset() {
|
||||
*x = SchnorrPubkey{}
|
||||
mi := &file_primitives_proto_msgTypes[11]
|
||||
mi := &file_primitives_proto_msgTypes[10]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -762,7 +664,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[10]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -775,7 +677,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{10}
|
||||
}
|
||||
|
||||
func (x *SchnorrPubkey) GetValue() *CheetahPoint {
|
||||
@ -801,7 +703,7 @@ type CheetahPoint struct {
|
||||
|
||||
func (x *CheetahPoint) Reset() {
|
||||
*x = CheetahPoint{}
|
||||
mi := &file_primitives_proto_msgTypes[12]
|
||||
mi := &file_primitives_proto_msgTypes[11]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -813,7 +715,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[11]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -826,7 +728,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{11}
|
||||
}
|
||||
|
||||
func (x *CheetahPoint) GetX() *SixBelt {
|
||||
@ -865,7 +767,7 @@ type SixBelt struct {
|
||||
|
||||
func (x *SixBelt) Reset() {
|
||||
*x = SixBelt{}
|
||||
mi := &file_primitives_proto_msgTypes[13]
|
||||
mi := &file_primitives_proto_msgTypes[12]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -877,7 +779,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[12]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -890,7 +792,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{12}
|
||||
}
|
||||
|
||||
func (x *SixBelt) GetBelt_1() *Belt {
|
||||
@ -945,7 +847,7 @@ type Belt struct {
|
||||
|
||||
func (x *Belt) Reset() {
|
||||
*x = Belt{}
|
||||
mi := &file_primitives_proto_msgTypes[14]
|
||||
mi := &file_primitives_proto_msgTypes[13]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -957,7 +859,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[13]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -970,7 +872,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{13}
|
||||
}
|
||||
|
||||
func (x *Belt) GetValue() uint64 {
|
||||
@ -984,22 +886,14 @@ var File_primitives_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_primitives_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x10primitives.proto\x12\x13nockchain.public.v1\"\x86\x01\n" +
|
||||
"\x10primitives.proto\x12\x13nockchain.public.v2\"\x86\x01\n" +
|
||||
"\vErrorStatus\x122\n" +
|
||||
"\x04code\x18\x01 \x01(\x0e2\x1e.nockchain.public.v1.ErrorCodeR\x04code\x12\x18\n" +
|
||||
"\x04code\x18\x01 \x01(\x0e2\x1e.nockchain.public.v2.ErrorCodeR\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\"\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" +
|
||||
@ -1009,36 +903,38 @@ const file_primitives_proto_rawDesc = "" +
|
||||
"\x05Nicks\x12\x14\n" +
|
||||
"\x05value\x18\x01 \x01(\x04R\x05value\"\x9b\x03\n" +
|
||||
"\tEightBelt\x120\n" +
|
||||
"\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt1\x120\n" +
|
||||
"\x06belt_2\x18\x02 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt2\x120\n" +
|
||||
"\x06belt_3\x18\x03 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt3\x120\n" +
|
||||
"\x06belt_4\x18\x04 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt4\x120\n" +
|
||||
"\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt5\x120\n" +
|
||||
"\x06belt_6\x18\x06 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt6\x120\n" +
|
||||
"\x06belt_7\x18\a \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt7\x120\n" +
|
||||
"\x06belt_8\x18\b \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt8\"\x80\x02\n" +
|
||||
"\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt1\x120\n" +
|
||||
"\x06belt_2\x18\x02 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt2\x120\n" +
|
||||
"\x06belt_3\x18\x03 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt3\x120\n" +
|
||||
"\x06belt_4\x18\x04 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt4\x120\n" +
|
||||
"\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt5\x120\n" +
|
||||
"\x06belt_6\x18\x06 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt6\x120\n" +
|
||||
"\x06belt_7\x18\a \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt7\x120\n" +
|
||||
"\x06belt_8\x18\b \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt8\"\x80\x02\n" +
|
||||
"\x04Hash\x120\n" +
|
||||
"\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt1\x120\n" +
|
||||
"\x06belt_2\x18\x02 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt2\x120\n" +
|
||||
"\x06belt_3\x18\x03 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt3\x120\n" +
|
||||
"\x06belt_4\x18\x04 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt4\x120\n" +
|
||||
"\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt5\" \n" +
|
||||
"\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt1\x120\n" +
|
||||
"\x06belt_2\x18\x02 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt2\x120\n" +
|
||||
"\x06belt_3\x18\x03 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt3\x120\n" +
|
||||
"\x06belt_4\x18\x04 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt4\x120\n" +
|
||||
"\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt5\" \n" +
|
||||
"\n" +
|
||||
"Base58Hash\x12\x12\n" +
|
||||
"\x04hash\x18\x01 \x01(\tR\x04hash\"H\n" +
|
||||
"\x04hash\x18\x01 \x01(\tR\x04hash\" \n" +
|
||||
"\fBase58Pubkey\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\"H\n" +
|
||||
"\rSchnorrPubkey\x127\n" +
|
||||
"\x05value\x18\x01 \x01(\v2!.nockchain.public.v1.CheetahPointR\x05value\"x\n" +
|
||||
"\x05value\x18\x01 \x01(\v2!.nockchain.public.v2.CheetahPointR\x05value\"x\n" +
|
||||
"\fCheetahPoint\x12*\n" +
|
||||
"\x01x\x18\x01 \x01(\v2\x1c.nockchain.public.v1.SixBeltR\x01x\x12*\n" +
|
||||
"\x01y\x18\x02 \x01(\v2\x1c.nockchain.public.v1.SixBeltR\x01y\x12\x10\n" +
|
||||
"\x01x\x18\x01 \x01(\v2\x1c.nockchain.public.v2.SixBeltR\x01x\x12*\n" +
|
||||
"\x01y\x18\x02 \x01(\v2\x1c.nockchain.public.v2.SixBeltR\x01y\x12\x10\n" +
|
||||
"\x03inf\x18\x03 \x01(\bR\x03inf\"\xb5\x02\n" +
|
||||
"\aSixBelt\x120\n" +
|
||||
"\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt1\x120\n" +
|
||||
"\x06belt_2\x18\x02 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt2\x120\n" +
|
||||
"\x06belt_3\x18\x03 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt3\x120\n" +
|
||||
"\x06belt_4\x18\x04 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt4\x120\n" +
|
||||
"\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt5\x120\n" +
|
||||
"\x06belt_6\x18\x06 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt6\"\x1c\n" +
|
||||
"\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt1\x120\n" +
|
||||
"\x06belt_2\x18\x02 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt2\x120\n" +
|
||||
"\x06belt_3\x18\x03 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt3\x120\n" +
|
||||
"\x06belt_4\x18\x04 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt4\x120\n" +
|
||||
"\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt5\x120\n" +
|
||||
"\x06belt_6\x18\x06 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt6\"\x1c\n" +
|
||||
"\x04Belt\x12\x14\n" +
|
||||
"\x05value\x18\x01 \x01(\x04R\x05value*\xf0\x02\n" +
|
||||
"\tErrorCode\x12\x1a\n" +
|
||||
@ -1069,55 +965,53 @@ 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, 14)
|
||||
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
|
||||
(ErrorCode)(0), // 0: nockchain.public.v2.ErrorCode
|
||||
(*ErrorStatus)(nil), // 1: nockchain.public.v2.ErrorStatus
|
||||
(*Acknowledged)(nil), // 2: nockchain.public.v2.Acknowledged
|
||||
(*NoteVersion)(nil), // 3: nockchain.public.v2.NoteVersion
|
||||
(*BlockHeight)(nil), // 4: nockchain.public.v2.BlockHeight
|
||||
(*BlockHeightDelta)(nil), // 5: nockchain.public.v2.BlockHeightDelta
|
||||
(*Nicks)(nil), // 6: nockchain.public.v2.Nicks
|
||||
(*EightBelt)(nil), // 7: nockchain.public.v2.EightBelt
|
||||
(*Hash)(nil), // 8: nockchain.public.v2.Hash
|
||||
(*Base58Hash)(nil), // 9: nockchain.public.v2.Base58Hash
|
||||
(*Base58Pubkey)(nil), // 10: nockchain.public.v2.Base58Pubkey
|
||||
(*SchnorrPubkey)(nil), // 11: nockchain.public.v2.SchnorrPubkey
|
||||
(*CheetahPoint)(nil), // 12: nockchain.public.v2.CheetahPoint
|
||||
(*SixBelt)(nil), // 13: nockchain.public.v2.SixBelt
|
||||
(*Belt)(nil), // 14: nockchain.public.v2.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
|
||||
0, // 0: nockchain.public.v2.ErrorStatus.code:type_name -> nockchain.public.v2.ErrorCode
|
||||
14, // 1: nockchain.public.v2.EightBelt.belt_1:type_name -> nockchain.public.v2.Belt
|
||||
14, // 2: nockchain.public.v2.EightBelt.belt_2:type_name -> nockchain.public.v2.Belt
|
||||
14, // 3: nockchain.public.v2.EightBelt.belt_3:type_name -> nockchain.public.v2.Belt
|
||||
14, // 4: nockchain.public.v2.EightBelt.belt_4:type_name -> nockchain.public.v2.Belt
|
||||
14, // 5: nockchain.public.v2.EightBelt.belt_5:type_name -> nockchain.public.v2.Belt
|
||||
14, // 6: nockchain.public.v2.EightBelt.belt_6:type_name -> nockchain.public.v2.Belt
|
||||
14, // 7: nockchain.public.v2.EightBelt.belt_7:type_name -> nockchain.public.v2.Belt
|
||||
14, // 8: nockchain.public.v2.EightBelt.belt_8:type_name -> nockchain.public.v2.Belt
|
||||
14, // 9: nockchain.public.v2.Hash.belt_1:type_name -> nockchain.public.v2.Belt
|
||||
14, // 10: nockchain.public.v2.Hash.belt_2:type_name -> nockchain.public.v2.Belt
|
||||
14, // 11: nockchain.public.v2.Hash.belt_3:type_name -> nockchain.public.v2.Belt
|
||||
14, // 12: nockchain.public.v2.Hash.belt_4:type_name -> nockchain.public.v2.Belt
|
||||
14, // 13: nockchain.public.v2.Hash.belt_5:type_name -> nockchain.public.v2.Belt
|
||||
12, // 14: nockchain.public.v2.SchnorrPubkey.value:type_name -> nockchain.public.v2.CheetahPoint
|
||||
13, // 15: nockchain.public.v2.CheetahPoint.x:type_name -> nockchain.public.v2.SixBelt
|
||||
13, // 16: nockchain.public.v2.CheetahPoint.y:type_name -> nockchain.public.v2.SixBelt
|
||||
14, // 17: nockchain.public.v2.SixBelt.belt_1:type_name -> nockchain.public.v2.Belt
|
||||
14, // 18: nockchain.public.v2.SixBelt.belt_2:type_name -> nockchain.public.v2.Belt
|
||||
14, // 19: nockchain.public.v2.SixBelt.belt_3:type_name -> nockchain.public.v2.Belt
|
||||
14, // 20: nockchain.public.v2.SixBelt.belt_4:type_name -> nockchain.public.v2.Belt
|
||||
14, // 21: nockchain.public.v2.SixBelt.belt_5:type_name -> nockchain.public.v2.Belt
|
||||
14, // 22: nockchain.public.v2.SixBelt.belt_6:type_name -> nockchain.public.v2.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 +1020,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: 14,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
@ -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.v2.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,20 +438,26 @@ 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"`
|
||||
Recipients string `protobuf:"bytes,2,opt,name=recipients,proto3" json:"recipients,omitempty"`
|
||||
Gifts string `protobuf:"bytes,3,opt,name=gifts,proto3" json:"gifts,omitempty"`
|
||||
Fee uint64 `protobuf:"varint,4,opt,name=fee,proto3" json:"fee,omitempty"`
|
||||
IsMasterKey bool `protobuf:"varint,5,opt,name=is_master_key,json=isMasterKey,proto3" json:"is_master_key,omitempty"`
|
||||
Key string `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"`
|
||||
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"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Names string `protobuf:"bytes,1,opt,name=names,proto3" json:"names,omitempty"`
|
||||
Recipients string `protobuf:"bytes,2,opt,name=recipients,proto3" json:"recipients,omitempty"`
|
||||
Fee uint64 `protobuf:"varint,3,opt,name=fee,proto3" json:"fee,omitempty"`
|
||||
IsMasterKey bool `protobuf:"varint,4,opt,name=is_master_key,json=isMasterKey,proto3" json:"is_master_key,omitempty"`
|
||||
Seed string `protobuf:"bytes,5,opt,name=seed,proto3" json:"seed,omitempty"`
|
||||
Index uint64 `protobuf:"varint,6,opt,name=index,proto3" json:"index,omitempty"`
|
||||
Hardened bool `protobuf:"varint,7,opt,name=hardened,proto3" json:"hardened,omitempty"`
|
||||
Version uint64 `protobuf:"varint,8,opt,name=version,proto3" json:"version,omitempty"`
|
||||
RefundAddress string `protobuf:"bytes,9,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *CreateTxRequest) Reset() {
|
||||
@ -457,13 +504,6 @@ func (x *CreateTxRequest) GetRecipients() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateTxRequest) GetGifts() string {
|
||||
if x != nil {
|
||||
return x.Gifts
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateTxRequest) GetFee() uint64 {
|
||||
if x != nil {
|
||||
return x.Fee
|
||||
@ -478,16 +518,9 @@ func (x *CreateTxRequest) GetIsMasterKey() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *CreateTxRequest) GetKey() string {
|
||||
func (x *CreateTxRequest) GetSeed() string {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateTxRequest) GetChainCode() string {
|
||||
if x != nil {
|
||||
return x.ChainCode
|
||||
return x.Seed
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -506,11 +539,18 @@ func (x *CreateTxRequest) GetHardened() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *CreateTxRequest) GetTimelockIntent() *TimelockIntent {
|
||||
func (x *CreateTxRequest) GetVersion() uint64 {
|
||||
if x != nil {
|
||||
return x.TimelockIntent
|
||||
return x.Version
|
||||
}
|
||||
return nil
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CreateTxRequest) GetRefundAddress() string {
|
||||
if x != nil {
|
||||
return x.RefundAddress
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CreateTxResponse struct {
|
||||
@ -557,118 +597,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"`
|
||||
@ -676,13 +604,14 @@ type ScanRequest struct {
|
||||
SearchDepth uint64 `protobuf:"varint,3,opt,name=search_depth,json=searchDepth,proto3" json:"search_depth,omitempty"`
|
||||
IncludeTimelocks bool `protobuf:"varint,4,opt,name=include_timelocks,json=includeTimelocks,proto3" json:"include_timelocks,omitempty"`
|
||||
IncludeMultisig bool `protobuf:"varint,5,opt,name=include_multisig,json=includeMultisig,proto3" json:"include_multisig,omitempty"`
|
||||
Version uint64 `protobuf:"varint,6,opt,name=version,proto3" json:"version,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
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 +623,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 +636,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 {
|
||||
@ -745,6 +674,13 @@ func (x *ScanRequest) GetIncludeMultisig() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *ScanRequest) GetVersion() uint64 {
|
||||
if x != nil {
|
||||
return x.Version
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ScanResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ScanData []*ScanData `protobuf:"bytes,1,rep,name=scan_data,json=scanData,proto3" json:"scan_data,omitempty"`
|
||||
@ -754,7 +690,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 +702,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 +715,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 {
|
||||
@ -790,15 +726,19 @@ func (x *ScanResponse) GetScanData() []*ScanData {
|
||||
}
|
||||
|
||||
type GetBalanceRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Selector:
|
||||
//
|
||||
// *GetBalanceRequest_Address
|
||||
// *GetBalanceRequest_FirstName
|
||||
Selector isGetBalanceRequest_Selector `protobuf_oneof:"selector"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
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 +750,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,26 +763,60 @@ 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) GetSelector() isGetBalanceRequest_Selector {
|
||||
if x != nil {
|
||||
return x.Selector
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GetBalanceRequest) GetAddress() string {
|
||||
if x != nil {
|
||||
return x.Address
|
||||
if x, ok := x.Selector.(*GetBalanceRequest_Address); ok {
|
||||
return x.Address
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetBalanceRequest) GetFirstName() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Selector.(*GetBalanceRequest_FirstName); ok {
|
||||
return x.FirstName
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type isGetBalanceRequest_Selector interface {
|
||||
isGetBalanceRequest_Selector()
|
||||
}
|
||||
|
||||
type GetBalanceRequest_Address struct {
|
||||
Address string `protobuf:"bytes,1,opt,name=address,proto3,oneof"`
|
||||
}
|
||||
|
||||
type GetBalanceRequest_FirstName struct {
|
||||
FirstName string `protobuf:"bytes,2,opt,name=first_name,json=firstName,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*GetBalanceRequest_Address) isGetBalanceRequest_Selector() {}
|
||||
|
||||
func (*GetBalanceRequest_FirstName) isGetBalanceRequest_Selector() {}
|
||||
|
||||
type GetBalanceResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Data *WalletBalanceData `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Data *Balance `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
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 +828,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,10 +841,10 @@ 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 {
|
||||
func (x *GetBalanceResponse) GetData() *Balance {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
@ -886,7 +860,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 +872,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 +885,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 +904,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 +916,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 +929,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,96 +943,92 @@ 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.v2\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.v2.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\"\x84\x02\n" +
|
||||
"\x0fCreateTxRequest\x12\x14\n" +
|
||||
"\x05names\x18\x01 \x01(\tR\x05names\x12\x1e\n" +
|
||||
"\n" +
|
||||
"recipients\x18\x02 \x01(\tR\n" +
|
||||
"recipients\x12\x14\n" +
|
||||
"\x05gifts\x18\x03 \x01(\tR\x05gifts\x12\x10\n" +
|
||||
"\x03fee\x18\x04 \x01(\x04R\x03fee\x12\"\n" +
|
||||
"\ris_master_key\x18\x05 \x01(\bR\visMasterKey\x12\x10\n" +
|
||||
"\x03key\x18\x06 \x01(\tR\x03key\x12\x1d\n" +
|
||||
"\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" +
|
||||
"recipients\x12\x10\n" +
|
||||
"\x03fee\x18\x03 \x01(\x04R\x03fee\x12\"\n" +
|
||||
"\ris_master_key\x18\x04 \x01(\bR\visMasterKey\x12\x12\n" +
|
||||
"\x04seed\x18\x05 \x01(\tR\x04seed\x12\x14\n" +
|
||||
"\x05index\x18\x06 \x01(\x04R\x05index\x12\x1a\n" +
|
||||
"\bhardened\x18\a \x01(\bR\bhardened\x12\x18\n" +
|
||||
"\aversion\x18\b \x01(\x04R\aversion\x12%\n" +
|
||||
"\x0erefund_address\x18\t \x01(\tR\rrefundAddress\"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.v2.RawTxR\x05rawTx\"\xe6\x01\n" +
|
||||
"\vScanRequest\x12#\n" +
|
||||
"\rmaster_pubkey\x18\x01 \x01(\tR\fmasterPubkey\x12\x1d\n" +
|
||||
"\n" +
|
||||
"chain_code\x18\x02 \x01(\tR\tchainCode\x12!\n" +
|
||||
"\fsearch_depth\x18\x03 \x01(\x04R\vsearchDepth\x12+\n" +
|
||||
"\x11include_timelocks\x18\x04 \x01(\bR\x10includeTimelocks\x12)\n" +
|
||||
"\x10include_multisig\x18\x05 \x01(\bR\x0fincludeMultisig\"J\n" +
|
||||
"\x10include_multisig\x18\x05 \x01(\bR\x0fincludeMultisig\x12\x18\n" +
|
||||
"\aversion\x18\x06 \x01(\x04R\aversion\"J\n" +
|
||||
"\fScanResponse\x12:\n" +
|
||||
"\tscan_data\x18\x01 \x03(\v2\x1d.nockchain.public.v1.ScanDataR\bscanData\"-\n" +
|
||||
"\x11GetBalanceRequest\x12\x18\n" +
|
||||
"\aaddress\x18\x01 \x01(\tR\aaddress\"P\n" +
|
||||
"\x12GetBalanceResponse\x12:\n" +
|
||||
"\x04data\x18\x01 \x01(\v2&.nockchain.public.v1.WalletBalanceDataR\x04data\"K\n" +
|
||||
"\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" +
|
||||
"\rWalletService\x12Q\n" +
|
||||
"\x06Keygen\x12\".nockchain.public.v1.KeygenRequest\x1a#.nockchain.public.v1.KeygenResponse\x12]\n" +
|
||||
"\tscan_data\x18\x01 \x03(\v2\x1d.nockchain.public.v2.ScanDataR\bscanData\"\\\n" +
|
||||
"\x11GetBalanceRequest\x12\x1a\n" +
|
||||
"\aaddress\x18\x01 \x01(\tH\x00R\aaddress\x12\x1f\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" +
|
||||
"\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" +
|
||||
"\x13TransactionAccepted\x12/.nockchain.public.v1.TransactionAcceptedRequest\x1a0.nockchain.public.v1.TransactionAcceptedResponseB\x0eZ\f./;nockchainb\x06proto3"
|
||||
"first_name\x18\x02 \x01(\tH\x00R\tfirstNameB\n" +
|
||||
"\n" +
|
||||
"\bselector\"F\n" +
|
||||
"\x12GetBalanceResponse\x120\n" +
|
||||
"\x04data\x18\x01 \x01(\v2\x1c.nockchain.public.v2.BalanceR\x04data\"K\n" +
|
||||
"\x16SendTransactionRequest\x121\n" +
|
||||
"\x06raw_tx\x18\x01 \x01(\v2\x1a.nockchain.public.v2.RawTxR\x05rawTx\"i\n" +
|
||||
"\x17SendTransactionResponse\x12N\n" +
|
||||
"\bresponse\x18\x01 \x01(\v22.nockchain.public.v2.WalletSendTransactionResponseR\bresponse2\x9c\x06\n" +
|
||||
"\rWalletService\x12Q\n" +
|
||||
"\x06Keygen\x12\".nockchain.public.v2.KeygenRequest\x1a#.nockchain.public.v2.KeygenResponse\x12]\n" +
|
||||
"\n" +
|
||||
"ImportKeys\x12&.nockchain.public.v2.ImportKeysRequest\x1a'.nockchain.public.v2.ImportKeysResponse\x12`\n" +
|
||||
"\vDeriveChild\x12'.nockchain.public.v2.DeriveChildRequest\x1a(.nockchain.public.v2.DeriveChildResponse\x12W\n" +
|
||||
"\bCreateTx\x12$.nockchain.public.v2.CreateTxRequest\x1a%.nockchain.public.v2.CreateTxResponse\x12K\n" +
|
||||
"\x04Scan\x12 .nockchain.public.v2.ScanRequest\x1a!.nockchain.public.v2.ScanResponse\x12c\n" +
|
||||
"\x10WalletGetBalance\x12&.nockchain.public.v2.GetBalanceRequest\x1a'.nockchain.public.v2.GetBalanceResponse\x12r\n" +
|
||||
"\x15WalletSendTransaction\x12+.nockchain.public.v2.SendTransactionRequest\x1a,.nockchain.public.v2.SendTransactionResponse\x12x\n" +
|
||||
"\x13TransactionAccepted\x12/.nockchain.public.v2.TransactionAcceptedRequest\x1a0.nockchain.public.v2.TransactionAcceptedResponseB\x0eZ\f./;nockchainb\x06proto3"
|
||||
|
||||
var (
|
||||
file_service_proto_rawDescOnce sync.Once
|
||||
@ -1072,64 +1042,58 @@ 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
|
||||
(*ImportKeysRequest)(nil), // 2: nockchain.public.v1.ImportKeysRequest
|
||||
(*ImportKeysResponse)(nil), // 3: nockchain.public.v1.ImportKeysResponse
|
||||
(*DeriveChildRequest)(nil), // 4: nockchain.public.v1.DeriveChildRequest
|
||||
(*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
|
||||
(*KeygenRequest)(nil), // 0: nockchain.public.v2.KeygenRequest
|
||||
(*KeygenResponse)(nil), // 1: nockchain.public.v2.KeygenResponse
|
||||
(*ImportKeysRequest)(nil), // 2: nockchain.public.v2.ImportKeysRequest
|
||||
(*ImportKeysResponse)(nil), // 3: nockchain.public.v2.ImportKeysResponse
|
||||
(*DeriveChildRequest)(nil), // 4: nockchain.public.v2.DeriveChildRequest
|
||||
(*DeriveChildResponse)(nil), // 5: nockchain.public.v2.DeriveChildResponse
|
||||
(*CreateTxRequest)(nil), // 6: nockchain.public.v2.CreateTxRequest
|
||||
(*CreateTxResponse)(nil), // 7: nockchain.public.v2.CreateTxResponse
|
||||
(*ScanRequest)(nil), // 8: nockchain.public.v2.ScanRequest
|
||||
(*ScanResponse)(nil), // 9: nockchain.public.v2.ScanResponse
|
||||
(*GetBalanceRequest)(nil), // 10: nockchain.public.v2.GetBalanceRequest
|
||||
(*GetBalanceResponse)(nil), // 11: nockchain.public.v2.GetBalanceResponse
|
||||
(*SendTransactionRequest)(nil), // 12: nockchain.public.v2.SendTransactionRequest
|
||||
(*SendTransactionResponse)(nil), // 13: nockchain.public.v2.SendTransactionResponse
|
||||
(ImportType)(0), // 14: nockchain.public.v2.ImportType
|
||||
(*RawTx)(nil), // 15: nockchain.public.v2.RawTx
|
||||
(*ScanData)(nil), // 16: nockchain.public.v2.ScanData
|
||||
(*Balance)(nil), // 17: nockchain.public.v2.Balance
|
||||
(*WalletSendTransactionResponse)(nil), // 18: nockchain.public.v2.WalletSendTransactionResponse
|
||||
(*TransactionAcceptedRequest)(nil), // 19: nockchain.public.v2.TransactionAcceptedRequest
|
||||
(*TransactionAcceptedResponse)(nil), // 20: nockchain.public.v2.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
|
||||
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
|
||||
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
|
||||
14, // 0: nockchain.public.v2.ImportKeysRequest.import_type:type_name -> nockchain.public.v2.ImportType
|
||||
15, // 1: nockchain.public.v2.CreateTxResponse.rawTx:type_name -> nockchain.public.v2.RawTx
|
||||
16, // 2: nockchain.public.v2.ScanResponse.scan_data:type_name -> nockchain.public.v2.ScanData
|
||||
17, // 3: nockchain.public.v2.GetBalanceResponse.data:type_name -> nockchain.public.v2.Balance
|
||||
15, // 4: nockchain.public.v2.SendTransactionRequest.raw_tx:type_name -> nockchain.public.v2.RawTx
|
||||
18, // 5: nockchain.public.v2.SendTransactionResponse.response:type_name -> nockchain.public.v2.WalletSendTransactionResponse
|
||||
0, // 6: nockchain.public.v2.WalletService.Keygen:input_type -> nockchain.public.v2.KeygenRequest
|
||||
2, // 7: nockchain.public.v2.WalletService.ImportKeys:input_type -> nockchain.public.v2.ImportKeysRequest
|
||||
4, // 8: nockchain.public.v2.WalletService.DeriveChild:input_type -> nockchain.public.v2.DeriveChildRequest
|
||||
6, // 9: nockchain.public.v2.WalletService.CreateTx:input_type -> nockchain.public.v2.CreateTxRequest
|
||||
8, // 10: nockchain.public.v2.WalletService.Scan:input_type -> nockchain.public.v2.ScanRequest
|
||||
10, // 11: nockchain.public.v2.WalletService.WalletGetBalance:input_type -> nockchain.public.v2.GetBalanceRequest
|
||||
12, // 12: nockchain.public.v2.WalletService.WalletSendTransaction:input_type -> nockchain.public.v2.SendTransactionRequest
|
||||
19, // 13: nockchain.public.v2.WalletService.TransactionAccepted:input_type -> nockchain.public.v2.TransactionAcceptedRequest
|
||||
1, // 14: nockchain.public.v2.WalletService.Keygen:output_type -> nockchain.public.v2.KeygenResponse
|
||||
3, // 15: nockchain.public.v2.WalletService.ImportKeys:output_type -> nockchain.public.v2.ImportKeysResponse
|
||||
5, // 16: nockchain.public.v2.WalletService.DeriveChild:output_type -> nockchain.public.v2.DeriveChildResponse
|
||||
7, // 17: nockchain.public.v2.WalletService.CreateTx:output_type -> nockchain.public.v2.CreateTxResponse
|
||||
9, // 18: nockchain.public.v2.WalletService.Scan:output_type -> nockchain.public.v2.ScanResponse
|
||||
11, // 19: nockchain.public.v2.WalletService.WalletGetBalance:output_type -> nockchain.public.v2.GetBalanceResponse
|
||||
13, // 20: nockchain.public.v2.WalletService.WalletSendTransaction:output_type -> nockchain.public.v2.SendTransactionResponse
|
||||
20, // 21: nockchain.public.v2.WalletService.TransactionAccepted:output_type -> nockchain.public.v2.TransactionAcceptedResponse
|
||||
14, // [14:22] is the sub-list for method output_type
|
||||
6, // [6:14] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_service_proto_init() }
|
||||
@ -1140,13 +1104,17 @@ func file_service_proto_init() {
|
||||
file_types_proto_init()
|
||||
file_blockchain_proto_init()
|
||||
file_nockchain_proto_init()
|
||||
file_service_proto_msgTypes[10].OneofWrappers = []any{
|
||||
(*GetBalanceRequest_Address)(nil),
|
||||
(*GetBalanceRequest_FirstName)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
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,
|
||||
},
|
||||
|
||||
@ -19,15 +19,14 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
WalletService_Keygen_FullMethodName = "/nockchain.public.v1.WalletService/Keygen"
|
||||
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"
|
||||
WalletService_TransactionAccepted_FullMethodName = "/nockchain.public.v1.WalletService/TransactionAccepted"
|
||||
WalletService_Keygen_FullMethodName = "/nockchain.public.v2.WalletService/Keygen"
|
||||
WalletService_ImportKeys_FullMethodName = "/nockchain.public.v2.WalletService/ImportKeys"
|
||||
WalletService_DeriveChild_FullMethodName = "/nockchain.public.v2.WalletService/DeriveChild"
|
||||
WalletService_CreateTx_FullMethodName = "/nockchain.public.v2.WalletService/CreateTx"
|
||||
WalletService_Scan_FullMethodName = "/nockchain.public.v2.WalletService/Scan"
|
||||
WalletService_WalletGetBalance_FullMethodName = "/nockchain.public.v2.WalletService/WalletGetBalance"
|
||||
WalletService_WalletSendTransaction_FullMethodName = "/nockchain.public.v2.WalletService/WalletSendTransaction"
|
||||
WalletService_TransactionAccepted_FullMethodName = "/nockchain.public.v2.WalletService/TransactionAccepted"
|
||||
)
|
||||
|
||||
// WalletServiceClient is the client API for WalletService service.
|
||||
@ -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 {
|
||||
@ -380,7 +348,7 @@ func _WalletService_TransactionAccepted_Handler(srv interface{}, ctx context.Con
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var WalletService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "nockchain.public.v1.WalletService",
|
||||
ServiceName: "nockchain.public.v2.WalletService",
|
||||
HandlerType: (*WalletServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
@ -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,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,17 @@
|
||||
// nockchain/common/v1/blockchain.proto
|
||||
// nockchain/common/v2/blockchain.proto
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package nockchain.public.v1;
|
||||
package nockchain.public.v2;
|
||||
|
||||
import "primitives.proto";
|
||||
import "pagination.proto";
|
||||
option go_package = "./;nockchain";
|
||||
message WalletBalanceData {
|
||||
// Page of full UTXO entries for the requested wallet. Entries are ordered
|
||||
// by (Name.first, Name.last) to support consistent pagination.
|
||||
repeated BalanceEntry notes = 1; // note name -> amount
|
||||
|
||||
// Snapshot metadata where this page was computed. Clients should include
|
||||
// the returned page token to continue paging against the same snapshot.
|
||||
BlockHeight height = 2; // block height where balance was computed
|
||||
optional Hash block_id = 3; // block where balance was computed
|
||||
|
||||
// Pagination cursor for fetching the next page in a paginated view.
|
||||
// When empty, there are no further results for this snapshot.
|
||||
message Balance {
|
||||
repeated BalanceEntry notes = 1;
|
||||
BlockHeight height = 2;
|
||||
optional Hash block_id = 3;
|
||||
PageResponse page = 4;
|
||||
}
|
||||
|
||||
@ -27,39 +20,107 @@ message BalanceEntry {
|
||||
Note note = 2;
|
||||
}
|
||||
|
||||
// the string key is the name of the input
|
||||
// message RawTransaction { map<Name, Input> inputs = 1; }
|
||||
message RawTransaction {
|
||||
repeated NamedInput named_inputs = 1;
|
||||
TimeLockRangeAbsolute timelock_range = 2;
|
||||
Nicks total_fees = 3;
|
||||
Hash id = 4;
|
||||
NoteVersion version = 1;
|
||||
Hash id = 2;
|
||||
repeated SpendEntry spends = 3;
|
||||
}
|
||||
|
||||
message NamedInput {
|
||||
message SpendEntry {
|
||||
Name name = 1;
|
||||
Input input = 2;
|
||||
}
|
||||
|
||||
message Input {
|
||||
Note note = 1;
|
||||
Spend spend = 2;
|
||||
}
|
||||
|
||||
message Spend {
|
||||
oneof spend_kind {
|
||||
LegacySpend legacy = 1;
|
||||
WitnessSpend witness = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message LegacySpend {
|
||||
Signature signature = 1;
|
||||
repeated Seed seeds = 2;
|
||||
Nicks miner_fee_nicks = 3;
|
||||
}
|
||||
|
||||
message WitnessSpend {
|
||||
Witness witness = 1;
|
||||
repeated Seed seeds = 2;
|
||||
Nicks fee = 3;
|
||||
}
|
||||
|
||||
message Seed {
|
||||
optional OutputSource output_source = 1;
|
||||
Lock recipient = 2;
|
||||
optional TimeLockIntent timelock_intent = 3;
|
||||
// Absent when the seed originates from a coinbase output.
|
||||
Source output_source = 1;
|
||||
Hash lock_root = 2;
|
||||
NoteData note_data = 3;
|
||||
Nicks gift = 4;
|
||||
Hash parent_hash = 5;
|
||||
}
|
||||
|
||||
message Witness {
|
||||
LockMerkleProof lock_merkle_proof = 1;
|
||||
PkhSignature pkh_signature = 2;
|
||||
repeated HaxPreimage hax = 3;
|
||||
//uint64 tim = 4; // reserved field, currently 0
|
||||
}
|
||||
|
||||
|
||||
message HaxPreimage {
|
||||
Hash hash = 1;
|
||||
bytes value = 2; // jammed noun bytes
|
||||
}
|
||||
|
||||
message PkhSignature {
|
||||
repeated PkhSignatureEntry entries = 1;
|
||||
}
|
||||
|
||||
message PkhSignatureEntry {
|
||||
Hash hash = 1;
|
||||
SchnorrPubkey pubkey = 2;
|
||||
SchnorrSignature signature = 3;
|
||||
}
|
||||
|
||||
message LockMerkleProof {
|
||||
SpendCondition spend_condition = 1;
|
||||
uint64 axis = 2;
|
||||
MerkleProof proof = 3;
|
||||
}
|
||||
|
||||
message SpendCondition {
|
||||
repeated LockPrimitive primitives = 1;
|
||||
}
|
||||
|
||||
message LockPrimitive {
|
||||
oneof primitive {
|
||||
PkhLock pkh = 1;
|
||||
LockTim tim = 2;
|
||||
HaxLock hax = 3;
|
||||
BurnLock burn = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message PkhLock {
|
||||
uint64 m = 1;
|
||||
repeated Hash hashes = 2;
|
||||
}
|
||||
|
||||
message LockTim {
|
||||
TimeLockRangeRelative rel = 1;
|
||||
TimeLockRangeAbsolute abs = 2;
|
||||
}
|
||||
|
||||
message HaxLock {
|
||||
repeated Hash hashes = 1;
|
||||
}
|
||||
|
||||
message BurnLock {}
|
||||
|
||||
message MerkleProof {
|
||||
Hash root = 1;
|
||||
repeated Hash path = 2;
|
||||
}
|
||||
|
||||
message OutputSource { optional Source source = 1; }
|
||||
|
||||
message Source {
|
||||
@ -110,7 +171,14 @@ message Name {
|
||||
Hash last = 2;
|
||||
}
|
||||
|
||||
|
||||
message Note {
|
||||
oneof note_version {
|
||||
NoteV0 legacy = 1;
|
||||
NoteV1 v1 = 2;
|
||||
}
|
||||
}
|
||||
message NoteV0 {
|
||||
BlockHeight origin_page = 1; // page-number when added to balance
|
||||
optional TimeLockIntent timelock = 2; // enforced timelock
|
||||
Name name = 3; // nname (human/name label)
|
||||
@ -120,11 +188,27 @@ message Note {
|
||||
NoteVersion version = 7; // note version (currently 0)
|
||||
}
|
||||
|
||||
message NoteV1 {
|
||||
NoteVersion version = 1;
|
||||
BlockHeight origin_page = 2;
|
||||
Name name = 3;
|
||||
NoteData note_data = 4;
|
||||
Nicks assets = 5;
|
||||
}
|
||||
|
||||
message NoteData {
|
||||
repeated NoteDataEntry entries = 1;
|
||||
}
|
||||
|
||||
message NoteDataEntry {
|
||||
string key = 1;
|
||||
bytes blob = 2; // jammed noun bytes
|
||||
}
|
||||
|
||||
message Signature { repeated SignatureEntry entries = 1; }
|
||||
|
||||
message SignatureEntry {
|
||||
SchnorrPubkey schnorr_pubkey =
|
||||
1; // serialized pubkey corresponding to the signer
|
||||
SchnorrPubkey schnorr_pubkey = 1; // serialized pubkey corresponding to the signer
|
||||
SchnorrSignature signature = 2;
|
||||
}
|
||||
|
||||
|
||||
75
proto/nockapp.proto
Normal file
75
proto/nockapp.proto
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package nockchain.public.v1;
|
||||
package nockchain.public.v2;
|
||||
|
||||
import "blockchain.proto";
|
||||
import "primitives.proto";
|
||||
@ -21,12 +21,15 @@ service NockchainService {
|
||||
|
||||
message WalletGetBalanceRequest {
|
||||
// pubkey cheetah point; specific address, or current wallet
|
||||
string address = 1;
|
||||
oneof selector {
|
||||
Base58Pubkey address = 1;
|
||||
Base58Hash first_name = 2;
|
||||
}
|
||||
// Pagination parameters. The server enforces limits and may return fewer
|
||||
// entries than requested to respect message size and policy. For consistent
|
||||
// paging across a stable snapshot, pass along the returned page_token from
|
||||
// the previous response without modification.
|
||||
PageRequest page = 2;
|
||||
PageRequest page = 3;
|
||||
}
|
||||
|
||||
message WalletGetBalanceResponse {
|
||||
@ -35,7 +38,7 @@ message WalletGetBalanceResponse {
|
||||
// Continue paging using `balance.page.next_page_token` until empty. Clients
|
||||
// should treat the page token as opaque; it may encode snapshot identity
|
||||
// and the last returned key.
|
||||
WalletBalanceData balance = 1;
|
||||
Balance balance = 1;
|
||||
ErrorStatus error = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package nockchain.public.v1;
|
||||
package nockchain.public.v2;
|
||||
option go_package = "./;nockchain";
|
||||
|
||||
// Generic pagination parameters for list-style RPCs.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package nockchain.public.v1;
|
||||
package nockchain.public.v2;
|
||||
option go_package = "./;nockchain";
|
||||
|
||||
message ErrorStatus {
|
||||
@ -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.
|
||||
@ -80,6 +63,10 @@ message Base58Hash {
|
||||
string hash = 1;
|
||||
}
|
||||
|
||||
message Base58Pubkey {
|
||||
string key = 1;
|
||||
}
|
||||
|
||||
// pub struct SchnorrPubkey(pub CheetahPoint);
|
||||
message SchnorrPubkey { CheetahPoint value = 1; }
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
syntax = "proto3";
|
||||
package nockchain.public.v1;
|
||||
package nockchain.public.v2;
|
||||
|
||||
option go_package = "./;nockchain";
|
||||
|
||||
@ -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,70 +21,76 @@ 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 {
|
||||
string names = 1;
|
||||
string recipients = 2;
|
||||
string gifts = 3;
|
||||
uint64 fee = 4;
|
||||
bool is_master_key = 5;
|
||||
string key = 6;
|
||||
string chain_code = 7;
|
||||
uint64 index = 8;
|
||||
bool hardened = 9;
|
||||
TimelockIntent timelock_intent = 10;
|
||||
uint64 fee = 3;
|
||||
bool is_master_key = 4;
|
||||
string seed = 5;
|
||||
uint64 index = 6;
|
||||
bool hardened = 7;
|
||||
uint64 version = 8;
|
||||
string refund_address = 9;
|
||||
}
|
||||
|
||||
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;
|
||||
@ -92,6 +98,7 @@ message ScanRequest {
|
||||
uint64 search_depth = 3;
|
||||
bool include_timelocks = 4;
|
||||
bool include_multisig = 5;
|
||||
uint64 version = 6;
|
||||
}
|
||||
|
||||
message ScanResponse {
|
||||
@ -99,11 +106,14 @@ message ScanResponse {
|
||||
}
|
||||
|
||||
message GetBalanceRequest {
|
||||
string address = 1;
|
||||
oneof selector {
|
||||
string address = 1;
|
||||
string first_name = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message GetBalanceResponse {
|
||||
WalletBalanceData data = 1;
|
||||
Balance data = 1;
|
||||
}
|
||||
|
||||
message SendTransactionRequest {
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
syntax = "proto3";
|
||||
package nockchain.public.v1;
|
||||
package nockchain.public.v2;
|
||||
|
||||
option go_package = "./;nockchain";
|
||||
|
||||
import "blockchain.proto";
|
||||
message ScanData {
|
||||
string pubkey = 1;
|
||||
WalletBalanceData data = 2;
|
||||
Balance data = 2;
|
||||
}
|
||||
enum ImportType {
|
||||
UNDEFINED = 0;
|
||||
@ -31,25 +31,52 @@ message Timelock {
|
||||
}
|
||||
|
||||
message RawTx {
|
||||
string tx_id = 1;
|
||||
repeated NockchainInput inputs = 2;
|
||||
TimelockRange timelock_range = 3;
|
||||
uint64 total_fees = 4;
|
||||
string tx_id = 1;
|
||||
Version version = 2;
|
||||
repeated NockchainNamedSpend named_spends = 3;
|
||||
}
|
||||
|
||||
message NockchainSpend {
|
||||
message NockchainNamedSpend {
|
||||
NockchainName name = 1;
|
||||
oneof spend_kind {
|
||||
NockchainSpendV0 legacy = 2;
|
||||
NockchainSpendV1 witness = 3;
|
||||
}
|
||||
}
|
||||
|
||||
message NockchainSpendV0 {
|
||||
repeated NockchainSignature signatures = 1;
|
||||
repeated NockchainSeed seeds = 2;
|
||||
uint64 fee = 3;
|
||||
}
|
||||
|
||||
message NockchainSpendV1 {
|
||||
repeated NockchainWitness witness = 1;
|
||||
repeated NockchainSeed seeds = 2;
|
||||
uint64 fee = 3;
|
||||
}
|
||||
|
||||
message NockchainNote {
|
||||
oneof note {
|
||||
NockchainNoteV0 v0 = 1;
|
||||
NockchainNoteV1 v1 = 2;
|
||||
}
|
||||
}
|
||||
message NockchainNoteV0 {
|
||||
Version version = 1;
|
||||
uint64 block_height = 2;
|
||||
optional TimelockIntent timelock = 3;
|
||||
NockchainName name = 4;
|
||||
NockchainLock lock = 5;
|
||||
NockchainSource source = 6;
|
||||
uint64 asset =7;
|
||||
uint64 origin_page = 2;
|
||||
NockchainName name = 3;
|
||||
NockchainLock lock = 4;
|
||||
NockchainSource source = 5;
|
||||
uint64 asset =6;
|
||||
}
|
||||
|
||||
message NockchainNoteV1 {
|
||||
Version version = 1;
|
||||
uint64 origin_page = 2;
|
||||
NockchainName name = 3;
|
||||
NockchainLock note_data = 4;
|
||||
uint64 assets = 5;
|
||||
}
|
||||
|
||||
message NockchainName {
|
||||
@ -57,25 +84,31 @@ message NockchainName {
|
||||
string last = 2;
|
||||
}
|
||||
|
||||
message NockchainInput {
|
||||
NockchainName name = 1;
|
||||
NockchainNote note = 2;
|
||||
NockchainSpend spend = 3;
|
||||
}
|
||||
|
||||
message NockchainSignature {
|
||||
string pubkey = 1;
|
||||
repeated uint64 chal = 2;
|
||||
repeated uint64 sig = 3;
|
||||
}
|
||||
|
||||
message NockchainWitness {
|
||||
NockchainLockMerkleProof lmp = 1;
|
||||
repeated NockchainSignature pkh = 2;
|
||||
}
|
||||
|
||||
message NockchainLockMerkleProof {
|
||||
NockchainLock spend_condition = 1;
|
||||
uint64 axis = 2;
|
||||
string merkle_root = 3;
|
||||
}
|
||||
|
||||
message NockchainSeed {
|
||||
optional NockchainSource output_source = 1;
|
||||
NockchainLock recipient = 2;
|
||||
optional TimelockIntent timelock_intent = 3;
|
||||
string lock_root = 2;
|
||||
NockchainLock note_data = 3;
|
||||
uint64 gift = 4;
|
||||
string parent_hash = 5;
|
||||
}
|
||||
|
||||
message NockchainLock {
|
||||
uint64 keys_required = 1;
|
||||
repeated string pubkeys = 2;
|
||||
@ -89,4 +122,4 @@ enum Version {
|
||||
V0 = 0;
|
||||
V1 = 1;
|
||||
V2 = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -38,26 +41,44 @@ func (nc *NockchainClient) Close() error {
|
||||
return nc.conn.Close()
|
||||
}
|
||||
|
||||
func (nc *NockchainClient) WalletGetBalance(address string) (*nockchain.WalletBalanceData, error) {
|
||||
func (nc *NockchainClient) WalletGetBalance(req *nockchain.GetBalanceRequest) (*nockchain.Balance, error) {
|
||||
pageToken := ""
|
||||
allNotes := []*nockchain.BalanceEntry{}
|
||||
var height *nockchain.BlockHeight
|
||||
var blockId *nockchain.Hash
|
||||
page := &nockchain.PageRequest{
|
||||
ClientPageItemsLimit: 0,
|
||||
PageToken: pageToken,
|
||||
MaxBytes: 0,
|
||||
}
|
||||
for {
|
||||
req := nockchain.WalletGetBalanceRequest{
|
||||
Address: address,
|
||||
Page: &nockchain.PageRequest{
|
||||
ClientPageItemsLimit: 0,
|
||||
PageToken: pageToken,
|
||||
MaxBytes: 0,
|
||||
},
|
||||
var request *nockchain.WalletGetBalanceRequest
|
||||
switch req.Selector.(type) {
|
||||
case *nockchain.GetBalanceRequest_Address:
|
||||
request = &nockchain.WalletGetBalanceRequest{
|
||||
Selector: &nockchain.WalletGetBalanceRequest_Address{
|
||||
Address: &nockchain.Base58Pubkey{
|
||||
Key: req.GetAddress(),
|
||||
},
|
||||
},
|
||||
Page: page,
|
||||
}
|
||||
case *nockchain.GetBalanceRequest_FirstName:
|
||||
request = &nockchain.WalletGetBalanceRequest{
|
||||
Selector: &nockchain.WalletGetBalanceRequest_FirstName{
|
||||
FirstName: &nockchain.Base58Hash{
|
||||
Hash: req.GetFirstName(),
|
||||
},
|
||||
},
|
||||
Page: page,
|
||||
}
|
||||
}
|
||||
resp, err := nc.client.WalletGetBalance(context.Background(), &req)
|
||||
resp, err := nc.client.WalletGetBalance(context.Background(), request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
balance := nockchain.WalletBalanceData{}
|
||||
balance := nockchain.Balance{}
|
||||
switch resp.Result.(type) {
|
||||
case *nockchain.WalletGetBalanceResponse_Balance:
|
||||
balance = *resp.GetBalance()
|
||||
@ -81,9 +102,11 @@ func (nc *NockchainClient) WalletGetBalance(address string) (*nockchain.WalletBa
|
||||
break
|
||||
} else {
|
||||
pageToken = balance.Page.NextPageToken
|
||||
page.PageToken = pageToken
|
||||
}
|
||||
}
|
||||
return &nockchain.WalletBalanceData{
|
||||
|
||||
return &nockchain.Balance{
|
||||
Notes: allNotes,
|
||||
Height: height,
|
||||
BlockId: blockId,
|
||||
@ -115,24 +138,22 @@ func (nc *NockchainClient) TxAccepted(txId string) (*nockchain.TransactionAccept
|
||||
}
|
||||
|
||||
func (nc *NockchainClient) WalletSendTransaction(tx *nockchain.RawTx) (*nockchain.WalletSendTransactionResponse, error) {
|
||||
inputs := []*nockchain.NamedInput{}
|
||||
for _, i := range tx.Inputs {
|
||||
input, err := ConvertInput(i)
|
||||
spends := []*nockchain.SpendEntry{}
|
||||
for _, namedSpend := range tx.NamedSpends {
|
||||
spendEntry, err := ConvertNamedSpend(namedSpend)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error converting input: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
inputs = append(inputs, input)
|
||||
spends = append(spends, spendEntry)
|
||||
}
|
||||
req := nockchain.WalletSendTransactionRequest{
|
||||
TxId: ParseHash(tx.TxId),
|
||||
RawTx: &nockchain.RawTransaction{
|
||||
Id: ParseHash(tx.TxId),
|
||||
NamedInputs: inputs,
|
||||
TotalFees: &nockchain.Nicks{Value: tx.TotalFees},
|
||||
TimelockRange: &nockchain.TimeLockRangeAbsolute{
|
||||
Min: (*nockchain.BlockHeight)(tx.TimelockRange.Min),
|
||||
Max: (*nockchain.BlockHeight)(tx.TimelockRange.Max),
|
||||
Id: ParseHash(tx.TxId),
|
||||
Version: &nockchain.NoteVersion{
|
||||
Value: uint32(tx.Version),
|
||||
},
|
||||
Spends: spends,
|
||||
},
|
||||
}
|
||||
|
||||
@ -150,3 +171,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")
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,9 @@ import (
|
||||
"github.com/phamminh0811/private-grpc/nockchain"
|
||||
)
|
||||
|
||||
var LastName = [5]uint64{9541855607561054508, 12383849149342406623, 11220017934615522559, 678840671137489369, 8985908938884028381}
|
||||
var (
|
||||
MerkleHash = [5]uint64{7971649669803894685, 16663670492333541326, 11038715785817710450, 18178011379925321681, 17049062282971338707}
|
||||
)
|
||||
|
||||
func HashPubkey(pkPoint crypto.CheetahPoint) [5]uint64 {
|
||||
belts := []crypto.Belt{{Value: 13}}
|
||||
@ -22,7 +24,7 @@ func HashPubkey(pkPoint crypto.CheetahPoint) [5]uint64 {
|
||||
return crypto.Tip5HashBelts(belts)
|
||||
}
|
||||
|
||||
func HashSignature(signature *nockchain.NockchainSignature) ([5]uint64, error) {
|
||||
func HashSignatureV0(signature *nockchain.NockchainSignature) ([5]uint64, error) {
|
||||
belts := []crypto.Belt{{Value: 16}}
|
||||
for _, i := range signature.Chal {
|
||||
belts = append(belts, crypto.Belt{Value: i})
|
||||
@ -40,19 +42,73 @@ func HashSignature(signature *nockchain.NockchainSignature) ([5]uint64, error) {
|
||||
}
|
||||
pkHash := HashPubkey(pkPoint)
|
||||
sigHash = crypto.Tip5RehashTenCell(pkHash, sigHash)
|
||||
sigHash = crypto.Tip5RehashTenCell(sigHash, crypto.Tip5ZeroZero)
|
||||
return crypto.Tip5RehashTenCell(crypto.Tip5Zero, sigHash), nil
|
||||
return crypto.Tip5RehashTenCell(sigHash, crypto.Tip5ZeroZero), nil
|
||||
}
|
||||
|
||||
func HashSignatureV1(signature *nockchain.NockchainSignature) ([5]uint64, error) {
|
||||
belts := []crypto.Belt{{Value: 16}}
|
||||
for _, i := range signature.Chal {
|
||||
belts = append(belts, crypto.Belt{Value: i})
|
||||
}
|
||||
for _, i := range signature.Sig {
|
||||
belts = append(belts, crypto.Belt{Value: i})
|
||||
}
|
||||
for _, i := range crypto.MagicDyckForT8 {
|
||||
belts = append(belts, crypto.Belt{Value: i})
|
||||
}
|
||||
sigHash := crypto.Tip5HashBelts(belts)
|
||||
pkPoint, err := crypto.CheetaPointFromBytes(base58.Decode(signature.Pubkey))
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
pkHash := HashPubkey(pkPoint)
|
||||
sigHash = crypto.Tip5RehashTenCell(pkHash, sigHash)
|
||||
pkHashSig := crypto.Tip5RehashTenCell(pkHash, sigHash)
|
||||
return crypto.Tip5RehashTenCell(pkHashSig, crypto.Tip5ZeroZero), nil
|
||||
}
|
||||
func HashWitness(witness *nockchain.NockchainWitness) ([5]uint64, error) {
|
||||
spendConditionHash := HashLock(witness.Lmp.SpendCondition)
|
||||
rootHash := crypto.Base58ToTip5Hash(witness.Lmp.MerkleRoot)
|
||||
rootHashZero := crypto.Tip5RehashTenCell(rootHash, crypto.Tip5Zero)
|
||||
axisHashRoot := crypto.Tip5RehashTenCell(MerkleHash, rootHashZero)
|
||||
lmpHash := crypto.Tip5RehashTenCell(spendConditionHash, axisHashRoot)
|
||||
|
||||
sigHash, err := HashSignatureV1(witness.Pkh[0])
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
sigHashZeroZero := crypto.Tip5RehashTenCell(sigHash, crypto.Tip5ZeroZero)
|
||||
return crypto.Tip5RehashTenCell(lmpHash, sigHashZeroZero), nil
|
||||
}
|
||||
|
||||
func HashNoteData(lock *nockchain.NockchainLock) [5]uint64 {
|
||||
keysRequiredHash := crypto.Tip5HashLeaf(lock.KeysRequired)
|
||||
// TODO: handle multisig
|
||||
finalHash := crypto.Base58ToTip5Hash(lock.Pubkeys[lock.KeysRequired-1])
|
||||
hash := crypto.Tip5RehashTenCell(crypto.Tip5HashLeaf(finalHash[3]), crypto.Tip5HashLeaf(finalHash[4]))
|
||||
hash = crypto.Tip5RehashTenCell(crypto.Tip5HashLeaf(finalHash[2]), hash)
|
||||
hash = crypto.Tip5RehashTenCell(crypto.Tip5HashLeaf(finalHash[1]), hash)
|
||||
hash = crypto.Tip5RehashTenCell(crypto.Tip5HashLeaf(finalHash[0]), hash)
|
||||
hash = crypto.Tip5RehashTenCell(hash, crypto.Tip5ZeroZero)
|
||||
|
||||
pkh := crypto.Tip5RehashTenCell(keysRequiredHash, hash)
|
||||
pkhWithPkhTag := crypto.Tip5RehashTenCell(crypto.PkhTagTip5Hash, pkh)
|
||||
pkhWithPkhTag = crypto.Tip5RehashTenCell(pkhWithPkhTag, crypto.Tip5Zero)
|
||||
pkhWithPkhTag = crypto.Tip5RehashTenCell(crypto.Tip5Zero, pkhWithPkhTag)
|
||||
|
||||
pkhWithPkhLockTag := crypto.Tip5RehashTenCell(crypto.LockTagTip5Hash, pkhWithPkhTag)
|
||||
return crypto.Tip5RehashTenCell(pkhWithPkhLockTag, crypto.Tip5ZeroZero)
|
||||
}
|
||||
func HashOwner(pkPoint crypto.CheetahPoint) [5]uint64 {
|
||||
pkHashedBelts := HashPubkey(pkPoint)
|
||||
pkHashedZeroZero := crypto.Tip5RehashTenCell(pkHashedBelts, crypto.Tip5ZeroZero)
|
||||
return crypto.Tip5RehashTenCell(crypto.Tip5One, pkHashedZeroZero)
|
||||
}
|
||||
|
||||
func NockName(ownerHash [5]uint64) ([5]uint64, [5]uint64) {
|
||||
firstName := first(ownerHash)
|
||||
return firstName, LastName
|
||||
func NockFirstName(ownerHash [5]uint64) [5]uint64 {
|
||||
ownerHashZero := crypto.Tip5RehashTenCell(ownerHash, crypto.Tip5Zero)
|
||||
ownerHashZeroOne := crypto.Tip5RehashTenCell(crypto.Tip5One, ownerHashZero)
|
||||
return crypto.Tip5RehashTenCell(crypto.Tip5Zero, ownerHashZeroOne)
|
||||
}
|
||||
|
||||
func HashName(name *nockchain.NockchainName) [5]uint64 {
|
||||
@ -79,15 +135,14 @@ func HashNameVarLen(name *nockchain.NockchainName) [5]uint64 {
|
||||
return res
|
||||
}
|
||||
|
||||
func HashNote(note *nockchain.NockchainNote) ([5]uint64, error) {
|
||||
func HashNoteV0(note *nockchain.NockchainNoteV0) ([5]uint64, error) {
|
||||
versionHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: uint64(note.Version)}})
|
||||
blockHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: note.BlockHeight}})
|
||||
timelockHash := HashTimelockIntent(note.Timelock)
|
||||
hashBlockTimeLock := crypto.Tip5RehashTenCell(blockHash, timelockHash)
|
||||
blockHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: note.OriginPage}})
|
||||
hashBlockTimeLock := crypto.Tip5RehashTenCell(blockHash, crypto.Tip5Zero)
|
||||
|
||||
p := crypto.Tip5RehashTenCell(versionHash, hashBlockTimeLock)
|
||||
nameHash := HashName(note.Name)
|
||||
lockHash, err := HashLock(note.Lock)
|
||||
lockHash, err := HashLockV0(note.Lock)
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
@ -101,6 +156,19 @@ func HashNote(note *nockchain.NockchainNote) ([5]uint64, error) {
|
||||
return crypto.Tip5RehashTenCell(p, q), nil
|
||||
}
|
||||
|
||||
func HashNoteV1(note *nockchain.NockchainNoteV1) [5]uint64 {
|
||||
versionHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: uint64(note.Version)}})
|
||||
blockHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: note.OriginPage}})
|
||||
nameHash := HashName(note.Name)
|
||||
noteDataHash := HashNoteData(note.NoteData)
|
||||
assetHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: uint64(note.Assets)}})
|
||||
|
||||
hashNoteDataAsset := crypto.Tip5RehashTenCell(noteDataHash, assetHash)
|
||||
hashNameNoteDataAsset := crypto.Tip5RehashTenCell(nameHash, hashNoteDataAsset)
|
||||
q := crypto.Tip5RehashTenCell(blockHash, hashNameNoteDataAsset)
|
||||
return crypto.Tip5RehashTenCell(versionHash, q)
|
||||
}
|
||||
|
||||
func HashTimelockIntent(timelock *nockchain.TimelockIntent) [5]uint64 {
|
||||
if timelock == nil {
|
||||
return crypto.Tip5Zero
|
||||
@ -133,7 +201,8 @@ func HashTimelockRange(timelockRange *nockchain.TimelockRange) [5]uint64 {
|
||||
|
||||
return hash
|
||||
}
|
||||
func HashLock(lock *nockchain.NockchainLock) ([5]uint64, error) {
|
||||
|
||||
func HashLockV0(lock *nockchain.NockchainLock) ([5]uint64, error) {
|
||||
keysRequiredHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: lock.KeysRequired}})
|
||||
|
||||
finalPk := base58.Decode(lock.Pubkeys[lock.KeysRequired-1])
|
||||
@ -159,6 +228,23 @@ func HashLock(lock *nockchain.NockchainLock) ([5]uint64, error) {
|
||||
return crypto.Tip5RehashTenCell(keysRequiredHash, finalHash), nil
|
||||
}
|
||||
|
||||
func HashLock(lock *nockchain.NockchainLock) [5]uint64 {
|
||||
keysRequiredHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: lock.KeysRequired}})
|
||||
|
||||
pkh := crypto.Base58ToTip5Hash(lock.Pubkeys[lock.KeysRequired-1])
|
||||
finalHash := crypto.Tip5RehashTenCell(pkh, crypto.Tip5ZeroZero)
|
||||
if lock.KeysRequired != 1 {
|
||||
for i := uint64(1); i < lock.KeysRequired; i++ {
|
||||
pkh := crypto.Base58ToTip5Hash(lock.Pubkeys[lock.KeysRequired-1-i])
|
||||
finalHash = crypto.Tip5RehashTenCell(pkh, finalHash)
|
||||
}
|
||||
}
|
||||
|
||||
lockHash := crypto.Tip5RehashTenCell(keysRequiredHash, finalHash)
|
||||
lockHashWithTag := crypto.Tip5RehashTenCell(crypto.PkhTagTip5Hash, lockHash)
|
||||
return crypto.Tip5RehashTenCell(lockHashWithTag, crypto.Tip5Zero)
|
||||
}
|
||||
|
||||
func HashSource(source *nockchain.NockchainSource) [5]uint64 {
|
||||
if source == nil {
|
||||
return crypto.Tip5Zero
|
||||
@ -167,43 +253,42 @@ func HashSource(source *nockchain.NockchainSource) [5]uint64 {
|
||||
return crypto.Tip5RehashTenCell(sourceHash, crypto.Tip5One)
|
||||
}
|
||||
|
||||
func HashSeedWithoutSource(seed *nockchain.NockchainSeed) ([5]uint64, error) {
|
||||
lockHash, err := HashLock(seed.Recipient)
|
||||
if err != nil {
|
||||
return [5]uint64{}, nil
|
||||
}
|
||||
timelockIntentHash := HashTimelockIntent(seed.TimelockIntent)
|
||||
func HashSeedWithoutSource(seed *nockchain.NockchainSeed) [5]uint64 {
|
||||
lockRoot := crypto.Base58ToTip5Hash(seed.LockRoot)
|
||||
assetHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: seed.Gift}})
|
||||
|
||||
parentHash := crypto.Base58ToTip5Hash(seed.ParentHash)
|
||||
assetHashparentHash := crypto.Tip5RehashTenCell(assetHash, parentHash)
|
||||
|
||||
timelockHashAssetParentHash := crypto.Tip5RehashTenCell(timelockIntentHash, assetHashparentHash)
|
||||
noteDataHash := HashNoteData(seed.NoteData)
|
||||
noteDataHashAssetParentHash := crypto.Tip5RehashTenCell(noteDataHash, assetHashparentHash)
|
||||
|
||||
seedHash := crypto.Tip5RehashTenCell(lockHash, timelockHashAssetParentHash)
|
||||
return seedHash, nil
|
||||
seedHash := crypto.Tip5RehashTenCell(lockRoot, noteDataHashAssetParentHash)
|
||||
return seedHash
|
||||
}
|
||||
func HashSeed(seed *nockchain.NockchainSeed) ([5]uint64, error) {
|
||||
seedHash, err := HashSeedWithoutSource(seed)
|
||||
if err != nil {
|
||||
return [5]uint64{}, nil
|
||||
}
|
||||
func HashSeed(seed *nockchain.NockchainSeed) [5]uint64 {
|
||||
seedHash := HashSeedWithoutSource(seed)
|
||||
sourceHash := HashSource(seed.OutputSource)
|
||||
return crypto.Tip5RehashTenCell(sourceHash, seedHash), nil
|
||||
return crypto.Tip5RehashTenCell(sourceHash, seedHash)
|
||||
}
|
||||
|
||||
func HashSeedVarLen(seed *nockchain.NockchainSeed) ([5]uint64, error) {
|
||||
func HashSeedVarLen(seed *nockchain.NockchainSeed) [5]uint64 {
|
||||
belts := []crypto.Belt{{Value: 0}}
|
||||
belts = append(belts, crypto.Belt{Value: seed.Recipient.KeysRequired})
|
||||
for _, pk := range seed.Recipient.Pubkeys {
|
||||
pkPoint, err := crypto.CheetaPointFromBytes(base58.Decode(pk))
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
belts = append(belts, pkPoint.X[:]...)
|
||||
belts = append(belts, pkPoint.Y[:]...)
|
||||
lockRoot := crypto.Base58ToTip5Hash(seed.LockRoot)
|
||||
for _, i := range lockRoot {
|
||||
belts = append(belts, crypto.Belt{Value: i})
|
||||
}
|
||||
belts = append(belts, []crypto.Belt{{Value: 1}, {Value: 0}, {Value: 0}, {Value: 0}, {Value: seed.Gift}}...)
|
||||
// %lock and %pkh tag
|
||||
belts = append(belts, []crypto.Belt{{Value: 1801678700}, {Value: 0}, {Value: 6843248}}...)
|
||||
belts = append(belts, crypto.Belt{Value: seed.NoteData.KeysRequired})
|
||||
for _, pk := range seed.NoteData.Pubkeys {
|
||||
pkHash := crypto.Base58ToTip5Hash(pk)
|
||||
for _, i := range pkHash {
|
||||
belts = append(belts, crypto.Belt{Value: i})
|
||||
}
|
||||
}
|
||||
|
||||
belts = append(belts, []crypto.Belt{{Value: 0}, {Value: 0}, {Value: 0}, {Value: 0}, {Value: 0}, {Value: seed.Gift}}...)
|
||||
parentHash := crypto.Base58ToTip5Hash(seed.ParentHash)
|
||||
for _, i := range parentHash {
|
||||
belts = append(belts, crypto.Belt{Value: i})
|
||||
@ -213,9 +298,12 @@ func HashSeedVarLen(seed *nockchain.NockchainSeed) ([5]uint64, error) {
|
||||
for _, i := range crypto.MagicDyckForSeed {
|
||||
belts = append(belts, crypto.Belt{Value: i})
|
||||
}
|
||||
return crypto.Tip5HashBelts(belts), nil
|
||||
return crypto.Tip5HashBelts(belts)
|
||||
}
|
||||
func HashNonce(pkPoint crypto.CheetahPoint, message [5]uint64) ([]crypto.Belt, [5]uint64) {
|
||||
|
||||
func HashNonce(pkPoint crypto.CheetahPoint, message [5]uint64, privKey []byte) ([]crypto.Belt, [5]uint64) {
|
||||
privKeyBigInt := new(big.Int).SetBytes(privKey)
|
||||
privKeyT8 := crypto.BigIntToT8(*privKeyBigInt)
|
||||
belts := []crypto.Belt{}
|
||||
for _, belt := range pkPoint.X {
|
||||
belts = append(belts, belt)
|
||||
@ -228,140 +316,179 @@ func HashNonce(pkPoint crypto.CheetahPoint, message [5]uint64) ([]crypto.Belt, [
|
||||
for _, belt := range message {
|
||||
belts = append(belts, crypto.Belt{Value: belt})
|
||||
}
|
||||
|
||||
resBelts := make([]crypto.Belt, len(belts))
|
||||
copy(resBelts, belts)
|
||||
|
||||
for _, belt := range privKeyT8 {
|
||||
belts = append(belts, crypto.Belt{Value: belt})
|
||||
}
|
||||
|
||||
return resBelts, crypto.Tip5HashBelts(belts)
|
||||
}
|
||||
|
||||
func HashSpend(spend *nockchain.NockchainSpend) ([5]uint64, error) {
|
||||
func HashSpendV0(spend *nockchain.NockchainSpendV0) ([5]uint64, error) {
|
||||
// TODO: handle multiple sig
|
||||
if len(spend.Signatures) == 0 {
|
||||
return [5]uint64{}, fmt.Errorf("signatures can not be empty")
|
||||
}
|
||||
|
||||
sigHash, err := HashSignature(spend.Signatures[0])
|
||||
sigHash, err := HashSignatureV0(spend.Signatures[0])
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
|
||||
seedsTree := NewZTree(
|
||||
func(i interface{}) [5]uint64 {
|
||||
if seed, ok := i.(*nockchain.NockchainSeed); ok {
|
||||
seedHash, err := HashSeedVarLen(seed)
|
||||
if err != nil {
|
||||
return [5]uint64{}
|
||||
}
|
||||
return seedHash
|
||||
} else {
|
||||
return [5]uint64{}
|
||||
}
|
||||
},
|
||||
func(i interface{}) ([5]uint64, error) {
|
||||
if seed, ok := i.(*nockchain.NockchainSeed); ok {
|
||||
hash, err := HashSeedWithoutSource(seed)
|
||||
return hash, err
|
||||
} else {
|
||||
return [5]uint64{}, fmt.Errorf("invalid input type")
|
||||
}
|
||||
},
|
||||
)
|
||||
for _, seed := range spend.Seeds {
|
||||
seedsTree.Insert(seed, seed)
|
||||
}
|
||||
finalSeedHash, err := seedsTree.Hash()
|
||||
seedHashFee, err := HashSeedsAndFee(spend.Seeds, spend.Fee)
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
|
||||
feeHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: spend.Fee}})
|
||||
seedHashFee := crypto.Tip5RehashTenCell(finalSeedHash, feeHash)
|
||||
return crypto.Tip5RehashTenCell(sigHash, seedHashFee), nil
|
||||
|
||||
}
|
||||
|
||||
func HashMsg(spend *nockchain.NockchainSpend) ([5]uint64, error) {
|
||||
func HashSpendV1(spend *nockchain.NockchainSpendV1) ([5]uint64, error) {
|
||||
if len(spend.Witness) == 0 {
|
||||
return [5]uint64{}, fmt.Errorf("witness can not be empty")
|
||||
}
|
||||
|
||||
witnessHash, err := HashWitness(spend.Witness[0])
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
|
||||
seedHashFee, err := HashSeedsAndFee(spend.Seeds, spend.Fee)
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
return crypto.Tip5RehashTenCell(witnessHash, seedHashFee), nil
|
||||
}
|
||||
|
||||
func HashMsg(seeds []*nockchain.NockchainSeed, fee uint64) ([5]uint64, error) {
|
||||
seedsTree := NewZTree(
|
||||
func(i interface{}) [5]uint64 {
|
||||
if seed, ok := i.(*nockchain.NockchainSeed); ok {
|
||||
seedHash, err := HashSeedVarLen(seed)
|
||||
if err != nil {
|
||||
return [5]uint64{}
|
||||
}
|
||||
return seedHash
|
||||
return HashSeedVarLen(seed)
|
||||
} else {
|
||||
return [5]uint64{}
|
||||
}
|
||||
},
|
||||
func(i interface{}) ([5]uint64, error) {
|
||||
if seed, ok := i.(*nockchain.NockchainSeed); ok {
|
||||
hash, err := HashSeed(seed)
|
||||
return hash, err
|
||||
return HashSeed(seed), nil
|
||||
} else {
|
||||
return [5]uint64{}, fmt.Errorf("invalid input type")
|
||||
}
|
||||
},
|
||||
)
|
||||
for _, seed := range spend.Seeds {
|
||||
for _, seed := range seeds {
|
||||
seedsTree.Insert(seed, seed)
|
||||
}
|
||||
finalSeedHash, err := seedsTree.Hash()
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
feeHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: spend.Fee}})
|
||||
feeHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: fee}})
|
||||
return crypto.Tip5RehashTenCell(finalSeedHash, feeHash), nil
|
||||
}
|
||||
|
||||
func HashInput(input *nockchain.NockchainInput) ([5]uint64, error) {
|
||||
nameHash := HashName(input.Name)
|
||||
|
||||
noteHash, err := HashNote(input.Note)
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
|
||||
}
|
||||
spendHash, err := HashSpend(input.Spend)
|
||||
if err != nil {
|
||||
return [5]uint64{}, err
|
||||
|
||||
}
|
||||
hashNoteSpend := crypto.Tip5RehashTenCell(noteHash, spendHash)
|
||||
return crypto.Tip5RehashTenCell(nameHash, hashNoteSpend), nil
|
||||
}
|
||||
|
||||
func ComputeTxId(inputs []*nockchain.NockchainInput, timelockRange *nockchain.TimelockRange, totalFees uint64) ([5]uint64, error) {
|
||||
|
||||
inputTree := NewZTree(
|
||||
func HashSeedsAndFee(seeds []*nockchain.NockchainSeed, fee uint64) ([5]uint64, error) {
|
||||
seedsTree := NewZTree(
|
||||
func(i interface{}) [5]uint64 {
|
||||
if name, ok := i.(*nockchain.NockchainName); ok {
|
||||
return HashNameVarLen(name)
|
||||
if seed, ok := i.(*nockchain.NockchainSeed); ok {
|
||||
return HashSeedVarLen(seed)
|
||||
} else {
|
||||
return [5]uint64{}
|
||||
}
|
||||
},
|
||||
func(i interface{}) ([5]uint64, error) {
|
||||
if input, ok := i.(*nockchain.NockchainInput); ok {
|
||||
hash, err := HashInput(input)
|
||||
return hash, err
|
||||
if seed, ok := i.(*nockchain.NockchainSeed); ok {
|
||||
return HashSeedWithoutSource(seed), nil
|
||||
} else {
|
||||
return [5]uint64{}, fmt.Errorf("invalid input type")
|
||||
}
|
||||
},
|
||||
)
|
||||
for _, input := range inputs {
|
||||
inputTree.Insert(input.Name, input)
|
||||
for _, seed := range seeds {
|
||||
seedsTree.Insert(seed, seed)
|
||||
}
|
||||
inputHash, err := inputTree.Hash()
|
||||
finalSeedHash, err := seedsTree.Hash()
|
||||
if err != nil {
|
||||
return [5]uint64{}, fmt.Errorf("error hashing inputs: %v", err)
|
||||
return [5]uint64{}, err
|
||||
}
|
||||
|
||||
timelockHash := HashTimelockRange(timelockRange)
|
||||
feeHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: fee}})
|
||||
return crypto.Tip5RehashTenCell(finalSeedHash, feeHash), nil
|
||||
}
|
||||
|
||||
totalFeesHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: totalFees}})
|
||||
func ComputeTxId(spends []*nockchain.NockchainNamedSpend, version uint64) ([5]uint64, error) {
|
||||
var spendHash [5]uint64
|
||||
var err error
|
||||
switch version {
|
||||
case 0:
|
||||
spendTree := NewZTree(
|
||||
func(i interface{}) [5]uint64 {
|
||||
if name, ok := i.(*nockchain.NockchainName); ok {
|
||||
return HashNameVarLen(name)
|
||||
} else {
|
||||
return [5]uint64{}
|
||||
}
|
||||
},
|
||||
func(i interface{}) ([5]uint64, error) {
|
||||
if spendEntry, ok := i.(*nockchain.NockchainNamedSpend); ok {
|
||||
nameHash := HashName(spendEntry.Name)
|
||||
spendV0Hash, err := HashSpendV0(spendEntry.GetLegacy())
|
||||
if err != nil {
|
||||
return [5]uint64{}, fmt.Errorf("error hashing spend: %v", err)
|
||||
}
|
||||
|
||||
q := crypto.Tip5RehashTenCell(timelockHash, totalFeesHash)
|
||||
return crypto.Tip5RehashTenCell(inputHash, q), nil
|
||||
zeroHashspend := crypto.Tip5RehashTenCell(crypto.Tip5Zero, spendV0Hash)
|
||||
return crypto.Tip5RehashTenCell(nameHash, zeroHashspend), nil
|
||||
} else {
|
||||
return [5]uint64{}, fmt.Errorf("invalid input type")
|
||||
}
|
||||
},
|
||||
)
|
||||
for _, spend := range spends {
|
||||
spendTree.Insert(spend.Name, spend)
|
||||
}
|
||||
spendHash, err = spendTree.Hash()
|
||||
if err != nil {
|
||||
return [5]uint64{}, fmt.Errorf("error hashing spends: %v", err)
|
||||
}
|
||||
case 1:
|
||||
spendTree := NewZTree(
|
||||
func(i interface{}) [5]uint64 {
|
||||
if name, ok := i.(*nockchain.NockchainName); ok {
|
||||
return HashNameVarLen(name)
|
||||
} else {
|
||||
return [5]uint64{}
|
||||
}
|
||||
},
|
||||
func(i interface{}) ([5]uint64, error) {
|
||||
if spendEntry, ok := i.(*nockchain.NockchainNamedSpend); ok {
|
||||
nameHash := HashName(spendEntry.Name)
|
||||
spendV1Hash, err := HashSpendV1(spendEntry.GetWitness())
|
||||
if err != nil {
|
||||
return [5]uint64{}, fmt.Errorf("error hashing spend: %v", err)
|
||||
}
|
||||
|
||||
oneHashspend := crypto.Tip5RehashTenCell(crypto.Tip5One, spendV1Hash)
|
||||
return crypto.Tip5RehashTenCell(nameHash, oneHashspend), nil
|
||||
} else {
|
||||
return [5]uint64{}, fmt.Errorf("invalid input type")
|
||||
}
|
||||
},
|
||||
)
|
||||
for _, spend := range spends {
|
||||
spendTree.Insert(spend.Name, spend)
|
||||
}
|
||||
spendHash, err = spendTree.Hash()
|
||||
if err != nil {
|
||||
return [5]uint64{}, fmt.Errorf("error hashing spends: %v", err)
|
||||
}
|
||||
default:
|
||||
return [5]uint64{}, fmt.Errorf("unsupported version %d", version)
|
||||
}
|
||||
return crypto.Tip5RehashTenCell(crypto.Tip5One, spendHash), nil
|
||||
}
|
||||
|
||||
func ComputeSig(m crypto.MasterKey, msg [5]uint64) ([8]uint64, [8]uint64, error) {
|
||||
@ -369,7 +496,7 @@ func ComputeSig(m crypto.MasterKey, msg [5]uint64) ([8]uint64, [8]uint64, error)
|
||||
if err != nil {
|
||||
return [8]uint64{}, [8]uint64{}, err
|
||||
}
|
||||
belts, nonce := HashNonce(pkPoint, msg)
|
||||
belts, nonce := HashNonce(pkPoint, msg, m.PrivateKey)
|
||||
nonceBigInt := crypto.TruncGOrder(nonce)
|
||||
scalar := crypto.CheetahScaleBig(crypto.A_GEN, *nonceBigInt)
|
||||
|
||||
@ -389,9 +516,3 @@ func ComputeSig(m crypto.MasterKey, msg [5]uint64) ([8]uint64, [8]uint64, error)
|
||||
sigT8 := crypto.BigIntToT8(*sig)
|
||||
return chalT8, sigT8, nil
|
||||
}
|
||||
|
||||
func first(ownerHash [5]uint64) [5]uint64 {
|
||||
ownerHashZero := crypto.Tip5RehashTenCell(ownerHash, crypto.Tip5Zero)
|
||||
ownerHashZeroOne := crypto.Tip5RehashTenCell(crypto.Tip5One, ownerHashZero)
|
||||
return crypto.Tip5RehashTenCell(crypto.Tip5Zero, ownerHashZeroOne)
|
||||
}
|
||||
|
||||
156
wallet/noun.go
Normal file
156
wallet/noun.go
Normal file
@ -0,0 +1,156 @@
|
||||
package wallet
|
||||
|
||||
import (
|
||||
"math/bits"
|
||||
|
||||
"github.com/phamminh0811/private-grpc/crypto"
|
||||
"github.com/phamminh0811/private-grpc/nockchain"
|
||||
)
|
||||
|
||||
var InitialBits = []bool{true, false, false, true, true, false, true, false, false, false, false, false, false, false, true, true, true, true, false, false, false, false, false, true, true, true, false, true, true, false, true, false, true, true, false, false, false, false, true, false, true, true, true, false}
|
||||
|
||||
func NumBitsUint64(v uint64) int {
|
||||
if v == 0 {
|
||||
return 0
|
||||
}
|
||||
return 64 - bits.LeadingZeros64(v)
|
||||
}
|
||||
|
||||
func Uint64ToBitsLSB0(x uint64) []bool {
|
||||
bits := make([]bool, 64)
|
||||
for i := 0; i < 64; i++ {
|
||||
bits[i] = ((x >> i) & 1) == 1
|
||||
}
|
||||
return bits
|
||||
}
|
||||
|
||||
func BitsToUint64LSB0(bits []bool, start, sz int) uint64 {
|
||||
var data uint64
|
||||
for i := 0; i < sz; i++ {
|
||||
if bits[start+i] {
|
||||
data |= 1 << i // LSB0: bit 0 = least significant
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func BoolsToBytesLSB0(bits []bool) []byte {
|
||||
if len(bits) == 0 {
|
||||
return nil
|
||||
}
|
||||
n := (len(bits) + 7) / 8 // ceil division
|
||||
bytes := make([]byte, n)
|
||||
for i, bit := range bits {
|
||||
if bit {
|
||||
byteIdx := i / 8
|
||||
bitIdx := i % 8
|
||||
bytes[byteIdx] |= 1 << bitIdx // LSB0: least-significant bit first
|
||||
}
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
|
||||
func BytesToBoolsLSB0(data []byte) []bool {
|
||||
bools := make([]bool, len(data)*8)
|
||||
for i, b := range data {
|
||||
for j := 0; j < 8; j++ {
|
||||
bools[i*8+j] = ((b >> j) & 1) == 1 // LSB0 order
|
||||
}
|
||||
}
|
||||
return bools
|
||||
}
|
||||
|
||||
func EncodeNoteData(noteData *nockchain.NockchainLock) []byte {
|
||||
bits := InitialBits
|
||||
|
||||
numPubkeys := noteData.KeysRequired
|
||||
numPubkeysSz := NumBitsUint64(uint64(numPubkeys))
|
||||
numPubkeysSzSz := NumBitsUint64(uint64(numPubkeysSz))
|
||||
|
||||
bits = append(bits, false)
|
||||
for i := 0; i < numPubkeysSzSz; i++ {
|
||||
bits = append(bits, false)
|
||||
}
|
||||
bits = append(bits, true)
|
||||
|
||||
if numPubkeysSzSz > 1 {
|
||||
numPubkeysSzBits := Uint64ToBitsLSB0(uint64(numPubkeysSz))
|
||||
bits = append(bits, numPubkeysSzBits[0:numPubkeysSzSz-1]...)
|
||||
}
|
||||
|
||||
numPubkeysBits := Uint64ToBitsLSB0(uint64(numPubkeys))
|
||||
bits = append(bits, numPubkeysBits[0:numPubkeysSz]...)
|
||||
bits = append(bits, []bool{true, false}...)
|
||||
for _, pkStr := range noteData.Pubkeys {
|
||||
pkHash := crypto.Base58ToTip5Hash(pkStr)
|
||||
for i, hash := range pkHash {
|
||||
if i != 4 {
|
||||
bits = append(bits, []bool{true, false}...)
|
||||
}
|
||||
hashSz := NumBitsUint64(hash)
|
||||
hashSzSz := NumBitsUint64(uint64(hashSz))
|
||||
|
||||
bits = append(bits, false)
|
||||
for i := 0; i < hashSzSz; i++ {
|
||||
bits = append(bits, false)
|
||||
}
|
||||
bits = append(bits, true)
|
||||
|
||||
if hashSzSz > 1 {
|
||||
hashSzBits := Uint64ToBitsLSB0(uint64(hashSz))
|
||||
bits = append(bits, hashSzBits[0:hashSzSz-1]...)
|
||||
}
|
||||
|
||||
hashBits := Uint64ToBitsLSB0(hash)
|
||||
bits = append(bits, hashBits[0:hashSz]...)
|
||||
}
|
||||
}
|
||||
|
||||
bits = append(bits, []bool{true, false, false, true, false, true, false, true}...)
|
||||
return BoolsToBytesLSB0(bits)
|
||||
}
|
||||
|
||||
func DecodeNoteData(blob []byte) *nockchain.NockchainLock {
|
||||
bits := BytesToBoolsLSB0(blob)
|
||||
|
||||
start := len(InitialBits) + 1
|
||||
count := 0
|
||||
for !bits[start] {
|
||||
start += 1
|
||||
count += 1
|
||||
}
|
||||
start += 1
|
||||
numPksSz := uint64(1)
|
||||
if count > 1 {
|
||||
numPksSz = BitsToUint64LSB0(bits, start, count-1)
|
||||
start += count - 1
|
||||
}
|
||||
numPks := BitsToUint64LSB0(bits, start, int(numPksSz))
|
||||
start += int(numPksSz)
|
||||
start += 2
|
||||
pkHash := [5]uint64{}
|
||||
for i := 0; i < 5; i++ {
|
||||
if i != 4 {
|
||||
start += 2
|
||||
}
|
||||
start += 1
|
||||
count := 0
|
||||
for !bits[start] {
|
||||
start += 1
|
||||
count += 1
|
||||
}
|
||||
start += 1
|
||||
hashSz := uint64(count)
|
||||
if count > 1 {
|
||||
hashSz = BitsToUint64LSB0(bits, start, count-1) + 1<<(count-1)
|
||||
start += count - 1
|
||||
}
|
||||
hash := BitsToUint64LSB0(bits, start, int(hashSz))
|
||||
start += int(hashSz)
|
||||
pkHash[i] = hash
|
||||
}
|
||||
return &nockchain.NockchainLock{
|
||||
KeysRequired: numPks,
|
||||
Pubkeys: []string{crypto.Tip5HashToBase58(pkHash)},
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package wallet
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
context "context"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
@ -15,6 +16,13 @@ import (
|
||||
"github.com/phamminh0811/private-grpc/nockchain"
|
||||
)
|
||||
|
||||
const (
|
||||
WitnessWordsCount = 55
|
||||
SignatureWordsCount = 31
|
||||
SeedWordsCount = 13
|
||||
BaseFee = 1 << 15
|
||||
)
|
||||
|
||||
type GprcHandler struct {
|
||||
nockchain.UnimplementedWalletServiceServer
|
||||
client NockchainClient
|
||||
@ -49,13 +57,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, int(req.Version), crypto.KeyType_PRIVATE)),
|
||||
ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, int(req.Version), crypto.KeyType_PUBLIC)),
|
||||
Version: req.Version,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -88,13 +109,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, int(req.Version), crypto.KeyType_PRIVATE)),
|
||||
ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, int(req.Version), crypto.KeyType_PUBLIC)),
|
||||
Version: req.Version,
|
||||
}, nil
|
||||
case strings.HasPrefix(req.Key, "zpub"):
|
||||
if len(data) != 147 {
|
||||
@ -111,13 +145,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, int(req.Version), crypto.KeyType_PUBLIC)),
|
||||
Version: req.Version,
|
||||
}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid extended key")
|
||||
@ -140,13 +187,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, int(req.Version), crypto.KeyType_PRIVATE)),
|
||||
ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, int(req.Version), crypto.KeyType_PUBLIC)),
|
||||
Version: req.Version,
|
||||
}, nil
|
||||
case nockchain.ImportType_SEEDPHRASE:
|
||||
masterKey, err := crypto.MasterKeyFromSeed(req.Key)
|
||||
@ -154,23 +214,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, int(req.Version), crypto.KeyType_PRIVATE)),
|
||||
ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, int(req.Version), 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 +298,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 +342,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")
|
||||
@ -256,20 +368,14 @@ func (h *GprcHandler) DeriveChild(ctx context.Context, req *nockchain.DeriveChil
|
||||
// - `names` - Comma-separated list of note name pairs in format "[first last]"
|
||||
// Example: "[first1 last1],[first2 last2]"
|
||||
//
|
||||
// - `recipients` - Comma-separated list of recipient $locks
|
||||
// Example: "[1 pk1],[2 pk2,pk3,pk4]"
|
||||
// A simple comma-separated list is also supported: "pk1,pk2,pk3",
|
||||
// where it is presumed that all recipients are single-signature,
|
||||
// that is to say, it is the same as "[1 pk1],[1 pk2],[1 pk3]"
|
||||
//
|
||||
// - `gifts` - Comma-separated list of amounts to send to each recipient
|
||||
// Example: "100,200"
|
||||
// - `recipients` Comma-separated list of transaction output, formatted as "<recipient1>:<amount1>,<recipient1>:<amount1>"
|
||||
//
|
||||
// - `fee` - Transaction fee to be subtracted from one of the input notes
|
||||
func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxRequest) (*nockchain.CreateTxResponse, error) {
|
||||
nnames := []*nockchain.NockchainName{}
|
||||
names := strings.Split(req.Names, ",")
|
||||
notes := make([]*nockchain.NockchainNote, len(names))
|
||||
notesV0 := make([]*nockchain.NockchainNoteV0, len(names))
|
||||
notesV1 := make([]*nockchain.NockchainNoteV1, len(names))
|
||||
for _, name := range names {
|
||||
name = strings.TrimSpace(name)
|
||||
if strings.HasPrefix(name, "[") && strings.HasSuffix(name, "]") {
|
||||
@ -284,87 +390,26 @@ func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxReque
|
||||
}
|
||||
}
|
||||
|
||||
nameTree := NewZTree(
|
||||
func(i interface{}) [5]uint64 {
|
||||
if name, ok := i.(*nockchain.NockchainName); ok {
|
||||
return HashNameVarLen(name)
|
||||
} else {
|
||||
return [5]uint64{}
|
||||
}
|
||||
},
|
||||
nil,
|
||||
)
|
||||
for _, name := range nnames {
|
||||
nameTree.Insert(name, nil)
|
||||
specs := strings.Split(req.Recipients, ",")
|
||||
if len(specs) == 0 {
|
||||
return nil, fmt.Errorf("at least one output must be provided")
|
||||
}
|
||||
nameList := nameTree.Tap()
|
||||
nameKeys := []string{}
|
||||
for _, nameKey := range nameList {
|
||||
name := nameKey.Key.(*nockchain.NockchainName)
|
||||
nameKeys = append(nameKeys, name.First+" "+name.Last)
|
||||
}
|
||||
indices := make([]int, len(nnames))
|
||||
for i, name := range nnames {
|
||||
if idx := slices.Index(nameKeys, name.First+" "+name.Last); idx != -1 {
|
||||
indices[idx] = i
|
||||
}
|
||||
if len(specs) > 1 {
|
||||
return nil, fmt.Errorf("multiple outputs are not supported yet, provide a single <pkh>:<amount> pair")
|
||||
}
|
||||
|
||||
recipents := []*nockchain.NockchainLock{}
|
||||
if strings.Contains(req.Recipients, "[") {
|
||||
pairs := strings.Split(req.Recipients, ",")
|
||||
for _, pair := range pairs {
|
||||
pair = strings.TrimSpace(pair)
|
||||
|
||||
if strings.HasPrefix(pair, "[") && strings.HasSuffix(pair, "]") {
|
||||
inner := pair[1 : len(pair)-1]
|
||||
parts := strings.SplitN(inner, " ", 2)
|
||||
|
||||
if len(parts) == 2 {
|
||||
number, err := strconv.ParseUint(parts[0], 10, 64)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
pubkeysStr := strings.Split(parts[1], ",")
|
||||
|
||||
recipents = append(recipents, &nockchain.NockchainLock{KeysRequired: number, Pubkeys: pubkeysStr})
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Parse simple format: "pk1,pk2,pk3"
|
||||
addrs := strings.Split(req.Recipients, ",")
|
||||
|
||||
for _, addr := range addrs {
|
||||
recipents = append(recipents, &nockchain.NockchainLock{KeysRequired: uint64(1), Pubkeys: []string{strings.TrimSpace(addr)}})
|
||||
}
|
||||
}
|
||||
gifts := []uint64{}
|
||||
for _, gift := range strings.Split(req.Gifts, ",") {
|
||||
gift, err := strconv.ParseUint(gift, 10, 64)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
gifts = append(gifts, gift)
|
||||
spec := specs[0]
|
||||
pairs := strings.Split(spec, ":")
|
||||
if len(pairs) != 2 {
|
||||
return nil, fmt.Errorf("%s", "Invalid output spec "+spec+", expected <pkh>:<amount>")
|
||||
}
|
||||
|
||||
// Verify lengths based on single vs multiple mode
|
||||
if len(recipents) == 1 && len(gifts) == 1 {
|
||||
// Single mode: can spend from multiple notes to single recipient
|
||||
// No additional validation needed - any number of names is allowed
|
||||
} else {
|
||||
// Multiple mode: all lengths must match
|
||||
if len(nnames) != len(recipents) || len(nnames) != len(gifts) {
|
||||
return nil, fmt.Errorf("multiple recipient mode requires names, recipients, and gifts to have the same length")
|
||||
}
|
||||
gift, err := strconv.ParseUint(strings.TrimSpace(pairs[1]), 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var masterKey *crypto.MasterKey
|
||||
chainCode := base58.Decode(req.ChainCode)
|
||||
key := base58.Decode(req.Key)
|
||||
masterKey, err := crypto.MasterKeyFromPrivKey(chainCode, key)
|
||||
masterKey, err := crypto.MasterKeyFromSeed(req.Seed)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -383,9 +428,55 @@ func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxReque
|
||||
}
|
||||
masterKey = &childKey
|
||||
}
|
||||
masterPkPoint, err := crypto.CheetaPointFromBytes(masterKey.PublicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pkHash := HashPubkey(masterPkPoint)
|
||||
|
||||
recipent := &nockchain.NockchainLock{
|
||||
KeysRequired: 1,
|
||||
Pubkeys: []string{strings.TrimSpace(pairs[0])},
|
||||
}
|
||||
if req.Version == 0 && req.RefundAddress == "" {
|
||||
return nil, fmt.Errorf("need to specify a refund address if spending from v0 notes")
|
||||
}
|
||||
refundAddr := req.RefundAddress
|
||||
if refundAddr == "" {
|
||||
refundAddr = crypto.Tip5HashToBase58(pkHash)
|
||||
}
|
||||
refundLock := &nockchain.NockchainLock{
|
||||
KeysRequired: 1,
|
||||
Pubkeys: []string{refundAddr},
|
||||
}
|
||||
|
||||
ownerLock := &nockchain.NockchainLock{
|
||||
KeysRequired: 1,
|
||||
Pubkeys: []string{crypto.Tip5HashToBase58(pkHash)},
|
||||
}
|
||||
|
||||
ownerHash := HashLock(ownerLock)
|
||||
// Scan key to get notes
|
||||
masterKeyScan, err := h.client.WalletGetBalance(base58.Encode(masterKey.PublicKey))
|
||||
var scanReq *nockchain.GetBalanceRequest
|
||||
switch req.Version {
|
||||
case 0:
|
||||
scanReq = &nockchain.GetBalanceRequest{
|
||||
Selector: &nockchain.GetBalanceRequest_Address{
|
||||
Address: base58.Encode(masterKey.PublicKey),
|
||||
},
|
||||
}
|
||||
case 1:
|
||||
|
||||
firstName := crypto.Tip5RehashTenCell(crypto.Tip5Zero, ownerHash)
|
||||
scanReq = &nockchain.GetBalanceRequest{
|
||||
Selector: &nockchain.GetBalanceRequest_FirstName{
|
||||
FirstName: crypto.Tip5HashToBase58(firstName),
|
||||
},
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("unsuport version")
|
||||
}
|
||||
masterKeyScan, err := h.client.WalletGetBalance(scanReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -408,64 +499,111 @@ func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxReque
|
||||
name := "[" + firstName + " " + lastName + "]"
|
||||
if i := slices.Index(names, name); i != -1 {
|
||||
balanceEntry := ParseBalanceEntry(note)
|
||||
notes[i] = &balanceEntry
|
||||
switch req.Version {
|
||||
case 0:
|
||||
notesV0[i] = balanceEntry.GetV0()
|
||||
case 1:
|
||||
notesV1[i] = balanceEntry.GetV1()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inputs := make([]*nockchain.NockchainInput, len(names))
|
||||
isSpent := false
|
||||
for i := 0; i < len(nameKeys); i++ {
|
||||
idx := indices[i]
|
||||
if notes[idx] == nil {
|
||||
return nil, fmt.Errorf("notes scanned is missing at name: %s", names[idx])
|
||||
giftRemaining := gift
|
||||
feeRemaining := req.Fee
|
||||
wordCount := 0
|
||||
for i := 0; i < len(names); i++ {
|
||||
switch req.Version {
|
||||
case 0:
|
||||
if notesV0[i] == nil {
|
||||
return nil, fmt.Errorf("notes scanned is missing at name: %s", names[i])
|
||||
}
|
||||
case 1:
|
||||
if notesV1[i] == nil {
|
||||
return nil, fmt.Errorf("notes scanned is missing at name: %s", names[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notesV0Sort := make([]*nockchain.NockchainNoteV0, len(notesV0))
|
||||
copy(notesV0Sort, notesV0)
|
||||
|
||||
notesV1Sort := make([]*nockchain.NockchainNoteV1, len(notesV1))
|
||||
copy(notesV1Sort, notesV1)
|
||||
|
||||
switch req.Version {
|
||||
case 0:
|
||||
slices.SortFunc(notesV0Sort, func(note1, note2 *nockchain.NockchainNoteV0) int {
|
||||
return cmp.Compare(note2.Asset, note1.Asset)
|
||||
})
|
||||
case 1:
|
||||
slices.SortFunc(notesV1Sort, func(note1, note2 *nockchain.NockchainNoteV1) int {
|
||||
return cmp.Compare(note2.Assets, note1.Assets)
|
||||
})
|
||||
}
|
||||
|
||||
spends := []*nockchain.NockchainNamedSpend{}
|
||||
for i := 0; i < len(names); i++ {
|
||||
asset := uint64(0)
|
||||
switch req.Version {
|
||||
case 0:
|
||||
asset = notesV0Sort[i].Asset
|
||||
case 1:
|
||||
asset = notesV1Sort[i].Assets
|
||||
}
|
||||
giftPortion := min(giftRemaining, asset)
|
||||
|
||||
feeAvailable := asset - giftPortion
|
||||
feePortion := min(feeRemaining, feeAvailable)
|
||||
|
||||
if giftPortion == 0 && feePortion == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if notes[idx].Asset < gifts[idx] {
|
||||
return nil, fmt.Errorf("note %s not enough balance", names[idx])
|
||||
giftRemaining = giftRemaining - giftPortion
|
||||
feeRemaining = feeRemaining - feePortion
|
||||
|
||||
refund := asset - giftPortion - feePortion
|
||||
if refund == 0 && giftPortion == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
parentHash, err := HashNote(notes[idx])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var parentHash [5]uint64
|
||||
switch req.Version {
|
||||
case 0:
|
||||
parentHash, err = HashNoteV0(notesV0Sort[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case 1:
|
||||
parentHash = HashNoteV1(notesV1Sort[i])
|
||||
}
|
||||
seeds := []*nockchain.NockchainSeed{
|
||||
{
|
||||
OutputSource: nil,
|
||||
Recipient: recipents[idx],
|
||||
TimelockIntent: req.TimelockIntent,
|
||||
Gift: gifts[idx],
|
||||
ParentHash: crypto.Tip5HashToBase58(parentHash),
|
||||
},
|
||||
}
|
||||
|
||||
assetLeft := notes[idx].Asset - gifts[idx]
|
||||
fee := uint64(0)
|
||||
if !isSpent && assetLeft >= req.Fee {
|
||||
isSpent = true
|
||||
fee = req.Fee
|
||||
assetLeft -= req.Fee
|
||||
}
|
||||
|
||||
if assetLeft != 0 {
|
||||
lockRoot := HashLock(recipent)
|
||||
seeds := []*nockchain.NockchainSeed{}
|
||||
if giftPortion != 0 {
|
||||
wordCount += SeedWordsCount
|
||||
seeds = append(seeds, &nockchain.NockchainSeed{
|
||||
OutputSource: nil,
|
||||
Recipient: &nockchain.NockchainLock{
|
||||
KeysRequired: 1,
|
||||
Pubkeys: []string{base58.Encode(masterKey.PublicKey)},
|
||||
},
|
||||
TimelockIntent: req.TimelockIntent,
|
||||
Gift: assetLeft,
|
||||
ParentHash: crypto.Tip5HashToBase58(parentHash),
|
||||
LockRoot: crypto.Tip5HashToBase58(lockRoot),
|
||||
NoteData: recipent,
|
||||
Gift: giftPortion,
|
||||
ParentHash: crypto.Tip5HashToBase58(parentHash),
|
||||
})
|
||||
}
|
||||
spend := nockchain.NockchainSpend{
|
||||
Signatures: nil,
|
||||
Seeds: seeds,
|
||||
Fee: fee,
|
||||
|
||||
if refund != 0 {
|
||||
wordCount += SeedWordsCount
|
||||
lockRoot := HashLock(refundLock)
|
||||
seeds = append(seeds, &nockchain.NockchainSeed{
|
||||
OutputSource: nil,
|
||||
LockRoot: crypto.Tip5HashToBase58(lockRoot),
|
||||
NoteData: refundLock,
|
||||
Gift: refund,
|
||||
ParentHash: crypto.Tip5HashToBase58(parentHash),
|
||||
})
|
||||
}
|
||||
|
||||
msg, err := HashMsg(&spend)
|
||||
msg, err := HashMsg(seeds, feePortion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -476,47 +614,85 @@ func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxReque
|
||||
return nil, err
|
||||
}
|
||||
|
||||
spend.Signatures = []*nockchain.NockchainSignature{
|
||||
sigs := []*nockchain.NockchainSignature{
|
||||
{
|
||||
Pubkey: base58.Encode(masterKey.PublicKey),
|
||||
Chal: chalT8[:],
|
||||
Sig: sigT8[:],
|
||||
},
|
||||
}
|
||||
switch req.Version {
|
||||
case 0:
|
||||
spend := nockchain.NockchainSpendV0{
|
||||
Signatures: nil,
|
||||
Seeds: seeds,
|
||||
Fee: feePortion,
|
||||
}
|
||||
|
||||
input := nockchain.NockchainInput{
|
||||
Name: nnames[idx],
|
||||
Note: notes[idx],
|
||||
Spend: &spend,
|
||||
spend.Signatures = sigs
|
||||
wordCount += SignatureWordsCount
|
||||
nameIdx := -1
|
||||
for j := 0; j < len(names); j++ {
|
||||
if nnames[j].Last == notesV0Sort[i].Name.Last {
|
||||
nameIdx = j
|
||||
break
|
||||
}
|
||||
}
|
||||
spends = append(spends, &nockchain.NockchainNamedSpend{
|
||||
Name: nnames[nameIdx],
|
||||
SpendKind: &nockchain.NockchainNamedSpend_Legacy{
|
||||
Legacy: &spend,
|
||||
},
|
||||
})
|
||||
case 1:
|
||||
spend := nockchain.NockchainSpendV1{
|
||||
Witness: nil,
|
||||
Seeds: seeds,
|
||||
Fee: feePortion,
|
||||
}
|
||||
|
||||
spend.Witness = []*nockchain.NockchainWitness{
|
||||
{
|
||||
Lmp: &nockchain.NockchainLockMerkleProof{
|
||||
SpendCondition: ownerLock,
|
||||
Axis: 1,
|
||||
MerkleRoot: crypto.Tip5HashToBase58(ownerHash),
|
||||
},
|
||||
Pkh: sigs,
|
||||
},
|
||||
}
|
||||
wordCount += WitnessWordsCount
|
||||
nameIdx := -1
|
||||
for j := 0; j < len(names); j++ {
|
||||
if nnames[j].Last == notesV1Sort[i].Name.Last {
|
||||
nameIdx = j
|
||||
break
|
||||
}
|
||||
}
|
||||
spends = append(spends, &nockchain.NockchainNamedSpend{
|
||||
Name: nnames[nameIdx],
|
||||
SpendKind: &nockchain.NockchainNamedSpend_Witness{
|
||||
Witness: &spend,
|
||||
},
|
||||
})
|
||||
}
|
||||
inputs[idx] = &input
|
||||
|
||||
}
|
||||
|
||||
if !isSpent {
|
||||
return nil, fmt.Errorf("insufficient funds")
|
||||
if giftRemaining != 0 || feeRemaining != 0 {
|
||||
return nil, fmt.Errorf("insufficient funds to pay fee and gift")
|
||||
}
|
||||
var timelockRange *nockchain.TimelockRange
|
||||
if req.TimelockIntent == nil {
|
||||
timelockRange = &nockchain.TimelockRange{
|
||||
Min: nil,
|
||||
Max: nil,
|
||||
}
|
||||
} else {
|
||||
if req.TimelockIntent.Absolute != nil {
|
||||
timelockRange = req.TimelockIntent.Absolute
|
||||
}
|
||||
if req.TimelockIntent.Relative != nil {
|
||||
timelockRange = req.TimelockIntent.Relative
|
||||
|
||||
}
|
||||
if wordCount*BaseFee > int(req.Fee) {
|
||||
return nil, fmt.Errorf("min fee not met, this transaction requires at least: %d", wordCount*BaseFee)
|
||||
}
|
||||
|
||||
rawTx := nockchain.RawTx{
|
||||
TxId: "",
|
||||
Inputs: inputs,
|
||||
TimelockRange: timelockRange,
|
||||
TotalFees: req.Fee,
|
||||
TxId: "",
|
||||
Version: 1,
|
||||
NamedSpends: spends,
|
||||
}
|
||||
txId, err := ComputeTxId(inputs, timelockRange, req.Fee)
|
||||
txId, err := ComputeTxId(spends, req.Version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -536,8 +712,23 @@ func (h *GprcHandler) Scan(ctx context.Context, req *nockchain.ScanRequest) (*no
|
||||
ChainCode: chainCode,
|
||||
PrivateKey: []byte{},
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
masterKeyScan, err := h.client.WalletGetBalance(req.MasterPubkey)
|
||||
masterKeyScan, err := h.client.WalletGetBalance(&nockchain.GetBalanceRequest{
|
||||
Selector: &nockchain.GetBalanceRequest_Address{
|
||||
Address: address,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -552,7 +743,39 @@ func (h *GprcHandler) Scan(ctx context.Context, req *nockchain.ScanRequest) (*no
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
childKeyScan, err := h.client.WalletGetBalance(base58.Encode(childKey.PublicKey))
|
||||
|
||||
pkPoint, err := crypto.CheetaPointFromBytes(childKey.PublicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pkHash := HashPubkey(pkPoint)
|
||||
ownerLock := &nockchain.NockchainLock{
|
||||
KeysRequired: 1,
|
||||
Pubkeys: []string{crypto.Tip5HashToBase58(pkHash)},
|
||||
}
|
||||
|
||||
ownerHash := HashLock(ownerLock)
|
||||
var scanReq *nockchain.GetBalanceRequest
|
||||
switch req.Version {
|
||||
case 0:
|
||||
scanReq = &nockchain.GetBalanceRequest{
|
||||
Selector: &nockchain.GetBalanceRequest_Address{
|
||||
Address: base58.Encode(childKey.PublicKey),
|
||||
},
|
||||
}
|
||||
case 1:
|
||||
|
||||
firstName := crypto.Tip5RehashTenCell(crypto.Tip5Zero, ownerHash)
|
||||
scanReq = &nockchain.GetBalanceRequest{
|
||||
Selector: &nockchain.GetBalanceRequest_FirstName{
|
||||
FirstName: crypto.Tip5HashToBase58(firstName),
|
||||
},
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("unsuport version")
|
||||
}
|
||||
|
||||
childKeyScan, err := h.client.WalletGetBalance(scanReq)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@ -570,7 +793,7 @@ func (h *GprcHandler) Scan(ctx context.Context, req *nockchain.ScanRequest) (*no
|
||||
}
|
||||
|
||||
func (h *GprcHandler) WalletGetBalance(_ context.Context, req *nockchain.GetBalanceRequest) (*nockchain.GetBalanceResponse, error) {
|
||||
data, err := h.client.WalletGetBalance(req.Address)
|
||||
data, err := h.client.WalletGetBalance(req)
|
||||
return &nockchain.GetBalanceResponse{
|
||||
Data: data,
|
||||
}, err
|
||||
@ -586,7 +809,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
|
||||
}
|
||||
|
||||
@ -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, 1, crypto.KeyType_PRIVATE)
|
||||
assert.Len(t, importPrivKey, 83)
|
||||
importPubKey := crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, 1, crypto.KeyType_PUBLIC)
|
||||
assert.Len(t, importPubKey, 147)
|
||||
|
||||
assert.Equal(t,
|
||||
base58.Encode(importPrivKey),
|
||||
"zprvLxxkCBq3s5HYzjhcW8wh3FhHSt5YowSGApRdHsptZQrtcCdqibUo7qwqfa7qkazttRgcaRwy4YYwv9DLhmUNcMG9uAtsgaPkfwyiGkf5Bpib",
|
||||
)
|
||||
assert.Equal(t,
|
||||
base58.Encode(importPubKey),
|
||||
"zpub2kRJ7D6VCvzVfDg5e6iXb4T2ea97QJKN6JzjTArrhgZzwHo6rmT8Z3mEp11T67fNvU8ZWLcTTFS17NLwvYs7ErmqCJQNrtjRgVcvZNeWBebpztihXzrhvHZumDiejPmLb6QQNhkPhhK3uyS6XBbaPybqGDdWAgHKvPHkKirVsSJWEmDJYEj8ePN4ufscv1DL2pTD",
|
||||
)
|
||||
}
|
||||
func TestImportKey(t *testing.T) {
|
||||
type Input struct {
|
||||
req *nockchain.ImportKeysRequest
|
||||
@ -76,41 +125,63 @@ func TestImportKey(t *testing.T) {
|
||||
errStr string
|
||||
}
|
||||
|
||||
correctImportPrivKey := base58.Decode("zprvLpf3WSvYWmHRd3jj5oR8UXr7bi88pGnfJXj1dM9RnwJwu1MLo6fZzcKauqpxL2W7dk2fmjYKAUzavbyaGpnvqY5QndcrUzsBrPQAHXNnhiXx")
|
||||
correctImportPrivKeyV0 := base58.Decode("zprvLpf3WSvYWmHRd3jj5oR8UXr7bi88pGnfJXj1dM9RnwJwu1MLo6fZzcKauqpxL2W7dk2fmjYKAUzavbyaGpnvqY5QndcrUzsBrPQAHXNnhiXx")
|
||||
correctImportPrivKeyV1 := base58.Decode("zprvLxxkCBq3s5HYziigQb3G4a7pyj7pG2f8MjogoqH4UoFDJy3GRBX5LF1tJAgsTYdgZAVfuM2DGrjqAqJX96SS8cTbVAaPV23834G1GqgfEEg7")
|
||||
invalidImportPrivKeyPrefix := make([]byte, 83)
|
||||
copy(invalidImportPrivKeyPrefix[:], correctImportPrivKey)
|
||||
copy(invalidImportPrivKeyPrefix[:], correctImportPrivKeyV0)
|
||||
invalidImportPrivKeyPrefix[46] = 0x01
|
||||
|
||||
invalidImportPrivKeyChecksum := make([]byte, 83)
|
||||
copy(invalidImportPrivKeyChecksum[:], correctImportPrivKey)
|
||||
copy(invalidImportPrivKeyChecksum[:], correctImportPrivKeyV0)
|
||||
copy(invalidImportPrivKeyChecksum[79:], []byte{1, 2, 3, 4})
|
||||
|
||||
correctImportPubkey := base58.Decode("zpub2jgndknkQprVYB4X4mqREyn7ZTUE5zp9qkSugdpiqhC5NSeNBceafoz6jGSLEpzJhaLryvY8MF6TokwZN627UXhsg5zd2U12woEL82UtZaLHRL8PZi8YiQnE41BiNJwkfpWjzAbq8mwbAHV3nXUEFgJW2BKCz4GmfoMCkCUDhJppYh5KFsMUkN41DzsfFZHuFrzo")
|
||||
correctImportPubkeyV0 := base58.Decode("zpub2jgndknkQprVYB4X4mqREyn7ZTUE5zp9qkSugdpiqhC5NSeNBceafoz6jGSLEpzJhaLryvY8MF6TokwZN627UXhsg5zd2U12woEL82UtZaLHRL8PZi8YiQnE41BiNJwkfpWjzAbq8mwbAHV3nXUEFgJW2BKCz4GmfoMCkCUDhJppYh5KFsMUkN41DzsfFZHuFrzo")
|
||||
correctImportPubkeyV1 := base58.Decode("zpub2kRJ7D6VCvzVfDb4F7drLsLVdViqUSiufhwkmZogDuTVLc5ird2DinQNHvu5WXgTcMGizEaqbnANjvg43bx3Lfz4fPVt27MPsiNBTuqqXgtvYbJZNwmXEa5vt87MGCRxKpAgo1zH6K7qy5Uokc94eUd47xEcmhij9YRm8twvU5y3ccCessJ8rdtEZahX6pv8RFBi")
|
||||
invalidImportPubkeyChecksum := make([]byte, 147)
|
||||
copy(invalidImportPubkeyChecksum[:], correctImportPubkey)
|
||||
copy(invalidImportPubkeyChecksum[:], correctImportPubkeyV0)
|
||||
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),
|
||||
ImportPrivateKey: base58.Encode(correctImportPrivKeyV0),
|
||||
ImportPublicKey: base58.Encode(correctImportPubkeyV0),
|
||||
Version: 0,
|
||||
}
|
||||
responseV1 := &nockchain.ImportKeysResponse{
|
||||
Address: "BAmYAxgpVrJeFqqPnKAZHVZZdmVfzrgu7bBqcRBNca8HpxQofzUZG8Q",
|
||||
PrivateKey: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg",
|
||||
ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8",
|
||||
ImportPrivateKey: base58.Encode(correctImportPrivKeyV1),
|
||||
ImportPublicKey: base58.Encode(correctImportPubkeyV1),
|
||||
Version: 1,
|
||||
}
|
||||
|
||||
responseReadOnly := &nockchain.ImportKeysResponse{
|
||||
PublicKey: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6",
|
||||
responseV0ReadOnly := &nockchain.ImportKeysResponse{
|
||||
Address: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6",
|
||||
PrivateKey: "",
|
||||
ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8",
|
||||
ImportPrivateKey: "",
|
||||
ImportPublicKey: base58.Encode(correctImportPubkey),
|
||||
ImportPublicKey: base58.Encode(correctImportPubkeyV0),
|
||||
Version: 0,
|
||||
}
|
||||
responseV1ReadOnly := &nockchain.ImportKeysResponse{
|
||||
Address: "BAmYAxgpVrJeFqqPnKAZHVZZdmVfzrgu7bBqcRBNca8HpxQofzUZG8Q",
|
||||
PrivateKey: "",
|
||||
ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8",
|
||||
ImportPrivateKey: "",
|
||||
ImportPublicKey: base58.Encode(correctImportPubkeyV1),
|
||||
Version: 1,
|
||||
}
|
||||
|
||||
inputs := []Input{
|
||||
// case invalid type
|
||||
{
|
||||
req: &nockchain.ImportKeysRequest{
|
||||
Key: "",
|
||||
ImportType: nockchain.ImportType_UNDEFINED,
|
||||
Version: 0,
|
||||
},
|
||||
expectResp: nil,
|
||||
isErr: true,
|
||||
@ -121,6 +192,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 +202,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 +212,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 +227,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),
|
||||
Key: base58.Encode(correctImportPrivKeyV0),
|
||||
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(correctImportPrivKeyV1),
|
||||
ImportType: nockchain.ImportType_EXTENDED_KEY,
|
||||
Version: 1,
|
||||
},
|
||||
expectResp: responseV1,
|
||||
isErr: false,
|
||||
errStr: "",
|
||||
},
|
||||
@ -168,6 +254,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 +264,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),
|
||||
Key: base58.Encode(correctImportPubkeyV0),
|
||||
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(correctImportPubkeyV1),
|
||||
ImportType: nockchain.ImportType_EXTENDED_KEY,
|
||||
Version: 1,
|
||||
},
|
||||
expectResp: responseV1ReadOnly,
|
||||
isErr: false,
|
||||
errStr: "",
|
||||
},
|
||||
@ -197,6 +297,7 @@ func TestImportKey(t *testing.T) {
|
||||
req: &nockchain.ImportKeysRequest{
|
||||
Key: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg",
|
||||
ImportType: nockchain.ImportType_MASTER_PRIVKEY,
|
||||
Version: 0,
|
||||
},
|
||||
expectResp: nil,
|
||||
isErr: true,
|
||||
@ -207,6 +308,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 +318,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: "",
|
||||
@ -274,169 +417,59 @@ func TestImportKey(t *testing.T) {
|
||||
// This test should be run with timeout 120s
|
||||
func TestScan(t *testing.T) {
|
||||
// some random seed we take to get empty notes
|
||||
seed1 := "foster chicken claw fade income frown junior abandon price lesson mango wrap dry clay loyal camera caught during property useless puppy royal soccer arm"
|
||||
seed2 := "brass vacuum stairs hurt brisk govern describe enforce fly exact rescue capable belt flavor lottery sauce easy frame orange legal injury border obey novel"
|
||||
seed1 := "rail nurse smile angle uphold gun kitten spoon quick frozen trigger cable decorate episode blame tray off bag arena taxi approve breeze job letter"
|
||||
|
||||
masterKey1, err := crypto.MasterKeyFromSeed(seed1)
|
||||
assert.NoError(t, err)
|
||||
|
||||
fmt.Println("pk: ", base58.Encode(masterKey1.PublicKey))
|
||||
nc, err := wallet.NewNockchainClient("nockchain-api.zorp.io:443")
|
||||
assert.NoError(t, err)
|
||||
|
||||
masterKey1Scan, err := nc.WalletGetBalance(base58.Encode(masterKey1.PublicKey))
|
||||
masterKey1Scan, err := nc.WalletGetBalance(&nockchain.GetBalanceRequest{
|
||||
Selector: &nockchain.GetBalanceRequest_Address{
|
||||
Address: base58.Encode(masterKey1.PublicKey),
|
||||
},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Empty(t, masterKey1Scan.Notes)
|
||||
|
||||
masterKey2, err := crypto.MasterKeyFromSeed(seed2)
|
||||
assert.NoError(t, err)
|
||||
|
||||
masterKey2Scan, err := nc.WalletGetBalance(base58.Encode(masterKey2.PublicKey))
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, masterKey2Scan.Notes, 1)
|
||||
assert.Equal(t, masterKey2Scan.Notes[0].Note.Assets.Value, uint64(100000))
|
||||
assert.Equal(t, masterKey2Scan.Notes[0].Note.OriginPage.Value, uint64(35054))
|
||||
fmt.Println("masterKey1Scan:", masterKey1Scan)
|
||||
assert.NotEmpty(t, masterKey1Scan.Notes)
|
||||
}
|
||||
|
||||
// This test should be run with timeout 120s
|
||||
func TestFullFlow(t *testing.T) {
|
||||
mnemonic1 := "rail nurse smile angle uphold gun kitten spoon quick frozen trigger cable decorate episode blame tray off bag arena taxi approve breeze job letter"
|
||||
masterKey1, err := crypto.MasterKeyFromSeed(mnemonic1)
|
||||
assert.NoError(t, err)
|
||||
|
||||
mnemonic2 := "brass vacuum stairs hurt brisk govern describe enforce fly exact rescue capable belt flavor lottery sauce easy frame orange legal injury border obey novel"
|
||||
masterKey2, err := crypto.MasterKeyFromSeed(mnemonic2)
|
||||
assert.NoError(t, err)
|
||||
|
||||
inputName := "[4taoqkpysafnp64WBQyzHDKVrqkMeNrdAiVSbWdzZmj7yQYZgQtCq4W 9cjUFbdtaFHeXNWCAKjsTphBchHmCoUU6a1aDbJAFz9qHqeG8osh4wF]"
|
||||
|
||||
nc, err := wallet.NewNockchainClient("nockchain-api.zorp.io:443")
|
||||
assert.NoError(t, err)
|
||||
|
||||
masterKeyScan, err := nc.WalletGetBalance(base58.Encode(masterKey1.PublicKey))
|
||||
assert.NoError(t, err)
|
||||
|
||||
var note *nockchain.NockchainNote
|
||||
for _, balanceEntry := range masterKeyScan.Notes {
|
||||
firstName := crypto.Tip5HashToBase58([5]uint64{
|
||||
balanceEntry.Name.First.Belt_1.Value,
|
||||
balanceEntry.Name.First.Belt_2.Value,
|
||||
balanceEntry.Name.First.Belt_3.Value,
|
||||
balanceEntry.Name.First.Belt_4.Value,
|
||||
balanceEntry.Name.First.Belt_5.Value,
|
||||
})
|
||||
lastName := crypto.Tip5HashToBase58([5]uint64{
|
||||
balanceEntry.Name.Last.Belt_1.Value,
|
||||
balanceEntry.Name.Last.Belt_2.Value,
|
||||
balanceEntry.Name.Last.Belt_3.Value,
|
||||
balanceEntry.Name.Last.Belt_4.Value,
|
||||
balanceEntry.Name.Last.Belt_5.Value,
|
||||
})
|
||||
nname := "[" + firstName + " " + lastName + "]"
|
||||
if nname == inputName {
|
||||
nnote := wallet.ParseBalanceEntry(balanceEntry)
|
||||
note = &nnote
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.NotNil(t, note)
|
||||
|
||||
parentHash, err := wallet.HashNote(note)
|
||||
assert.NoError(t, err)
|
||||
|
||||
gift := uint64(100000)
|
||||
seed1 := &nockchain.NockchainSeed{
|
||||
OutputSource: nil,
|
||||
Recipient: &nockchain.NockchainLock{
|
||||
KeysRequired: 1,
|
||||
Pubkeys: []string{base58.Encode(masterKey2.PublicKey)},
|
||||
},
|
||||
TimelockIntent: nil,
|
||||
Gift: gift,
|
||||
ParentHash: crypto.Tip5HashToBase58(parentHash),
|
||||
func TestEncodeDecodeNoun(t *testing.T) {
|
||||
lock1 := &nockchain.NockchainLock{
|
||||
KeysRequired: 1,
|
||||
Pubkeys: []string{"5wef35rKxbJDJRAtzGG1VwbMQK9jF3Wr5e6fyMsh2hxnCQZDZJV1YNQ"},
|
||||
}
|
||||
|
||||
gift = note.Asset - gift - 100
|
||||
seed2 := &nockchain.NockchainSeed{
|
||||
OutputSource: nil,
|
||||
Recipient: &nockchain.NockchainLock{
|
||||
KeysRequired: 1,
|
||||
Pubkeys: []string{base58.Encode(masterKey1.PublicKey)},
|
||||
},
|
||||
TimelockIntent: nil,
|
||||
Gift: gift,
|
||||
ParentHash: crypto.Tip5HashToBase58(parentHash),
|
||||
}
|
||||
lock1Encode := wallet.EncodeNoteData(lock1)
|
||||
assert.Equal(t, lock1Encode, []byte{89, 192, 131, 91, 67, 199, 5, 16, 32, 24, 199, 52, 39, 171, 121, 6, 15, 240, 167, 243, 69, 34, 254, 110, 4, 78, 3, 8, 44, 245, 128, 176, 69, 72, 150, 253, 6, 232, 167, 34, 133, 115, 154, 56, 106, 106, 192, 175, 176, 88, 89, 160, 208, 117, 55, 78, 5})
|
||||
|
||||
spend := nockchain.NockchainSpend{
|
||||
Signatures: nil,
|
||||
Seeds: []*nockchain.NockchainSeed{
|
||||
seed1, seed2,
|
||||
},
|
||||
Fee: 100,
|
||||
}
|
||||
lock1Decode := wallet.DecodeNoteData(lock1Encode)
|
||||
assert.Equal(t, lock1Decode.KeysRequired, lock1.KeysRequired)
|
||||
assert.Equal(t, lock1Decode.Pubkeys, lock1.Pubkeys)
|
||||
|
||||
msg, err := wallet.HashMsg(&spend)
|
||||
assert.NoError(t, err)
|
||||
lock2 := lock1
|
||||
lock2.Pubkeys = []string{"7UXNF2HXzEaPUvLDVDgGJyriKqpd2974Kj7U2RnLuBPeRGa7ZezhGmK"}
|
||||
lock2Encode := wallet.EncodeNoteData(lock2)
|
||||
assert.Equal(t, lock2Encode, []byte{89, 192, 131, 91, 67, 199, 5, 248, 151, 186, 241, 213, 183, 156, 103, 181, 1, 254, 206, 33, 184, 3, 142, 3, 99, 101, 0, 1, 246, 168, 22, 252, 21, 155, 53, 205, 0, 2, 172, 67, 150, 149, 228, 139, 80, 206, 0, 1, 203, 54, 188, 141, 54, 21, 39, 193, 84})
|
||||
|
||||
chalT8, sigT8, err := wallet.ComputeSig(*masterKey1, msg)
|
||||
assert.NoError(t, err)
|
||||
|
||||
spend.Signatures = []*nockchain.NockchainSignature{
|
||||
{
|
||||
Pubkey: base58.Encode(masterKey1.PublicKey),
|
||||
Chal: chalT8[:],
|
||||
Sig: sigT8[:],
|
||||
},
|
||||
}
|
||||
|
||||
input := nockchain.NockchainInput{
|
||||
Name: &nockchain.NockchainName{
|
||||
First: "4taoqkpysafnp64WBQyzHDKVrqkMeNrdAiVSbWdzZmj7yQYZgQtCq4W",
|
||||
Last: "9cjUFbdtaFHeXNWCAKjsTphBchHmCoUU6a1aDbJAFz9qHqeG8osh4wF",
|
||||
},
|
||||
Note: note,
|
||||
Spend: &spend,
|
||||
}
|
||||
|
||||
id, err := wallet.ComputeTxId([]*nockchain.NockchainInput{&input}, &nockchain.TimelockRange{
|
||||
Min: nil,
|
||||
Max: nil,
|
||||
}, 100)
|
||||
assert.NoError(t, err)
|
||||
|
||||
rawTx := nockchain.RawTx{
|
||||
TxId: crypto.Tip5HashToBase58(id),
|
||||
Inputs: []*nockchain.NockchainInput{&input},
|
||||
TimelockRange: &nockchain.TimelockRange{
|
||||
Min: nil,
|
||||
Max: nil,
|
||||
},
|
||||
TotalFees: 100,
|
||||
}
|
||||
resp, err := nc.WalletSendTransaction(&rawTx)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, resp.Result, &nockchain.WalletSendTransactionResponse_Ack{
|
||||
Ack: &nockchain.Acknowledged{},
|
||||
})
|
||||
|
||||
txAcceptedResp, err := nc.TxAccepted(rawTx.TxId)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, txAcceptedResp.Result, &nockchain.TransactionAcceptedResponse_Accepted{
|
||||
Accepted: true,
|
||||
})
|
||||
lock2Decode := wallet.DecodeNoteData(lock2Encode)
|
||||
assert.Equal(t, lock2Decode.KeysRequired, lock2.KeysRequired)
|
||||
assert.Equal(t, lock2Decode.Pubkeys, lock2.Pubkeys)
|
||||
}
|
||||
|
||||
// This test should be run with timeout 300s
|
||||
func TestCreateTx(t *testing.T) {
|
||||
seed1 := "brass vacuum stairs hurt brisk govern describe enforce fly exact rescue capable belt flavor lottery sauce easy frame orange legal injury border obey novel"
|
||||
|
||||
func TestCreateTxV0(t *testing.T) {
|
||||
seed1 := "rail nurse smile angle uphold gun kitten spoon quick frozen trigger cable decorate episode blame tray off bag arena taxi approve breeze job letter"
|
||||
masterKey1, err := crypto.MasterKeyFromSeed(seed1)
|
||||
assert.NoError(t, err)
|
||||
fmt.Println("masterKey1: ", base58.Encode(masterKey1.PublicKey))
|
||||
|
||||
// nockchain-wallet create-tx --names '[5bcr83LnCYyHqQh4ExK6metaf1cs7JYDqMYc92Awqhwc6VEpZJL9wj9 AmSjC3SDNtb7ZrUkTXc242BvGeimeL1nAV4CqV63HpLMryhom4L9W59],[5bcr83LnCYyHqQh4ExK6metaf1cs7JYDqMYc92Awqhwc6VEpZJL9wj9 7oo4x3fuwcJ5DrbFY1yf715ctjtE6CqqPagJWT8d687Q6sgMVWc1SXz],[5bcr83LnCYyHqQh4ExK6metaf1cs7JYDqMYc92Awqhwc6VEpZJL9wj9 8BrF9XAKwzvFdy8p7KAB8VEvcswPADhs2WamhWSLUErYN9z8U8cynaA]' --recipients '37Ttw4d6Fq1WGis5qVz8SbeEtpqsbg2ihArBedi4ZeuhFFo8tbCNvwWNq9D8KFBc2qv7uzvPJmKmJg68aEHEh21FiXk9iJCmzyE3NqdSgpsPMCx7Q39yhUUrKkKvGnHUKzMe,37Ttw4d6Fq1WGis5qVz8SbeEtpqsbg2ihArBedi4ZeuhFFo8tbCNvwWNq9D8KFBc2qv7uzvPJmKmJg68aEHEh21FiXk9iJCmzyE3NqdSgpsPMCx7Q39yhUUrKkKvGnHUKzMe,37Ttw4d6Fq1WGis5qVz8SbeEtpqsbg2ihArBedi4ZeuhFFo8tbCNvwWNq9D8KFBc2qv7uzvPJmKmJg68aEHEh21FiXk9iJCmzyE3NqdSgpsPMCx7Q39yhUUrKkKvGnHUKzMe' --gifts '50,50,50' --fee 100
|
||||
pkPoint1, err := crypto.CheetaPointFromBytes(masterKey1.PublicKey)
|
||||
assert.NoError(t, err)
|
||||
addr1 := wallet.HashPubkey(pkPoint1)
|
||||
// nockchain-wallet create-tx --names '[4taoqkpysafnp64WBQyzHDKVrqkMeNrdAiVSbWdzZmj7yQYZgQtCq4W 8yd685r3WhvRYsYWFy3LNQqSMMNwWyE3QZe5fqp1jgG3PWtLPvXdYvR]" --fee 1867776 --recipient "5wef35rKxbJDJRAtzGG1VwbMQK9jF3Wr5e6fyMsh2hxnCQZDZJV1YNQ:2000000" --refund-pkh 7UXNF2HXzEaPUvLDVDgGJyriKqpd2974Kj7U2RnLuBPeRGa7ZezhGmK
|
||||
|
||||
seed2 := "chimney endorse scan ramp cheap harvest mother ball winter way barrel foil tissue pupil answer worth right undo one chimney element grape image unlock"
|
||||
seed2 := "anchor various pair jazz panel rubber virus address achieve opinion end silent runway bus wolf pony cigar nuclear moral mixed gold window timber member"
|
||||
masterKey2, err := crypto.MasterKeyFromSeed(seed2)
|
||||
assert.NoError(t, err)
|
||||
fmt.Println("masterKey2", base58.Encode(masterKey2.PublicKey))
|
||||
@ -445,27 +478,61 @@ func TestCreateTx(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
handler := wallet.NewGprcHandler(*nc)
|
||||
|
||||
inputs := "[5bcr83LnCYyHqQh4ExK6metaf1cs7JYDqMYc92Awqhwc6VEpZJL9wj9 AmSjC3SDNtb7ZrUkTXc242BvGeimeL1nAV4CqV63HpLMryhom4L9W59],[5bcr83LnCYyHqQh4ExK6metaf1cs7JYDqMYc92Awqhwc6VEpZJL9wj9 7oo4x3fuwcJ5DrbFY1yf715ctjtE6CqqPagJWT8d687Q6sgMVWc1SXz],[5bcr83LnCYyHqQh4ExK6metaf1cs7JYDqMYc92Awqhwc6VEpZJL9wj9 8BrF9XAKwzvFdy8p7KAB8VEvcswPADhs2WamhWSLUErYN9z8U8cynaA]"
|
||||
recipients := fmt.Sprintf("%s,%s,%s", base58.Encode(masterKey2.PublicKey), base58.Encode(masterKey2.PublicKey), base58.Encode(masterKey2.PublicKey))
|
||||
gifts := "50,50,50"
|
||||
fee := 100
|
||||
inputs := "[4taoqkpysafnp64WBQyzHDKVrqkMeNrdAiVSbWdzZmj7yQYZgQtCq4W 8yd685r3WhvRYsYWFy3LNQqSMMNwWyE3QZe5fqp1jgG3PWtLPvXdYvR]"
|
||||
|
||||
pkPoint2, err := crypto.CheetaPointFromBytes(masterKey2.PublicKey)
|
||||
assert.NoError(t, err)
|
||||
addr2 := wallet.HashPubkey(pkPoint2)
|
||||
|
||||
recipients := fmt.Sprintf("%s:2000000", crypto.Tip5HashToBase58(addr2))
|
||||
fee := 1867776 // min fee
|
||||
|
||||
req := &nockchain.CreateTxRequest{
|
||||
Names: inputs,
|
||||
Recipients: recipients,
|
||||
Gifts: gifts,
|
||||
Fee: uint64(fee),
|
||||
IsMasterKey: true,
|
||||
Key: base58.Encode(masterKey1.PrivateKey),
|
||||
ChainCode: base58.Encode(masterKey1.ChainCode),
|
||||
Index: 0,
|
||||
Hardened: false,
|
||||
TimelockIntent: nil,
|
||||
Names: inputs,
|
||||
Recipients: recipients,
|
||||
Fee: uint64(fee),
|
||||
IsMasterKey: true,
|
||||
Seed: seed1,
|
||||
Index: 0,
|
||||
Hardened: false,
|
||||
Version: 0,
|
||||
RefundAddress: crypto.Tip5HashToBase58(addr1),
|
||||
}
|
||||
|
||||
res, err := handler.CreateTx(context.Background(), req)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// the result is taken from create-tx scripts
|
||||
assert.Equal(t, res.RawTx.TxId, "A8vSeRde61B4sZccSnNPEnkQgTe15EssoFwyhQXbkhtk4UNm5hyGSid")
|
||||
assert.Equal(t, res.RawTx.TxId, "6oDgTWnk6sL98yK49hcQTRAfCdFfgKh58U6TDTKmGPirhoxkMii2D6E")
|
||||
}
|
||||
|
||||
func TestCreateTxV1(t *testing.T) {
|
||||
seed := "pledge vessel toilet sunny hockey skirt spend wire disorder attitude crumble lecture problem bundle bone rather address over suit ancient primary gospel silent repair"
|
||||
_, err := crypto.MasterKeyFromSeed(seed)
|
||||
assert.NoError(t, err)
|
||||
|
||||
nc, err := wallet.NewNockchainClient("nockchain-api.zorp.io:443")
|
||||
assert.NoError(t, err)
|
||||
handler := wallet.NewGprcHandler(*nc)
|
||||
|
||||
inputs := "[9McQZWZzqFCLwsF37gUHLHt3cxWVbLA64SabN3AMMSgNuSM2b9SmMsj 88uZqY63kneffJnVAEYpb67W96sk3xsdFYTjzj8DSBiigL9AZd9pHsC],[9McQZWZzqFCLwsF37gUHLHt3cxWVbLA64SabN3AMMSgNuSM2b9SmMsj 2JLcp5oXBTtgTCKN4na9Dnk2YuHJCXuDAkk5qT8n9iP1d4iz1c3Amfo]"
|
||||
|
||||
recipients := fmt.Sprintf("%s:747336", "D6NUb9HC4ursvZzYdMAtWAMSyyJWwtdqnsyRXxsADsyqQwh5dcDsTRm")
|
||||
fee := 4456448
|
||||
|
||||
req := &nockchain.CreateTxRequest{
|
||||
Names: inputs,
|
||||
Recipients: recipients,
|
||||
Fee: uint64(fee),
|
||||
IsMasterKey: true,
|
||||
Seed: seed,
|
||||
Index: 0,
|
||||
Hardened: false,
|
||||
Version: 1,
|
||||
}
|
||||
|
||||
resp, err := handler.CreateTx(context.Background(), req)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, resp.RawTx.TxId, "9DfaTJgtsGU8Fs2mAPhGpiMMw5RcRXjEVfnmFcTTxoSFMLWpv2Ae4eG")
|
||||
}
|
||||
|
||||
379
wallet/types.go
379
wallet/types.go
@ -7,182 +7,253 @@ import (
|
||||
)
|
||||
|
||||
func ParseBalanceEntry(entry *nockchain.BalanceEntry) nockchain.NockchainNote {
|
||||
version := nockchain.Version(entry.Note.Version.Value)
|
||||
pubkeys := []string{}
|
||||
for _, pk := range entry.Note.Lock.SchnorrPubkeys {
|
||||
pkPoint := crypto.CheetahPoint{
|
||||
X: [6]crypto.Belt{
|
||||
{Value: pk.Value.X.Belt_1.Value},
|
||||
{Value: pk.Value.X.Belt_2.Value},
|
||||
{Value: pk.Value.X.Belt_3.Value},
|
||||
{Value: pk.Value.X.Belt_4.Value},
|
||||
{Value: pk.Value.X.Belt_5.Value},
|
||||
{Value: pk.Value.X.Belt_6.Value},
|
||||
},
|
||||
Y: [6]crypto.Belt{
|
||||
{Value: pk.Value.Y.Belt_1.Value},
|
||||
{Value: pk.Value.Y.Belt_2.Value},
|
||||
{Value: pk.Value.Y.Belt_3.Value},
|
||||
{Value: pk.Value.Y.Belt_4.Value},
|
||||
{Value: pk.Value.Y.Belt_5.Value},
|
||||
{Value: pk.Value.Y.Belt_6.Value},
|
||||
},
|
||||
Inf: pk.Value.Inf,
|
||||
name := &nockchain.NockchainName{
|
||||
First: crypto.Tip5HashToBase58([5]uint64{
|
||||
entry.Name.First.Belt_1.Value,
|
||||
entry.Name.First.Belt_2.Value,
|
||||
entry.Name.First.Belt_3.Value,
|
||||
entry.Name.First.Belt_4.Value,
|
||||
entry.Name.First.Belt_5.Value,
|
||||
}),
|
||||
Last: crypto.Tip5HashToBase58([5]uint64{
|
||||
entry.Name.Last.Belt_1.Value,
|
||||
entry.Name.Last.Belt_2.Value,
|
||||
entry.Name.Last.Belt_3.Value,
|
||||
entry.Name.Last.Belt_4.Value,
|
||||
entry.Name.Last.Belt_5.Value,
|
||||
}),
|
||||
}
|
||||
switch entry.Note.NoteVersion.(type) {
|
||||
case *nockchain.Note_Legacy:
|
||||
note := entry.Note.GetLegacy()
|
||||
version := nockchain.Version(note.Version.Value)
|
||||
pubkeys := []string{}
|
||||
for _, pk := range note.Lock.SchnorrPubkeys {
|
||||
pkPoint := crypto.CheetahPoint{
|
||||
X: [6]crypto.Belt{
|
||||
{Value: pk.Value.X.Belt_1.Value},
|
||||
{Value: pk.Value.X.Belt_2.Value},
|
||||
{Value: pk.Value.X.Belt_3.Value},
|
||||
{Value: pk.Value.X.Belt_4.Value},
|
||||
{Value: pk.Value.X.Belt_5.Value},
|
||||
{Value: pk.Value.X.Belt_6.Value},
|
||||
},
|
||||
Y: [6]crypto.Belt{
|
||||
{Value: pk.Value.Y.Belt_1.Value},
|
||||
{Value: pk.Value.Y.Belt_2.Value},
|
||||
{Value: pk.Value.Y.Belt_3.Value},
|
||||
{Value: pk.Value.Y.Belt_4.Value},
|
||||
{Value: pk.Value.Y.Belt_5.Value},
|
||||
{Value: pk.Value.Y.Belt_6.Value},
|
||||
},
|
||||
Inf: pk.Value.Inf,
|
||||
}
|
||||
|
||||
pkStr := base58.Encode(pkPoint.Bytes())
|
||||
pubkeys = append(pubkeys, pkStr)
|
||||
}
|
||||
sourceHash := [5]uint64{
|
||||
note.Source.Hash.Belt_1.Value,
|
||||
note.Source.Hash.Belt_2.Value,
|
||||
note.Source.Hash.Belt_3.Value,
|
||||
note.Source.Hash.Belt_4.Value,
|
||||
note.Source.Hash.Belt_5.Value,
|
||||
}
|
||||
return nockchain.NockchainNote{
|
||||
Note: &nockchain.NockchainNote_V0{
|
||||
V0: &nockchain.NockchainNoteV0{
|
||||
Version: version,
|
||||
OriginPage: note.OriginPage.Value,
|
||||
Name: name,
|
||||
Lock: &nockchain.NockchainLock{
|
||||
KeysRequired: uint64(note.Lock.KeysRequired),
|
||||
Pubkeys: pubkeys,
|
||||
},
|
||||
Source: &nockchain.NockchainSource{
|
||||
Source: crypto.Tip5HashToBase58(sourceHash),
|
||||
IsCoinbase: note.Source.Coinbase,
|
||||
},
|
||||
Asset: note.Assets.Value,
|
||||
},
|
||||
},
|
||||
}
|
||||
case *nockchain.Note_V1:
|
||||
note := entry.Note.GetV1()
|
||||
version := nockchain.Version(note.Version.Value)
|
||||
if len(note.NoteData.Entries) != 1 || note.NoteData.Entries[0].Key != "lock" {
|
||||
panic("invalid note data")
|
||||
}
|
||||
lock := DecodeNoteData(note.NoteData.Entries[0].Blob)
|
||||
|
||||
pkStr := base58.Encode(pkPoint.Bytes())
|
||||
pubkeys = append(pubkeys, pkStr)
|
||||
}
|
||||
|
||||
sourceHash := [5]uint64{
|
||||
entry.Note.Source.Hash.Belt_1.Value,
|
||||
entry.Note.Source.Hash.Belt_2.Value,
|
||||
entry.Note.Source.Hash.Belt_3.Value,
|
||||
entry.Note.Source.Hash.Belt_4.Value,
|
||||
entry.Note.Source.Hash.Belt_5.Value,
|
||||
}
|
||||
return nockchain.NockchainNote{
|
||||
Version: version,
|
||||
BlockHeight: entry.Note.OriginPage.Value,
|
||||
Timelock: ParseTimelockIntent(entry.Note.Timelock),
|
||||
Name: &nockchain.NockchainName{
|
||||
First: crypto.Tip5HashToBase58([5]uint64{
|
||||
entry.Name.First.Belt_1.Value,
|
||||
entry.Name.First.Belt_2.Value,
|
||||
entry.Name.First.Belt_3.Value,
|
||||
entry.Name.First.Belt_4.Value,
|
||||
entry.Name.First.Belt_5.Value,
|
||||
}),
|
||||
Last: crypto.Tip5HashToBase58([5]uint64{
|
||||
entry.Name.Last.Belt_1.Value,
|
||||
entry.Name.Last.Belt_2.Value,
|
||||
entry.Name.Last.Belt_3.Value,
|
||||
entry.Name.Last.Belt_4.Value,
|
||||
entry.Name.Last.Belt_5.Value,
|
||||
}),
|
||||
},
|
||||
Lock: &nockchain.NockchainLock{
|
||||
KeysRequired: uint64(entry.Note.Lock.KeysRequired),
|
||||
Pubkeys: pubkeys,
|
||||
},
|
||||
Source: &nockchain.NockchainSource{
|
||||
Source: crypto.Tip5HashToBase58(sourceHash),
|
||||
IsCoinbase: entry.Note.Source.Coinbase,
|
||||
},
|
||||
Asset: entry.Note.Assets.Value,
|
||||
return nockchain.NockchainNote{
|
||||
Note: &nockchain.NockchainNote_V1{
|
||||
V1: &nockchain.NockchainNoteV1{
|
||||
Version: version,
|
||||
OriginPage: note.OriginPage.Value,
|
||||
Name: name,
|
||||
NoteData: lock,
|
||||
Assets: note.Assets.Value,
|
||||
},
|
||||
},
|
||||
}
|
||||
default:
|
||||
return nockchain.NockchainNote{}
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertRawTx(rawTx *nockchain.RawTx) nockchain.RawTransaction {
|
||||
id := crypto.Base58ToTip5Hash(rawTx.TxId)
|
||||
|
||||
var timelockRange *nockchain.TimeLockRangeAbsolute
|
||||
if rawTx.TimelockRange != nil {
|
||||
timelockRange = &nockchain.TimeLockRangeAbsolute{
|
||||
Min: (*nockchain.BlockHeight)(rawTx.TimelockRange.Min),
|
||||
Max: (*nockchain.BlockHeight)(rawTx.TimelockRange.Max),
|
||||
}
|
||||
}
|
||||
|
||||
return nockchain.RawTransaction{
|
||||
Id: &nockchain.Hash{
|
||||
Belt_1: &nockchain.Belt{Value: id[0]},
|
||||
Belt_2: &nockchain.Belt{Value: id[1]},
|
||||
Belt_3: &nockchain.Belt{Value: id[2]},
|
||||
Belt_4: &nockchain.Belt{Value: id[3]},
|
||||
Belt_5: &nockchain.Belt{Value: id[4]},
|
||||
},
|
||||
TimelockRange: timelockRange,
|
||||
TotalFees: &nockchain.Nicks{
|
||||
Value: rawTx.TotalFees,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertInput(input *nockchain.NockchainInput) (*nockchain.NamedInput, error) {
|
||||
pks := []*nockchain.SchnorrPubkey{}
|
||||
|
||||
for _, i := range input.Note.Lock.Pubkeys {
|
||||
pk, err := ParseSchnorrPubkey(i)
|
||||
func ConvertNamedSpend(spend *nockchain.NockchainNamedSpend) (*nockchain.SpendEntry, error) {
|
||||
convertedSpend := &nockchain.Spend{}
|
||||
switch spend.SpendKind.(type) {
|
||||
case *nockchain.NockchainNamedSpend_Legacy:
|
||||
legacySpend := spend.GetLegacy()
|
||||
signature, err := ConvertSignatures(legacySpend.Signatures)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pks = append(pks, pk)
|
||||
}
|
||||
seeds := []*nockchain.Seed{}
|
||||
for _, seed := range input.Spend.Seeds {
|
||||
seedPks := []*nockchain.SchnorrPubkey{}
|
||||
seeds := []*nockchain.Seed{}
|
||||
for _, seed := range legacySpend.Seeds {
|
||||
seeds = append(seeds, &nockchain.Seed{
|
||||
OutputSource: &nockchain.Source{
|
||||
Hash: ParseHash(seed.OutputSource.Source),
|
||||
Coinbase: seed.OutputSource.IsCoinbase,
|
||||
},
|
||||
LockRoot: ParseHash(seed.LockRoot),
|
||||
NoteData: &nockchain.NoteData{
|
||||
Entries: []*nockchain.NoteDataEntry{
|
||||
{
|
||||
Key: "lock",
|
||||
Blob: EncodeNoteData(seed.NoteData),
|
||||
},
|
||||
},
|
||||
},
|
||||
Gift: &nockchain.Nicks{
|
||||
Value: seed.Gift,
|
||||
},
|
||||
ParentHash: ParseHash(seed.ParentHash),
|
||||
})
|
||||
}
|
||||
convertedSpend = &nockchain.Spend{
|
||||
SpendKind: &nockchain.Spend_Legacy{
|
||||
Legacy: &nockchain.LegacySpend{
|
||||
Signature: signature,
|
||||
Seeds: seeds,
|
||||
MinerFeeNicks: &nockchain.Nicks{
|
||||
Value: legacySpend.Fee,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
case *nockchain.NockchainNamedSpend_Witness:
|
||||
witnessSpend := spend.GetWitness()
|
||||
seeds := []*nockchain.Seed{}
|
||||
for _, seed := range witnessSpend.Seeds {
|
||||
seeds = append(seeds, &nockchain.Seed{
|
||||
OutputSource: &nockchain.Source{
|
||||
Hash: ParseHash(seed.OutputSource.Source),
|
||||
Coinbase: seed.OutputSource.IsCoinbase,
|
||||
},
|
||||
LockRoot: ParseHash(seed.LockRoot),
|
||||
NoteData: &nockchain.NoteData{
|
||||
Entries: []*nockchain.NoteDataEntry{
|
||||
{
|
||||
Key: "lock",
|
||||
Blob: EncodeNoteData(seed.NoteData),
|
||||
},
|
||||
},
|
||||
},
|
||||
Gift: &nockchain.Nicks{
|
||||
Value: seed.Gift,
|
||||
},
|
||||
ParentHash: ParseHash(seed.ParentHash),
|
||||
})
|
||||
}
|
||||
|
||||
for _, i := range seed.Recipient.Pubkeys {
|
||||
pk, err := ParseSchnorrPubkey(i)
|
||||
witness := witnessSpend.Witness[0]
|
||||
lockHashes := []*nockchain.Hash{}
|
||||
for i := 0; i < len(witness.Lmp.SpendCondition.Pubkeys); i++ {
|
||||
lockHashes = append(lockHashes, ParseHash(witness.Lmp.SpendCondition.Pubkeys[i]))
|
||||
}
|
||||
|
||||
pkhSigs := []*nockchain.PkhSignatureEntry{}
|
||||
for _, pkh := range witness.Pkh {
|
||||
pk, err := crypto.CheetaPointFromBytes(base58.Decode(pkh.Pubkey))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
seedPks = append(seedPks, pk)
|
||||
}
|
||||
var source *nockchain.OutputSource
|
||||
if seed.OutputSource != nil {
|
||||
source = &nockchain.OutputSource{
|
||||
Source: &nockchain.Source{
|
||||
Hash: ParseHash(seed.OutputSource.Source),
|
||||
Coinbase: input.Note.Source.IsCoinbase,
|
||||
},
|
||||
schnorrPk, err := ParseSchnorrPubkey(pkh.Pubkey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
seeds = append(seeds, &nockchain.Seed{
|
||||
OutputSource: source,
|
||||
Recipient: &nockchain.Lock{
|
||||
KeysRequired: uint32(seed.Recipient.KeysRequired),
|
||||
SchnorrPubkeys: seedPks,
|
||||
},
|
||||
TimelockIntent: ConvertTimelockIntent(seed.TimelockIntent),
|
||||
Gift: &nockchain.Nicks{Value: seed.Gift},
|
||||
ParentHash: ParseHash(seed.ParentHash),
|
||||
})
|
||||
}
|
||||
|
||||
sigEntries := []*nockchain.SignatureEntry{}
|
||||
for _, sig := range input.Spend.Signatures {
|
||||
pk, err := ParseSchnorrPubkey(sig.Pubkey)
|
||||
pkHash := HashPubkey(pk)
|
||||
pkhSigs = append(pkhSigs, &nockchain.PkhSignatureEntry{
|
||||
Hash: ParseHash(crypto.Tip5HashToBase58(pkHash)),
|
||||
Pubkey: schnorrPk,
|
||||
Signature: &nockchain.SchnorrSignature{
|
||||
Chal: ParseEightBelt(pkh.Chal),
|
||||
Sig: ParseEightBelt(pkh.Sig),
|
||||
},
|
||||
})
|
||||
}
|
||||
convertedSpend = &nockchain.Spend{
|
||||
SpendKind: &nockchain.Spend_Witness{
|
||||
Witness: &nockchain.WitnessSpend{
|
||||
Witness: &nockchain.Witness{
|
||||
LockMerkleProof: &nockchain.LockMerkleProof{
|
||||
SpendCondition: &nockchain.SpendCondition{
|
||||
Primitives: []*nockchain.LockPrimitive{
|
||||
{
|
||||
Primitive: &nockchain.LockPrimitive_Pkh{
|
||||
Pkh: &nockchain.PkhLock{
|
||||
M: witness.Lmp.SpendCondition.KeysRequired,
|
||||
Hashes: lockHashes,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Axis: witness.Lmp.Axis,
|
||||
Proof: &nockchain.MerkleProof{
|
||||
Root: ParseHash(witness.Lmp.MerkleRoot),
|
||||
Path: []*nockchain.Hash{},
|
||||
},
|
||||
},
|
||||
PkhSignature: &nockchain.PkhSignature{
|
||||
Entries: pkhSigs,
|
||||
},
|
||||
},
|
||||
Seeds: seeds,
|
||||
Fee: &nockchain.Nicks{
|
||||
Value: witnessSpend.Fee,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
// Conversion logic here
|
||||
return &nockchain.SpendEntry{
|
||||
Name: ConvertName(spend.Name),
|
||||
Spend: convertedSpend,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ConvertSignatures(signatures []*nockchain.NockchainSignature) (*nockchain.Signature, error) {
|
||||
entries := make([]*nockchain.SignatureEntry, len(signatures))
|
||||
for i, sig := range signatures {
|
||||
pubkey, err := ParseSchnorrPubkey(sig.Pubkey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sigEntries = append(sigEntries, &nockchain.SignatureEntry{
|
||||
SchnorrPubkey: pk,
|
||||
entries[i] = &nockchain.SignatureEntry{
|
||||
SchnorrPubkey: pubkey,
|
||||
Signature: &nockchain.SchnorrSignature{
|
||||
Chal: ParseEightBelt(sig.Chal),
|
||||
Sig: ParseEightBelt(sig.Sig),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
return &nockchain.NamedInput{
|
||||
Name: ConvertName(input.Name),
|
||||
Input: &nockchain.Input{
|
||||
Note: &nockchain.Note{
|
||||
OriginPage: &nockchain.BlockHeight{
|
||||
Value: input.Note.BlockHeight,
|
||||
},
|
||||
Timelock: ConvertTimelockIntent(input.Note.Timelock),
|
||||
Name: ConvertName(input.Name),
|
||||
Lock: &nockchain.Lock{
|
||||
KeysRequired: uint32(input.Note.Lock.KeysRequired),
|
||||
SchnorrPubkeys: pks,
|
||||
},
|
||||
Source: &nockchain.Source{
|
||||
Hash: ParseHash(input.Note.Source.Source),
|
||||
Coinbase: input.Note.Source.IsCoinbase,
|
||||
},
|
||||
Assets: &nockchain.Nicks{Value: input.Note.Asset},
|
||||
Version: &nockchain.NoteVersion{Value: uint32(input.Note.Version)},
|
||||
},
|
||||
Spend: &nockchain.Spend{
|
||||
Signature: &nockchain.Signature{
|
||||
Entries: sigEntries,
|
||||
},
|
||||
Seeds: seeds,
|
||||
MinerFeeNicks: &nockchain.Nicks{Value: input.Spend.Fee},
|
||||
},
|
||||
},
|
||||
return &nockchain.Signature{
|
||||
Entries: entries,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user