Compare commits

..

No commits in common. "minh/address-v1" and "main" have entirely different histories.

25 changed files with 1980 additions and 5122 deletions

View File

@ -17,13 +17,11 @@ var (
PublicKeyStart = []byte{12, 14, 187, 9} 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} 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} 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, 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} 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}
MagicDyckForName = []uint64{0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 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} Tip5Zero = [5]uint64{1730770831742798981, 2676322185709933211, 8329210750824781744, 16756092452590401876, 3547445316740171466}
Tip5One = [5]uint64{6727110957294540849, 15606243244732609007, 11887284596344881785, 10646863421881571398, 8146872807338919620} Tip5One = [5]uint64{6727110957294540849, 15606243244732609007, 11887284596344881785, 10646863421881571398, 8146872807338919620}
Tip5ZeroZero = [5]uint64{4372149332062030091, 17876920912185183887, 13348798570422431948, 8872865212694716527, 3385176510443841516} 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 { type MasterKey struct {
@ -194,12 +192,13 @@ func BigIntToT8(data big.Int) [8]uint64 {
res := rip(data) res := rip(data)
return [8]uint64(res) return [8]uint64(res)
} }
func SerializeExtend(chainCode []byte, key []byte, ver int, keyType KeyType) []byte { func SerializeExtend(chainCode []byte, key []byte, keyType KeyType) []byte {
data := []byte{} data := []byte{}
// dep: depth in chain // dep: depth in chain
// idx: index at depth // idx: index at depth
// pf: parent fingerprint // pf: parent fingerprint
// ver: version // ver: version
ver := 0
depth := 0 depth := 0
idx := []byte{0, 0, 0, 0} idx := []byte{0, 0, 0, 0}
pf := []byte{0, 0, 0, 0} pf := []byte{0, 0, 0, 0}

View File

@ -144,14 +144,6 @@ var (
INIT_SPONGE_FIX = [16]uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295} 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 { func Tip5HashBelts(input []Belt) [5]uint64 {
inputLen := len(input) inputLen := len(input)
q := inputLen / RATE q := inputLen / RATE

File diff suppressed because it is too large Load Diff

View File

@ -1,709 +0,0 @@
// 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
}

View File

@ -1,161 +0,0 @@
// 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",
}

View File

@ -26,17 +26,12 @@ const (
type WalletGetBalanceRequest struct { type WalletGetBalanceRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// pubkey cheetah point; specific address, or current wallet // 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 // Pagination parameters. The server enforces limits and may return fewer
// entries than requested to respect message size and policy. For consistent // entries than requested to respect message size and policy. For consistent
// paging across a stable snapshot, pass along the returned page_token from // paging across a stable snapshot, pass along the returned page_token from
// the previous response without modification. // the previous response without modification.
Page *PageRequest `protobuf:"bytes,3,opt,name=page,proto3" json:"page,omitempty"` Page *PageRequest `protobuf:"bytes,2,opt,name=page,proto3" json:"page,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -71,29 +66,11 @@ func (*WalletGetBalanceRequest) Descriptor() ([]byte, []int) {
return file_nockchain_proto_rawDescGZIP(), []int{0} return file_nockchain_proto_rawDescGZIP(), []int{0}
} }
func (x *WalletGetBalanceRequest) GetSelector() isWalletGetBalanceRequest_Selector { func (x *WalletGetBalanceRequest) GetAddress() string {
if x != nil { if x != nil {
return x.Selector
}
return nil
}
func (x *WalletGetBalanceRequest) GetAddress() *Base58Pubkey {
if x != nil {
if x, ok := x.Selector.(*WalletGetBalanceRequest_Address); ok {
return x.Address return x.Address
} }
} return ""
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 { func (x *WalletGetBalanceRequest) GetPage() *PageRequest {
@ -103,22 +80,6 @@ func (x *WalletGetBalanceRequest) GetPage() *PageRequest {
return nil 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 { type WalletGetBalanceResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// Types that are valid to be assigned to Result: // Types that are valid to be assigned to Result:
@ -167,7 +128,7 @@ func (x *WalletGetBalanceResponse) GetResult() isWalletGetBalanceResponse_Result
return nil return nil
} }
func (x *WalletGetBalanceResponse) GetBalance() *Balance { func (x *WalletGetBalanceResponse) GetBalance() *WalletBalanceData {
if x != nil { if x != nil {
if x, ok := x.Result.(*WalletGetBalanceResponse_Balance); ok { if x, ok := x.Result.(*WalletGetBalanceResponse_Balance); ok {
return x.Balance return x.Balance
@ -194,7 +155,7 @@ type WalletGetBalanceResponse_Balance struct {
// Continue paging using `balance.page.next_page_token` until empty. Clients // Continue paging using `balance.page.next_page_token` until empty. Clients
// should treat the page token as opaque; it may encode snapshot identity // should treat the page token as opaque; it may encode snapshot identity
// and the last returned key. // and the last returned key.
Balance *Balance `protobuf:"bytes,1,opt,name=balance,proto3,oneof"` Balance *WalletBalanceData `protobuf:"bytes,1,opt,name=balance,proto3,oneof"`
} }
type WalletGetBalanceResponse_Error struct { type WalletGetBalanceResponse_Error struct {
@ -476,35 +437,31 @@ var File_nockchain_proto protoreflect.FileDescriptor
const file_nockchain_proto_rawDesc = "" + const file_nockchain_proto_rawDesc = "" +
"\n" + "\n" +
"\x0fnockchain.proto\x12\x13nockchain.public.v2\x1a\x10blockchain.proto\x1a\x10primitives.proto\x1a\x10pagination.proto\"\xdc\x01\n" + "\x0fnockchain.proto\x12\x13nockchain.public.v1\x1a\x10blockchain.proto\x1a\x10primitives.proto\x1a\x10pagination.proto\"i\n" +
"\x17WalletGetBalanceRequest\x12=\n" + "\x17WalletGetBalanceRequest\x12\x18\n" +
"\aaddress\x18\x01 \x01(\v2!.nockchain.public.v2.Base58PubkeyH\x00R\aaddress\x12@\n" + "\aaddress\x18\x01 \x01(\tR\aaddress\x124\n" +
"\n" + "\x04page\x18\x02 \x01(\v2 .nockchain.public.v1.PageRequestR\x04page\"\xa2\x01\n" +
"first_name\x18\x02 \x01(\v2\x1f.nockchain.public.v2.Base58HashH\x00R\tfirstName\x124\n" + "\x18WalletGetBalanceResponse\x12B\n" +
"\x04page\x18\x03 \x01(\v2 .nockchain.public.v2.PageRequestR\x04pageB\n" + "\abalance\x18\x01 \x01(\v2&.nockchain.public.v1.WalletBalanceDataH\x00R\abalance\x128\n" +
"\n" + "\x05error\x18\x02 \x01(\v2 .nockchain.public.v1.ErrorStatusH\x00R\x05errorB\b\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" + "\x06result\"\x8a\x01\n" +
"\x1cWalletSendTransactionRequest\x12.\n" + "\x1cWalletSendTransactionRequest\x12.\n" +
"\x05tx_id\x18\x01 \x01(\v2\x19.nockchain.public.v2.HashR\x04txId\x12:\n" + "\x05tx_id\x18\x01 \x01(\v2\x19.nockchain.public.v1.HashR\x04txId\x12:\n" +
"\x06raw_tx\x18\x02 \x01(\v2#.nockchain.public.v2.RawTransactionR\x05rawTx\"\x9a\x01\n" + "\x06raw_tx\x18\x02 \x01(\v2#.nockchain.public.v1.RawTransactionR\x05rawTx\"\x9a\x01\n" +
"\x1dWalletSendTransactionResponse\x125\n" + "\x1dWalletSendTransactionResponse\x125\n" +
"\x03ack\x18\x01 \x01(\v2!.nockchain.public.v2.AcknowledgedH\x00R\x03ack\x128\n" + "\x03ack\x18\x01 \x01(\v2!.nockchain.public.v1.AcknowledgedH\x00R\x03ack\x128\n" +
"\x05error\x18\x02 \x01(\v2 .nockchain.public.v2.ErrorStatusH\x00R\x05errorB\b\n" + "\x05error\x18\x02 \x01(\v2 .nockchain.public.v1.ErrorStatusH\x00R\x05errorB\b\n" +
"\x06result\"R\n" + "\x06result\"R\n" +
"\x1aTransactionAcceptedRequest\x124\n" + "\x1aTransactionAcceptedRequest\x124\n" +
"\x05tx_id\x18\x01 \x01(\v2\x1f.nockchain.public.v2.Base58HashR\x04txId\"\x7f\n" + "\x05tx_id\x18\x01 \x01(\v2\x1f.nockchain.public.v1.Base58HashR\x04txId\"\x7f\n" +
"\x1bTransactionAcceptedResponse\x12\x1c\n" + "\x1bTransactionAcceptedResponse\x12\x1c\n" +
"\baccepted\x18\x01 \x01(\bH\x00R\baccepted\x128\n" + "\baccepted\x18\x01 \x01(\bH\x00R\baccepted\x128\n" +
"\x05error\x18\x02 \x01(\v2 .nockchain.public.v2.ErrorStatusH\x00R\x05errorB\b\n" + "\x05error\x18\x02 \x01(\v2 .nockchain.public.v1.ErrorStatusH\x00R\x05errorB\b\n" +
"\x06result2\xfd\x02\n" + "\x06result2\xfd\x02\n" +
"\x10NockchainService\x12o\n" + "\x10NockchainService\x12o\n" +
"\x10WalletGetBalance\x12,.nockchain.public.v2.WalletGetBalanceRequest\x1a-.nockchain.public.v2.WalletGetBalanceResponse\x12~\n" + "\x10WalletGetBalance\x12,.nockchain.public.v1.WalletGetBalanceRequest\x1a-.nockchain.public.v1.WalletGetBalanceResponse\x12~\n" +
"\x15WalletSendTransaction\x121.nockchain.public.v2.WalletSendTransactionRequest\x1a2.nockchain.public.v2.WalletSendTransactionResponse\x12x\n" + "\x15WalletSendTransaction\x121.nockchain.public.v1.WalletSendTransactionRequest\x1a2.nockchain.public.v1.WalletSendTransactionResponse\x12x\n" +
"\x13TransactionAccepted\x12/.nockchain.public.v2.TransactionAcceptedRequest\x1a0.nockchain.public.v2.TransactionAcceptedResponseB\x0eZ\f./;nockchainb\x06proto3" "\x13TransactionAccepted\x12/.nockchain.public.v1.TransactionAcceptedRequest\x1a0.nockchain.public.v1.TransactionAcceptedResponseB\x0eZ\f./;nockchainb\x06proto3"
var ( var (
file_nockchain_proto_rawDescOnce sync.Once file_nockchain_proto_rawDescOnce sync.Once
@ -520,44 +477,41 @@ func file_nockchain_proto_rawDescGZIP() []byte {
var file_nockchain_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_nockchain_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_nockchain_proto_goTypes = []any{ var file_nockchain_proto_goTypes = []any{
(*WalletGetBalanceRequest)(nil), // 0: nockchain.public.v2.WalletGetBalanceRequest (*WalletGetBalanceRequest)(nil), // 0: nockchain.public.v1.WalletGetBalanceRequest
(*WalletGetBalanceResponse)(nil), // 1: nockchain.public.v2.WalletGetBalanceResponse (*WalletGetBalanceResponse)(nil), // 1: nockchain.public.v1.WalletGetBalanceResponse
(*WalletSendTransactionRequest)(nil), // 2: nockchain.public.v2.WalletSendTransactionRequest (*WalletSendTransactionRequest)(nil), // 2: nockchain.public.v1.WalletSendTransactionRequest
(*WalletSendTransactionResponse)(nil), // 3: nockchain.public.v2.WalletSendTransactionResponse (*WalletSendTransactionResponse)(nil), // 3: nockchain.public.v1.WalletSendTransactionResponse
(*TransactionAcceptedRequest)(nil), // 4: nockchain.public.v2.TransactionAcceptedRequest (*TransactionAcceptedRequest)(nil), // 4: nockchain.public.v1.TransactionAcceptedRequest
(*TransactionAcceptedResponse)(nil), // 5: nockchain.public.v2.TransactionAcceptedResponse (*TransactionAcceptedResponse)(nil), // 5: nockchain.public.v1.TransactionAcceptedResponse
(*Base58Pubkey)(nil), // 6: nockchain.public.v2.Base58Pubkey (*PageRequest)(nil), // 6: nockchain.public.v1.PageRequest
(*Base58Hash)(nil), // 7: nockchain.public.v2.Base58Hash (*WalletBalanceData)(nil), // 7: nockchain.public.v1.WalletBalanceData
(*PageRequest)(nil), // 8: nockchain.public.v2.PageRequest (*ErrorStatus)(nil), // 8: nockchain.public.v1.ErrorStatus
(*Balance)(nil), // 9: nockchain.public.v2.Balance (*Hash)(nil), // 9: nockchain.public.v1.Hash
(*ErrorStatus)(nil), // 10: nockchain.public.v2.ErrorStatus (*RawTransaction)(nil), // 10: nockchain.public.v1.RawTransaction
(*Hash)(nil), // 11: nockchain.public.v2.Hash (*Acknowledged)(nil), // 11: nockchain.public.v1.Acknowledged
(*RawTransaction)(nil), // 12: nockchain.public.v2.RawTransaction (*Base58Hash)(nil), // 12: nockchain.public.v1.Base58Hash
(*Acknowledged)(nil), // 13: nockchain.public.v2.Acknowledged
} }
var file_nockchain_proto_depIdxs = []int32{ var file_nockchain_proto_depIdxs = []int32{
6, // 0: nockchain.public.v2.WalletGetBalanceRequest.address:type_name -> nockchain.public.v2.Base58Pubkey 6, // 0: nockchain.public.v1.WalletGetBalanceRequest.page:type_name -> nockchain.public.v1.PageRequest
7, // 1: nockchain.public.v2.WalletGetBalanceRequest.first_name:type_name -> nockchain.public.v2.Base58Hash 7, // 1: nockchain.public.v1.WalletGetBalanceResponse.balance:type_name -> nockchain.public.v1.WalletBalanceData
8, // 2: nockchain.public.v2.WalletGetBalanceRequest.page:type_name -> nockchain.public.v2.PageRequest 8, // 2: nockchain.public.v1.WalletGetBalanceResponse.error:type_name -> nockchain.public.v1.ErrorStatus
9, // 3: nockchain.public.v2.WalletGetBalanceResponse.balance:type_name -> nockchain.public.v2.Balance 9, // 3: nockchain.public.v1.WalletSendTransactionRequest.tx_id:type_name -> nockchain.public.v1.Hash
10, // 4: nockchain.public.v2.WalletGetBalanceResponse.error:type_name -> nockchain.public.v2.ErrorStatus 10, // 4: nockchain.public.v1.WalletSendTransactionRequest.raw_tx:type_name -> nockchain.public.v1.RawTransaction
11, // 5: nockchain.public.v2.WalletSendTransactionRequest.tx_id:type_name -> nockchain.public.v2.Hash 11, // 5: nockchain.public.v1.WalletSendTransactionResponse.ack:type_name -> nockchain.public.v1.Acknowledged
12, // 6: nockchain.public.v2.WalletSendTransactionRequest.raw_tx:type_name -> nockchain.public.v2.RawTransaction 8, // 6: nockchain.public.v1.WalletSendTransactionResponse.error:type_name -> nockchain.public.v1.ErrorStatus
13, // 7: nockchain.public.v2.WalletSendTransactionResponse.ack:type_name -> nockchain.public.v2.Acknowledged 12, // 7: nockchain.public.v1.TransactionAcceptedRequest.tx_id:type_name -> nockchain.public.v1.Base58Hash
10, // 8: nockchain.public.v2.WalletSendTransactionResponse.error:type_name -> nockchain.public.v2.ErrorStatus 8, // 8: nockchain.public.v1.TransactionAcceptedResponse.error:type_name -> nockchain.public.v1.ErrorStatus
7, // 9: nockchain.public.v2.TransactionAcceptedRequest.tx_id:type_name -> nockchain.public.v2.Base58Hash 0, // 9: nockchain.public.v1.NockchainService.WalletGetBalance:input_type -> nockchain.public.v1.WalletGetBalanceRequest
10, // 10: nockchain.public.v2.TransactionAcceptedResponse.error:type_name -> nockchain.public.v2.ErrorStatus 2, // 10: nockchain.public.v1.NockchainService.WalletSendTransaction:input_type -> nockchain.public.v1.WalletSendTransactionRequest
0, // 11: nockchain.public.v2.NockchainService.WalletGetBalance:input_type -> nockchain.public.v2.WalletGetBalanceRequest 4, // 11: nockchain.public.v1.NockchainService.TransactionAccepted:input_type -> nockchain.public.v1.TransactionAcceptedRequest
2, // 12: nockchain.public.v2.NockchainService.WalletSendTransaction:input_type -> nockchain.public.v2.WalletSendTransactionRequest 1, // 12: nockchain.public.v1.NockchainService.WalletGetBalance:output_type -> nockchain.public.v1.WalletGetBalanceResponse
4, // 13: nockchain.public.v2.NockchainService.TransactionAccepted:input_type -> nockchain.public.v2.TransactionAcceptedRequest 3, // 13: nockchain.public.v1.NockchainService.WalletSendTransaction:output_type -> nockchain.public.v1.WalletSendTransactionResponse
1, // 14: nockchain.public.v2.NockchainService.WalletGetBalance:output_type -> nockchain.public.v2.WalletGetBalanceResponse 5, // 14: nockchain.public.v1.NockchainService.TransactionAccepted:output_type -> nockchain.public.v1.TransactionAcceptedResponse
3, // 15: nockchain.public.v2.NockchainService.WalletSendTransaction:output_type -> nockchain.public.v2.WalletSendTransactionResponse 12, // [12:15] is the sub-list for method output_type
5, // 16: nockchain.public.v2.NockchainService.TransactionAccepted:output_type -> nockchain.public.v2.TransactionAcceptedResponse 9, // [9:12] is the sub-list for method input_type
14, // [14:17] is the sub-list for method output_type 9, // [9:9] is the sub-list for extension type_name
11, // [11:14] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension extendee
11, // [11:11] is the sub-list for extension type_name 0, // [0:9] is the sub-list for field 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() } func init() { file_nockchain_proto_init() }
@ -568,10 +522,6 @@ func file_nockchain_proto_init() {
file_blockchain_proto_init() file_blockchain_proto_init()
file_primitives_proto_init() file_primitives_proto_init()
file_pagination_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{ file_nockchain_proto_msgTypes[1].OneofWrappers = []any{
(*WalletGetBalanceResponse_Balance)(nil), (*WalletGetBalanceResponse_Balance)(nil),
(*WalletGetBalanceResponse_Error)(nil), (*WalletGetBalanceResponse_Error)(nil),

View File

@ -21,9 +21,9 @@ import (
const _ = grpc.SupportPackageIsVersion9 const _ = grpc.SupportPackageIsVersion9
const ( const (
NockchainService_WalletGetBalance_FullMethodName = "/nockchain.public.v2.NockchainService/WalletGetBalance" NockchainService_WalletGetBalance_FullMethodName = "/nockchain.public.v1.NockchainService/WalletGetBalance"
NockchainService_WalletSendTransaction_FullMethodName = "/nockchain.public.v2.NockchainService/WalletSendTransaction" NockchainService_WalletSendTransaction_FullMethodName = "/nockchain.public.v1.NockchainService/WalletSendTransaction"
NockchainService_TransactionAccepted_FullMethodName = "/nockchain.public.v2.NockchainService/TransactionAccepted" NockchainService_TransactionAccepted_FullMethodName = "/nockchain.public.v1.NockchainService/TransactionAccepted"
) )
// NockchainServiceClient is the client API for NockchainService service. // 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, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
var NockchainService_ServiceDesc = grpc.ServiceDesc{ var NockchainService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "nockchain.public.v2.NockchainService", ServiceName: "nockchain.public.v1.NockchainService",
HandlerType: (*NockchainServiceServer)(nil), HandlerType: (*NockchainServiceServer)(nil),
Methods: []grpc.MethodDesc{ Methods: []grpc.MethodDesc{
{ {

View File

@ -152,7 +152,7 @@ var File_pagination_proto protoreflect.FileDescriptor
const file_pagination_proto_rawDesc = "" + const file_pagination_proto_rawDesc = "" +
"\n" + "\n" +
"\x10pagination.proto\x12\x13nockchain.public.v2\"\x80\x01\n" + "\x10pagination.proto\x12\x13nockchain.public.v1\"\x80\x01\n" +
"\vPageRequest\x125\n" + "\vPageRequest\x125\n" +
"\x17client_page_items_limit\x18\x01 \x01(\rR\x14clientPageItemsLimit\x12\x1d\n" + "\x17client_page_items_limit\x18\x01 \x01(\rR\x14clientPageItemsLimit\x12\x1d\n" +
"\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_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_pagination_proto_goTypes = []any{ var file_pagination_proto_goTypes = []any{
(*PageRequest)(nil), // 0: nockchain.public.v2.PageRequest (*PageRequest)(nil), // 0: nockchain.public.v1.PageRequest
(*PageResponse)(nil), // 1: nockchain.public.v2.PageResponse (*PageResponse)(nil), // 1: nockchain.public.v1.PageResponse
} }
var file_pagination_proto_depIdxs = []int32{ var file_pagination_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method output_type

View File

@ -101,7 +101,7 @@ func (ErrorCode) EnumDescriptor() ([]byte, []int) {
type ErrorStatus struct { type ErrorStatus struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=nockchain.public.v2.ErrorCode" json:"code,omitempty"` Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=nockchain.public.v1.ErrorCode" json:"code,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,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 Details *string `protobuf:"bytes,3,opt,name=details,proto3,oneof" json:"details,omitempty"` // additional error context
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
@ -195,6 +195,148 @@ func (*Acknowledged) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{1} 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 // Note: prefer using raw numeric fields in messages
// instead of these wrappers to simplify conversions. // instead of these wrappers to simplify conversions.
// These remain defined for potential future use. // These remain defined for potential future use.
@ -207,7 +349,7 @@ type NoteVersion struct {
func (x *NoteVersion) Reset() { func (x *NoteVersion) Reset() {
*x = NoteVersion{} *x = NoteVersion{}
mi := &file_primitives_proto_msgTypes[2] mi := &file_primitives_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -219,7 +361,7 @@ func (x *NoteVersion) String() string {
func (*NoteVersion) ProtoMessage() {} func (*NoteVersion) ProtoMessage() {}
func (x *NoteVersion) ProtoReflect() protoreflect.Message { func (x *NoteVersion) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[2] mi := &file_primitives_proto_msgTypes[4]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -232,7 +374,7 @@ func (x *NoteVersion) ProtoReflect() protoreflect.Message {
// Deprecated: Use NoteVersion.ProtoReflect.Descriptor instead. // Deprecated: Use NoteVersion.ProtoReflect.Descriptor instead.
func (*NoteVersion) Descriptor() ([]byte, []int) { func (*NoteVersion) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{2} return file_primitives_proto_rawDescGZIP(), []int{4}
} }
func (x *NoteVersion) GetValue() uint32 { func (x *NoteVersion) GetValue() uint32 {
@ -251,7 +393,7 @@ type BlockHeight struct {
func (x *BlockHeight) Reset() { func (x *BlockHeight) Reset() {
*x = BlockHeight{} *x = BlockHeight{}
mi := &file_primitives_proto_msgTypes[3] mi := &file_primitives_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -263,7 +405,7 @@ func (x *BlockHeight) String() string {
func (*BlockHeight) ProtoMessage() {} func (*BlockHeight) ProtoMessage() {}
func (x *BlockHeight) ProtoReflect() protoreflect.Message { func (x *BlockHeight) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[3] mi := &file_primitives_proto_msgTypes[5]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -276,7 +418,7 @@ func (x *BlockHeight) ProtoReflect() protoreflect.Message {
// Deprecated: Use BlockHeight.ProtoReflect.Descriptor instead. // Deprecated: Use BlockHeight.ProtoReflect.Descriptor instead.
func (*BlockHeight) Descriptor() ([]byte, []int) { func (*BlockHeight) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{3} return file_primitives_proto_rawDescGZIP(), []int{5}
} }
func (x *BlockHeight) GetValue() uint64 { func (x *BlockHeight) GetValue() uint64 {
@ -295,7 +437,7 @@ type BlockHeightDelta struct {
func (x *BlockHeightDelta) Reset() { func (x *BlockHeightDelta) Reset() {
*x = BlockHeightDelta{} *x = BlockHeightDelta{}
mi := &file_primitives_proto_msgTypes[4] mi := &file_primitives_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -307,7 +449,7 @@ func (x *BlockHeightDelta) String() string {
func (*BlockHeightDelta) ProtoMessage() {} func (*BlockHeightDelta) ProtoMessage() {}
func (x *BlockHeightDelta) ProtoReflect() protoreflect.Message { func (x *BlockHeightDelta) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[4] mi := &file_primitives_proto_msgTypes[6]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -320,7 +462,7 @@ func (x *BlockHeightDelta) ProtoReflect() protoreflect.Message {
// Deprecated: Use BlockHeightDelta.ProtoReflect.Descriptor instead. // Deprecated: Use BlockHeightDelta.ProtoReflect.Descriptor instead.
func (*BlockHeightDelta) Descriptor() ([]byte, []int) { func (*BlockHeightDelta) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{4} return file_primitives_proto_rawDescGZIP(), []int{6}
} }
func (x *BlockHeightDelta) GetValue() uint64 { func (x *BlockHeightDelta) GetValue() uint64 {
@ -339,7 +481,7 @@ type Nicks struct {
func (x *Nicks) Reset() { func (x *Nicks) Reset() {
*x = Nicks{} *x = Nicks{}
mi := &file_primitives_proto_msgTypes[5] mi := &file_primitives_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -351,7 +493,7 @@ func (x *Nicks) String() string {
func (*Nicks) ProtoMessage() {} func (*Nicks) ProtoMessage() {}
func (x *Nicks) ProtoReflect() protoreflect.Message { func (x *Nicks) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[5] mi := &file_primitives_proto_msgTypes[7]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -364,7 +506,7 @@ func (x *Nicks) ProtoReflect() protoreflect.Message {
// Deprecated: Use Nicks.ProtoReflect.Descriptor instead. // Deprecated: Use Nicks.ProtoReflect.Descriptor instead.
func (*Nicks) Descriptor() ([]byte, []int) { func (*Nicks) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{5} return file_primitives_proto_rawDescGZIP(), []int{7}
} }
func (x *Nicks) GetValue() uint64 { func (x *Nicks) GetValue() uint64 {
@ -392,7 +534,7 @@ type EightBelt struct {
func (x *EightBelt) Reset() { func (x *EightBelt) Reset() {
*x = EightBelt{} *x = EightBelt{}
mi := &file_primitives_proto_msgTypes[6] mi := &file_primitives_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -404,7 +546,7 @@ func (x *EightBelt) String() string {
func (*EightBelt) ProtoMessage() {} func (*EightBelt) ProtoMessage() {}
func (x *EightBelt) ProtoReflect() protoreflect.Message { func (x *EightBelt) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[6] mi := &file_primitives_proto_msgTypes[8]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -417,7 +559,7 @@ func (x *EightBelt) ProtoReflect() protoreflect.Message {
// Deprecated: Use EightBelt.ProtoReflect.Descriptor instead. // Deprecated: Use EightBelt.ProtoReflect.Descriptor instead.
func (*EightBelt) Descriptor() ([]byte, []int) { func (*EightBelt) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{6} return file_primitives_proto_rawDescGZIP(), []int{8}
} }
func (x *EightBelt) GetBelt_1() *Belt { func (x *EightBelt) GetBelt_1() *Belt {
@ -491,7 +633,7 @@ type Hash struct {
func (x *Hash) Reset() { func (x *Hash) Reset() {
*x = Hash{} *x = Hash{}
mi := &file_primitives_proto_msgTypes[7] mi := &file_primitives_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -503,7 +645,7 @@ func (x *Hash) String() string {
func (*Hash) ProtoMessage() {} func (*Hash) ProtoMessage() {}
func (x *Hash) ProtoReflect() protoreflect.Message { func (x *Hash) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[7] mi := &file_primitives_proto_msgTypes[9]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -516,7 +658,7 @@ func (x *Hash) ProtoReflect() protoreflect.Message {
// Deprecated: Use Hash.ProtoReflect.Descriptor instead. // Deprecated: Use Hash.ProtoReflect.Descriptor instead.
func (*Hash) Descriptor() ([]byte, []int) { func (*Hash) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{7} return file_primitives_proto_rawDescGZIP(), []int{9}
} }
func (x *Hash) GetBelt_1() *Belt { func (x *Hash) GetBelt_1() *Belt {
@ -563,7 +705,7 @@ type Base58Hash struct {
func (x *Base58Hash) Reset() { func (x *Base58Hash) Reset() {
*x = Base58Hash{} *x = Base58Hash{}
mi := &file_primitives_proto_msgTypes[8] mi := &file_primitives_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -575,7 +717,7 @@ func (x *Base58Hash) String() string {
func (*Base58Hash) ProtoMessage() {} func (*Base58Hash) ProtoMessage() {}
func (x *Base58Hash) ProtoReflect() protoreflect.Message { func (x *Base58Hash) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[8] mi := &file_primitives_proto_msgTypes[10]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -588,7 +730,7 @@ func (x *Base58Hash) ProtoReflect() protoreflect.Message {
// Deprecated: Use Base58Hash.ProtoReflect.Descriptor instead. // Deprecated: Use Base58Hash.ProtoReflect.Descriptor instead.
func (*Base58Hash) Descriptor() ([]byte, []int) { func (*Base58Hash) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{8} return file_primitives_proto_rawDescGZIP(), []int{10}
} }
func (x *Base58Hash) GetHash() string { func (x *Base58Hash) GetHash() string {
@ -598,50 +740,6 @@ func (x *Base58Hash) GetHash() string {
return "" 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); // pub struct SchnorrPubkey(pub CheetahPoint);
type SchnorrPubkey struct { type SchnorrPubkey struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
@ -652,7 +750,7 @@ type SchnorrPubkey struct {
func (x *SchnorrPubkey) Reset() { func (x *SchnorrPubkey) Reset() {
*x = SchnorrPubkey{} *x = SchnorrPubkey{}
mi := &file_primitives_proto_msgTypes[10] mi := &file_primitives_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -664,7 +762,7 @@ func (x *SchnorrPubkey) String() string {
func (*SchnorrPubkey) ProtoMessage() {} func (*SchnorrPubkey) ProtoMessage() {}
func (x *SchnorrPubkey) ProtoReflect() protoreflect.Message { func (x *SchnorrPubkey) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[10] mi := &file_primitives_proto_msgTypes[11]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -677,7 +775,7 @@ func (x *SchnorrPubkey) ProtoReflect() protoreflect.Message {
// Deprecated: Use SchnorrPubkey.ProtoReflect.Descriptor instead. // Deprecated: Use SchnorrPubkey.ProtoReflect.Descriptor instead.
func (*SchnorrPubkey) Descriptor() ([]byte, []int) { func (*SchnorrPubkey) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{10} return file_primitives_proto_rawDescGZIP(), []int{11}
} }
func (x *SchnorrPubkey) GetValue() *CheetahPoint { func (x *SchnorrPubkey) GetValue() *CheetahPoint {
@ -703,7 +801,7 @@ type CheetahPoint struct {
func (x *CheetahPoint) Reset() { func (x *CheetahPoint) Reset() {
*x = CheetahPoint{} *x = CheetahPoint{}
mi := &file_primitives_proto_msgTypes[11] mi := &file_primitives_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -715,7 +813,7 @@ func (x *CheetahPoint) String() string {
func (*CheetahPoint) ProtoMessage() {} func (*CheetahPoint) ProtoMessage() {}
func (x *CheetahPoint) ProtoReflect() protoreflect.Message { func (x *CheetahPoint) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[11] mi := &file_primitives_proto_msgTypes[12]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -728,7 +826,7 @@ func (x *CheetahPoint) ProtoReflect() protoreflect.Message {
// Deprecated: Use CheetahPoint.ProtoReflect.Descriptor instead. // Deprecated: Use CheetahPoint.ProtoReflect.Descriptor instead.
func (*CheetahPoint) Descriptor() ([]byte, []int) { func (*CheetahPoint) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{11} return file_primitives_proto_rawDescGZIP(), []int{12}
} }
func (x *CheetahPoint) GetX() *SixBelt { func (x *CheetahPoint) GetX() *SixBelt {
@ -767,7 +865,7 @@ type SixBelt struct {
func (x *SixBelt) Reset() { func (x *SixBelt) Reset() {
*x = SixBelt{} *x = SixBelt{}
mi := &file_primitives_proto_msgTypes[12] mi := &file_primitives_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -779,7 +877,7 @@ func (x *SixBelt) String() string {
func (*SixBelt) ProtoMessage() {} func (*SixBelt) ProtoMessage() {}
func (x *SixBelt) ProtoReflect() protoreflect.Message { func (x *SixBelt) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[12] mi := &file_primitives_proto_msgTypes[13]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -792,7 +890,7 @@ func (x *SixBelt) ProtoReflect() protoreflect.Message {
// Deprecated: Use SixBelt.ProtoReflect.Descriptor instead. // Deprecated: Use SixBelt.ProtoReflect.Descriptor instead.
func (*SixBelt) Descriptor() ([]byte, []int) { func (*SixBelt) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{12} return file_primitives_proto_rawDescGZIP(), []int{13}
} }
func (x *SixBelt) GetBelt_1() *Belt { func (x *SixBelt) GetBelt_1() *Belt {
@ -847,7 +945,7 @@ type Belt struct {
func (x *Belt) Reset() { func (x *Belt) Reset() {
*x = Belt{} *x = Belt{}
mi := &file_primitives_proto_msgTypes[13] mi := &file_primitives_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -859,7 +957,7 @@ func (x *Belt) String() string {
func (*Belt) ProtoMessage() {} func (*Belt) ProtoMessage() {}
func (x *Belt) ProtoReflect() protoreflect.Message { func (x *Belt) ProtoReflect() protoreflect.Message {
mi := &file_primitives_proto_msgTypes[13] mi := &file_primitives_proto_msgTypes[14]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -872,7 +970,7 @@ func (x *Belt) ProtoReflect() protoreflect.Message {
// Deprecated: Use Belt.ProtoReflect.Descriptor instead. // Deprecated: Use Belt.ProtoReflect.Descriptor instead.
func (*Belt) Descriptor() ([]byte, []int) { func (*Belt) Descriptor() ([]byte, []int) {
return file_primitives_proto_rawDescGZIP(), []int{13} return file_primitives_proto_rawDescGZIP(), []int{14}
} }
func (x *Belt) GetValue() uint64 { func (x *Belt) GetValue() uint64 {
@ -886,14 +984,22 @@ var File_primitives_proto protoreflect.FileDescriptor
const file_primitives_proto_rawDesc = "" + const file_primitives_proto_rawDesc = "" +
"\n" + "\n" +
"\x10primitives.proto\x12\x13nockchain.public.v2\"\x86\x01\n" + "\x10primitives.proto\x12\x13nockchain.public.v1\"\x86\x01\n" +
"\vErrorStatus\x122\n" + "\vErrorStatus\x122\n" +
"\x04code\x18\x01 \x01(\x0e2\x1e.nockchain.public.v2.ErrorCodeR\x04code\x12\x18\n" + "\x04code\x18\x01 \x01(\x0e2\x1e.nockchain.public.v1.ErrorCodeR\x04code\x12\x18\n" +
"\amessage\x18\x02 \x01(\tR\amessage\x12\x1d\n" + "\amessage\x18\x02 \x01(\tR\amessage\x12\x1d\n" +
"\adetails\x18\x03 \x01(\tH\x00R\adetails\x88\x01\x01B\n" + "\adetails\x18\x03 \x01(\tH\x00R\adetails\x88\x01\x01B\n" +
"\n" + "\n" +
"\b_details\"\x0e\n" + "\b_details\"\x0e\n" +
"\fAcknowledged\"#\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" +
"\vNoteVersion\x12\x14\n" + "\vNoteVersion\x12\x14\n" +
"\x05value\x18\x01 \x01(\rR\x05value\"#\n" + "\x05value\x18\x01 \x01(\rR\x05value\"#\n" +
"\vBlockHeight\x12\x14\n" + "\vBlockHeight\x12\x14\n" +
@ -903,38 +1009,36 @@ const file_primitives_proto_rawDesc = "" +
"\x05Nicks\x12\x14\n" + "\x05Nicks\x12\x14\n" +
"\x05value\x18\x01 \x01(\x04R\x05value\"\x9b\x03\n" + "\x05value\x18\x01 \x01(\x04R\x05value\"\x9b\x03\n" +
"\tEightBelt\x120\n" + "\tEightBelt\x120\n" +
"\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt1\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.v2.BeltR\x05belt2\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.v2.BeltR\x05belt3\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.v2.BeltR\x05belt4\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.v2.BeltR\x05belt5\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.v2.BeltR\x05belt6\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.v2.BeltR\x05belt7\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.v2.BeltR\x05belt8\"\x80\x02\n" + "\x06belt_8\x18\b \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt8\"\x80\x02\n" +
"\x04Hash\x120\n" + "\x04Hash\x120\n" +
"\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt1\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.v2.BeltR\x05belt2\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.v2.BeltR\x05belt3\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.v2.BeltR\x05belt4\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.v2.BeltR\x05belt5\" \n" + "\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt5\" \n" +
"\n" + "\n" +
"Base58Hash\x12\x12\n" + "Base58Hash\x12\x12\n" +
"\x04hash\x18\x01 \x01(\tR\x04hash\" \n" + "\x04hash\x18\x01 \x01(\tR\x04hash\"H\n" +
"\fBase58Pubkey\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\"H\n" +
"\rSchnorrPubkey\x127\n" + "\rSchnorrPubkey\x127\n" +
"\x05value\x18\x01 \x01(\v2!.nockchain.public.v2.CheetahPointR\x05value\"x\n" + "\x05value\x18\x01 \x01(\v2!.nockchain.public.v1.CheetahPointR\x05value\"x\n" +
"\fCheetahPoint\x12*\n" + "\fCheetahPoint\x12*\n" +
"\x01x\x18\x01 \x01(\v2\x1c.nockchain.public.v2.SixBeltR\x01x\x12*\n" + "\x01x\x18\x01 \x01(\v2\x1c.nockchain.public.v1.SixBeltR\x01x\x12*\n" +
"\x01y\x18\x02 \x01(\v2\x1c.nockchain.public.v2.SixBeltR\x01y\x12\x10\n" + "\x01y\x18\x02 \x01(\v2\x1c.nockchain.public.v1.SixBeltR\x01y\x12\x10\n" +
"\x03inf\x18\x03 \x01(\bR\x03inf\"\xb5\x02\n" + "\x03inf\x18\x03 \x01(\bR\x03inf\"\xb5\x02\n" +
"\aSixBelt\x120\n" + "\aSixBelt\x120\n" +
"\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v2.BeltR\x05belt1\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.v2.BeltR\x05belt2\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.v2.BeltR\x05belt3\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.v2.BeltR\x05belt4\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.v2.BeltR\x05belt5\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.v2.BeltR\x05belt6\"\x1c\n" + "\x06belt_6\x18\x06 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt6\"\x1c\n" +
"\x04Belt\x12\x14\n" + "\x04Belt\x12\x14\n" +
"\x05value\x18\x01 \x01(\x04R\x05value*\xf0\x02\n" + "\x05value\x18\x01 \x01(\x04R\x05value*\xf0\x02\n" +
"\tErrorCode\x12\x1a\n" + "\tErrorCode\x12\x1a\n" +
@ -965,53 +1069,55 @@ func file_primitives_proto_rawDescGZIP() []byte {
} }
var file_primitives_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_primitives_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_primitives_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_primitives_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
var file_primitives_proto_goTypes = []any{ var file_primitives_proto_goTypes = []any{
(ErrorCode)(0), // 0: nockchain.public.v2.ErrorCode (ErrorCode)(0), // 0: nockchain.public.v1.ErrorCode
(*ErrorStatus)(nil), // 1: nockchain.public.v2.ErrorStatus (*ErrorStatus)(nil), // 1: nockchain.public.v1.ErrorStatus
(*Acknowledged)(nil), // 2: nockchain.public.v2.Acknowledged (*Acknowledged)(nil), // 2: nockchain.public.v1.Acknowledged
(*NoteVersion)(nil), // 3: nockchain.public.v2.NoteVersion (*Wire)(nil), // 3: nockchain.public.v1.Wire
(*BlockHeight)(nil), // 4: nockchain.public.v2.BlockHeight (*WireTag)(nil), // 4: nockchain.public.v1.WireTag
(*BlockHeightDelta)(nil), // 5: nockchain.public.v2.BlockHeightDelta (*NoteVersion)(nil), // 5: nockchain.public.v1.NoteVersion
(*Nicks)(nil), // 6: nockchain.public.v2.Nicks (*BlockHeight)(nil), // 6: nockchain.public.v1.BlockHeight
(*EightBelt)(nil), // 7: nockchain.public.v2.EightBelt (*BlockHeightDelta)(nil), // 7: nockchain.public.v1.BlockHeightDelta
(*Hash)(nil), // 8: nockchain.public.v2.Hash (*Nicks)(nil), // 8: nockchain.public.v1.Nicks
(*Base58Hash)(nil), // 9: nockchain.public.v2.Base58Hash (*EightBelt)(nil), // 9: nockchain.public.v1.EightBelt
(*Base58Pubkey)(nil), // 10: nockchain.public.v2.Base58Pubkey (*Hash)(nil), // 10: nockchain.public.v1.Hash
(*SchnorrPubkey)(nil), // 11: nockchain.public.v2.SchnorrPubkey (*Base58Hash)(nil), // 11: nockchain.public.v1.Base58Hash
(*CheetahPoint)(nil), // 12: nockchain.public.v2.CheetahPoint (*SchnorrPubkey)(nil), // 12: nockchain.public.v1.SchnorrPubkey
(*SixBelt)(nil), // 13: nockchain.public.v2.SixBelt (*CheetahPoint)(nil), // 13: nockchain.public.v1.CheetahPoint
(*Belt)(nil), // 14: nockchain.public.v2.Belt (*SixBelt)(nil), // 14: nockchain.public.v1.SixBelt
(*Belt)(nil), // 15: nockchain.public.v1.Belt
} }
var file_primitives_proto_depIdxs = []int32{ var file_primitives_proto_depIdxs = []int32{
0, // 0: nockchain.public.v2.ErrorStatus.code:type_name -> nockchain.public.v2.ErrorCode 0, // 0: nockchain.public.v1.ErrorStatus.code:type_name -> nockchain.public.v1.ErrorCode
14, // 1: nockchain.public.v2.EightBelt.belt_1:type_name -> nockchain.public.v2.Belt 4, // 1: nockchain.public.v1.Wire.tags:type_name -> nockchain.public.v1.WireTag
14, // 2: nockchain.public.v2.EightBelt.belt_2:type_name -> nockchain.public.v2.Belt 15, // 2: nockchain.public.v1.EightBelt.belt_1:type_name -> nockchain.public.v1.Belt
14, // 3: nockchain.public.v2.EightBelt.belt_3:type_name -> nockchain.public.v2.Belt 15, // 3: nockchain.public.v1.EightBelt.belt_2:type_name -> nockchain.public.v1.Belt
14, // 4: nockchain.public.v2.EightBelt.belt_4:type_name -> nockchain.public.v2.Belt 15, // 4: nockchain.public.v1.EightBelt.belt_3:type_name -> nockchain.public.v1.Belt
14, // 5: nockchain.public.v2.EightBelt.belt_5:type_name -> nockchain.public.v2.Belt 15, // 5: nockchain.public.v1.EightBelt.belt_4:type_name -> nockchain.public.v1.Belt
14, // 6: nockchain.public.v2.EightBelt.belt_6:type_name -> nockchain.public.v2.Belt 15, // 6: nockchain.public.v1.EightBelt.belt_5:type_name -> nockchain.public.v1.Belt
14, // 7: nockchain.public.v2.EightBelt.belt_7:type_name -> nockchain.public.v2.Belt 15, // 7: nockchain.public.v1.EightBelt.belt_6:type_name -> nockchain.public.v1.Belt
14, // 8: nockchain.public.v2.EightBelt.belt_8:type_name -> nockchain.public.v2.Belt 15, // 8: nockchain.public.v1.EightBelt.belt_7:type_name -> nockchain.public.v1.Belt
14, // 9: nockchain.public.v2.Hash.belt_1:type_name -> nockchain.public.v2.Belt 15, // 9: nockchain.public.v1.EightBelt.belt_8:type_name -> nockchain.public.v1.Belt
14, // 10: nockchain.public.v2.Hash.belt_2:type_name -> nockchain.public.v2.Belt 15, // 10: nockchain.public.v1.Hash.belt_1:type_name -> nockchain.public.v1.Belt
14, // 11: nockchain.public.v2.Hash.belt_3:type_name -> nockchain.public.v2.Belt 15, // 11: nockchain.public.v1.Hash.belt_2:type_name -> nockchain.public.v1.Belt
14, // 12: nockchain.public.v2.Hash.belt_4:type_name -> nockchain.public.v2.Belt 15, // 12: nockchain.public.v1.Hash.belt_3:type_name -> nockchain.public.v1.Belt
14, // 13: nockchain.public.v2.Hash.belt_5:type_name -> nockchain.public.v2.Belt 15, // 13: nockchain.public.v1.Hash.belt_4:type_name -> nockchain.public.v1.Belt
12, // 14: nockchain.public.v2.SchnorrPubkey.value:type_name -> nockchain.public.v2.CheetahPoint 15, // 14: nockchain.public.v1.Hash.belt_5:type_name -> nockchain.public.v1.Belt
13, // 15: nockchain.public.v2.CheetahPoint.x:type_name -> nockchain.public.v2.SixBelt 13, // 15: nockchain.public.v1.SchnorrPubkey.value:type_name -> nockchain.public.v1.CheetahPoint
13, // 16: nockchain.public.v2.CheetahPoint.y:type_name -> nockchain.public.v2.SixBelt 14, // 16: nockchain.public.v1.CheetahPoint.x:type_name -> nockchain.public.v1.SixBelt
14, // 17: nockchain.public.v2.SixBelt.belt_1:type_name -> nockchain.public.v2.Belt 14, // 17: nockchain.public.v1.CheetahPoint.y:type_name -> nockchain.public.v1.SixBelt
14, // 18: nockchain.public.v2.SixBelt.belt_2:type_name -> nockchain.public.v2.Belt 15, // 18: nockchain.public.v1.SixBelt.belt_1:type_name -> nockchain.public.v1.Belt
14, // 19: nockchain.public.v2.SixBelt.belt_3:type_name -> nockchain.public.v2.Belt 15, // 19: nockchain.public.v1.SixBelt.belt_2:type_name -> nockchain.public.v1.Belt
14, // 20: nockchain.public.v2.SixBelt.belt_4:type_name -> nockchain.public.v2.Belt 15, // 20: nockchain.public.v1.SixBelt.belt_3:type_name -> nockchain.public.v1.Belt
14, // 21: nockchain.public.v2.SixBelt.belt_5:type_name -> nockchain.public.v2.Belt 15, // 21: nockchain.public.v1.SixBelt.belt_4:type_name -> nockchain.public.v1.Belt
14, // 22: nockchain.public.v2.SixBelt.belt_6:type_name -> nockchain.public.v2.Belt 15, // 22: nockchain.public.v1.SixBelt.belt_5:type_name -> nockchain.public.v1.Belt
23, // [23:23] is the sub-list for method output_type 15, // 23: nockchain.public.v1.SixBelt.belt_6:type_name -> nockchain.public.v1.Belt
23, // [23:23] is the sub-list for method input_type 24, // [24:24] is the sub-list for method output_type
23, // [23:23] is the sub-list for extension type_name 24, // [24:24] is the sub-list for method input_type
23, // [23:23] is the sub-list for extension extendee 24, // [24:24] is the sub-list for extension type_name
0, // [0:23] is the sub-list for field type_name 24, // [24:24] is the sub-list for extension extendee
0, // [0:24] is the sub-list for field type_name
} }
func init() { file_primitives_proto_init() } func init() { file_primitives_proto_init() }
@ -1020,13 +1126,17 @@ func file_primitives_proto_init() {
return return
} }
file_primitives_proto_msgTypes[0].OneofWrappers = []any{} file_primitives_proto_msgTypes[0].OneofWrappers = []any{}
file_primitives_proto_msgTypes[3].OneofWrappers = []any{
(*WireTag_Text)(nil),
(*WireTag_Number)(nil),
}
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_primitives_proto_rawDesc), len(file_primitives_proto_rawDesc)), RawDescriptor: unsafe.Slice(unsafe.StringData(file_primitives_proto_rawDesc), len(file_primitives_proto_rawDesc)),
NumEnums: 1, NumEnums: 1,
NumMessages: 14, NumMessages: 15,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -23,7 +23,6 @@ const (
type KeygenRequest struct { type KeygenRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -58,22 +57,14 @@ func (*KeygenRequest) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{0} return file_service_proto_rawDescGZIP(), []int{0}
} }
func (x *KeygenRequest) GetVersion() uint64 {
if x != nil {
return x.Version
}
return 0
}
type KeygenResponse struct { type KeygenResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,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"` 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"` 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"` 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"` 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 unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -108,9 +99,9 @@ func (*KeygenResponse) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{1} return file_service_proto_rawDescGZIP(), []int{1}
} }
func (x *KeygenResponse) GetAddress() string { func (x *KeygenResponse) GetPublicKey() string {
if x != nil { if x != nil {
return x.Address return x.PublicKey
} }
return "" return ""
} }
@ -150,18 +141,10 @@ func (x *KeygenResponse) GetImportPublicKey() string {
return "" return ""
} }
func (x *KeygenResponse) GetVersion() uint64 {
if x != nil {
return x.Version
}
return 0
}
type ImportKeysRequest struct { type ImportKeysRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Version uint64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` ImportType ImportType `protobuf:"varint,2,opt,name=import_type,json=importType,proto3,enum=nockchain.public.v1.ImportType" json:"import_type,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 unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -203,13 +186,6 @@ func (x *ImportKeysRequest) GetKey() string {
return "" return ""
} }
func (x *ImportKeysRequest) GetVersion() uint64 {
if x != nil {
return x.Version
}
return 0
}
func (x *ImportKeysRequest) GetImportType() ImportType { func (x *ImportKeysRequest) GetImportType() ImportType {
if x != nil { if x != nil {
return x.ImportType return x.ImportType
@ -219,13 +195,12 @@ func (x *ImportKeysRequest) GetImportType() ImportType {
type ImportKeysResponse struct { type ImportKeysResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,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"` 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"` 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"` 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"` 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 unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -260,9 +235,9 @@ func (*ImportKeysResponse) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{3} return file_service_proto_rawDescGZIP(), []int{3}
} }
func (x *ImportKeysResponse) GetAddress() string { func (x *ImportKeysResponse) GetPublicKey() string {
if x != nil { if x != nil {
return x.Address return x.PublicKey
} }
return "" return ""
} }
@ -302,19 +277,11 @@ func (x *ImportKeysResponse) GetImportPublicKey() string {
return "" return ""
} }
func (x *ImportKeysResponse) GetVersion() uint64 {
if x != nil {
return x.Version
}
return 0
}
type DeriveChildRequest struct { type DeriveChildRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
ImportedKey string `protobuf:"bytes,1,opt,name=imported_key,json=importedKey,proto3" json:"imported_key,omitempty"` 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"` Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
Hardened bool `protobuf:"varint,3,opt,name=hardened,proto3" json:"hardened,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 unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -370,19 +337,11 @@ func (x *DeriveChildRequest) GetHardened() bool {
return false return false
} }
func (x *DeriveChildRequest) GetVersion() uint64 {
if x != nil {
return x.Version
}
return 0
}
type DeriveChildResponse struct { type DeriveChildResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,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"` 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 unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -417,9 +376,9 @@ func (*DeriveChildResponse) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{5} return file_service_proto_rawDescGZIP(), []int{5}
} }
func (x *DeriveChildResponse) GetAddress() string { func (x *DeriveChildResponse) GetPublicKey() string {
if x != nil { if x != nil {
return x.Address return x.PublicKey
} }
return "" return ""
} }
@ -438,24 +397,18 @@ func (x *DeriveChildResponse) GetChainCode() string {
return "" return ""
} }
func (x *DeriveChildResponse) GetVersion() uint64 {
if x != nil {
return x.Version
}
return 0
}
type CreateTxRequest struct { type CreateTxRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Names string `protobuf:"bytes,1,opt,name=names,proto3" json:"names,omitempty"` Names string `protobuf:"bytes,1,opt,name=names,proto3" json:"names,omitempty"`
Recipients string `protobuf:"bytes,2,opt,name=recipients,proto3" json:"recipients,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"` Gifts string `protobuf:"bytes,3,opt,name=gifts,proto3" json:"gifts,omitempty"`
IsMasterKey bool `protobuf:"varint,4,opt,name=is_master_key,json=isMasterKey,proto3" json:"is_master_key,omitempty"` Fee uint64 `protobuf:"varint,4,opt,name=fee,proto3" json:"fee,omitempty"`
Seed string `protobuf:"bytes,5,opt,name=seed,proto3" json:"seed,omitempty"` IsMasterKey bool `protobuf:"varint,5,opt,name=is_master_key,json=isMasterKey,proto3" json:"is_master_key,omitempty"`
Index uint64 `protobuf:"varint,6,opt,name=index,proto3" json:"index,omitempty"` Key string `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"`
Hardened bool `protobuf:"varint,7,opt,name=hardened,proto3" json:"hardened,omitempty"` ChainCode string `protobuf:"bytes,7,opt,name=chain_code,json=chainCode,proto3" json:"chain_code,omitempty"`
Version uint64 `protobuf:"varint,8,opt,name=version,proto3" json:"version,omitempty"` Index uint64 `protobuf:"varint,8,opt,name=index,proto3" json:"index,omitempty"`
RefundAddress string `protobuf:"bytes,9,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,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 unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -504,6 +457,13 @@ func (x *CreateTxRequest) GetRecipients() string {
return "" return ""
} }
func (x *CreateTxRequest) GetGifts() string {
if x != nil {
return x.Gifts
}
return ""
}
func (x *CreateTxRequest) GetFee() uint64 { func (x *CreateTxRequest) GetFee() uint64 {
if x != nil { if x != nil {
return x.Fee return x.Fee
@ -518,9 +478,16 @@ func (x *CreateTxRequest) GetIsMasterKey() bool {
return false return false
} }
func (x *CreateTxRequest) GetSeed() string { func (x *CreateTxRequest) GetKey() string {
if x != nil { if x != nil {
return x.Seed return x.Key
}
return ""
}
func (x *CreateTxRequest) GetChainCode() string {
if x != nil {
return x.ChainCode
} }
return "" return ""
} }
@ -539,18 +506,11 @@ func (x *CreateTxRequest) GetHardened() bool {
return false return false
} }
func (x *CreateTxRequest) GetVersion() uint64 { func (x *CreateTxRequest) GetTimelockIntent() *TimelockIntent {
if x != nil { if x != nil {
return x.Version return x.TimelockIntent
} }
return 0 return nil
}
func (x *CreateTxRequest) GetRefundAddress() string {
if x != nil {
return x.RefundAddress
}
return ""
} }
type CreateTxResponse struct { type CreateTxResponse struct {
@ -597,6 +557,118 @@ func (x *CreateTxResponse) GetRawTx() *RawTx {
return nil 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 { type ScanRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
MasterPubkey string `protobuf:"bytes,1,opt,name=master_pubkey,json=masterPubkey,proto3" json:"master_pubkey,omitempty"` MasterPubkey string `protobuf:"bytes,1,opt,name=master_pubkey,json=masterPubkey,proto3" json:"master_pubkey,omitempty"`
@ -604,14 +676,13 @@ type ScanRequest struct {
SearchDepth uint64 `protobuf:"varint,3,opt,name=search_depth,json=searchDepth,proto3" json:"search_depth,omitempty"` 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"` 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"` 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 unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
func (x *ScanRequest) Reset() { func (x *ScanRequest) Reset() {
*x = ScanRequest{} *x = ScanRequest{}
mi := &file_service_proto_msgTypes[8] mi := &file_service_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -623,7 +694,7 @@ func (x *ScanRequest) String() string {
func (*ScanRequest) ProtoMessage() {} func (*ScanRequest) ProtoMessage() {}
func (x *ScanRequest) ProtoReflect() protoreflect.Message { func (x *ScanRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_proto_msgTypes[8] mi := &file_service_proto_msgTypes[10]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -636,7 +707,7 @@ func (x *ScanRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ScanRequest.ProtoReflect.Descriptor instead. // Deprecated: Use ScanRequest.ProtoReflect.Descriptor instead.
func (*ScanRequest) Descriptor() ([]byte, []int) { func (*ScanRequest) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{8} return file_service_proto_rawDescGZIP(), []int{10}
} }
func (x *ScanRequest) GetMasterPubkey() string { func (x *ScanRequest) GetMasterPubkey() string {
@ -674,13 +745,6 @@ func (x *ScanRequest) GetIncludeMultisig() bool {
return false return false
} }
func (x *ScanRequest) GetVersion() uint64 {
if x != nil {
return x.Version
}
return 0
}
type ScanResponse struct { type ScanResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
ScanData []*ScanData `protobuf:"bytes,1,rep,name=scan_data,json=scanData,proto3" json:"scan_data,omitempty"` ScanData []*ScanData `protobuf:"bytes,1,rep,name=scan_data,json=scanData,proto3" json:"scan_data,omitempty"`
@ -690,7 +754,7 @@ type ScanResponse struct {
func (x *ScanResponse) Reset() { func (x *ScanResponse) Reset() {
*x = ScanResponse{} *x = ScanResponse{}
mi := &file_service_proto_msgTypes[9] mi := &file_service_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -702,7 +766,7 @@ func (x *ScanResponse) String() string {
func (*ScanResponse) ProtoMessage() {} func (*ScanResponse) ProtoMessage() {}
func (x *ScanResponse) ProtoReflect() protoreflect.Message { func (x *ScanResponse) ProtoReflect() protoreflect.Message {
mi := &file_service_proto_msgTypes[9] mi := &file_service_proto_msgTypes[11]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -715,7 +779,7 @@ func (x *ScanResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ScanResponse.ProtoReflect.Descriptor instead. // Deprecated: Use ScanResponse.ProtoReflect.Descriptor instead.
func (*ScanResponse) Descriptor() ([]byte, []int) { func (*ScanResponse) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{9} return file_service_proto_rawDescGZIP(), []int{11}
} }
func (x *ScanResponse) GetScanData() []*ScanData { func (x *ScanResponse) GetScanData() []*ScanData {
@ -727,18 +791,14 @@ func (x *ScanResponse) GetScanData() []*ScanData {
type GetBalanceRequest struct { type GetBalanceRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// Types that are valid to be assigned to Selector: Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
//
// *GetBalanceRequest_Address
// *GetBalanceRequest_FirstName
Selector isGetBalanceRequest_Selector `protobuf_oneof:"selector"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
func (x *GetBalanceRequest) Reset() { func (x *GetBalanceRequest) Reset() {
*x = GetBalanceRequest{} *x = GetBalanceRequest{}
mi := &file_service_proto_msgTypes[10] mi := &file_service_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -750,7 +810,7 @@ func (x *GetBalanceRequest) String() string {
func (*GetBalanceRequest) ProtoMessage() {} func (*GetBalanceRequest) ProtoMessage() {}
func (x *GetBalanceRequest) ProtoReflect() protoreflect.Message { func (x *GetBalanceRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_proto_msgTypes[10] mi := &file_service_proto_msgTypes[12]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -763,60 +823,26 @@ func (x *GetBalanceRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetBalanceRequest.ProtoReflect.Descriptor instead. // Deprecated: Use GetBalanceRequest.ProtoReflect.Descriptor instead.
func (*GetBalanceRequest) Descriptor() ([]byte, []int) { func (*GetBalanceRequest) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{10} return file_service_proto_rawDescGZIP(), []int{12}
}
func (x *GetBalanceRequest) GetSelector() isGetBalanceRequest_Selector {
if x != nil {
return x.Selector
}
return nil
} }
func (x *GetBalanceRequest) GetAddress() string { func (x *GetBalanceRequest) GetAddress() string {
if x != nil { if x != nil {
if x, ok := x.Selector.(*GetBalanceRequest_Address); ok {
return x.Address return x.Address
} }
}
return "" 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 { type GetBalanceResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Data *Balance `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Data *WalletBalanceData `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
func (x *GetBalanceResponse) Reset() { func (x *GetBalanceResponse) Reset() {
*x = GetBalanceResponse{} *x = GetBalanceResponse{}
mi := &file_service_proto_msgTypes[11] mi := &file_service_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -828,7 +854,7 @@ func (x *GetBalanceResponse) String() string {
func (*GetBalanceResponse) ProtoMessage() {} func (*GetBalanceResponse) ProtoMessage() {}
func (x *GetBalanceResponse) ProtoReflect() protoreflect.Message { func (x *GetBalanceResponse) ProtoReflect() protoreflect.Message {
mi := &file_service_proto_msgTypes[11] mi := &file_service_proto_msgTypes[13]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -841,10 +867,10 @@ func (x *GetBalanceResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetBalanceResponse.ProtoReflect.Descriptor instead. // Deprecated: Use GetBalanceResponse.ProtoReflect.Descriptor instead.
func (*GetBalanceResponse) Descriptor() ([]byte, []int) { func (*GetBalanceResponse) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{11} return file_service_proto_rawDescGZIP(), []int{13}
} }
func (x *GetBalanceResponse) GetData() *Balance { func (x *GetBalanceResponse) GetData() *WalletBalanceData {
if x != nil { if x != nil {
return x.Data return x.Data
} }
@ -860,7 +886,7 @@ type SendTransactionRequest struct {
func (x *SendTransactionRequest) Reset() { func (x *SendTransactionRequest) Reset() {
*x = SendTransactionRequest{} *x = SendTransactionRequest{}
mi := &file_service_proto_msgTypes[12] mi := &file_service_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -872,7 +898,7 @@ func (x *SendTransactionRequest) String() string {
func (*SendTransactionRequest) ProtoMessage() {} func (*SendTransactionRequest) ProtoMessage() {}
func (x *SendTransactionRequest) ProtoReflect() protoreflect.Message { func (x *SendTransactionRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_proto_msgTypes[12] mi := &file_service_proto_msgTypes[14]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -885,7 +911,7 @@ func (x *SendTransactionRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use SendTransactionRequest.ProtoReflect.Descriptor instead. // Deprecated: Use SendTransactionRequest.ProtoReflect.Descriptor instead.
func (*SendTransactionRequest) Descriptor() ([]byte, []int) { func (*SendTransactionRequest) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{12} return file_service_proto_rawDescGZIP(), []int{14}
} }
func (x *SendTransactionRequest) GetRawTx() *RawTx { func (x *SendTransactionRequest) GetRawTx() *RawTx {
@ -904,7 +930,7 @@ type SendTransactionResponse struct {
func (x *SendTransactionResponse) Reset() { func (x *SendTransactionResponse) Reset() {
*x = SendTransactionResponse{} *x = SendTransactionResponse{}
mi := &file_service_proto_msgTypes[13] mi := &file_service_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -916,7 +942,7 @@ func (x *SendTransactionResponse) String() string {
func (*SendTransactionResponse) ProtoMessage() {} func (*SendTransactionResponse) ProtoMessage() {}
func (x *SendTransactionResponse) ProtoReflect() protoreflect.Message { func (x *SendTransactionResponse) ProtoReflect() protoreflect.Message {
mi := &file_service_proto_msgTypes[13] mi := &file_service_proto_msgTypes[15]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -929,7 +955,7 @@ func (x *SendTransactionResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use SendTransactionResponse.ProtoReflect.Descriptor instead. // Deprecated: Use SendTransactionResponse.ProtoReflect.Descriptor instead.
func (*SendTransactionResponse) Descriptor() ([]byte, []int) { func (*SendTransactionResponse) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{13} return file_service_proto_rawDescGZIP(), []int{15}
} }
func (x *SendTransactionResponse) GetResponse() *WalletSendTransactionResponse { func (x *SendTransactionResponse) GetResponse() *WalletSendTransactionResponse {
@ -943,92 +969,96 @@ var File_service_proto protoreflect.FileDescriptor
const file_service_proto_rawDesc = "" + const file_service_proto_rawDesc = "" +
"\n" + "\n" +
"\rservice.proto\x12\x13nockchain.public.v2\x1a\vtypes.proto\x1a\x10blockchain.proto\x1a\x0fnockchain.proto\")\n" + "\rservice.proto\x12\x13nockchain.public.v1\x1a\vtypes.proto\x1a\x10blockchain.proto\x1a\x0fnockchain.proto\"\x0f\n" +
"\rKeygenRequest\x12\x18\n" + "\rKeygenRequest\"\xdd\x01\n" +
"\aversion\x18\x01 \x01(\x04R\aversion\"\xf2\x01\n" + "\x0eKeygenResponse\x12\x1d\n" +
"\x0eKeygenResponse\x12\x18\n" + "\n" +
"\aaddress\x18\x01 \x01(\tR\aaddress\x12\x1f\n" + "public_key\x18\x01 \x01(\tR\tpublicKey\x12\x1f\n" +
"\vprivate_key\x18\x02 \x01(\tR\n" + "\vprivate_key\x18\x02 \x01(\tR\n" +
"privateKey\x12\x12\n" + "privateKey\x12\x12\n" +
"\x04seed\x18\x03 \x01(\tR\x04seed\x12\x1d\n" + "\x04seed\x18\x03 \x01(\tR\x04seed\x12\x1d\n" +
"\n" + "\n" +
"chain_code\x18\x04 \x01(\tR\tchainCode\x12,\n" + "chain_code\x18\x04 \x01(\tR\tchainCode\x12,\n" +
"\x12import_private_key\x18\x05 \x01(\tR\x10importPrivateKey\x12*\n" + "\x12import_private_key\x18\x05 \x01(\tR\x10importPrivateKey\x12*\n" +
"\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\x12\x18\n" + "\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\"g\n" +
"\aversion\x18\a \x01(\x04R\aversion\"\x81\x01\n" +
"\x11ImportKeysRequest\x12\x10\n" + "\x11ImportKeysRequest\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x18\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12@\n" +
"\aversion\x18\x02 \x01(\x04R\aversion\x12@\n" + "\vimport_type\x18\x02 \x01(\x0e2\x1f.nockchain.public.v1.ImportTypeR\n" +
"\vimport_type\x18\x03 \x01(\x0e2\x1f.nockchain.public.v2.ImportTypeR\n" + "importType\"\xe1\x01\n" +
"importType\"\xf6\x01\n" + "\x12ImportKeysResponse\x12\x1d\n" +
"\x12ImportKeysResponse\x12\x18\n" + "\n" +
"\aaddress\x18\x01 \x01(\tR\aaddress\x12\x1f\n" + "public_key\x18\x01 \x01(\tR\tpublicKey\x12\x1f\n" +
"\vprivate_key\x18\x02 \x01(\tR\n" + "\vprivate_key\x18\x02 \x01(\tR\n" +
"privateKey\x12\x12\n" + "privateKey\x12\x12\n" +
"\x04seed\x18\x03 \x01(\tR\x04seed\x12\x1d\n" + "\x04seed\x18\x03 \x01(\tR\x04seed\x12\x1d\n" +
"\n" + "\n" +
"chain_code\x18\x04 \x01(\tR\tchainCode\x12,\n" + "chain_code\x18\x04 \x01(\tR\tchainCode\x12,\n" +
"\x12import_private_key\x18\x05 \x01(\tR\x10importPrivateKey\x12*\n" + "\x12import_private_key\x18\x05 \x01(\tR\x10importPrivateKey\x12*\n" +
"\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\x12\x18\n" + "\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\"i\n" +
"\aversion\x18\a \x01(\x04R\aversion\"\x83\x01\n" +
"\x12DeriveChildRequest\x12!\n" + "\x12DeriveChildRequest\x12!\n" +
"\fimported_key\x18\x01 \x01(\tR\vimportedKey\x12\x14\n" + "\fimported_key\x18\x01 \x01(\tR\vimportedKey\x12\x14\n" +
"\x05index\x18\x02 \x01(\x04R\x05index\x12\x1a\n" + "\x05index\x18\x02 \x01(\x04R\x05index\x12\x1a\n" +
"\bhardened\x18\x03 \x01(\bR\bhardened\x12\x18\n" + "\bhardened\x18\x03 \x01(\bR\bhardened\"t\n" +
"\aversion\x18\x04 \x01(\x04R\aversion\"\x89\x01\n" + "\x13DeriveChildResponse\x12\x1d\n" +
"\x13DeriveChildResponse\x12\x18\n" + "\n" +
"\aaddress\x18\x01 \x01(\tR\aaddress\x12\x1f\n" + "public_key\x18\x01 \x01(\tR\tpublicKey\x12\x1f\n" +
"\vprivate_key\x18\x02 \x01(\tR\n" + "\vprivate_key\x18\x02 \x01(\tR\n" +
"privateKey\x12\x1d\n" + "privateKey\x12\x1d\n" +
"\n" + "\n" +
"chain_code\x18\x03 \x01(\tR\tchainCode\x12\x18\n" + "chain_code\x18\x03 \x01(\tR\tchainCode\"\xc4\x02\n" +
"\aversion\x18\x04 \x01(\x04R\aversion\"\x84\x02\n" +
"\x0fCreateTxRequest\x12\x14\n" + "\x0fCreateTxRequest\x12\x14\n" +
"\x05names\x18\x01 \x01(\tR\x05names\x12\x1e\n" + "\x05names\x18\x01 \x01(\tR\x05names\x12\x1e\n" +
"\n" + "\n" +
"recipients\x18\x02 \x01(\tR\n" + "recipients\x18\x02 \x01(\tR\n" +
"recipients\x12\x10\n" + "recipients\x12\x14\n" +
"\x03fee\x18\x03 \x01(\x04R\x03fee\x12\"\n" + "\x05gifts\x18\x03 \x01(\tR\x05gifts\x12\x10\n" +
"\ris_master_key\x18\x04 \x01(\bR\visMasterKey\x12\x12\n" + "\x03fee\x18\x04 \x01(\x04R\x03fee\x12\"\n" +
"\x04seed\x18\x05 \x01(\tR\x04seed\x12\x14\n" + "\ris_master_key\x18\x05 \x01(\bR\visMasterKey\x12\x10\n" +
"\x05index\x18\x06 \x01(\x04R\x05index\x12\x1a\n" + "\x03key\x18\x06 \x01(\tR\x03key\x12\x1d\n" +
"\bhardened\x18\a \x01(\bR\bhardened\x12\x18\n" + "\n" +
"\aversion\x18\b \x01(\x04R\aversion\x12%\n" + "chain_code\x18\a \x01(\tR\tchainCode\x12\x14\n" +
"\x0erefund_address\x18\t \x01(\tR\rrefundAddress\"D\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" +
"\x10CreateTxResponse\x120\n" + "\x10CreateTxResponse\x120\n" +
"\x05rawTx\x18\x01 \x01(\v2\x1a.nockchain.public.v2.RawTxR\x05rawTx\"\xe6\x01\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" +
"\vScanRequest\x12#\n" + "\vScanRequest\x12#\n" +
"\rmaster_pubkey\x18\x01 \x01(\tR\fmasterPubkey\x12\x1d\n" + "\rmaster_pubkey\x18\x01 \x01(\tR\fmasterPubkey\x12\x1d\n" +
"\n" + "\n" +
"chain_code\x18\x02 \x01(\tR\tchainCode\x12!\n" + "chain_code\x18\x02 \x01(\tR\tchainCode\x12!\n" +
"\fsearch_depth\x18\x03 \x01(\x04R\vsearchDepth\x12+\n" + "\fsearch_depth\x18\x03 \x01(\x04R\vsearchDepth\x12+\n" +
"\x11include_timelocks\x18\x04 \x01(\bR\x10includeTimelocks\x12)\n" + "\x11include_timelocks\x18\x04 \x01(\bR\x10includeTimelocks\x12)\n" +
"\x10include_multisig\x18\x05 \x01(\bR\x0fincludeMultisig\x12\x18\n" + "\x10include_multisig\x18\x05 \x01(\bR\x0fincludeMultisig\"J\n" +
"\aversion\x18\x06 \x01(\x04R\aversion\"J\n" +
"\fScanResponse\x12:\n" + "\fScanResponse\x12:\n" +
"\tscan_data\x18\x01 \x03(\v2\x1d.nockchain.public.v2.ScanDataR\bscanData\"\\\n" + "\tscan_data\x18\x01 \x03(\v2\x1d.nockchain.public.v1.ScanDataR\bscanData\"-\n" +
"\x11GetBalanceRequest\x12\x1a\n" + "\x11GetBalanceRequest\x12\x18\n" +
"\aaddress\x18\x01 \x01(\tH\x00R\aaddress\x12\x1f\n" + "\aaddress\x18\x01 \x01(\tR\aaddress\"P\n" +
"\n" + "\x12GetBalanceResponse\x12:\n" +
"first_name\x18\x02 \x01(\tH\x00R\tfirstNameB\n" + "\x04data\x18\x01 \x01(\v2&.nockchain.public.v1.WalletBalanceDataR\x04data\"K\n" +
"\n" +
"\bselector\"F\n" +
"\x12GetBalanceResponse\x120\n" +
"\x04data\x18\x01 \x01(\v2\x1c.nockchain.public.v2.BalanceR\x04data\"K\n" +
"\x16SendTransactionRequest\x121\n" + "\x16SendTransactionRequest\x121\n" +
"\x06raw_tx\x18\x01 \x01(\v2\x1a.nockchain.public.v2.RawTxR\x05rawTx\"i\n" + "\x06raw_tx\x18\x01 \x01(\v2\x1a.nockchain.public.v1.RawTxR\x05rawTx\"i\n" +
"\x17SendTransactionResponse\x12N\n" + "\x17SendTransactionResponse\x12N\n" +
"\bresponse\x18\x01 \x01(\v22.nockchain.public.v2.WalletSendTransactionResponseR\bresponse2\x9c\x06\n" + "\bresponse\x18\x01 \x01(\v22.nockchain.public.v1.WalletSendTransactionResponseR\bresponse2\xef\x06\n" +
"\rWalletService\x12Q\n" + "\rWalletService\x12Q\n" +
"\x06Keygen\x12\".nockchain.public.v2.KeygenRequest\x1a#.nockchain.public.v2.KeygenResponse\x12]\n" + "\x06Keygen\x12\".nockchain.public.v1.KeygenRequest\x1a#.nockchain.public.v1.KeygenResponse\x12]\n" +
"\n" + "\n" +
"ImportKeys\x12&.nockchain.public.v2.ImportKeysRequest\x1a'.nockchain.public.v2.ImportKeysResponse\x12`\n" + "ImportKeys\x12&.nockchain.public.v1.ImportKeysRequest\x1a'.nockchain.public.v1.ImportKeysResponse\x12`\n" +
"\vDeriveChild\x12'.nockchain.public.v2.DeriveChildRequest\x1a(.nockchain.public.v2.DeriveChildResponse\x12W\n" + "\vDeriveChild\x12'.nockchain.public.v1.DeriveChildRequest\x1a(.nockchain.public.v1.DeriveChildResponse\x12W\n" +
"\bCreateTx\x12$.nockchain.public.v2.CreateTxRequest\x1a%.nockchain.public.v2.CreateTxResponse\x12K\n" + "\bCreateTx\x12$.nockchain.public.v1.CreateTxRequest\x1a%.nockchain.public.v1.CreateTxResponse\x12Q\n" +
"\x04Scan\x12 .nockchain.public.v2.ScanRequest\x1a!.nockchain.public.v2.ScanResponse\x12c\n" + "\x06SignTx\x12\".nockchain.public.v1.SignTxRequest\x1a#.nockchain.public.v1.SignTxResponse\x12K\n" +
"\x10WalletGetBalance\x12&.nockchain.public.v2.GetBalanceRequest\x1a'.nockchain.public.v2.GetBalanceResponse\x12r\n" + "\x04Scan\x12 .nockchain.public.v1.ScanRequest\x1a!.nockchain.public.v1.ScanResponse\x12c\n" +
"\x15WalletSendTransaction\x12+.nockchain.public.v2.SendTransactionRequest\x1a,.nockchain.public.v2.SendTransactionResponse\x12x\n" + "\x10WalletGetBalance\x12&.nockchain.public.v1.GetBalanceRequest\x1a'.nockchain.public.v1.GetBalanceResponse\x12r\n" +
"\x13TransactionAccepted\x12/.nockchain.public.v2.TransactionAcceptedRequest\x1a0.nockchain.public.v2.TransactionAcceptedResponseB\x0eZ\f./;nockchainb\x06proto3" "\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"
var ( var (
file_service_proto_rawDescOnce sync.Once file_service_proto_rawDescOnce sync.Once
@ -1042,58 +1072,64 @@ func file_service_proto_rawDescGZIP() []byte {
return file_service_proto_rawDescData return file_service_proto_rawDescData
} }
var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 16)
var file_service_proto_goTypes = []any{ var file_service_proto_goTypes = []any{
(*KeygenRequest)(nil), // 0: nockchain.public.v2.KeygenRequest (*KeygenRequest)(nil), // 0: nockchain.public.v1.KeygenRequest
(*KeygenResponse)(nil), // 1: nockchain.public.v2.KeygenResponse (*KeygenResponse)(nil), // 1: nockchain.public.v1.KeygenResponse
(*ImportKeysRequest)(nil), // 2: nockchain.public.v2.ImportKeysRequest (*ImportKeysRequest)(nil), // 2: nockchain.public.v1.ImportKeysRequest
(*ImportKeysResponse)(nil), // 3: nockchain.public.v2.ImportKeysResponse (*ImportKeysResponse)(nil), // 3: nockchain.public.v1.ImportKeysResponse
(*DeriveChildRequest)(nil), // 4: nockchain.public.v2.DeriveChildRequest (*DeriveChildRequest)(nil), // 4: nockchain.public.v1.DeriveChildRequest
(*DeriveChildResponse)(nil), // 5: nockchain.public.v2.DeriveChildResponse (*DeriveChildResponse)(nil), // 5: nockchain.public.v1.DeriveChildResponse
(*CreateTxRequest)(nil), // 6: nockchain.public.v2.CreateTxRequest (*CreateTxRequest)(nil), // 6: nockchain.public.v1.CreateTxRequest
(*CreateTxResponse)(nil), // 7: nockchain.public.v2.CreateTxResponse (*CreateTxResponse)(nil), // 7: nockchain.public.v1.CreateTxResponse
(*ScanRequest)(nil), // 8: nockchain.public.v2.ScanRequest (*SignTxRequest)(nil), // 8: nockchain.public.v1.SignTxRequest
(*ScanResponse)(nil), // 9: nockchain.public.v2.ScanResponse (*SignTxResponse)(nil), // 9: nockchain.public.v1.SignTxResponse
(*GetBalanceRequest)(nil), // 10: nockchain.public.v2.GetBalanceRequest (*ScanRequest)(nil), // 10: nockchain.public.v1.ScanRequest
(*GetBalanceResponse)(nil), // 11: nockchain.public.v2.GetBalanceResponse (*ScanResponse)(nil), // 11: nockchain.public.v1.ScanResponse
(*SendTransactionRequest)(nil), // 12: nockchain.public.v2.SendTransactionRequest (*GetBalanceRequest)(nil), // 12: nockchain.public.v1.GetBalanceRequest
(*SendTransactionResponse)(nil), // 13: nockchain.public.v2.SendTransactionResponse (*GetBalanceResponse)(nil), // 13: nockchain.public.v1.GetBalanceResponse
(ImportType)(0), // 14: nockchain.public.v2.ImportType (*SendTransactionRequest)(nil), // 14: nockchain.public.v1.SendTransactionRequest
(*RawTx)(nil), // 15: nockchain.public.v2.RawTx (*SendTransactionResponse)(nil), // 15: nockchain.public.v1.SendTransactionResponse
(*ScanData)(nil), // 16: nockchain.public.v2.ScanData (ImportType)(0), // 16: nockchain.public.v1.ImportType
(*Balance)(nil), // 17: nockchain.public.v2.Balance (*TimelockIntent)(nil), // 17: nockchain.public.v1.TimelockIntent
(*WalletSendTransactionResponse)(nil), // 18: nockchain.public.v2.WalletSendTransactionResponse (*RawTx)(nil), // 18: nockchain.public.v1.RawTx
(*TransactionAcceptedRequest)(nil), // 19: nockchain.public.v2.TransactionAcceptedRequest (*ScanData)(nil), // 19: nockchain.public.v1.ScanData
(*TransactionAcceptedResponse)(nil), // 20: nockchain.public.v2.TransactionAcceptedResponse (*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
} }
var file_service_proto_depIdxs = []int32{ var file_service_proto_depIdxs = []int32{
14, // 0: nockchain.public.v2.ImportKeysRequest.import_type:type_name -> nockchain.public.v2.ImportType 16, // 0: nockchain.public.v1.ImportKeysRequest.import_type:type_name -> nockchain.public.v1.ImportType
15, // 1: nockchain.public.v2.CreateTxResponse.rawTx:type_name -> nockchain.public.v2.RawTx 17, // 1: nockchain.public.v1.CreateTxRequest.timelock_intent:type_name -> nockchain.public.v1.TimelockIntent
16, // 2: nockchain.public.v2.ScanResponse.scan_data:type_name -> nockchain.public.v2.ScanData 18, // 2: nockchain.public.v1.CreateTxResponse.rawTx:type_name -> nockchain.public.v1.RawTx
17, // 3: nockchain.public.v2.GetBalanceResponse.data:type_name -> nockchain.public.v2.Balance 19, // 3: nockchain.public.v1.ScanResponse.scan_data:type_name -> nockchain.public.v1.ScanData
15, // 4: nockchain.public.v2.SendTransactionRequest.raw_tx:type_name -> nockchain.public.v2.RawTx 20, // 4: nockchain.public.v1.GetBalanceResponse.data:type_name -> nockchain.public.v1.WalletBalanceData
18, // 5: nockchain.public.v2.SendTransactionResponse.response:type_name -> nockchain.public.v2.WalletSendTransactionResponse 18, // 5: nockchain.public.v1.SendTransactionRequest.raw_tx:type_name -> nockchain.public.v1.RawTx
0, // 6: nockchain.public.v2.WalletService.Keygen:input_type -> nockchain.public.v2.KeygenRequest 21, // 6: nockchain.public.v1.SendTransactionResponse.response:type_name -> nockchain.public.v1.WalletSendTransactionResponse
2, // 7: nockchain.public.v2.WalletService.ImportKeys:input_type -> nockchain.public.v2.ImportKeysRequest 0, // 7: nockchain.public.v1.WalletService.Keygen:input_type -> nockchain.public.v1.KeygenRequest
4, // 8: nockchain.public.v2.WalletService.DeriveChild:input_type -> nockchain.public.v2.DeriveChildRequest 2, // 8: nockchain.public.v1.WalletService.ImportKeys:input_type -> nockchain.public.v1.ImportKeysRequest
6, // 9: nockchain.public.v2.WalletService.CreateTx:input_type -> nockchain.public.v2.CreateTxRequest 4, // 9: nockchain.public.v1.WalletService.DeriveChild:input_type -> nockchain.public.v1.DeriveChildRequest
8, // 10: nockchain.public.v2.WalletService.Scan:input_type -> nockchain.public.v2.ScanRequest 6, // 10: nockchain.public.v1.WalletService.CreateTx:input_type -> nockchain.public.v1.CreateTxRequest
10, // 11: nockchain.public.v2.WalletService.WalletGetBalance:input_type -> nockchain.public.v2.GetBalanceRequest 8, // 11: nockchain.public.v1.WalletService.SignTx:input_type -> nockchain.public.v1.SignTxRequest
12, // 12: nockchain.public.v2.WalletService.WalletSendTransaction:input_type -> nockchain.public.v2.SendTransactionRequest 10, // 12: nockchain.public.v1.WalletService.Scan:input_type -> nockchain.public.v1.ScanRequest
19, // 13: nockchain.public.v2.WalletService.TransactionAccepted:input_type -> nockchain.public.v2.TransactionAcceptedRequest 12, // 13: nockchain.public.v1.WalletService.WalletGetBalance:input_type -> nockchain.public.v1.GetBalanceRequest
1, // 14: nockchain.public.v2.WalletService.Keygen:output_type -> nockchain.public.v2.KeygenResponse 14, // 14: nockchain.public.v1.WalletService.WalletSendTransaction:input_type -> nockchain.public.v1.SendTransactionRequest
3, // 15: nockchain.public.v2.WalletService.ImportKeys:output_type -> nockchain.public.v2.ImportKeysResponse 22, // 15: nockchain.public.v1.WalletService.TransactionAccepted:input_type -> nockchain.public.v1.TransactionAcceptedRequest
5, // 16: nockchain.public.v2.WalletService.DeriveChild:output_type -> nockchain.public.v2.DeriveChildResponse 1, // 16: nockchain.public.v1.WalletService.Keygen:output_type -> nockchain.public.v1.KeygenResponse
7, // 17: nockchain.public.v2.WalletService.CreateTx:output_type -> nockchain.public.v2.CreateTxResponse 3, // 17: nockchain.public.v1.WalletService.ImportKeys:output_type -> nockchain.public.v1.ImportKeysResponse
9, // 18: nockchain.public.v2.WalletService.Scan:output_type -> nockchain.public.v2.ScanResponse 5, // 18: nockchain.public.v1.WalletService.DeriveChild:output_type -> nockchain.public.v1.DeriveChildResponse
11, // 19: nockchain.public.v2.WalletService.WalletGetBalance:output_type -> nockchain.public.v2.GetBalanceResponse 7, // 19: nockchain.public.v1.WalletService.CreateTx:output_type -> nockchain.public.v1.CreateTxResponse
13, // 20: nockchain.public.v2.WalletService.WalletSendTransaction:output_type -> nockchain.public.v2.SendTransactionResponse 9, // 20: nockchain.public.v1.WalletService.SignTx:output_type -> nockchain.public.v1.SignTxResponse
20, // 21: nockchain.public.v2.WalletService.TransactionAccepted:output_type -> nockchain.public.v2.TransactionAcceptedResponse 11, // 21: nockchain.public.v1.WalletService.Scan:output_type -> nockchain.public.v1.ScanResponse
14, // [14:22] is the sub-list for method output_type 13, // 22: nockchain.public.v1.WalletService.WalletGetBalance:output_type -> nockchain.public.v1.GetBalanceResponse
6, // [6:14] is the sub-list for method input_type 15, // 23: nockchain.public.v1.WalletService.WalletSendTransaction:output_type -> nockchain.public.v1.SendTransactionResponse
6, // [6:6] is the sub-list for extension type_name 23, // 24: nockchain.public.v1.WalletService.TransactionAccepted:output_type -> nockchain.public.v1.TransactionAcceptedResponse
6, // [6:6] is the sub-list for extension extendee 16, // [16:25] is the sub-list for method output_type
0, // [0:6] is the sub-list for field type_name 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
} }
func init() { file_service_proto_init() } func init() { file_service_proto_init() }
@ -1104,17 +1140,13 @@ func file_service_proto_init() {
file_types_proto_init() file_types_proto_init()
file_blockchain_proto_init() file_blockchain_proto_init()
file_nockchain_proto_init() file_nockchain_proto_init()
file_service_proto_msgTypes[10].OneofWrappers = []any{
(*GetBalanceRequest_Address)(nil),
(*GetBalanceRequest_FirstName)(nil),
}
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_service_proto_rawDesc), len(file_service_proto_rawDesc)), RawDescriptor: unsafe.Slice(unsafe.StringData(file_service_proto_rawDesc), len(file_service_proto_rawDesc)),
NumEnums: 0, NumEnums: 0,
NumMessages: 14, NumMessages: 16,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@ -19,14 +19,15 @@ import (
const _ = grpc.SupportPackageIsVersion9 const _ = grpc.SupportPackageIsVersion9
const ( const (
WalletService_Keygen_FullMethodName = "/nockchain.public.v2.WalletService/Keygen" WalletService_Keygen_FullMethodName = "/nockchain.public.v1.WalletService/Keygen"
WalletService_ImportKeys_FullMethodName = "/nockchain.public.v2.WalletService/ImportKeys" WalletService_ImportKeys_FullMethodName = "/nockchain.public.v1.WalletService/ImportKeys"
WalletService_DeriveChild_FullMethodName = "/nockchain.public.v2.WalletService/DeriveChild" WalletService_DeriveChild_FullMethodName = "/nockchain.public.v1.WalletService/DeriveChild"
WalletService_CreateTx_FullMethodName = "/nockchain.public.v2.WalletService/CreateTx" WalletService_CreateTx_FullMethodName = "/nockchain.public.v1.WalletService/CreateTx"
WalletService_Scan_FullMethodName = "/nockchain.public.v2.WalletService/Scan" WalletService_SignTx_FullMethodName = "/nockchain.public.v1.WalletService/SignTx"
WalletService_WalletGetBalance_FullMethodName = "/nockchain.public.v2.WalletService/WalletGetBalance" WalletService_Scan_FullMethodName = "/nockchain.public.v1.WalletService/Scan"
WalletService_WalletSendTransaction_FullMethodName = "/nockchain.public.v2.WalletService/WalletSendTransaction" WalletService_WalletGetBalance_FullMethodName = "/nockchain.public.v1.WalletService/WalletGetBalance"
WalletService_TransactionAccepted_FullMethodName = "/nockchain.public.v2.WalletService/TransactionAccepted" WalletService_WalletSendTransaction_FullMethodName = "/nockchain.public.v1.WalletService/WalletSendTransaction"
WalletService_TransactionAccepted_FullMethodName = "/nockchain.public.v1.WalletService/TransactionAccepted"
) )
// WalletServiceClient is the client API for WalletService service. // WalletServiceClient is the client API for WalletService service.
@ -37,7 +38,7 @@ type WalletServiceClient interface {
ImportKeys(ctx context.Context, in *ImportKeysRequest, opts ...grpc.CallOption) (*ImportKeysResponse, error) ImportKeys(ctx context.Context, in *ImportKeysRequest, opts ...grpc.CallOption) (*ImportKeysResponse, error)
DeriveChild(ctx context.Context, in *DeriveChildRequest, opts ...grpc.CallOption) (*DeriveChildResponse, error) DeriveChild(ctx context.Context, in *DeriveChildRequest, opts ...grpc.CallOption) (*DeriveChildResponse, error)
CreateTx(ctx context.Context, in *CreateTxRequest, opts ...grpc.CallOption) (*CreateTxResponse, error) CreateTx(ctx context.Context, in *CreateTxRequest, opts ...grpc.CallOption) (*CreateTxResponse, error)
// rpc SignTx(SignTxRequest) returns (SignTxResponse); SignTx(ctx context.Context, in *SignTxRequest, opts ...grpc.CallOption) (*SignTxResponse, error)
Scan(ctx context.Context, in *ScanRequest, opts ...grpc.CallOption) (*ScanResponse, error) Scan(ctx context.Context, in *ScanRequest, opts ...grpc.CallOption) (*ScanResponse, error)
WalletGetBalance(ctx context.Context, in *GetBalanceRequest, opts ...grpc.CallOption) (*GetBalanceResponse, error) WalletGetBalance(ctx context.Context, in *GetBalanceRequest, opts ...grpc.CallOption) (*GetBalanceResponse, error)
WalletSendTransaction(ctx context.Context, in *SendTransactionRequest, opts ...grpc.CallOption) (*SendTransactionResponse, error) WalletSendTransaction(ctx context.Context, in *SendTransactionRequest, opts ...grpc.CallOption) (*SendTransactionResponse, error)
@ -92,6 +93,16 @@ func (c *walletServiceClient) CreateTx(ctx context.Context, in *CreateTxRequest,
return out, nil 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) { func (c *walletServiceClient) Scan(ctx context.Context, in *ScanRequest, opts ...grpc.CallOption) (*ScanResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ScanResponse) out := new(ScanResponse)
@ -140,7 +151,7 @@ type WalletServiceServer interface {
ImportKeys(context.Context, *ImportKeysRequest) (*ImportKeysResponse, error) ImportKeys(context.Context, *ImportKeysRequest) (*ImportKeysResponse, error)
DeriveChild(context.Context, *DeriveChildRequest) (*DeriveChildResponse, error) DeriveChild(context.Context, *DeriveChildRequest) (*DeriveChildResponse, error)
CreateTx(context.Context, *CreateTxRequest) (*CreateTxResponse, error) CreateTx(context.Context, *CreateTxRequest) (*CreateTxResponse, error)
// rpc SignTx(SignTxRequest) returns (SignTxResponse); SignTx(context.Context, *SignTxRequest) (*SignTxResponse, error)
Scan(context.Context, *ScanRequest) (*ScanResponse, error) Scan(context.Context, *ScanRequest) (*ScanResponse, error)
WalletGetBalance(context.Context, *GetBalanceRequest) (*GetBalanceResponse, error) WalletGetBalance(context.Context, *GetBalanceRequest) (*GetBalanceResponse, error)
WalletSendTransaction(context.Context, *SendTransactionRequest) (*SendTransactionResponse, error) WalletSendTransaction(context.Context, *SendTransactionRequest) (*SendTransactionResponse, error)
@ -167,6 +178,9 @@ func (UnimplementedWalletServiceServer) DeriveChild(context.Context, *DeriveChil
func (UnimplementedWalletServiceServer) CreateTx(context.Context, *CreateTxRequest) (*CreateTxResponse, error) { func (UnimplementedWalletServiceServer) CreateTx(context.Context, *CreateTxRequest) (*CreateTxResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateTx not implemented") 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) { func (UnimplementedWalletServiceServer) Scan(context.Context, *ScanRequest) (*ScanResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Scan not implemented") return nil, status.Errorf(codes.Unimplemented, "method Scan not implemented")
} }
@ -272,6 +286,24 @@ func _WalletService_CreateTx_Handler(srv interface{}, ctx context.Context, dec f
return interceptor(ctx, in, info, handler) 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) { func _WalletService_Scan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ScanRequest) in := new(ScanRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
@ -348,7 +380,7 @@ func _WalletService_TransactionAccepted_Handler(srv interface{}, ctx context.Con
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
var WalletService_ServiceDesc = grpc.ServiceDesc{ var WalletService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "nockchain.public.v2.WalletService", ServiceName: "nockchain.public.v1.WalletService",
HandlerType: (*WalletServiceServer)(nil), HandlerType: (*WalletServiceServer)(nil),
Methods: []grpc.MethodDesc{ Methods: []grpc.MethodDesc{
{ {
@ -367,6 +399,10 @@ var WalletService_ServiceDesc = grpc.ServiceDesc{
MethodName: "CreateTx", MethodName: "CreateTx",
Handler: _WalletService_CreateTx_Handler, Handler: _WalletService_CreateTx_Handler,
}, },
{
MethodName: "SignTx",
Handler: _WalletService_SignTx_Handler,
},
{ {
MethodName: "Scan", MethodName: "Scan",
Handler: _WalletService_Scan_Handler, Handler: _WalletService_Scan_Handler,

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,24 @@
// nockchain/common/v2/blockchain.proto // nockchain/common/v1/blockchain.proto
syntax = "proto3"; syntax = "proto3";
package nockchain.public.v2; package nockchain.public.v1;
import "primitives.proto"; import "primitives.proto";
import "pagination.proto"; import "pagination.proto";
option go_package = "./;nockchain"; 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
message Balance { // Snapshot metadata where this page was computed. Clients should include
repeated BalanceEntry notes = 1; // the returned page token to continue paging against the same snapshot.
BlockHeight height = 2; BlockHeight height = 2; // block height where balance was computed
optional Hash block_id = 3; 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.
PageResponse page = 4; PageResponse page = 4;
} }
@ -20,107 +27,39 @@ message BalanceEntry {
Note note = 2; Note note = 2;
} }
// the string key is the name of the input
// message RawTransaction { map<Name, Input> inputs = 1; }
message RawTransaction { message RawTransaction {
NoteVersion version = 1; repeated NamedInput named_inputs = 1;
Hash id = 2; TimeLockRangeAbsolute timelock_range = 2;
repeated SpendEntry spends = 3; Nicks total_fees = 3;
Hash id = 4;
} }
message SpendEntry {
message NamedInput {
Name name = 1; Name name = 1;
Input input = 2;
}
message Input {
Note note = 1;
Spend spend = 2; Spend spend = 2;
} }
message Spend { message Spend {
oneof spend_kind {
LegacySpend legacy = 1;
WitnessSpend witness = 2;
}
}
message LegacySpend {
Signature signature = 1; Signature signature = 1;
repeated Seed seeds = 2; repeated Seed seeds = 2;
Nicks miner_fee_nicks = 3; Nicks miner_fee_nicks = 3;
} }
message WitnessSpend {
Witness witness = 1;
repeated Seed seeds = 2;
Nicks fee = 3;
}
message Seed { message Seed {
// Absent when the seed originates from a coinbase output. optional OutputSource output_source = 1;
Source output_source = 1; Lock recipient = 2;
Hash lock_root = 2; optional TimeLockIntent timelock_intent = 3;
NoteData note_data = 3;
Nicks gift = 4; Nicks gift = 4;
Hash parent_hash = 5; 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 OutputSource { optional Source source = 1; }
message Source { message Source {
@ -171,14 +110,7 @@ message Name {
Hash last = 2; Hash last = 2;
} }
message Note { message Note {
oneof note_version {
NoteV0 legacy = 1;
NoteV1 v1 = 2;
}
}
message NoteV0 {
BlockHeight origin_page = 1; // page-number when added to balance BlockHeight origin_page = 1; // page-number when added to balance
optional TimeLockIntent timelock = 2; // enforced timelock optional TimeLockIntent timelock = 2; // enforced timelock
Name name = 3; // nname (human/name label) Name name = 3; // nname (human/name label)
@ -188,27 +120,11 @@ message NoteV0 {
NoteVersion version = 7; // note version (currently 0) 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 Signature { repeated SignatureEntry entries = 1; }
message SignatureEntry { 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; SchnorrSignature signature = 2;
} }

View File

@ -1,75 +0,0 @@
// 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;
}
}

View File

@ -2,7 +2,7 @@
syntax = "proto3"; syntax = "proto3";
package nockchain.public.v2; package nockchain.public.v1;
import "blockchain.proto"; import "blockchain.proto";
import "primitives.proto"; import "primitives.proto";
@ -21,15 +21,12 @@ service NockchainService {
message WalletGetBalanceRequest { message WalletGetBalanceRequest {
// pubkey cheetah point; specific address, or current wallet // pubkey cheetah point; specific address, or current wallet
oneof selector { string address = 1;
Base58Pubkey address = 1;
Base58Hash first_name = 2;
}
// Pagination parameters. The server enforces limits and may return fewer // Pagination parameters. The server enforces limits and may return fewer
// entries than requested to respect message size and policy. For consistent // entries than requested to respect message size and policy. For consistent
// paging across a stable snapshot, pass along the returned page_token from // paging across a stable snapshot, pass along the returned page_token from
// the previous response without modification. // the previous response without modification.
PageRequest page = 3; PageRequest page = 2;
} }
message WalletGetBalanceResponse { message WalletGetBalanceResponse {
@ -38,7 +35,7 @@ message WalletGetBalanceResponse {
// Continue paging using `balance.page.next_page_token` until empty. Clients // Continue paging using `balance.page.next_page_token` until empty. Clients
// should treat the page token as opaque; it may encode snapshot identity // should treat the page token as opaque; it may encode snapshot identity
// and the last returned key. // and the last returned key.
Balance balance = 1; WalletBalanceData balance = 1;
ErrorStatus error = 2; ErrorStatus error = 2;
} }
} }

View File

@ -2,7 +2,7 @@
syntax = "proto3"; syntax = "proto3";
package nockchain.public.v2; package nockchain.public.v1;
option go_package = "./;nockchain"; option go_package = "./;nockchain";
// Generic pagination parameters for list-style RPCs. // Generic pagination parameters for list-style RPCs.

View File

@ -2,7 +2,7 @@
syntax = "proto3"; syntax = "proto3";
package nockchain.public.v2; package nockchain.public.v1;
option go_package = "./;nockchain"; option go_package = "./;nockchain";
message ErrorStatus { message ErrorStatus {
@ -28,6 +28,23 @@ enum ErrorCode {
ERROR_CODE_KERNEL_ERROR = 11; 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 // Note: prefer using raw numeric fields in messages
// instead of these wrappers to simplify conversions. // instead of these wrappers to simplify conversions.
// These remain defined for potential future use. // These remain defined for potential future use.
@ -63,10 +80,6 @@ message Base58Hash {
string hash = 1; string hash = 1;
} }
message Base58Pubkey {
string key = 1;
}
// pub struct SchnorrPubkey(pub CheetahPoint); // pub struct SchnorrPubkey(pub CheetahPoint);
message SchnorrPubkey { CheetahPoint value = 1; } message SchnorrPubkey { CheetahPoint value = 1; }

View File

@ -1,5 +1,5 @@
syntax = "proto3"; syntax = "proto3";
package nockchain.public.v2; package nockchain.public.v1;
option go_package = "./;nockchain"; option go_package = "./;nockchain";
@ -11,7 +11,7 @@ service WalletService {
rpc ImportKeys(ImportKeysRequest) returns (ImportKeysResponse); rpc ImportKeys(ImportKeysRequest) returns (ImportKeysResponse);
rpc DeriveChild(DeriveChildRequest) returns (DeriveChildResponse); rpc DeriveChild(DeriveChildRequest) returns (DeriveChildResponse);
rpc CreateTx(CreateTxRequest) returns (CreateTxResponse); rpc CreateTx(CreateTxRequest) returns (CreateTxResponse);
// rpc SignTx(SignTxRequest) returns (SignTxResponse); rpc SignTx(SignTxRequest) returns (SignTxResponse);
rpc Scan(ScanRequest) returns (ScanResponse); rpc Scan(ScanRequest) returns (ScanResponse);
rpc WalletGetBalance(GetBalanceRequest) rpc WalletGetBalance(GetBalanceRequest)
returns (GetBalanceResponse); returns (GetBalanceResponse);
@ -21,76 +21,70 @@ service WalletService {
returns (TransactionAcceptedResponse); returns (TransactionAcceptedResponse);
} }
message KeygenRequest { message KeygenRequest {}
uint64 version = 1;
}
message KeygenResponse { message KeygenResponse {
string address = 1; string public_key = 1;
string private_key = 2; string private_key = 2;
string seed = 3; string seed = 3;
string chain_code = 4; string chain_code = 4;
string import_private_key = 5; string import_private_key = 5;
string import_public_key = 6; string import_public_key = 6;
uint64 version = 7;
} }
message ImportKeysRequest { message ImportKeysRequest {
string key = 1; string key = 1;
uint64 version = 2; ImportType import_type = 2;
ImportType import_type = 3;
} }
message ImportKeysResponse { message ImportKeysResponse {
string address = 1; string public_key = 1;
string private_key = 2; string private_key = 2;
string seed = 3; string seed = 3;
string chain_code = 4; string chain_code = 4;
string import_private_key = 5; string import_private_key = 5;
string import_public_key = 6; string import_public_key = 6;
uint64 version = 7;
} }
message DeriveChildRequest { message DeriveChildRequest {
string imported_key = 1; string imported_key = 1;
uint64 index = 2; uint64 index = 2;
bool hardened = 3; bool hardened = 3;
uint64 version = 4;
} }
message DeriveChildResponse { message DeriveChildResponse {
string address = 1; string public_key = 1;
string private_key = 2; string private_key = 2;
string chain_code = 3; string chain_code = 3;
uint64 version = 4;
} }
message CreateTxRequest { message CreateTxRequest {
string names = 1; string names = 1;
string recipients = 2; string recipients = 2;
uint64 fee = 3; string gifts = 3;
bool is_master_key = 4; uint64 fee = 4;
string seed = 5; bool is_master_key = 5;
uint64 index = 6; string key = 6;
bool hardened = 7; string chain_code = 7;
uint64 version = 8; uint64 index = 8;
string refund_address = 9; bool hardened = 9;
TimelockIntent timelock_intent = 10;
} }
message CreateTxResponse { message CreateTxResponse {
RawTx rawTx = 1; RawTx rawTx = 1;
} }
// message SignTxRequest { message SignTxRequest {
// string unsigned_tx = 1; string unsigned_tx = 1;
// uint64 index = 2; uint64 index = 2;
// bool hardened = 3; bool hardened = 3;
// } }
// message SignTxResponse { message SignTxResponse {
// string signed_tx = 1; string signed_tx = 1;
// string error = 2; string error = 2;
// } }
message ScanRequest { message ScanRequest {
string master_pubkey = 1; string master_pubkey = 1;
@ -98,7 +92,6 @@ message ScanRequest {
uint64 search_depth = 3; uint64 search_depth = 3;
bool include_timelocks = 4; bool include_timelocks = 4;
bool include_multisig = 5; bool include_multisig = 5;
uint64 version = 6;
} }
message ScanResponse { message ScanResponse {
@ -106,14 +99,11 @@ message ScanResponse {
} }
message GetBalanceRequest { message GetBalanceRequest {
oneof selector {
string address = 1; string address = 1;
string first_name = 2;
}
} }
message GetBalanceResponse { message GetBalanceResponse {
Balance data = 1; WalletBalanceData data = 1;
} }
message SendTransactionRequest { message SendTransactionRequest {

View File

@ -1,12 +1,12 @@
syntax = "proto3"; syntax = "proto3";
package nockchain.public.v2; package nockchain.public.v1;
option go_package = "./;nockchain"; option go_package = "./;nockchain";
import "blockchain.proto"; import "blockchain.proto";
message ScanData { message ScanData {
string pubkey = 1; string pubkey = 1;
Balance data = 2; WalletBalanceData data = 2;
} }
enum ImportType { enum ImportType {
UNDEFINED = 0; UNDEFINED = 0;
@ -32,51 +32,24 @@ message Timelock {
message RawTx { message RawTx {
string tx_id = 1; string tx_id = 1;
Version version = 2; repeated NockchainInput inputs = 2;
repeated NockchainNamedSpend named_spends = 3; TimelockRange timelock_range = 3;
uint64 total_fees = 4;
} }
message NockchainNamedSpend { message NockchainSpend {
NockchainName name = 1;
oneof spend_kind {
NockchainSpendV0 legacy = 2;
NockchainSpendV1 witness = 3;
}
}
message NockchainSpendV0 {
repeated NockchainSignature signatures = 1; repeated NockchainSignature signatures = 1;
repeated NockchainSeed seeds = 2; repeated NockchainSeed seeds = 2;
uint64 fee = 3; uint64 fee = 3;
} }
message NockchainSpendV1 {
repeated NockchainWitness witness = 1;
repeated NockchainSeed seeds = 2;
uint64 fee = 3;
}
message NockchainNote { message NockchainNote {
oneof note {
NockchainNoteV0 v0 = 1;
NockchainNoteV1 v1 = 2;
}
}
message NockchainNoteV0 {
Version version = 1; Version version = 1;
uint64 origin_page = 2; uint64 block_height = 2;
NockchainName name = 3; optional TimelockIntent timelock = 3;
NockchainLock lock = 4; NockchainName name = 4;
NockchainSource source = 5; NockchainLock lock = 5;
uint64 asset =6; NockchainSource source = 6;
} uint64 asset =7;
message NockchainNoteV1 {
Version version = 1;
uint64 origin_page = 2;
NockchainName name = 3;
NockchainLock note_data = 4;
uint64 assets = 5;
} }
message NockchainName { message NockchainName {
@ -84,31 +57,25 @@ message NockchainName {
string last = 2; string last = 2;
} }
message NockchainInput {
NockchainName name = 1;
NockchainNote note = 2;
NockchainSpend spend = 3;
}
message NockchainSignature { message NockchainSignature {
string pubkey = 1; string pubkey = 1;
repeated uint64 chal = 2; repeated uint64 chal = 2;
repeated uint64 sig = 3; 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 { message NockchainSeed {
optional NockchainSource output_source = 1; optional NockchainSource output_source = 1;
string lock_root = 2; NockchainLock recipient = 2;
NockchainLock note_data = 3; optional TimelockIntent timelock_intent = 3;
uint64 gift = 4; uint64 gift = 4;
string parent_hash = 5; string parent_hash = 5;
} }
message NockchainLock { message NockchainLock {
uint64 keys_required = 1; uint64 keys_required = 1;
repeated string pubkeys = 2; repeated string pubkeys = 2;

View File

@ -12,7 +12,6 @@ import (
type NockchainClient struct { type NockchainClient struct {
conn *grpc.ClientConn conn *grpc.ClientConn
client nockchain.NockchainServiceClient client nockchain.NockchainServiceClient
appClient nockchain.NockAppServiceClient
} }
// NewNockchainClient creates a new gRPC client connection // NewNockchainClient creates a new gRPC client connection
@ -28,12 +27,10 @@ func NewNockchainClient(address string) (*NockchainClient, error) {
} }
client := nockchain.NewNockchainServiceClient(conn) client := nockchain.NewNockchainServiceClient(conn)
appClient := nockchain.NewNockAppServiceClient(conn)
return &NockchainClient{ return &NockchainClient{
conn: conn, conn: conn,
client: client, client: client,
appClient: appClient,
}, nil }, nil
} }
@ -41,44 +38,26 @@ func (nc *NockchainClient) Close() error {
return nc.conn.Close() return nc.conn.Close()
} }
func (nc *NockchainClient) WalletGetBalance(req *nockchain.GetBalanceRequest) (*nockchain.Balance, error) { func (nc *NockchainClient) WalletGetBalance(address string) (*nockchain.WalletBalanceData, error) {
pageToken := "" pageToken := ""
allNotes := []*nockchain.BalanceEntry{} allNotes := []*nockchain.BalanceEntry{}
var height *nockchain.BlockHeight var height *nockchain.BlockHeight
var blockId *nockchain.Hash var blockId *nockchain.Hash
page := &nockchain.PageRequest{ for {
req := nockchain.WalletGetBalanceRequest{
Address: address,
Page: &nockchain.PageRequest{
ClientPageItemsLimit: 0, ClientPageItemsLimit: 0,
PageToken: pageToken, PageToken: pageToken,
MaxBytes: 0, MaxBytes: 0,
}
for {
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: resp, err := nc.client.WalletGetBalance(context.Background(), &req)
request = &nockchain.WalletGetBalanceRequest{
Selector: &nockchain.WalletGetBalanceRequest_FirstName{
FirstName: &nockchain.Base58Hash{
Hash: req.GetFirstName(),
},
},
Page: page,
}
}
resp, err := nc.client.WalletGetBalance(context.Background(), request)
if err != nil { if err != nil {
return nil, err return nil, err
} }
balance := nockchain.Balance{} balance := nockchain.WalletBalanceData{}
switch resp.Result.(type) { switch resp.Result.(type) {
case *nockchain.WalletGetBalanceResponse_Balance: case *nockchain.WalletGetBalanceResponse_Balance:
balance = *resp.GetBalance() balance = *resp.GetBalance()
@ -102,11 +81,9 @@ func (nc *NockchainClient) WalletGetBalance(req *nockchain.GetBalanceRequest) (*
break break
} else { } else {
pageToken = balance.Page.NextPageToken pageToken = balance.Page.NextPageToken
page.PageToken = pageToken
} }
} }
return &nockchain.WalletBalanceData{
return &nockchain.Balance{
Notes: allNotes, Notes: allNotes,
Height: height, Height: height,
BlockId: blockId, BlockId: blockId,
@ -138,22 +115,24 @@ func (nc *NockchainClient) TxAccepted(txId string) (*nockchain.TransactionAccept
} }
func (nc *NockchainClient) WalletSendTransaction(tx *nockchain.RawTx) (*nockchain.WalletSendTransactionResponse, error) { func (nc *NockchainClient) WalletSendTransaction(tx *nockchain.RawTx) (*nockchain.WalletSendTransactionResponse, error) {
spends := []*nockchain.SpendEntry{} inputs := []*nockchain.NamedInput{}
for _, namedSpend := range tx.NamedSpends { for _, i := range tx.Inputs {
spendEntry, err := ConvertNamedSpend(namedSpend) input, err := ConvertInput(i)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("error converting input: %v", err)
} }
spends = append(spends, spendEntry) inputs = append(inputs, input)
} }
req := nockchain.WalletSendTransactionRequest{ req := nockchain.WalletSendTransactionRequest{
TxId: ParseHash(tx.TxId), TxId: ParseHash(tx.TxId),
RawTx: &nockchain.RawTransaction{ RawTx: &nockchain.RawTransaction{
Id: ParseHash(tx.TxId), Id: ParseHash(tx.TxId),
Version: &nockchain.NoteVersion{ NamedInputs: inputs,
Value: uint32(tx.Version), TotalFees: &nockchain.Nicks{Value: tx.TotalFees},
TimelockRange: &nockchain.TimeLockRangeAbsolute{
Min: (*nockchain.BlockHeight)(tx.TimelockRange.Min),
Max: (*nockchain.BlockHeight)(tx.TimelockRange.Max),
}, },
Spends: spends,
}, },
} }
@ -171,44 +150,3 @@ func (nc *NockchainClient) WalletSendTransaction(tx *nockchain.RawTx) (*nockchai
return nil, fmt.Errorf("invalid result type") 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")
}
}

View File

@ -9,9 +9,7 @@ import (
"github.com/phamminh0811/private-grpc/nockchain" "github.com/phamminh0811/private-grpc/nockchain"
) )
var ( var LastName = [5]uint64{9541855607561054508, 12383849149342406623, 11220017934615522559, 678840671137489369, 8985908938884028381}
MerkleHash = [5]uint64{7971649669803894685, 16663670492333541326, 11038715785817710450, 18178011379925321681, 17049062282971338707}
)
func HashPubkey(pkPoint crypto.CheetahPoint) [5]uint64 { func HashPubkey(pkPoint crypto.CheetahPoint) [5]uint64 {
belts := []crypto.Belt{{Value: 13}} belts := []crypto.Belt{{Value: 13}}
@ -24,7 +22,7 @@ func HashPubkey(pkPoint crypto.CheetahPoint) [5]uint64 {
return crypto.Tip5HashBelts(belts) return crypto.Tip5HashBelts(belts)
} }
func HashSignatureV0(signature *nockchain.NockchainSignature) ([5]uint64, error) { func HashSignature(signature *nockchain.NockchainSignature) ([5]uint64, error) {
belts := []crypto.Belt{{Value: 16}} belts := []crypto.Belt{{Value: 16}}
for _, i := range signature.Chal { for _, i := range signature.Chal {
belts = append(belts, crypto.Belt{Value: i}) belts = append(belts, crypto.Belt{Value: i})
@ -42,73 +40,19 @@ func HashSignatureV0(signature *nockchain.NockchainSignature) ([5]uint64, error)
} }
pkHash := HashPubkey(pkPoint) pkHash := HashPubkey(pkPoint)
sigHash = crypto.Tip5RehashTenCell(pkHash, sigHash) sigHash = crypto.Tip5RehashTenCell(pkHash, sigHash)
return crypto.Tip5RehashTenCell(sigHash, crypto.Tip5ZeroZero), nil sigHash = crypto.Tip5RehashTenCell(sigHash, crypto.Tip5ZeroZero)
return crypto.Tip5RehashTenCell(crypto.Tip5Zero, sigHash), 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 { func HashOwner(pkPoint crypto.CheetahPoint) [5]uint64 {
pkHashedBelts := HashPubkey(pkPoint) pkHashedBelts := HashPubkey(pkPoint)
pkHashedZeroZero := crypto.Tip5RehashTenCell(pkHashedBelts, crypto.Tip5ZeroZero) pkHashedZeroZero := crypto.Tip5RehashTenCell(pkHashedBelts, crypto.Tip5ZeroZero)
return crypto.Tip5RehashTenCell(crypto.Tip5One, pkHashedZeroZero) return crypto.Tip5RehashTenCell(crypto.Tip5One, pkHashedZeroZero)
} }
func NockFirstName(ownerHash [5]uint64) [5]uint64 { func NockName(ownerHash [5]uint64) ([5]uint64, [5]uint64) {
ownerHashZero := crypto.Tip5RehashTenCell(ownerHash, crypto.Tip5Zero) firstName := first(ownerHash)
ownerHashZeroOne := crypto.Tip5RehashTenCell(crypto.Tip5One, ownerHashZero) return firstName, LastName
return crypto.Tip5RehashTenCell(crypto.Tip5Zero, ownerHashZeroOne)
} }
func HashName(name *nockchain.NockchainName) [5]uint64 { func HashName(name *nockchain.NockchainName) [5]uint64 {
@ -135,14 +79,15 @@ func HashNameVarLen(name *nockchain.NockchainName) [5]uint64 {
return res return res
} }
func HashNoteV0(note *nockchain.NockchainNoteV0) ([5]uint64, error) { func HashNote(note *nockchain.NockchainNote) ([5]uint64, error) {
versionHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: uint64(note.Version)}}) versionHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: uint64(note.Version)}})
blockHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: note.OriginPage}}) blockHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: note.BlockHeight}})
hashBlockTimeLock := crypto.Tip5RehashTenCell(blockHash, crypto.Tip5Zero) timelockHash := HashTimelockIntent(note.Timelock)
hashBlockTimeLock := crypto.Tip5RehashTenCell(blockHash, timelockHash)
p := crypto.Tip5RehashTenCell(versionHash, hashBlockTimeLock) p := crypto.Tip5RehashTenCell(versionHash, hashBlockTimeLock)
nameHash := HashName(note.Name) nameHash := HashName(note.Name)
lockHash, err := HashLockV0(note.Lock) lockHash, err := HashLock(note.Lock)
if err != nil { if err != nil {
return [5]uint64{}, err return [5]uint64{}, err
} }
@ -156,19 +101,6 @@ func HashNoteV0(note *nockchain.NockchainNoteV0) ([5]uint64, error) {
return crypto.Tip5RehashTenCell(p, q), nil 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 { func HashTimelockIntent(timelock *nockchain.TimelockIntent) [5]uint64 {
if timelock == nil { if timelock == nil {
return crypto.Tip5Zero return crypto.Tip5Zero
@ -201,8 +133,7 @@ func HashTimelockRange(timelockRange *nockchain.TimelockRange) [5]uint64 {
return hash 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}}) keysRequiredHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: lock.KeysRequired}})
finalPk := base58.Decode(lock.Pubkeys[lock.KeysRequired-1]) finalPk := base58.Decode(lock.Pubkeys[lock.KeysRequired-1])
@ -228,23 +159,6 @@ func HashLockV0(lock *nockchain.NockchainLock) ([5]uint64, error) {
return crypto.Tip5RehashTenCell(keysRequiredHash, finalHash), nil 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 { func HashSource(source *nockchain.NockchainSource) [5]uint64 {
if source == nil { if source == nil {
return crypto.Tip5Zero return crypto.Tip5Zero
@ -253,42 +167,43 @@ func HashSource(source *nockchain.NockchainSource) [5]uint64 {
return crypto.Tip5RehashTenCell(sourceHash, crypto.Tip5One) return crypto.Tip5RehashTenCell(sourceHash, crypto.Tip5One)
} }
func HashSeedWithoutSource(seed *nockchain.NockchainSeed) [5]uint64 { func HashSeedWithoutSource(seed *nockchain.NockchainSeed) ([5]uint64, error) {
lockRoot := crypto.Base58ToTip5Hash(seed.LockRoot) lockHash, err := HashLock(seed.Recipient)
if err != nil {
return [5]uint64{}, nil
}
timelockIntentHash := HashTimelockIntent(seed.TimelockIntent)
assetHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: seed.Gift}}) assetHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: seed.Gift}})
parentHash := crypto.Base58ToTip5Hash(seed.ParentHash) parentHash := crypto.Base58ToTip5Hash(seed.ParentHash)
assetHashparentHash := crypto.Tip5RehashTenCell(assetHash, parentHash) assetHashparentHash := crypto.Tip5RehashTenCell(assetHash, parentHash)
noteDataHash := HashNoteData(seed.NoteData) timelockHashAssetParentHash := crypto.Tip5RehashTenCell(timelockIntentHash, assetHashparentHash)
noteDataHashAssetParentHash := crypto.Tip5RehashTenCell(noteDataHash, assetHashparentHash)
seedHash := crypto.Tip5RehashTenCell(lockRoot, noteDataHashAssetParentHash) seedHash := crypto.Tip5RehashTenCell(lockHash, timelockHashAssetParentHash)
return seedHash return seedHash, nil
} }
func HashSeed(seed *nockchain.NockchainSeed) [5]uint64 { func HashSeed(seed *nockchain.NockchainSeed) ([5]uint64, error) {
seedHash := HashSeedWithoutSource(seed) seedHash, err := HashSeedWithoutSource(seed)
if err != nil {
return [5]uint64{}, nil
}
sourceHash := HashSource(seed.OutputSource) sourceHash := HashSource(seed.OutputSource)
return crypto.Tip5RehashTenCell(sourceHash, seedHash) return crypto.Tip5RehashTenCell(sourceHash, seedHash), nil
} }
func HashSeedVarLen(seed *nockchain.NockchainSeed) [5]uint64 { func HashSeedVarLen(seed *nockchain.NockchainSeed) ([5]uint64, error) {
belts := []crypto.Belt{{Value: 0}} belts := []crypto.Belt{{Value: 0}}
lockRoot := crypto.Base58ToTip5Hash(seed.LockRoot) belts = append(belts, crypto.Belt{Value: seed.Recipient.KeysRequired})
for _, i := range lockRoot { for _, pk := range seed.Recipient.Pubkeys {
belts = append(belts, crypto.Belt{Value: i}) pkPoint, err := crypto.CheetaPointFromBytes(base58.Decode(pk))
if err != nil {
return [5]uint64{}, err
} }
// %lock and %pkh tag belts = append(belts, pkPoint.X[:]...)
belts = append(belts, []crypto.Belt{{Value: 1801678700}, {Value: 0}, {Value: 6843248}}...) belts = append(belts, pkPoint.Y[:]...)
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: 1}, {Value: 0}, {Value: 0}, {Value: 0}, {Value: seed.Gift}}...)
belts = append(belts, []crypto.Belt{{Value: 0}, {Value: 0}, {Value: 0}, {Value: 0}, {Value: 0}, {Value: seed.Gift}}...)
parentHash := crypto.Base58ToTip5Hash(seed.ParentHash) parentHash := crypto.Base58ToTip5Hash(seed.ParentHash)
for _, i := range parentHash { for _, i := range parentHash {
belts = append(belts, crypto.Belt{Value: i}) belts = append(belts, crypto.Belt{Value: i})
@ -298,12 +213,9 @@ func HashSeedVarLen(seed *nockchain.NockchainSeed) [5]uint64 {
for _, i := range crypto.MagicDyckForSeed { for _, i := range crypto.MagicDyckForSeed {
belts = append(belts, crypto.Belt{Value: i}) belts = append(belts, crypto.Belt{Value: i})
} }
return crypto.Tip5HashBelts(belts) return crypto.Tip5HashBelts(belts), nil
} }
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{} belts := []crypto.Belt{}
for _, belt := range pkPoint.X { for _, belt := range pkPoint.X {
belts = append(belts, belt) belts = append(belts, belt)
@ -316,115 +228,110 @@ func HashNonce(pkPoint crypto.CheetahPoint, message [5]uint64, privKey []byte) (
for _, belt := range message { for _, belt := range message {
belts = append(belts, crypto.Belt{Value: belt}) belts = append(belts, crypto.Belt{Value: belt})
} }
resBelts := make([]crypto.Belt, len(belts)) resBelts := make([]crypto.Belt, len(belts))
copy(resBelts, belts) copy(resBelts, belts)
for _, belt := range privKeyT8 {
belts = append(belts, crypto.Belt{Value: belt})
}
return resBelts, crypto.Tip5HashBelts(belts) return resBelts, crypto.Tip5HashBelts(belts)
} }
func HashSpendV0(spend *nockchain.NockchainSpendV0) ([5]uint64, error) { func HashSpend(spend *nockchain.NockchainSpend) ([5]uint64, error) {
// TODO: handle multiple sig // TODO: handle multiple sig
if len(spend.Signatures) == 0 { if len(spend.Signatures) == 0 {
return [5]uint64{}, fmt.Errorf("signatures can not be empty") return [5]uint64{}, fmt.Errorf("signatures can not be empty")
} }
sigHash, err := HashSignatureV0(spend.Signatures[0]) sigHash, err := HashSignature(spend.Signatures[0])
if err != nil { if err != nil {
return [5]uint64{}, err return [5]uint64{}, err
} }
seedHashFee, err := HashSeedsAndFee(spend.Seeds, spend.Fee) 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()
if err != nil { if err != nil {
return [5]uint64{}, err 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 return crypto.Tip5RehashTenCell(sigHash, seedHashFee), nil
} }
func HashSpendV1(spend *nockchain.NockchainSpendV1) ([5]uint64, error) { func HashMsg(spend *nockchain.NockchainSpend) ([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( seedsTree := NewZTree(
func(i interface{}) [5]uint64 { func(i interface{}) [5]uint64 {
if seed, ok := i.(*nockchain.NockchainSeed); ok { if seed, ok := i.(*nockchain.NockchainSeed); ok {
return HashSeedVarLen(seed) seedHash, err := HashSeedVarLen(seed)
if err != nil {
return [5]uint64{}
}
return seedHash
} else { } else {
return [5]uint64{} return [5]uint64{}
} }
}, },
func(i interface{}) ([5]uint64, error) { func(i interface{}) ([5]uint64, error) {
if seed, ok := i.(*nockchain.NockchainSeed); ok { if seed, ok := i.(*nockchain.NockchainSeed); ok {
return HashSeed(seed), nil hash, err := HashSeed(seed)
return hash, err
} else { } else {
return [5]uint64{}, fmt.Errorf("invalid input type") return [5]uint64{}, fmt.Errorf("invalid input type")
} }
}, },
) )
for _, seed := range seeds { for _, seed := range spend.Seeds {
seedsTree.Insert(seed, seed) seedsTree.Insert(seed, seed)
} }
finalSeedHash, err := seedsTree.Hash() finalSeedHash, err := seedsTree.Hash()
if err != nil { if err != nil {
return [5]uint64{}, err return [5]uint64{}, err
} }
feeHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: fee}}) feeHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: spend.Fee}})
return crypto.Tip5RehashTenCell(finalSeedHash, feeHash), nil return crypto.Tip5RehashTenCell(finalSeedHash, feeHash), nil
} }
func HashSeedsAndFee(seeds []*nockchain.NockchainSeed, fee uint64) ([5]uint64, error) { func HashInput(input *nockchain.NockchainInput) ([5]uint64, error) {
seedsTree := NewZTree( nameHash := HashName(input.Name)
func(i interface{}) [5]uint64 {
if seed, ok := i.(*nockchain.NockchainSeed); ok { noteHash, err := HashNote(input.Note)
return HashSeedVarLen(seed)
} else {
return [5]uint64{}
}
},
func(i interface{}) ([5]uint64, error) {
if seed, ok := i.(*nockchain.NockchainSeed); ok {
return HashSeedWithoutSource(seed), nil
} else {
return [5]uint64{}, fmt.Errorf("invalid input type")
}
},
)
for _, seed := range seeds {
seedsTree.Insert(seed, seed)
}
finalSeedHash, err := seedsTree.Hash()
if err != nil { if err != nil {
return [5]uint64{}, err return [5]uint64{}, err
}
feeHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: fee}}) }
return crypto.Tip5RehashTenCell(finalSeedHash, feeHash), nil 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(spends []*nockchain.NockchainNamedSpend, version uint64) ([5]uint64, error) { func ComputeTxId(inputs []*nockchain.NockchainInput, timelockRange *nockchain.TimelockRange, totalFees uint64) ([5]uint64, error) {
var spendHash [5]uint64
var err error inputTree := NewZTree(
switch version {
case 0:
spendTree := NewZTree(
func(i interface{}) [5]uint64 { func(i interface{}) [5]uint64 {
if name, ok := i.(*nockchain.NockchainName); ok { if name, ok := i.(*nockchain.NockchainName); ok {
return HashNameVarLen(name) return HashNameVarLen(name)
@ -433,62 +340,28 @@ func ComputeTxId(spends []*nockchain.NockchainNamedSpend, version uint64) ([5]ui
} }
}, },
func(i interface{}) ([5]uint64, error) { func(i interface{}) ([5]uint64, error) {
if spendEntry, ok := i.(*nockchain.NockchainNamedSpend); ok { if input, ok := i.(*nockchain.NockchainInput); ok {
nameHash := HashName(spendEntry.Name) hash, err := HashInput(input)
spendV0Hash, err := HashSpendV0(spendEntry.GetLegacy()) return hash, err
if err != nil {
return [5]uint64{}, fmt.Errorf("error hashing spend: %v", err)
}
zeroHashspend := crypto.Tip5RehashTenCell(crypto.Tip5Zero, spendV0Hash)
return crypto.Tip5RehashTenCell(nameHash, zeroHashspend), nil
} else { } else {
return [5]uint64{}, fmt.Errorf("invalid input type") return [5]uint64{}, fmt.Errorf("invalid input type")
} }
}, },
) )
for _, spend := range spends { for _, input := range inputs {
spendTree.Insert(spend.Name, spend) inputTree.Insert(input.Name, input)
} }
spendHash, err = spendTree.Hash() inputHash, err := inputTree.Hash()
if err != nil { if err != nil {
return [5]uint64{}, fmt.Errorf("error hashing spends: %v", err) return [5]uint64{}, fmt.Errorf("error hashing inputs: %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) timelockHash := HashTimelockRange(timelockRange)
return crypto.Tip5RehashTenCell(nameHash, oneHashspend), nil
} else { totalFeesHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: totalFees}})
return [5]uint64{}, fmt.Errorf("invalid input type")
} q := crypto.Tip5RehashTenCell(timelockHash, totalFeesHash)
}, return crypto.Tip5RehashTenCell(inputHash, q), nil
)
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) { func ComputeSig(m crypto.MasterKey, msg [5]uint64) ([8]uint64, [8]uint64, error) {
@ -496,7 +369,7 @@ func ComputeSig(m crypto.MasterKey, msg [5]uint64) ([8]uint64, [8]uint64, error)
if err != nil { if err != nil {
return [8]uint64{}, [8]uint64{}, err return [8]uint64{}, [8]uint64{}, err
} }
belts, nonce := HashNonce(pkPoint, msg, m.PrivateKey) belts, nonce := HashNonce(pkPoint, msg)
nonceBigInt := crypto.TruncGOrder(nonce) nonceBigInt := crypto.TruncGOrder(nonce)
scalar := crypto.CheetahScaleBig(crypto.A_GEN, *nonceBigInt) scalar := crypto.CheetahScaleBig(crypto.A_GEN, *nonceBigInt)
@ -516,3 +389,9 @@ func ComputeSig(m crypto.MasterKey, msg [5]uint64) ([8]uint64, [8]uint64, error)
sigT8 := crypto.BigIntToT8(*sig) sigT8 := crypto.BigIntToT8(*sig)
return chalT8, sigT8, nil 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)
}

View File

@ -1,156 +0,0 @@
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)},
}
}

View File

@ -1,7 +1,6 @@
package wallet package wallet
import ( import (
"cmp"
context "context" context "context"
"crypto/rand" "crypto/rand"
"crypto/sha256" "crypto/sha256"
@ -16,13 +15,6 @@ import (
"github.com/phamminh0811/private-grpc/nockchain" "github.com/phamminh0811/private-grpc/nockchain"
) )
const (
WitnessWordsCount = 55
SignatureWordsCount = 31
SeedWordsCount = 13
BaseFee = 1 << 15
)
type GprcHandler struct { type GprcHandler struct {
nockchain.UnimplementedWalletServiceServer nockchain.UnimplementedWalletServiceServer
client NockchainClient client NockchainClient
@ -57,26 +49,13 @@ func (h *GprcHandler) Keygen(ctx context.Context, req *nockchain.KeygenRequest)
return nil, err return nil, err
} }
privBytes := append([]byte{0x00}, masterKey.PrivateKey...) 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{ return &nockchain.KeygenResponse{
Seed: mnemonic, Seed: mnemonic,
PrivateKey: base58.Encode(masterKey.PrivateKey), PrivateKey: base58.Encode(masterKey.PrivateKey),
Address: address, PublicKey: base58.Encode(masterKey.PublicKey),
ChainCode: base58.Encode(masterKey.ChainCode), ChainCode: base58.Encode(masterKey.ChainCode),
ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, int(req.Version), crypto.KeyType_PRIVATE)), ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE)),
ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, int(req.Version), crypto.KeyType_PUBLIC)), ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC)),
Version: req.Version,
}, nil }, nil
} }
@ -109,26 +88,13 @@ func (h *GprcHandler) ImportKeys(ctx context.Context, req *nockchain.ImportKeysR
return nil, err return nil, err
} }
privBytes := append([]byte{0x00}, masterKey.PrivateKey...) 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{ return &nockchain.ImportKeysResponse{
Seed: "", Seed: "",
PrivateKey: base58.Encode(masterKey.PrivateKey), PrivateKey: base58.Encode(masterKey.PrivateKey),
Address: address, PublicKey: base58.Encode(masterKey.PublicKey),
ChainCode: base58.Encode(masterKey.ChainCode), ChainCode: base58.Encode(masterKey.ChainCode),
ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, int(req.Version), crypto.KeyType_PRIVATE)), ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE)),
ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, int(req.Version), crypto.KeyType_PUBLIC)), ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC)),
Version: req.Version,
}, nil }, nil
case strings.HasPrefix(req.Key, "zpub"): case strings.HasPrefix(req.Key, "zpub"):
if len(data) != 147 { if len(data) != 147 {
@ -145,26 +111,13 @@ func (h *GprcHandler) ImportKeys(ctx context.Context, req *nockchain.ImportKeysR
copy(chainCode, data[14:46]) copy(chainCode, data[14:46])
publicKey := make([]byte, 97) publicKey := make([]byte, 97)
copy(publicKey, data[46:143]) 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{ return &nockchain.ImportKeysResponse{
Seed: "", Seed: "",
PrivateKey: "", PrivateKey: "",
Address: address, PublicKey: base58.Encode(publicKey),
ChainCode: base58.Encode(chainCode), ChainCode: base58.Encode(chainCode),
ImportPrivateKey: "", ImportPrivateKey: "",
ImportPublicKey: base58.Encode(crypto.SerializeExtend(chainCode, publicKey, int(req.Version), crypto.KeyType_PUBLIC)), ImportPublicKey: base58.Encode(crypto.SerializeExtend(chainCode, publicKey, crypto.KeyType_PUBLIC)),
Version: req.Version,
}, nil }, nil
default: default:
return nil, fmt.Errorf("invalid extended key") return nil, fmt.Errorf("invalid extended key")
@ -187,26 +140,13 @@ func (h *GprcHandler) ImportKeys(ctx context.Context, req *nockchain.ImportKeysR
return nil, err return nil, err
} }
privBytes := append([]byte{0x00}, masterKey.PrivateKey...) 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{ return &nockchain.ImportKeysResponse{
Seed: "", Seed: "",
PrivateKey: base58.Encode(masterKey.PrivateKey), PrivateKey: base58.Encode(masterKey.PrivateKey),
Address: address, PublicKey: base58.Encode(masterKey.PublicKey),
ChainCode: base58.Encode(masterKey.ChainCode), ChainCode: base58.Encode(masterKey.ChainCode),
ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, int(req.Version), crypto.KeyType_PRIVATE)), ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE)),
ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, int(req.Version), crypto.KeyType_PUBLIC)), ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC)),
Version: req.Version,
}, nil }, nil
case nockchain.ImportType_SEEDPHRASE: case nockchain.ImportType_SEEDPHRASE:
masterKey, err := crypto.MasterKeyFromSeed(req.Key) masterKey, err := crypto.MasterKeyFromSeed(req.Key)
@ -214,49 +154,23 @@ func (h *GprcHandler) ImportKeys(ctx context.Context, req *nockchain.ImportKeysR
return nil, err return nil, err
} }
privBytes := append([]byte{0x00}, masterKey.PrivateKey...) 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{ return &nockchain.ImportKeysResponse{
Seed: "", Seed: "",
PrivateKey: base58.Encode(masterKey.PrivateKey), PrivateKey: base58.Encode(masterKey.PrivateKey),
Address: address, PublicKey: base58.Encode(masterKey.PublicKey),
ChainCode: base58.Encode(masterKey.ChainCode), ChainCode: base58.Encode(masterKey.ChainCode),
ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, int(req.Version), crypto.KeyType_PRIVATE)), ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE)),
ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, int(req.Version), crypto.KeyType_PUBLIC)), ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC)),
Version: req.Version,
}, nil }, nil
case nockchain.ImportType_WATCH_ONLY: 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{ return &nockchain.ImportKeysResponse{
Seed: "", Seed: "",
PrivateKey: "", PrivateKey: "",
Address: address, PublicKey: base58.Encode(pubKey),
ChainCode: "", ChainCode: "",
ImportPrivateKey: "", ImportPrivateKey: "",
ImportPublicKey: "", ImportPublicKey: "",
Version: req.Version,
}, nil }, nil
default: default:
return nil, fmt.Errorf("invalid import type") return nil, fmt.Errorf("invalid import type")
@ -298,23 +212,10 @@ func (h *GprcHandler) DeriveChild(ctx context.Context, req *nockchain.DeriveChil
if err != nil { if err != nil {
return nil, err 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{ return &nockchain.DeriveChildResponse{
Address: address, PublicKey: base58.Encode(childKey.PublicKey),
PrivateKey: base58.Encode(childKey.PrivateKey), PrivateKey: base58.Encode(childKey.PrivateKey),
ChainCode: base58.Encode(childKey.ChainCode), ChainCode: base58.Encode(childKey.ChainCode),
Version: req.Version,
}, nil }, nil
case strings.HasPrefix(req.ImportedKey, "zpub"): case strings.HasPrefix(req.ImportedKey, "zpub"):
@ -342,23 +243,10 @@ func (h *GprcHandler) DeriveChild(ctx context.Context, req *nockchain.DeriveChil
if err != nil { if err != nil {
return nil, err 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{ return &nockchain.DeriveChildResponse{
Address: address, PublicKey: base58.Encode(childKey.PublicKey),
PrivateKey: "", PrivateKey: "",
ChainCode: base58.Encode(childKey.ChainCode), ChainCode: base58.Encode(childKey.ChainCode),
Version: req.Version,
}, nil }, nil
default: default:
return nil, fmt.Errorf("invalid extended key") return nil, fmt.Errorf("invalid extended key")
@ -368,14 +256,20 @@ func (h *GprcHandler) DeriveChild(ctx context.Context, req *nockchain.DeriveChil
// - `names` - Comma-separated list of note name pairs in format "[first last]" // - `names` - Comma-separated list of note name pairs in format "[first last]"
// Example: "[first1 last1],[first2 last2]" // Example: "[first1 last1],[first2 last2]"
// //
// - `recipients` Comma-separated list of transaction output, formatted as "<recipient1>:<amount1>,<recipient1>:<amount1>" // - `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"
// //
// - `fee` - Transaction fee to be subtracted from one of the input notes // - `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) { func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxRequest) (*nockchain.CreateTxResponse, error) {
nnames := []*nockchain.NockchainName{} nnames := []*nockchain.NockchainName{}
names := strings.Split(req.Names, ",") names := strings.Split(req.Names, ",")
notesV0 := make([]*nockchain.NockchainNoteV0, len(names)) notes := make([]*nockchain.NockchainNote, len(names))
notesV1 := make([]*nockchain.NockchainNoteV1, len(names))
for _, name := range names { for _, name := range names {
name = strings.TrimSpace(name) name = strings.TrimSpace(name)
if strings.HasPrefix(name, "[") && strings.HasSuffix(name, "]") { if strings.HasPrefix(name, "[") && strings.HasSuffix(name, "]") {
@ -390,26 +284,87 @@ func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxReque
} }
} }
specs := strings.Split(req.Recipients, ",") nameTree := NewZTree(
if len(specs) == 0 { func(i interface{}) [5]uint64 {
return nil, fmt.Errorf("at least one output must be provided") if name, ok := i.(*nockchain.NockchainName); ok {
return HashNameVarLen(name)
} else {
return [5]uint64{}
}
},
nil,
)
for _, name := range nnames {
nameTree.Insert(name, nil)
}
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")
} }
spec := specs[0] recipents := []*nockchain.NockchainLock{}
pairs := strings.Split(spec, ":") if strings.Contains(req.Recipients, "[") {
if len(pairs) != 2 { pairs := strings.Split(req.Recipients, ",")
return nil, fmt.Errorf("%s", "Invalid output spec "+spec+", expected <pkh>:<amount>") for _, pair := range pairs {
} pair = strings.TrimSpace(pair)
gift, err := strconv.ParseUint(strings.TrimSpace(pairs[1]), 10, 64) 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 { if err != nil {
return nil, err continue
} }
masterKey, err := crypto.MasterKeyFromSeed(req.Seed) 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)
}
// 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")
}
}
var masterKey *crypto.MasterKey
chainCode := base58.Decode(req.ChainCode)
key := base58.Decode(req.Key)
masterKey, err := crypto.MasterKeyFromPrivKey(chainCode, key)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -428,55 +383,9 @@ func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxReque
} }
masterKey = &childKey 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 // Scan key to get notes
var scanReq *nockchain.GetBalanceRequest masterKeyScan, err := h.client.WalletGetBalance(base58.Encode(masterKey.PublicKey))
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 { if err != nil {
return nil, err return nil, err
} }
@ -499,111 +408,64 @@ func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxReque
name := "[" + firstName + " " + lastName + "]" name := "[" + firstName + " " + lastName + "]"
if i := slices.Index(names, name); i != -1 { if i := slices.Index(names, name); i != -1 {
balanceEntry := ParseBalanceEntry(note) balanceEntry := ParseBalanceEntry(note)
switch req.Version { notes[i] = &balanceEntry
case 0:
notesV0[i] = balanceEntry.GetV0()
case 1:
notesV1[i] = balanceEntry.GetV1()
}
}
}
}
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)) inputs := make([]*nockchain.NockchainInput, len(names))
copy(notesV0Sort, notesV0) isSpent := false
for i := 0; i < len(nameKeys); i++ {
notesV1Sort := make([]*nockchain.NockchainNoteV1, len(notesV1)) idx := indices[i]
copy(notesV1Sort, notesV1) if notes[idx] == nil {
return nil, fmt.Errorf("notes scanned is missing at name: %s", names[idx])
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{} if notes[idx].Asset < gifts[idx] {
for i := 0; i < len(names); i++ { return nil, fmt.Errorf("note %s not enough balance", names[idx])
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
} }
giftRemaining = giftRemaining - giftPortion parentHash, err := HashNote(notes[idx])
feeRemaining = feeRemaining - feePortion
refund := asset - giftPortion - feePortion
if refund == 0 && giftPortion == 0 {
continue
}
var parentHash [5]uint64
switch req.Version {
case 0:
parentHash, err = HashNoteV0(notesV0Sort[i])
if err != nil { if err != nil {
return nil, err return nil, err
} }
case 1: seeds := []*nockchain.NockchainSeed{
parentHash = HashNoteV1(notesV1Sort[i]) {
OutputSource: nil,
Recipient: recipents[idx],
TimelockIntent: req.TimelockIntent,
Gift: gifts[idx],
ParentHash: crypto.Tip5HashToBase58(parentHash),
},
} }
lockRoot := HashLock(recipent)
seeds := []*nockchain.NockchainSeed{} assetLeft := notes[idx].Asset - gifts[idx]
if giftPortion != 0 { fee := uint64(0)
wordCount += SeedWordsCount if !isSpent && assetLeft >= req.Fee {
isSpent = true
fee = req.Fee
assetLeft -= req.Fee
}
if assetLeft != 0 {
seeds = append(seeds, &nockchain.NockchainSeed{ seeds = append(seeds, &nockchain.NockchainSeed{
OutputSource: nil, OutputSource: nil,
LockRoot: crypto.Tip5HashToBase58(lockRoot), Recipient: &nockchain.NockchainLock{
NoteData: recipent, KeysRequired: 1,
Gift: giftPortion, Pubkeys: []string{base58.Encode(masterKey.PublicKey)},
},
TimelockIntent: req.TimelockIntent,
Gift: assetLeft,
ParentHash: crypto.Tip5HashToBase58(parentHash), ParentHash: crypto.Tip5HashToBase58(parentHash),
}) })
} }
spend := nockchain.NockchainSpend{
if refund != 0 { Signatures: nil,
wordCount += SeedWordsCount Seeds: seeds,
lockRoot := HashLock(refundLock) Fee: fee,
seeds = append(seeds, &nockchain.NockchainSeed{
OutputSource: nil,
LockRoot: crypto.Tip5HashToBase58(lockRoot),
NoteData: refundLock,
Gift: refund,
ParentHash: crypto.Tip5HashToBase58(parentHash),
})
} }
msg, err := HashMsg(seeds, feePortion) msg, err := HashMsg(&spend)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -614,85 +476,47 @@ func (h *GprcHandler) CreateTx(ctx context.Context, req *nockchain.CreateTxReque
return nil, err return nil, err
} }
sigs := []*nockchain.NockchainSignature{ spend.Signatures = []*nockchain.NockchainSignature{
{ {
Pubkey: base58.Encode(masterKey.PublicKey), Pubkey: base58.Encode(masterKey.PublicKey),
Chal: chalT8[:], Chal: chalT8[:],
Sig: sigT8[:], Sig: sigT8[:],
}, },
} }
switch req.Version {
case 0: input := nockchain.NockchainInput{
spend := nockchain.NockchainSpendV0{ Name: nnames[idx],
Signatures: nil, Note: notes[idx],
Seeds: seeds, Spend: &spend,
Fee: feePortion, }
inputs[idx] = &input
} }
spend.Signatures = sigs if !isSpent {
wordCount += SignatureWordsCount return nil, fmt.Errorf("insufficient funds")
nameIdx := -1
for j := 0; j < len(names); j++ {
if nnames[j].Last == notesV0Sort[i].Name.Last {
nameIdx = j
break
} }
var timelockRange *nockchain.TimelockRange
if req.TimelockIntent == nil {
timelockRange = &nockchain.TimelockRange{
Min: nil,
Max: nil,
} }
spends = append(spends, &nockchain.NockchainNamedSpend{ } else {
Name: nnames[nameIdx], if req.TimelockIntent.Absolute != nil {
SpendKind: &nockchain.NockchainNamedSpend_Legacy{ timelockRange = req.TimelockIntent.Absolute
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,
},
})
} }
if req.TimelockIntent.Relative != nil {
timelockRange = req.TimelockIntent.Relative
} }
if giftRemaining != 0 || feeRemaining != 0 {
return nil, fmt.Errorf("insufficient funds to pay fee and gift")
} }
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{ rawTx := nockchain.RawTx{
TxId: "", TxId: "",
Version: 1, Inputs: inputs,
NamedSpends: spends, TimelockRange: timelockRange,
TotalFees: req.Fee,
} }
txId, err := ComputeTxId(spends, req.Version) txId, err := ComputeTxId(inputs, timelockRange, req.Fee)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -712,23 +536,8 @@ func (h *GprcHandler) Scan(ctx context.Context, req *nockchain.ScanRequest) (*no
ChainCode: chainCode, ChainCode: chainCode,
PrivateKey: []byte{}, 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(&nockchain.GetBalanceRequest{ masterKeyScan, err := h.client.WalletGetBalance(req.MasterPubkey)
Selector: &nockchain.GetBalanceRequest_Address{
Address: address,
},
})
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -743,39 +552,7 @@ func (h *GprcHandler) Scan(ctx context.Context, req *nockchain.ScanRequest) (*no
if err != nil { if err != nil {
continue 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 { if err != nil {
continue continue
} }
@ -793,7 +570,7 @@ func (h *GprcHandler) Scan(ctx context.Context, req *nockchain.ScanRequest) (*no
} }
func (h *GprcHandler) WalletGetBalance(_ context.Context, req *nockchain.GetBalanceRequest) (*nockchain.GetBalanceResponse, error) { func (h *GprcHandler) WalletGetBalance(_ context.Context, req *nockchain.GetBalanceRequest) (*nockchain.GetBalanceResponse, error) {
data, err := h.client.WalletGetBalance(req) data, err := h.client.WalletGetBalance(req.Address)
return &nockchain.GetBalanceResponse{ return &nockchain.GetBalanceResponse{
Data: data, Data: data,
}, err }, err
@ -809,3 +586,7 @@ func (h *GprcHandler) WalletSendTransaction(_ context.Context, req *nockchain.Se
func (h *GprcHandler) TransactionAccepted(_ context.Context, req *nockchain.TransactionAcceptedRequest) (*nockchain.TransactionAcceptedResponse, error) { func (h *GprcHandler) TransactionAccepted(_ context.Context, req *nockchain.TransactionAcceptedRequest) (*nockchain.TransactionAcceptedResponse, error) {
return h.client.TxAccepted(req.TxId.Hash) return h.client.TxAccepted(req.TxId.Hash)
} }
func (h *GprcHandler) SignTx(context.Context, *nockchain.SignTxRequest) (*nockchain.SignTxResponse, error) {
return nil, nil
}

View File

@ -16,7 +16,7 @@ import (
) )
// The entropy, salt and result is taken from "nockchain-wallet keygen" command // The entropy, salt and result is taken from "nockchain-wallet keygen" command
func TestKeyGenV0(t *testing.T) { func TestKeyGen(t *testing.T) {
entropyBigInt, isOk := new(big.Int).SetString("37133536588676344913489312523941366110857274548479981512263368615793750653450", 10) entropyBigInt, isOk := new(big.Int).SetString("37133536588676344913489312523941366110857274548479981512263368615793750653450", 10)
assert.True(t, isOk) assert.True(t, isOk)
@ -38,10 +38,6 @@ func TestKeyGenV0(t *testing.T) {
masterKey, err := crypto.MasterKeyFromSeed(mnemonic) masterKey, err := crypto.MasterKeyFromSeed(mnemonic)
assert.NoError(t, err) assert.NoError(t, err)
pkPoint, err := crypto.CheetaPointFromBytes(masterKey.PublicKey)
assert.NoError(t, err)
fmt.Println(crypto.Tip5HashToBase58(wallet.HashPubkey(pkPoint)))
assert.Equal(t, assert.Equal(t,
base58.Encode(masterKey.PublicKey), base58.Encode(masterKey.PublicKey),
"34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6",
@ -57,9 +53,9 @@ func TestKeyGenV0(t *testing.T) {
// assert import priv/pubkey // assert import priv/pubkey
privBytes := append([]byte{0x00}, masterKey.PrivateKey...) privBytes := append([]byte{0x00}, masterKey.PrivateKey...)
importPrivKey := crypto.SerializeExtend(masterKey.ChainCode, privBytes, 0, crypto.KeyType_PRIVATE) importPrivKey := crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.KeyType_PRIVATE)
assert.Len(t, importPrivKey, 83) assert.Len(t, importPrivKey, 83)
importPubKey := crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, 0, crypto.KeyType_PUBLIC) importPubKey := crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.KeyType_PUBLIC)
assert.Len(t, importPubKey, 147) assert.Len(t, importPubKey, 147)
assert.Equal(t, assert.Equal(t,
@ -72,51 +68,6 @@ func TestKeyGenV0(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) { func TestImportKey(t *testing.T) {
type Input struct { type Input struct {
req *nockchain.ImportKeysRequest req *nockchain.ImportKeysRequest
@ -125,63 +76,41 @@ func TestImportKey(t *testing.T) {
errStr string errStr string
} }
correctImportPrivKeyV0 := base58.Decode("zprvLpf3WSvYWmHRd3jj5oR8UXr7bi88pGnfJXj1dM9RnwJwu1MLo6fZzcKauqpxL2W7dk2fmjYKAUzavbyaGpnvqY5QndcrUzsBrPQAHXNnhiXx") correctImportPrivKey := base58.Decode("zprvLpf3WSvYWmHRd3jj5oR8UXr7bi88pGnfJXj1dM9RnwJwu1MLo6fZzcKauqpxL2W7dk2fmjYKAUzavbyaGpnvqY5QndcrUzsBrPQAHXNnhiXx")
correctImportPrivKeyV1 := base58.Decode("zprvLxxkCBq3s5HYziigQb3G4a7pyj7pG2f8MjogoqH4UoFDJy3GRBX5LF1tJAgsTYdgZAVfuM2DGrjqAqJX96SS8cTbVAaPV23834G1GqgfEEg7")
invalidImportPrivKeyPrefix := make([]byte, 83) invalidImportPrivKeyPrefix := make([]byte, 83)
copy(invalidImportPrivKeyPrefix[:], correctImportPrivKeyV0) copy(invalidImportPrivKeyPrefix[:], correctImportPrivKey)
invalidImportPrivKeyPrefix[46] = 0x01 invalidImportPrivKeyPrefix[46] = 0x01
invalidImportPrivKeyChecksum := make([]byte, 83) invalidImportPrivKeyChecksum := make([]byte, 83)
copy(invalidImportPrivKeyChecksum[:], correctImportPrivKeyV0) copy(invalidImportPrivKeyChecksum[:], correctImportPrivKey)
copy(invalidImportPrivKeyChecksum[79:], []byte{1, 2, 3, 4}) copy(invalidImportPrivKeyChecksum[79:], []byte{1, 2, 3, 4})
correctImportPubkeyV0 := base58.Decode("zpub2jgndknkQprVYB4X4mqREyn7ZTUE5zp9qkSugdpiqhC5NSeNBceafoz6jGSLEpzJhaLryvY8MF6TokwZN627UXhsg5zd2U12woEL82UtZaLHRL8PZi8YiQnE41BiNJwkfpWjzAbq8mwbAHV3nXUEFgJW2BKCz4GmfoMCkCUDhJppYh5KFsMUkN41DzsfFZHuFrzo") correctImportPubkey := base58.Decode("zpub2jgndknkQprVYB4X4mqREyn7ZTUE5zp9qkSugdpiqhC5NSeNBceafoz6jGSLEpzJhaLryvY8MF6TokwZN627UXhsg5zd2U12woEL82UtZaLHRL8PZi8YiQnE41BiNJwkfpWjzAbq8mwbAHV3nXUEFgJW2BKCz4GmfoMCkCUDhJppYh5KFsMUkN41DzsfFZHuFrzo")
correctImportPubkeyV1 := base58.Decode("zpub2kRJ7D6VCvzVfDb4F7drLsLVdViqUSiufhwkmZogDuTVLc5ird2DinQNHvu5WXgTcMGizEaqbnANjvg43bx3Lfz4fPVt27MPsiNBTuqqXgtvYbJZNwmXEa5vt87MGCRxKpAgo1zH6K7qy5Uokc94eUd47xEcmhij9YRm8twvU5y3ccCessJ8rdtEZahX6pv8RFBi")
invalidImportPubkeyChecksum := make([]byte, 147) invalidImportPubkeyChecksum := make([]byte, 147)
copy(invalidImportPubkeyChecksum[:], correctImportPubkeyV0) copy(invalidImportPubkeyChecksum[:], correctImportPubkey)
copy(invalidImportPubkeyChecksum[143:], []byte{1, 2, 3, 4}) copy(invalidImportPubkeyChecksum[143:], []byte{1, 2, 3, 4})
responseV0 := &nockchain.ImportKeysResponse{ response := &nockchain.ImportKeysResponse{
Address: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", PublicKey: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6",
PrivateKey: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", PrivateKey: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg",
ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8", ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8",
ImportPrivateKey: base58.Encode(correctImportPrivKeyV0), ImportPrivateKey: base58.Encode(correctImportPrivKey),
ImportPublicKey: base58.Encode(correctImportPubkeyV0), ImportPublicKey: base58.Encode(correctImportPubkey),
Version: 0,
}
responseV1 := &nockchain.ImportKeysResponse{
Address: "BAmYAxgpVrJeFqqPnKAZHVZZdmVfzrgu7bBqcRBNca8HpxQofzUZG8Q",
PrivateKey: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg",
ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8",
ImportPrivateKey: base58.Encode(correctImportPrivKeyV1),
ImportPublicKey: base58.Encode(correctImportPubkeyV1),
Version: 1,
} }
responseV0ReadOnly := &nockchain.ImportKeysResponse{ responseReadOnly := &nockchain.ImportKeysResponse{
Address: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", PublicKey: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6",
PrivateKey: "", PrivateKey: "",
ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8", ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8",
ImportPrivateKey: "", ImportPrivateKey: "",
ImportPublicKey: base58.Encode(correctImportPubkeyV0), ImportPublicKey: base58.Encode(correctImportPubkey),
Version: 0,
} }
responseV1ReadOnly := &nockchain.ImportKeysResponse{
Address: "BAmYAxgpVrJeFqqPnKAZHVZZdmVfzrgu7bBqcRBNca8HpxQofzUZG8Q",
PrivateKey: "",
ChainCode: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8",
ImportPrivateKey: "",
ImportPublicKey: base58.Encode(correctImportPubkeyV1),
Version: 1,
}
inputs := []Input{ inputs := []Input{
// case invalid type // case invalid type
{ {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: "", Key: "",
ImportType: nockchain.ImportType_UNDEFINED, ImportType: nockchain.ImportType_UNDEFINED,
Version: 0,
}, },
expectResp: nil, expectResp: nil,
isErr: true, isErr: true,
@ -192,7 +121,6 @@ func TestImportKey(t *testing.T) {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: "some wrong string", Key: "some wrong string",
ImportType: nockchain.ImportType_EXTENDED_KEY, ImportType: nockchain.ImportType_EXTENDED_KEY,
Version: 0,
}, },
expectResp: nil, expectResp: nil,
isErr: true, isErr: true,
@ -202,7 +130,6 @@ func TestImportKey(t *testing.T) {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: "zprv wrong priv import key length", Key: "zprv wrong priv import key length",
ImportType: nockchain.ImportType_EXTENDED_KEY, ImportType: nockchain.ImportType_EXTENDED_KEY,
Version: 0,
}, },
expectResp: nil, expectResp: nil,
isErr: true, isErr: true,
@ -212,7 +139,6 @@ func TestImportKey(t *testing.T) {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: base58.Encode(invalidImportPrivKeyPrefix), Key: base58.Encode(invalidImportPrivKeyPrefix),
ImportType: nockchain.ImportType_EXTENDED_KEY, ImportType: nockchain.ImportType_EXTENDED_KEY,
Version: 0,
}, },
expectResp: nil, expectResp: nil,
isErr: true, isErr: true,
@ -227,25 +153,13 @@ func TestImportKey(t *testing.T) {
isErr: true, isErr: true,
errStr: "invalid checksum", errStr: "invalid checksum",
}, },
// case success import priv key v0 // case success import priv key
{ {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: base58.Encode(correctImportPrivKeyV0), Key: base58.Encode(correctImportPrivKey),
ImportType: nockchain.ImportType_EXTENDED_KEY, ImportType: nockchain.ImportType_EXTENDED_KEY,
Version: 0,
}, },
expectResp: responseV0, expectResp: response,
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, isErr: false,
errStr: "", errStr: "",
}, },
@ -254,7 +168,6 @@ func TestImportKey(t *testing.T) {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: "zpub wrong public import key length", Key: "zpub wrong public import key length",
ImportType: nockchain.ImportType_EXTENDED_KEY, ImportType: nockchain.ImportType_EXTENDED_KEY,
Version: 0,
}, },
expectResp: nil, expectResp: nil,
isErr: true, isErr: true,
@ -264,31 +177,18 @@ func TestImportKey(t *testing.T) {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: base58.Encode(invalidImportPubkeyChecksum), Key: base58.Encode(invalidImportPubkeyChecksum),
ImportType: nockchain.ImportType_EXTENDED_KEY, ImportType: nockchain.ImportType_EXTENDED_KEY,
Version: 0,
}, },
expectResp: nil, expectResp: nil,
isErr: true, isErr: true,
errStr: "invalid checksum", errStr: "invalid checksum",
}, },
// case success import pub key v0 // case success import pub key
{ {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: base58.Encode(correctImportPubkeyV0), Key: base58.Encode(correctImportPubkey),
ImportType: nockchain.ImportType_EXTENDED_KEY, ImportType: nockchain.ImportType_EXTENDED_KEY,
Version: 0,
}, },
expectResp: responseV0ReadOnly, expectResp: responseReadOnly,
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, isErr: false,
errStr: "", errStr: "",
}, },
@ -297,7 +197,6 @@ func TestImportKey(t *testing.T) {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", Key: "3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg",
ImportType: nockchain.ImportType_MASTER_PRIVKEY, ImportType: nockchain.ImportType_MASTER_PRIVKEY,
Version: 0,
}, },
expectResp: nil, expectResp: nil,
isErr: true, isErr: true,
@ -308,7 +207,6 @@ func TestImportKey(t *testing.T) {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: "abcdxyz,3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", Key: "abcdxyz,3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg",
ImportType: nockchain.ImportType_MASTER_PRIVKEY, ImportType: nockchain.ImportType_MASTER_PRIVKEY,
Version: 0,
}, },
expectResp: nil, expectResp: nil,
isErr: true, isErr: true,
@ -318,80 +216,39 @@ func TestImportKey(t *testing.T) {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8,abcdxyz", Key: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8,abcdxyz",
ImportType: nockchain.ImportType_MASTER_PRIVKEY, ImportType: nockchain.ImportType_MASTER_PRIVKEY,
Version: 0,
}, },
expectResp: nil, expectResp: nil,
isErr: true, isErr: true,
errStr: "invalid priv key length", errStr: "invalid priv key length",
}, },
// case success import master privkey v0 // case success import master privkey
{ {
req: &nockchain.ImportKeysRequest{ req: &nockchain.ImportKeysRequest{
Key: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8,3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg", Key: "2ztGPxS8xYzMXoAHf3HMbMuyh4siew8X4Kz4KuTXvqX8,3B8Q5ZTHH63h9DT6WSwNZhea5zvtueuKpxk3qwZJEjsg",
ImportType: nockchain.ImportType_MASTER_PRIVKEY, ImportType: nockchain.ImportType_MASTER_PRIVKEY,
Version: 0,
}, },
expectResp: responseV0, expectResp: response,
isErr: false, isErr: false,
errStr: "", errStr: "",
}, },
// case success import master privkey v1 // case success import seed
{
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{ 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", 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, ImportType: nockchain.ImportType_SEEDPHRASE,
Version: 0,
}, },
expectResp: responseV0, expectResp: response,
isErr: false, isErr: false,
errStr: "", errStr: "",
}, },
// case success import seed v1 // case sucess import pubkey
{
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{ req: &nockchain.ImportKeysRequest{
Key: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", Key: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6",
ImportType: nockchain.ImportType_WATCH_ONLY, ImportType: nockchain.ImportType_WATCH_ONLY,
Version: 0,
}, },
expectResp: &nockchain.ImportKeysResponse{ expectResp: &nockchain.ImportKeysResponse{
Address: "34VqjU7ojQXWiFZz7kvXe1xfxhbdimmqqUAgp21XGESLqJSXxHkqrcquWirFcCPPj1pmSL4pRc8GndZoiiK8ijeYjgcJ3QR7fb2s4b2WdJhDao4Dx7gw3NRSt4RjXawqUQw6", PublicKey: "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, isErr: false,
errStr: "", errStr: "",
@ -417,59 +274,169 @@ func TestImportKey(t *testing.T) {
// This test should be run with timeout 120s // This test should be run with timeout 120s
func TestScan(t *testing.T) { func TestScan(t *testing.T) {
// some random seed we take to get empty notes // some random seed we take to get empty notes
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" 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"
masterKey1, err := crypto.MasterKeyFromSeed(seed1) masterKey1, err := crypto.MasterKeyFromSeed(seed1)
assert.NoError(t, err) assert.NoError(t, err)
fmt.Println("pk: ", base58.Encode(masterKey1.PublicKey))
nc, err := wallet.NewNockchainClient("nockchain-api.zorp.io:443") nc, err := wallet.NewNockchainClient("nockchain-api.zorp.io:443")
assert.NoError(t, err) assert.NoError(t, err)
masterKey1Scan, err := nc.WalletGetBalance(&nockchain.GetBalanceRequest{ masterKey1Scan, err := nc.WalletGetBalance(base58.Encode(masterKey1.PublicKey))
Selector: &nockchain.GetBalanceRequest_Address{
Address: base58.Encode(masterKey1.PublicKey),
},
})
assert.NoError(t, err) assert.NoError(t, err)
fmt.Println("masterKey1Scan:", masterKey1Scan) assert.Empty(t, masterKey1Scan.Notes)
assert.NotEmpty(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))
} }
func TestEncodeDecodeNoun(t *testing.T) { // This test should be run with timeout 120s
lock1 := &nockchain.NockchainLock{ 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, KeysRequired: 1,
Pubkeys: []string{"5wef35rKxbJDJRAtzGG1VwbMQK9jF3Wr5e6fyMsh2hxnCQZDZJV1YNQ"}, Pubkeys: []string{base58.Encode(masterKey2.PublicKey)},
},
TimelockIntent: nil,
Gift: gift,
ParentHash: crypto.Tip5HashToBase58(parentHash),
} }
lock1Encode := wallet.EncodeNoteData(lock1) gift = note.Asset - gift - 100
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}) seed2 := &nockchain.NockchainSeed{
OutputSource: nil,
Recipient: &nockchain.NockchainLock{
KeysRequired: 1,
Pubkeys: []string{base58.Encode(masterKey1.PublicKey)},
},
TimelockIntent: nil,
Gift: gift,
ParentHash: crypto.Tip5HashToBase58(parentHash),
}
lock1Decode := wallet.DecodeNoteData(lock1Encode) spend := nockchain.NockchainSpend{
assert.Equal(t, lock1Decode.KeysRequired, lock1.KeysRequired) Signatures: nil,
assert.Equal(t, lock1Decode.Pubkeys, lock1.Pubkeys) Seeds: []*nockchain.NockchainSeed{
seed1, seed2,
},
Fee: 100,
}
lock2 := lock1 msg, err := wallet.HashMsg(&spend)
lock2.Pubkeys = []string{"7UXNF2HXzEaPUvLDVDgGJyriKqpd2974Kj7U2RnLuBPeRGa7ZezhGmK"} assert.NoError(t, err)
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})
lock2Decode := wallet.DecodeNoteData(lock2Encode) chalT8, sigT8, err := wallet.ComputeSig(*masterKey1, msg)
assert.Equal(t, lock2Decode.KeysRequired, lock2.KeysRequired) assert.NoError(t, err)
assert.Equal(t, lock2Decode.Pubkeys, lock2.Pubkeys)
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,
})
} }
// This test should be run with timeout 300s // This test should be run with timeout 300s
func TestCreateTxV0(t *testing.T) { func TestCreateTx(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" 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"
masterKey1, err := crypto.MasterKeyFromSeed(seed1) masterKey1, err := crypto.MasterKeyFromSeed(seed1)
assert.NoError(t, err) assert.NoError(t, err)
fmt.Println("masterKey1: ", base58.Encode(masterKey1.PublicKey))
pkPoint1, err := crypto.CheetaPointFromBytes(masterKey1.PublicKey) // nockchain-wallet create-tx --names '[5bcr83LnCYyHqQh4ExK6metaf1cs7JYDqMYc92Awqhwc6VEpZJL9wj9 AmSjC3SDNtb7ZrUkTXc242BvGeimeL1nAV4CqV63HpLMryhom4L9W59],[5bcr83LnCYyHqQh4ExK6metaf1cs7JYDqMYc92Awqhwc6VEpZJL9wj9 7oo4x3fuwcJ5DrbFY1yf715ctjtE6CqqPagJWT8d687Q6sgMVWc1SXz],[5bcr83LnCYyHqQh4ExK6metaf1cs7JYDqMYc92Awqhwc6VEpZJL9wj9 8BrF9XAKwzvFdy8p7KAB8VEvcswPADhs2WamhWSLUErYN9z8U8cynaA]' --recipients '37Ttw4d6Fq1WGis5qVz8SbeEtpqsbg2ihArBedi4ZeuhFFo8tbCNvwWNq9D8KFBc2qv7uzvPJmKmJg68aEHEh21FiXk9iJCmzyE3NqdSgpsPMCx7Q39yhUUrKkKvGnHUKzMe,37Ttw4d6Fq1WGis5qVz8SbeEtpqsbg2ihArBedi4ZeuhFFo8tbCNvwWNq9D8KFBc2qv7uzvPJmKmJg68aEHEh21FiXk9iJCmzyE3NqdSgpsPMCx7Q39yhUUrKkKvGnHUKzMe,37Ttw4d6Fq1WGis5qVz8SbeEtpqsbg2ihArBedi4ZeuhFFo8tbCNvwWNq9D8KFBc2qv7uzvPJmKmJg68aEHEh21FiXk9iJCmzyE3NqdSgpsPMCx7Q39yhUUrKkKvGnHUKzMe' --gifts '50,50,50' --fee 100
assert.NoError(t, err)
addr1 := wallet.HashPubkey(pkPoint1)
// nockchain-wallet create-tx --names '[4taoqkpysafnp64WBQyzHDKVrqkMeNrdAiVSbWdzZmj7yQYZgQtCq4W 8yd685r3WhvRYsYWFy3LNQqSMMNwWyE3QZe5fqp1jgG3PWtLPvXdYvR]" --fee 1867776 --recipient "5wef35rKxbJDJRAtzGG1VwbMQK9jF3Wr5e6fyMsh2hxnCQZDZJV1YNQ:2000000" --refund-pkh 7UXNF2HXzEaPUvLDVDgGJyriKqpd2974Kj7U2RnLuBPeRGa7ZezhGmK
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" 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"
masterKey2, err := crypto.MasterKeyFromSeed(seed2) masterKey2, err := crypto.MasterKeyFromSeed(seed2)
assert.NoError(t, err) assert.NoError(t, err)
fmt.Println("masterKey2", base58.Encode(masterKey2.PublicKey)) fmt.Println("masterKey2", base58.Encode(masterKey2.PublicKey))
@ -478,61 +445,27 @@ func TestCreateTxV0(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
handler := wallet.NewGprcHandler(*nc) handler := wallet.NewGprcHandler(*nc)
inputs := "[4taoqkpysafnp64WBQyzHDKVrqkMeNrdAiVSbWdzZmj7yQYZgQtCq4W 8yd685r3WhvRYsYWFy3LNQqSMMNwWyE3QZe5fqp1jgG3PWtLPvXdYvR]" 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))
pkPoint2, err := crypto.CheetaPointFromBytes(masterKey2.PublicKey) gifts := "50,50,50"
assert.NoError(t, err) fee := 100
addr2 := wallet.HashPubkey(pkPoint2)
recipients := fmt.Sprintf("%s:2000000", crypto.Tip5HashToBase58(addr2))
fee := 1867776 // min fee
req := &nockchain.CreateTxRequest{ req := &nockchain.CreateTxRequest{
Names: inputs, Names: inputs,
Recipients: recipients, Recipients: recipients,
Gifts: gifts,
Fee: uint64(fee), Fee: uint64(fee),
IsMasterKey: true, IsMasterKey: true,
Seed: seed1, Key: base58.Encode(masterKey1.PrivateKey),
ChainCode: base58.Encode(masterKey1.ChainCode),
Index: 0, Index: 0,
Hardened: false, Hardened: false,
Version: 0, TimelockIntent: nil,
RefundAddress: crypto.Tip5HashToBase58(addr1),
} }
res, err := handler.CreateTx(context.Background(), req) res, err := handler.CreateTx(context.Background(), req)
assert.NoError(t, err) assert.NoError(t, err)
// the result is taken from create-tx scripts // the result is taken from create-tx scripts
assert.Equal(t, res.RawTx.TxId, "6oDgTWnk6sL98yK49hcQTRAfCdFfgKh58U6TDTKmGPirhoxkMii2D6E") assert.Equal(t, res.RawTx.TxId, "A8vSeRde61B4sZccSnNPEnkQgTe15EssoFwyhQXbkhtk4UNm5hyGSid")
}
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")
} }

View File

@ -7,28 +7,9 @@ import (
) )
func ParseBalanceEntry(entry *nockchain.BalanceEntry) nockchain.NockchainNote { func ParseBalanceEntry(entry *nockchain.BalanceEntry) nockchain.NockchainNote {
name := &nockchain.NockchainName{ version := nockchain.Version(entry.Note.Version.Value)
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{} pubkeys := []string{}
for _, pk := range note.Lock.SchnorrPubkeys { for _, pk := range entry.Note.Lock.SchnorrPubkeys {
pkPoint := crypto.CheetahPoint{ pkPoint := crypto.CheetahPoint{
X: [6]crypto.Belt{ X: [6]crypto.Belt{
{Value: pk.Value.X.Belt_1.Value}, {Value: pk.Value.X.Belt_1.Value},
@ -52,208 +33,156 @@ func ParseBalanceEntry(entry *nockchain.BalanceEntry) nockchain.NockchainNote {
pkStr := base58.Encode(pkPoint.Bytes()) pkStr := base58.Encode(pkPoint.Bytes())
pubkeys = append(pubkeys, pkStr) pubkeys = append(pubkeys, pkStr)
} }
sourceHash := [5]uint64{ sourceHash := [5]uint64{
note.Source.Hash.Belt_1.Value, entry.Note.Source.Hash.Belt_1.Value,
note.Source.Hash.Belt_2.Value, entry.Note.Source.Hash.Belt_2.Value,
note.Source.Hash.Belt_3.Value, entry.Note.Source.Hash.Belt_3.Value,
note.Source.Hash.Belt_4.Value, entry.Note.Source.Hash.Belt_4.Value,
note.Source.Hash.Belt_5.Value, entry.Note.Source.Hash.Belt_5.Value,
} }
return nockchain.NockchainNote{ return nockchain.NockchainNote{
Note: &nockchain.NockchainNote_V0{
V0: &nockchain.NockchainNoteV0{
Version: version, Version: version,
OriginPage: note.OriginPage.Value, BlockHeight: entry.Note.OriginPage.Value,
Name: name, 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{ Lock: &nockchain.NockchainLock{
KeysRequired: uint64(note.Lock.KeysRequired), KeysRequired: uint64(entry.Note.Lock.KeysRequired),
Pubkeys: pubkeys, Pubkeys: pubkeys,
}, },
Source: &nockchain.NockchainSource{ Source: &nockchain.NockchainSource{
Source: crypto.Tip5HashToBase58(sourceHash), Source: crypto.Tip5HashToBase58(sourceHash),
IsCoinbase: note.Source.Coinbase, IsCoinbase: entry.Note.Source.Coinbase,
}, },
Asset: note.Assets.Value, Asset: entry.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)
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 ConvertNamedSpend(spend *nockchain.NockchainNamedSpend) (*nockchain.SpendEntry, error) { func ConvertRawTx(rawTx *nockchain.RawTx) nockchain.RawTransaction {
convertedSpend := &nockchain.Spend{} id := crypto.Base58ToTip5Hash(rawTx.TxId)
switch spend.SpendKind.(type) {
case *nockchain.NockchainNamedSpend_Legacy: var timelockRange *nockchain.TimeLockRangeAbsolute
legacySpend := spend.GetLegacy() if rawTx.TimelockRange != nil {
signature, err := ConvertSignatures(legacySpend.Signatures) 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)
if err != nil { if err != nil {
return nil, err return nil, err
} }
seeds := []*nockchain.Seed{} pks = append(pks, pk)
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{ seeds := []*nockchain.Seed{}
SpendKind: &nockchain.Spend_Legacy{ for _, seed := range input.Spend.Seeds {
Legacy: &nockchain.LegacySpend{ seedPks := []*nockchain.SchnorrPubkey{}
Signature: signature,
Seeds: seeds, for _, i := range seed.Recipient.Pubkeys {
MinerFeeNicks: &nockchain.Nicks{ pk, err := ParseSchnorrPubkey(i)
Value: legacySpend.Fee, 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,
}, },
} }
case *nockchain.NockchainNamedSpend_Witness: }
witnessSpend := spend.GetWitness()
seeds := []*nockchain.Seed{}
for _, seed := range witnessSpend.Seeds {
seeds = append(seeds, &nockchain.Seed{ seeds = append(seeds, &nockchain.Seed{
OutputSource: &nockchain.Source{ OutputSource: source,
Hash: ParseHash(seed.OutputSource.Source), Recipient: &nockchain.Lock{
Coinbase: seed.OutputSource.IsCoinbase, KeysRequired: uint32(seed.Recipient.KeysRequired),
}, SchnorrPubkeys: seedPks,
LockRoot: ParseHash(seed.LockRoot),
NoteData: &nockchain.NoteData{
Entries: []*nockchain.NoteDataEntry{
{
Key: "lock",
Blob: EncodeNoteData(seed.NoteData),
},
},
},
Gift: &nockchain.Nicks{
Value: seed.Gift,
}, },
TimelockIntent: ConvertTimelockIntent(seed.TimelockIntent),
Gift: &nockchain.Nicks{Value: seed.Gift},
ParentHash: ParseHash(seed.ParentHash), ParentHash: ParseHash(seed.ParentHash),
}) })
} }
witness := witnessSpend.Witness[0] sigEntries := []*nockchain.SignatureEntry{}
lockHashes := []*nockchain.Hash{} for _, sig := range input.Spend.Signatures {
for i := 0; i < len(witness.Lmp.SpendCondition.Pubkeys); i++ { pk, err := ParseSchnorrPubkey(sig.Pubkey)
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 { if err != nil {
return nil, err return nil, err
} }
schnorrPk, err := ParseSchnorrPubkey(pkh.Pubkey) sigEntries = append(sigEntries, &nockchain.SignatureEntry{
if err != nil { SchnorrPubkey: pk,
return nil, err
}
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
}
entries[i] = &nockchain.SignatureEntry{
SchnorrPubkey: pubkey,
Signature: &nockchain.SchnorrSignature{ Signature: &nockchain.SchnorrSignature{
Chal: ParseEightBelt(sig.Chal), Chal: ParseEightBelt(sig.Chal),
Sig: ParseEightBelt(sig.Sig), Sig: ParseEightBelt(sig.Sig),
}, },
})
} }
} return &nockchain.NamedInput{
return &nockchain.Signature{ Name: ConvertName(input.Name),
Entries: entries, 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},
},
},
}, nil }, nil
} }