commit 65ccf9157cd3e288190c0008502596e79cfc640d Author: Trinity Date: Mon Oct 6 13:38:53 2025 +0700 first draft for nockchain-grpc diff --git a/crypto/argon2.go b/crypto/argon2.go new file mode 100644 index 0000000..5855afe --- /dev/null +++ b/crypto/argon2.go @@ -0,0 +1,283 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package argon2 implements the key derivation function Argon2. +// Argon2 was selected as the winner of the Password Hashing Competition and can +// be used to derive cryptographic keys from passwords. +// +// For a detailed specification of Argon2 see [1]. +// +// If you aren't sure which function you need, use Argon2id (IDKey) and +// the parameter recommendations for your scenario. +// +// # Argon2i +// +// Argon2i (implemented by Key) is the side-channel resistant version of Argon2. +// It uses data-independent memory access, which is preferred for password +// hashing and password-based key derivation. Argon2i requires more passes over +// memory than Argon2id to protect from trade-off attacks. The recommended +// parameters (taken from [2]) for non-interactive operations are time=3 and to +// use the maximum available memory. +// +// # Argon2id +// +// Argon2id (implemented by IDKey) is a hybrid version of Argon2 combining +// Argon2i and Argon2d. It uses data-independent memory access for the first +// half of the first iteration over the memory and data-dependent memory access +// for the rest. Argon2id is side-channel resistant and provides better brute- +// force cost savings due to time-memory tradeoffs than Argon2i. The recommended +// parameters for non-interactive operations (taken from [2]) are time=1 and to +// use the maximum available memory. +// +// [1] https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf +// [2] https://tools.ietf.org/html/draft-irtf-cfrg-argon2-03#section-9.3 +package crypto + +import ( + "encoding/binary" + "sync" + + "golang.org/x/crypto/blake2b" +) + +// The Argon2 version implemented by this package. +const Version = 0x13 + +const ( + argon2d = iota + argon2i + argon2id +) + +// Key derives a key from the password, salt, and cost parameters using Argon2i +// returning a byte slice of length keyLen that can be used as cryptographic +// key. The CPU cost and parallelism degree must be greater than zero. +// +// For example, you can get a derived key for e.g. AES-256 (which needs a +// 32-byte key) by doing: +// +// key := argon2.Key([]byte("some password"), salt, 3, 32*1024, 4, 32) +// +// The draft RFC recommends[2] time=3, and memory=32*1024 is a sensible number. +// If using that amount of memory (32 MB) is not possible in some contexts then +// the time parameter can be increased to compensate. +// +// The time parameter specifies the number of passes over the memory and the +// memory parameter specifies the size of the memory in KiB. For example +// memory=32*1024 sets the memory cost to ~32 MB. The number of threads can be +// adjusted to the number of available CPUs. The cost parameters should be +// increased as memory latency and CPU parallelism increases. Remember to get a +// good random salt. +func Key(password, salt []byte, time, memory uint32, threads uint8, keyLen uint32) []byte { + return DeriveKey(argon2i, password, salt, nil, nil, time, memory, threads, keyLen) +} + +// IDKey derives a key from the password, salt, and cost parameters using +// Argon2id returning a byte slice of length keyLen that can be used as +// cryptographic key. The CPU cost and parallelism degree must be greater than +// zero. +// +// For example, you can get a derived key for e.g. AES-256 (which needs a +// 32-byte key) by doing: +// +// key := argon2.IDKey([]byte("some password"), salt, 1, 64*1024, 4, 32) +// +// The draft RFC recommends[2] time=1, and memory=64*1024 is a sensible number. +// If using that amount of memory (64 MB) is not possible in some contexts then +// the time parameter can be increased to compensate. +// +// The time parameter specifies the number of passes over the memory and the +// memory parameter specifies the size of the memory in KiB. For example +// memory=64*1024 sets the memory cost to ~64 MB. The number of threads can be +// adjusted to the numbers of available CPUs. The cost parameters should be +// increased as memory latency and CPU parallelism increases. Remember to get a +// good random salt. +func IDKey(password, salt []byte, time, memory uint32, threads uint8, keyLen uint32) []byte { + return DeriveKey(argon2id, password, salt, nil, nil, time, memory, threads, keyLen) +} + +func DeriveKey(mode int, password, salt, secret, data []byte, time, memory uint32, threads uint8, keyLen uint32) []byte { + if time < 1 { + panic("argon2: number of rounds too small") + } + if threads < 1 { + panic("argon2: parallelism degree too low") + } + h0 := initHash(password, salt, secret, data, time, memory, uint32(threads), keyLen, mode) + + memory = memory / (syncPoints * uint32(threads)) * (syncPoints * uint32(threads)) + if memory < 2*syncPoints*uint32(threads) { + memory = 2 * syncPoints * uint32(threads) + } + B := initBlocks(&h0, memory, uint32(threads)) + processBlocks(B, time, memory, uint32(threads), mode) + return extractKey(B, memory, uint32(threads), keyLen) +} + +const ( + blockLength = 128 + syncPoints = 4 +) + +type block [blockLength]uint64 + +func initHash(password, salt, key, data []byte, time, memory, threads, keyLen uint32, mode int) [blake2b.Size + 8]byte { + var ( + h0 [blake2b.Size + 8]byte + params [24]byte + tmp [4]byte + ) + + b2, _ := blake2b.New512(nil) + binary.LittleEndian.PutUint32(params[0:4], threads) + binary.LittleEndian.PutUint32(params[4:8], keyLen) + binary.LittleEndian.PutUint32(params[8:12], memory) + binary.LittleEndian.PutUint32(params[12:16], time) + binary.LittleEndian.PutUint32(params[16:20], uint32(Version)) + binary.LittleEndian.PutUint32(params[20:24], uint32(mode)) + b2.Write(params[:]) + binary.LittleEndian.PutUint32(tmp[:], uint32(len(password))) + b2.Write(tmp[:]) + b2.Write(password) + binary.LittleEndian.PutUint32(tmp[:], uint32(len(salt))) + b2.Write(tmp[:]) + b2.Write(salt) + binary.LittleEndian.PutUint32(tmp[:], uint32(len(key))) + b2.Write(tmp[:]) + b2.Write(key) + binary.LittleEndian.PutUint32(tmp[:], uint32(len(data))) + b2.Write(tmp[:]) + b2.Write(data) + b2.Sum(h0[:0]) + return h0 +} + +func initBlocks(h0 *[blake2b.Size + 8]byte, memory, threads uint32) []block { + var block0 [1024]byte + B := make([]block, memory) + for lane := uint32(0); lane < threads; lane++ { + j := lane * (memory / threads) + binary.LittleEndian.PutUint32(h0[blake2b.Size+4:], lane) + + binary.LittleEndian.PutUint32(h0[blake2b.Size:], 0) + blake2bHash(block0[:], h0[:]) + for i := range B[j+0] { + B[j+0][i] = binary.LittleEndian.Uint64(block0[i*8:]) + } + + binary.LittleEndian.PutUint32(h0[blake2b.Size:], 1) + blake2bHash(block0[:], h0[:]) + for i := range B[j+1] { + B[j+1][i] = binary.LittleEndian.Uint64(block0[i*8:]) + } + } + return B +} + +func processBlocks(B []block, time, memory, threads uint32, mode int) { + lanes := memory / threads + segments := lanes / syncPoints + + processSegment := func(n, slice, lane uint32, wg *sync.WaitGroup) { + var addresses, in, zero block + if mode == argon2i || (mode == argon2id && n == 0 && slice < syncPoints/2) { + in[0] = uint64(n) + in[1] = uint64(lane) + in[2] = uint64(slice) + in[3] = uint64(memory) + in[4] = uint64(time) + in[5] = uint64(mode) + } + + index := uint32(0) + if n == 0 && slice == 0 { + index = 2 // we have already generated the first two blocks + if mode == argon2i || mode == argon2id { + in[6]++ + processBlock(&addresses, &in, &zero) + processBlock(&addresses, &addresses, &zero) + } + } + + offset := lane*lanes + slice*segments + index + var random uint64 + for index < segments { + prev := offset - 1 + if index == 0 && slice == 0 { + prev += lanes // last block in lane + } + if mode == argon2i || (mode == argon2id && n == 0 && slice < syncPoints/2) { + if index%blockLength == 0 { + in[6]++ + processBlock(&addresses, &in, &zero) + processBlock(&addresses, &addresses, &zero) + } + random = addresses[index%blockLength] + } else { + random = B[prev][0] + } + newOffset := indexAlpha(random, lanes, segments, threads, n, slice, lane, index) + processBlockXOR(&B[offset], &B[prev], &B[newOffset]) + index, offset = index+1, offset+1 + } + wg.Done() + } + + for n := uint32(0); n < time; n++ { + for slice := uint32(0); slice < syncPoints; slice++ { + var wg sync.WaitGroup + for lane := uint32(0); lane < threads; lane++ { + wg.Add(1) + go processSegment(n, slice, lane, &wg) + } + wg.Wait() + } + } + +} + +func extractKey(B []block, memory, threads, keyLen uint32) []byte { + lanes := memory / threads + for lane := uint32(0); lane < threads-1; lane++ { + for i, v := range B[(lane*lanes)+lanes-1] { + B[memory-1][i] ^= v + } + } + + var block [1024]byte + for i, v := range B[memory-1] { + binary.LittleEndian.PutUint64(block[i*8:], v) + } + key := make([]byte, keyLen) + blake2bHash(key, block[:]) + return key +} + +func indexAlpha(rand uint64, lanes, segments, threads, n, slice, lane, index uint32) uint32 { + refLane := uint32(rand>>32) % threads + if n == 0 && slice == 0 { + refLane = lane + } + m, s := 3*segments, ((slice+1)%syncPoints)*segments + if lane == refLane { + m += index + } + if n == 0 { + m, s = slice*segments, 0 + if slice == 0 || lane == refLane { + m += index + } + } + if index == 0 || lane == refLane { + m-- + } + return phi(rand, uint64(m), uint64(s), refLane, lanes) +} + +func phi(rand, m, s uint64, lane, lanes uint32) uint32 { + p := rand & 0xFFFFFFFF + p = (p * p) >> 32 + p = (p * m) >> 32 + return lane*lanes + uint32((s+m-(p+1))%uint64(lanes)) +} diff --git a/crypto/belt.go b/crypto/belt.go new file mode 100644 index 0000000..ccdd0a9 --- /dev/null +++ b/crypto/belt.go @@ -0,0 +1,302 @@ +package crypto + +import ( + "fmt" + "math/big" + "math/bits" +) + +const ( + // Base field arithmetic functions. + PRIME uint64 = 18446744069414584321 + PRIME_PRIME uint64 = PRIME - 2 + // R_MOD_P uint64 = 0xFFFF_FFFF; + H uint64 = 20033703337 + ORDER uint64 = 1 << 32 +) + +var ROOTS = []uint64{ + 0x0000000000000001, 0xffffffff00000000, 0x0001000000000000, 0xfffffffeff000001, + 0xefffffff00000001, 0x00003fffffffc000, 0x0000008000000000, 0xf80007ff08000001, + 0xbf79143ce60ca966, 0x1905d02a5c411f4e, 0x9d8f2ad78bfed972, 0x0653b4801da1c8cf, + 0xf2c35199959dfcb6, 0x1544ef2335d17997, 0xe0ee099310bba1e2, 0xf6b2cffe2306baac, + 0x54df9630bf79450e, 0xabd0a6e8aa3d8a0e, 0x81281a7b05f9beac, 0xfbd41c6b8caa3302, + 0x30ba2ecd5e93e76d, 0xf502aef532322654, 0x4b2a18ade67246b5, 0xea9d5a1336fbc98b, + 0x86cdcc31c307e171, 0x4bbaf5976ecfefd8, 0xed41d05b78d6e286, 0x10d78dd8915a171d, + 0x59049500004a4485, 0xdfa8c93ba46d2666, 0x7e9bd009b86a0845, 0x400a7f755588e659, + 0x185629dcda58878c, +} + +var ( + PRIME_128, _ = new(big.Int).SetString("18446744069414584321", 10) + RP, _ = new(big.Int).SetString("340282366841710300967557013911933812736", 10) + R2, _ = new(big.Int).SetString("18446744065119617025", 10) +) + +type Belt struct { + Value uint64 +} + +func BaseCheck(x uint64) bool { + return x < PRIME +} + +func ZeroBelt() Belt { + return Belt{Value: 0} +} + +func OneBelt() Belt { + return Belt{Value: 1} +} + +func (belt *Belt) IsZero() bool { + return belt.Value == 0 +} + +func (belt *Belt) IsOne() bool { + return belt.Value == 1 +} + +func (belt *Belt) OrderedRoot() (Belt, error) { + // Belt(bpow(H, ORDER / self.0)) + log2 := bits.Len(uint(belt.Value)) - 1 + if log2 > len(ROOTS) { + return Belt{}, fmt.Errorf("ordered_root: out of bounds") + } + // assert that it was an even power of two + if (1 << log2) != belt.Value { + return Belt{}, fmt.Errorf("ordered_root: not a power of two") + } + return Belt{Value: ROOTS[log2]}, nil +} + +func (belt *Belt) Inv() Belt { + return Belt{Value: binv(belt.Value)} +} + +func (belt *Belt) Add(other Belt) Belt { + a := belt.Value + b := other.Value + return Belt{Value: badd(a, b)} +} + +func (belt *Belt) Sub(other Belt) Belt { + a := belt.Value + b := other.Value + return Belt{Value: bsub(a, b)} +} + +func (belt *Belt) Neg() Belt { + return Belt{Value: bneg(belt.Value)} +} + +func (belt *Belt) Mul(other Belt) Belt { + a := belt.Value + b := other.Value + return Belt{Value: bmul(a, b)} +} + +func (belt *Belt) Eq(other Belt) bool { + return belt.Value == other.Value +} + +func (belt *Belt) Pow(exp uint64) Belt { + return Belt{Value: bpow(belt.Value, exp)} +} + +func (belt *Belt) Div(other Belt) Belt { + return belt.Mul(other.Inv()) +} + +func binv(a uint64) uint64 { + if !BaseCheck(a) { + fmt.Println("element must be inside the field") + } + y := montify(a) + y2 := montiply(y, montiply(y, y)) + y3 := montiply(y, montiply(y2, y2)) + y5 := montiply(y2, montwopow(y3, 2)) + y10 := montiply(y5, montwopow(y5, 5)) + y20 := montiply(y10, montwopow(y10, 10)) + y30 := montiply(y10, montwopow(y20, 10)) + y31 := montiply(y, montiply(y30, y30)) + dup := montiply(montwopow(y31, 32), y31) + + res := new(big.Int) + res.SetUint64(montiply(y, montiply(dup, dup))) + return montReduction(res) +} + +func badd(a, b uint64) uint64 { + if !BaseCheck(a) || !BaseCheck(b) { + fmt.Println("element must be inside the field") + } + + b = PRIME - b + r, c := overflowingSub(a, b) + + adj := uint32(0) + if c { + adj = adj - 1 + } + return r - uint64(adj) +} + +func bsub(a, b uint64) uint64 { + if !BaseCheck(a) || !BaseCheck(b) { + fmt.Println("element must be inside the field") + } + + r, c := overflowingSub(a, b) + adj := uint32(0) + if c { + adj = adj - 1 + } + + return r - uint64(adj) +} + +func bneg(a uint64) uint64 { + if !BaseCheck(a) { + fmt.Println("element must be inside the field") + } + + if a != 0 { + return PRIME - a + } else { + return 0 + } +} + +func bmul(a, b uint64) uint64 { + if !BaseCheck(a) || !BaseCheck(b) { + fmt.Println("element must be inside the field") + } + aBig := new(big.Int).SetUint64(a) + bBig := new(big.Int).SetUint64(b) + return reduce(aBig.Mul(aBig, bBig)) +} + +func bpow(a, b uint64) uint64 { + if !BaseCheck(a) || !BaseCheck(b) { + fmt.Println("element must be inside the field") + } + c := uint64(1) + if b == 0 { + return c + } + + for b > 1 { + if b&1 == 0 { + a = bmul(a, a) + b >>= 1 + } else { + c = bmul(c, a) + a = bmul(a, a) + b = (b - 1) >> 1 + } + } + + return bmul(a, c) +} + +func overflowingSub(a, b uint64) (uint64, bool) { + res := a - b + overflow := a < b + return res, overflow +} + +func overflowingAdd(a, b uint64) (uint64, bool) { + res := a + b + overflow := res < a || res < b + return res, overflow +} + +func montify(a uint64) uint64 { + if !BaseCheck(a) { + fmt.Println("element must be inside the field") + } + aBig := new(big.Int).SetUint64(a) + return montReduction(aBig.Mul(aBig, R2)) +} + +func montiply(a, b uint64) uint64 { + if !BaseCheck(a) || !BaseCheck(b) { + fmt.Println("element must be inside the field") + } + aBig := new(big.Int).SetUint64(a) + bBig := new(big.Int).SetUint64(b) + return montReduction(aBig.Mul(aBig, bBig)) +} + +func montwopow(a uint64, exp int) uint64 { + if !BaseCheck(a) { + fmt.Println("element must be inside the field") + } + + res := a + for i := 0; i < exp; i++ { + res = montiply(res, res) + } + return res +} +func montReduction(a *big.Int) uint64 { + if a.Cmp(RP) >= 0 { + fmt.Println("element must be inside the field") + } + + x1 := new(big.Int) + x1.And(x1.Rsh(a, 32), new(big.Int).SetUint64(0xFFFFFFFF)) + + x2 := new(big.Int) + x2.Rsh(a, 64) + + x0 := new(big.Int) + x0.And(a, new(big.Int).SetUint64(0xFFFFFFFF)) + + c := new(big.Int) + c.Lsh(x0.Add(x0, x1), 32) + + f := new(big.Int) + f.Rsh(c, 64) + + d := new(big.Int) + d.Sub(c, d.Add(x1, d.Mul(f, PRIME_128))) + if x2.Cmp(d) >= 0 { + ret := new(big.Int) + ret.Sub(x2, d) + return ret.Uint64() + } else { + ret := new(big.Int) + ret.Sub(ret.Add(x2, PRIME_128), d) + return ret.Uint64() + } +} + +func reduce(a *big.Int) uint64 { + low := new(big.Int).And(a, new(big.Int).SetUint64(0xFFFFFFFFFFFFFFFF)) + + mid := new(big.Int) + mid.And(mid.Rsh(a, 64), big.NewInt(0xFFFFFFFF)) + + high := new(big.Int) + high.Rsh(a, 96) + + low2, carry := overflowingSub(low.Uint64(), high.Uint64()) + if carry { + low2 = low2 + PRIME + } + + product := mid.Uint64() << 32 + product -= product >> 32 + + result, carry := overflowingAdd(low2, product) + if carry { + result = result - PRIME + } + + if result >= PRIME { + result -= PRIME + } + return result +} diff --git a/crypto/blake2b.go b/crypto/blake2b.go new file mode 100644 index 0000000..41f6e94 --- /dev/null +++ b/crypto/blake2b.go @@ -0,0 +1,49 @@ +package crypto + +import ( + "encoding/binary" + "hash" + + "golang.org/x/crypto/blake2b" +) + +// blake2bHash computes an arbitrary long hash value of in +// and writes the hash to out. +func blake2bHash(out []byte, in []byte) { + var b2 hash.Hash + if n := len(out); n < blake2b.Size { + b2, _ = blake2b.New(n, nil) + } else { + b2, _ = blake2b.New512(nil) + } + + var buffer [blake2b.Size]byte + binary.LittleEndian.PutUint32(buffer[:4], uint32(len(out))) + b2.Write(buffer[:4]) + b2.Write(in) + + if len(out) <= blake2b.Size { + b2.Sum(out[:0]) + return + } + + outLen := len(out) + b2.Sum(buffer[:0]) + b2.Reset() + copy(out, buffer[:32]) + out = out[32:] + for len(out) > blake2b.Size { + b2.Write(buffer[:]) + b2.Sum(buffer[:0]) + copy(out, buffer[:32]) + out = out[32:] + b2.Reset() + } + + if outLen%blake2b.Size > 0 { // outLen > 64 + r := ((outLen + 31) / 32) - 2 // ⌈τ /32⌉-2 + b2, _ = blake2b.New(outLen-32*r, nil) + } + b2.Write(buffer[:]) + b2.Sum(out[:0]) +} diff --git a/crypto/blamka_generic.go b/crypto/blamka_generic.go new file mode 100644 index 0000000..8a8d61b --- /dev/null +++ b/crypto/blamka_generic.go @@ -0,0 +1,165 @@ +package crypto + +func processBlock(out, in1, in2 *block) { + processBlockGeneric(out, in1, in2, false) +} + +func processBlockXOR(out, in1, in2 *block) { + processBlockGeneric(out, in1, in2, true) +} + +func processBlockGeneric(out, in1, in2 *block, xor bool) { + var t block + for i := range t { + t[i] = in1[i] ^ in2[i] + } + for i := 0; i < blockLength; i += 16 { + blamkaGeneric( + &t[i+0], &t[i+1], &t[i+2], &t[i+3], + &t[i+4], &t[i+5], &t[i+6], &t[i+7], + &t[i+8], &t[i+9], &t[i+10], &t[i+11], + &t[i+12], &t[i+13], &t[i+14], &t[i+15], + ) + } + for i := 0; i < blockLength/8; i += 2 { + blamkaGeneric( + &t[i], &t[i+1], &t[16+i], &t[16+i+1], + &t[32+i], &t[32+i+1], &t[48+i], &t[48+i+1], + &t[64+i], &t[64+i+1], &t[80+i], &t[80+i+1], + &t[96+i], &t[96+i+1], &t[112+i], &t[112+i+1], + ) + } + if xor { + for i := range t { + out[i] ^= in1[i] ^ in2[i] ^ t[i] + } + } else { + for i := range t { + out[i] = in1[i] ^ in2[i] ^ t[i] + } + } +} + +func blamkaGeneric(t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15 *uint64) { + v00, v01, v02, v03 := *t00, *t01, *t02, *t03 + v04, v05, v06, v07 := *t04, *t05, *t06, *t07 + v08, v09, v10, v11 := *t08, *t09, *t10, *t11 + v12, v13, v14, v15 := *t12, *t13, *t14, *t15 + + v00 += v04 + 2*uint64(uint32(v00))*uint64(uint32(v04)) + v12 ^= v00 + v12 = v12>>32 | v12<<32 + v08 += v12 + 2*uint64(uint32(v08))*uint64(uint32(v12)) + v04 ^= v08 + v04 = v04>>24 | v04<<40 + + v00 += v04 + 2*uint64(uint32(v00))*uint64(uint32(v04)) + v12 ^= v00 + v12 = v12>>16 | v12<<48 + v08 += v12 + 2*uint64(uint32(v08))*uint64(uint32(v12)) + v04 ^= v08 + v04 = v04>>63 | v04<<1 + + v01 += v05 + 2*uint64(uint32(v01))*uint64(uint32(v05)) + v13 ^= v01 + v13 = v13>>32 | v13<<32 + v09 += v13 + 2*uint64(uint32(v09))*uint64(uint32(v13)) + v05 ^= v09 + v05 = v05>>24 | v05<<40 + + v01 += v05 + 2*uint64(uint32(v01))*uint64(uint32(v05)) + v13 ^= v01 + v13 = v13>>16 | v13<<48 + v09 += v13 + 2*uint64(uint32(v09))*uint64(uint32(v13)) + v05 ^= v09 + v05 = v05>>63 | v05<<1 + + v02 += v06 + 2*uint64(uint32(v02))*uint64(uint32(v06)) + v14 ^= v02 + v14 = v14>>32 | v14<<32 + v10 += v14 + 2*uint64(uint32(v10))*uint64(uint32(v14)) + v06 ^= v10 + v06 = v06>>24 | v06<<40 + + v02 += v06 + 2*uint64(uint32(v02))*uint64(uint32(v06)) + v14 ^= v02 + v14 = v14>>16 | v14<<48 + v10 += v14 + 2*uint64(uint32(v10))*uint64(uint32(v14)) + v06 ^= v10 + v06 = v06>>63 | v06<<1 + + v03 += v07 + 2*uint64(uint32(v03))*uint64(uint32(v07)) + v15 ^= v03 + v15 = v15>>32 | v15<<32 + v11 += v15 + 2*uint64(uint32(v11))*uint64(uint32(v15)) + v07 ^= v11 + v07 = v07>>24 | v07<<40 + + v03 += v07 + 2*uint64(uint32(v03))*uint64(uint32(v07)) + v15 ^= v03 + v15 = v15>>16 | v15<<48 + v11 += v15 + 2*uint64(uint32(v11))*uint64(uint32(v15)) + v07 ^= v11 + v07 = v07>>63 | v07<<1 + + v00 += v05 + 2*uint64(uint32(v00))*uint64(uint32(v05)) + v15 ^= v00 + v15 = v15>>32 | v15<<32 + v10 += v15 + 2*uint64(uint32(v10))*uint64(uint32(v15)) + v05 ^= v10 + v05 = v05>>24 | v05<<40 + + v00 += v05 + 2*uint64(uint32(v00))*uint64(uint32(v05)) + v15 ^= v00 + v15 = v15>>16 | v15<<48 + v10 += v15 + 2*uint64(uint32(v10))*uint64(uint32(v15)) + v05 ^= v10 + v05 = v05>>63 | v05<<1 + + v01 += v06 + 2*uint64(uint32(v01))*uint64(uint32(v06)) + v12 ^= v01 + v12 = v12>>32 | v12<<32 + v11 += v12 + 2*uint64(uint32(v11))*uint64(uint32(v12)) + v06 ^= v11 + v06 = v06>>24 | v06<<40 + + v01 += v06 + 2*uint64(uint32(v01))*uint64(uint32(v06)) + v12 ^= v01 + v12 = v12>>16 | v12<<48 + v11 += v12 + 2*uint64(uint32(v11))*uint64(uint32(v12)) + v06 ^= v11 + v06 = v06>>63 | v06<<1 + + v02 += v07 + 2*uint64(uint32(v02))*uint64(uint32(v07)) + v13 ^= v02 + v13 = v13>>32 | v13<<32 + v08 += v13 + 2*uint64(uint32(v08))*uint64(uint32(v13)) + v07 ^= v08 + v07 = v07>>24 | v07<<40 + + v02 += v07 + 2*uint64(uint32(v02))*uint64(uint32(v07)) + v13 ^= v02 + v13 = v13>>16 | v13<<48 + v08 += v13 + 2*uint64(uint32(v08))*uint64(uint32(v13)) + v07 ^= v08 + v07 = v07>>63 | v07<<1 + + v03 += v04 + 2*uint64(uint32(v03))*uint64(uint32(v04)) + v14 ^= v03 + v14 = v14>>32 | v14<<32 + v09 += v14 + 2*uint64(uint32(v09))*uint64(uint32(v14)) + v04 ^= v09 + v04 = v04>>24 | v04<<40 + + v03 += v04 + 2*uint64(uint32(v03))*uint64(uint32(v04)) + v14 ^= v03 + v14 = v14>>16 | v14<<48 + v09 += v14 + 2*uint64(uint32(v09))*uint64(uint32(v14)) + v04 ^= v09 + v04 = v04>>63 | v04<<1 + + *t00, *t01, *t02, *t03 = v00, v01, v02, v03 + *t04, *t05, *t06, *t07 = v04, v05, v06, v07 + *t08, *t09, *t10, *t11 = v08, v09, v10, v11 + *t12, *t13, *t14, *t15 = v12, v13, v14, v15 +} diff --git a/crypto/bpoly.go b/crypto/bpoly.go new file mode 100644 index 0000000..0b76020 --- /dev/null +++ b/crypto/bpoly.go @@ -0,0 +1,229 @@ +package crypto + +type Bpoly struct { + Value []Belt +} + +func (p *Bpoly) IsZero() bool { + length := len(p.Value) + if length == 0 { + return true + } + if length == 1 && p.Value[0].IsZero() { + return true + } + + for _, i := range p.Value { + if !i.IsZero() { + return false + } + } + return true + +} + +func (p *Bpoly) Degree() uint32 { + for i := len(p.Value) - 1; i >= 0; i-- { + if !p.Value[i].IsZero() { + return uint32(i) + } + } + return 0 +} + +func (p *Bpoly) Add(other Bpoly) Bpoly { + min := Bpoly{} + max := Bpoly{} + if len(p.Value) <= len(other.Value) { + min = *p + max = other + } else { + min = other + max = *p + } + + res := Bpoly{Value: make([]Belt, len(max.Value))} + for i := range max.Value { + if i < len(min.Value) { + res.Value[i] = min.Value[i].Add(max.Value[i]) + } else { + res.Value[i] = max.Value[i] + } + } + return res +} + +func (p *Bpoly) Sub(other Bpoly) Bpoly { + resLen := len(p.Value) + if len(other.Value) > resLen { + resLen = len(other.Value) + } + res := Bpoly{Value: make([]Belt, resLen)} + + for i := 0; i < resLen; i++ { + if i < len(p.Value) && i < len(other.Value) { + res.Value[i] = p.Value[i].Sub(other.Value[i]) + } else if i < len(p.Value) { + res.Value[i] = p.Value[i] + } else { + res.Value[i] = other.Value[i].Neg() + } + } + return res +} + +func (p *Bpoly) Mul(other Bpoly) Bpoly { + resLen := len(p.Value) + len(other.Value) - 1 + res := Bpoly{Value: make([]Belt, resLen)} + for i := range res.Value { + res.Value[i] = BELT_ZERO + } + + if p.IsZero() || other.IsZero() { + return res + } + + for i := 0; i < len(p.Value); i++ { + if p.Value[i].IsZero() { + continue + } + for j := 0; j < len(other.Value); j++ { + res.Value[i+j] = res.Value[i+j].Add(p.Value[i].Mul(other.Value[j])) + } + } + return res +} + +func (p *Bpoly) ScalarMul(scalar Belt, resLen int) Bpoly { + res := Bpoly{Value: make([]Belt, resLen)} + for i := range res.Value { + res.Value[i] = p.Value[i].Mul(scalar) + } + return res +} + +func Dvr(a Bpoly, b Bpoly) (Bpoly, Bpoly) { + degA := a.Degree() + degB := b.Degree() + + degQ := uint32(0) + if degA >= degB { + degQ = degA - degB + } + + lenQ := degQ + 1 + lenR := degB + 1 + q := Bpoly{Value: make([]Belt, lenQ)} + res := Bpoly{Value: make([]Belt, lenR)} + + for i := range q.Value { + q.Value[i] = BELT_ZERO + } + for i := range res.Value { + res.Value[i] = BELT_ZERO + } + if a.IsZero() { + return q, res + } else if b.IsZero() { + panic("division by zero") + } + + r := a + i := degA + degR := degA + qIdx := degQ + for degR >= degB { + coeff := r.Value[i].Div(b.Value[degB]) + q.Value[qIdx] = coeff + for k := 0; k <= int(degB); k++ { + if k <= int(degA) && k < len(b.Value) && k <= int(i) { + r.Value[i-uint32(k)] = r.Value[i-uint32(k)].Sub(coeff.Mul(b.Value[degB-uint32(k)])) + } + } + if degR >= 1 { + degR-- + } + if qIdx >= 1 { + qIdx-- + } + if degR == 0 && r.Value[0].IsZero() { + break + } + i-- + } + + rLen := int(degR) + 1 + for i := 0; i < rLen; i++ { + res.Value[i] = r.Value[i] + } + return q, res +} + +func Egcd(a Bpoly, b Bpoly) (Bpoly, Bpoly, Bpoly) { + m1u := Bpoly{Value: []Belt{BELT_ZERO}} + m2u := Bpoly{Value: []Belt{BELT_ONE}} + m1v := Bpoly{Value: []Belt{BELT_ONE}} + m2v := Bpoly{Value: []Belt{BELT_ZERO}} + + // length of d is at most min(len a, len b) + 1 + dLen := min(len(a.Value), len(b.Value)) + 1 + // length of u is at most deg(b) + uLen := b.Degree() + // length of u is at most deg(a) + vLen := a.Degree() + + d := Bpoly{Value: make([]Belt, dLen)} + u := Bpoly{Value: make([]Belt, uLen)} + v := Bpoly{Value: make([]Belt, vLen)} + + for i := range d.Value { + d.Value[i] = BELT_ZERO + } + for i := range u.Value { + u.Value[i] = BELT_ZERO + } + for i := range v.Value { + v.Value[i] = BELT_ZERO + } + + aCopy := a + bCopy := b + + for !bCopy.IsZero() { + degQ := uint32(0) + if aCopy.Degree() >= bCopy.Degree() { + degQ = aCopy.Degree() - bCopy.Degree() + } + qLen := degQ + 1 + rLen := bCopy.Degree() + 1 + q := Bpoly{Value: make([]Belt, qLen)} + r := Bpoly{Value: make([]Belt, rLen)} + for i := range q.Value { + q.Value[i] = BELT_ZERO + } + for i := range r.Value { + r.Value[i] = BELT_ZERO + } + + q, r = Dvr(aCopy, bCopy) + aCopy = bCopy + bCopy = r + + res1 := q.Mul(m1u) + res2 := m2u.Sub(res1) + + m2u = m1u + m1u = res2 + + res1 = q.Mul(m1v) + res3 := m2v.Sub(res1) + + m2v = m1v + m1v = res3 + } + + d.Value = aCopy.Value + u.Value = m2u.Value + v.Value = m2v.Value + return d, u, v +} diff --git a/crypto/cheetah.go b/crypto/cheetah.go new file mode 100644 index 0000000..3e45628 --- /dev/null +++ b/crypto/cheetah.go @@ -0,0 +1,308 @@ +package crypto + +import ( + "encoding/binary" + "fmt" + "math/big" + "slices" +) + +var ( + BELT_ZERO = Belt{Value: 0} + BELT_ONE = Belt{Value: 1} + F6_ZERO = [6]Belt{BELT_ZERO, BELT_ZERO, BELT_ZERO, BELT_ZERO, BELT_ZERO, BELT_ZERO} + F6_ONE = [6]Belt{BELT_ONE, BELT_ZERO, BELT_ZERO, BELT_ZERO, BELT_ZERO, BELT_ZERO} + A_ID = CheetahPoint{ + X: F6_ZERO, + Y: F6_ONE, + Inf: true, + } + A_GEN = CheetahPoint{ + X: [6]Belt{ + {Value: 2754611494552410273}, + {Value: 8599518745794843693}, + {Value: 10526511002404673680}, + {Value: 4830863958577994148}, + {Value: 375185138577093320}, + {Value: 12938930721685970739}, + }, + Y: [6]Belt{ + {Value: 15384029202802550068}, + {Value: 2774812795997841935}, + {Value: 14375303400746062753}, + {Value: 10708493419890101954}, + {Value: 13187678623570541764}, + {Value: 9990732138772505951}, + }, + Inf: false, + } + + P_BIG = new(big.Int).SetUint64(PRIME) + P_BIG_2 = new(big.Int).Mul(P_BIG, P_BIG) + P_BIG_3 = new(big.Int).Mul(P_BIG_2, P_BIG) + + G_ORDER, _ = new(big.Int).SetString("55610362957290864006699123731285679659474893560816383126640993521607086746831", 10) +) + +type CheetahPoint struct { + X, Y [6]Belt + Inf bool +} + +func (p *CheetahPoint) Bytes() []byte { + bytes := []byte{0x1} + for i := 5; i >= 0; i-- { + belt := p.Y[i].Value + buf := make([]byte, 8) + binary.BigEndian.PutUint64(buf, belt) + bytes = append(bytes, buf...) + } + + for i := 5; i >= 0; i-- { + belt := p.X[i].Value + buf := make([]byte, 8) + binary.BigEndian.PutUint64(buf, belt) + bytes = append(bytes, buf...) + } + return bytes +} + +func CheetaPointFromBytes(bytes []byte) (CheetahPoint, error) { + if len(bytes) != 97 { + return CheetahPoint{}, fmt.Errorf("invalid point length %d, length must be 97", len(bytes)) + } + bytes = bytes[1:] + + if len(bytes)%8 != 0 { + return CheetahPoint{}, fmt.Errorf("input length not multiple of 8") + } + + n := len(bytes) / 8 + belts := []Belt{} + + for i := 0; i < n; i++ { + chunk := bytes[i*8 : (i+1)*8] + belt := binary.BigEndian.Uint64(chunk) + belts = append(belts, Belt{Value: belt}) + } + + slices.Reverse(belts) + point := CheetahPoint{ + X: [6]Belt(belts[0:6]), + Y: [6]Belt(belts[6:]), + Inf: false, + } + if point.InCurve() { + return point, nil + } + return CheetahPoint{}, fmt.Errorf("point not in curve") +} +func (p *CheetahPoint) InCurve() bool { + if *p == A_ID { + return true + } + + scaled := CheetahScaleBig(*p, *G_ORDER) + return scaled == A_ID +} + +func CheetahScaleBig(p CheetahPoint, n big.Int) CheetahPoint { + zero := big.NewInt(0) + nCopy := new(big.Int).Set(&n) + acc := A_ID + + for nCopy.Cmp(zero) > 0 { + if nCopy.Bit(0) == 1 { + acc = CheetahAdd(acc, p) + } + p = CheetahDouble(p) + nCopy.Rsh(nCopy, 1) + } + return acc +} + +func CheetahAdd(p, q CheetahPoint) CheetahPoint { + if p.Inf { + return q + } + + if q.Inf { + return p + } + + if p == CheetahNeg(q) { + return A_ID + } + + if p == q { + return CheetahDouble(p) + } + + return cheetahAddUnsafe(&p, &q) +} + +func CheetahNeg(p CheetahPoint) CheetahPoint { + negP := p + for i := 0; i < 6; i++ { + negP.Y[i] = p.Y[i].Neg() + } + return negP +} + +func CheetahDouble(p CheetahPoint) CheetahPoint { + if p.Inf { + return A_ID + } + if p.Y == F6_ZERO { + return A_ID + } + return cheetahDoubleUnsafe(&p) +} + +func cheetahAddUnsafe(p, q *CheetahPoint) CheetahPoint { + slope := f6Mul(f6Sub(p.Y, q.Y), f6Inv(f6Sub(p.X, q.X))) + xOut := f6Sub(f6Square(slope), f6Add(p.X, q.X)) + yOut := f6Sub(f6Mul(slope, f6Sub(p.X, xOut)), p.Y) + return CheetahPoint{ + X: xOut, + Y: yOut, + Inf: false, + } +} + +func cheetahDoubleUnsafe(p *CheetahPoint) CheetahPoint { + slope := f6Mul( + f6Add(f6ScalarMul(f6Square(p.X), Belt{Value: 3}), F6_ONE), + f6Inv(f6ScalarMul(p.Y, Belt{Value: 2})), + ) + xOut := f6Sub(f6Square(slope), f6ScalarMul(p.X, Belt{Value: 2})) + yOut := f6Sub(f6Mul(slope, f6Sub(p.X, xOut)), p.Y) + return CheetahPoint{ + X: xOut, + Y: yOut, + Inf: false, + } +} + +func f6Inv(a [6]Belt) [6]Belt { + if a == F6_ZERO { + panic("Cannot invert zero") + } + + aPoly := Bpoly{Value: a[:]} + + b := Bpoly{ + Value: []Belt{ + Belt{Value: bneg(7)}, + BELT_ZERO, + BELT_ZERO, + BELT_ZERO, + BELT_ZERO, + BELT_ZERO, + BELT_ONE, + }, + } + + d, u, _ := Egcd(aPoly, b) + dInv := d.Value[0].Inv() + res := u.ScalarMul(dInv, 6) + return [6]Belt{res.Value[0], res.Value[1], res.Value[2], res.Value[3], res.Value[4], res.Value[5]} +} + +func f6Mul(a, b [6]Belt) [6]Belt { + a0b0 := karat3([3]Belt{a[0], a[1], a[2]}, [3]Belt{b[0], b[1], b[2]}) + a1b1 := karat3([3]Belt{a[3], a[4], a[5]}, [3]Belt{b[3], b[4], b[5]}) + + foil := karat3( + [3]Belt{a[0].Add(a[3]), a[1].Add(a[4]), a[2].Add(a[5])}, + [3]Belt{b[0].Add(b[3]), b[1].Add(b[4]), b[2].Add(b[5])}, + ) + + foil_0 := foil[0].Sub(a0b0[0]) + foil_1 := foil[1].Sub(a0b0[1]) + foil_2 := foil[2].Sub(a0b0[2]) + foil_3 := foil[3].Sub(a0b0[3]) + foil_4 := foil[4].Sub(a0b0[4]) + cross := [5]Belt{ + foil_0.Sub(a1b1[0]), + foil_1.Sub(a1b1[1]), + foil_2.Sub(a1b1[2]), + foil_3.Sub(a1b1[3]), + foil_4.Sub(a1b1[4]), + } + + seven := Belt{Value: 7} + a0b0cross0 := a0b0[3].Add(cross[0]) + a0b0cross1 := a0b0[4].Add(cross[1]) + return [6]Belt{ + a0b0[0].Add(seven.Mul(cross[3].Add(a1b1[0]))), + a0b0[1].Add(seven.Mul(cross[4].Add(a1b1[1]))), + a0b0[2].Add(seven.Mul(a1b1[2])), + a0b0cross0.Add(seven.Mul(a1b1[3])), + a0b0cross1.Add(seven.Mul(a1b1[4])), + cross[2], + } +} + +func f6ScalarMul(a [6]Belt, scalar Belt) [6]Belt { + res := F6_ZERO + for i := range res { + res[i] = a[i].Mul(scalar) + } + return res +} + +func f6Add(a, b [6]Belt) [6]Belt { + res := F6_ZERO + for i := range res { + res[i] = a[i].Add(b[i]) + } + return res +} + +func f6Sub(a, b [6]Belt) [6]Belt { + return f6Add(a, f6Neg(b)) +} + +func f6Neg(a [6]Belt) [6]Belt { + res := F6_ZERO + for i := range res { + res[i] = a[i].Neg() + } + return res +} + +func f6Square(a [6]Belt) [6]Belt { + return f6Mul(a, a) +} + +func karat3(a, b [3]Belt) [5]Belt { + m := [3]Belt{ + a[0].Mul(b[0]), + a[1].Mul(b[1]), + a[2].Mul(b[2]), + } + + a0a1 := a[0].Add(a[1]) + b0b1 := b[0].Add(b[1]) + m0m1 := m[0].Add(m[1]) + a0a1b0b1 := a0a1.Mul(b0b1) + + a0a2 := a[0].Add(a[2]) + b0b2 := b[0].Add(b[2]) + m0m2 := m[0].Add(m[2]) + m0m2m1 := m0m2.Sub(m[1]) + a0a2b0b2 := a0a2.Mul(b0b2) + + a1a2 := a[1].Add(a[2]) + b1b2 := b[1].Add(b[2]) + m1m2 := m[1].Add(m[2]) + a1a2b1b2 := a1a2.Mul(b1b2) + return [5]Belt{ + m[0], + a0a1b0b1.Sub(m0m1), + a0a2b0b2.Sub(m0m2m1), + a1a2b1b2.Sub(m1m2), + m[2], + } +} diff --git a/crypto/master_key.go b/crypto/master_key.go new file mode 100644 index 0000000..2265634 --- /dev/null +++ b/crypto/master_key.go @@ -0,0 +1,220 @@ +package crypto + +import ( + "crypto/hmac" + "crypto/sha256" + "crypto/sha512" + "encoding/binary" + "fmt" + "math/big" + + "github.com/cosmos/go-bip39" +) + +var ( + DomainSeparator = []byte("Nockchain seed") + PrivateKeyStart = []byte{4, 178, 67, 11} + PublicKeyStart = []byte{234, 230, 92} + 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} + Tip5Zero = [5]uint64{1730770831742798981, 2676322185709933211, 8329210750824781744, 16756092452590401876, 3547445316740171466} + Tip5One = [5]uint64{6727110957294540849, 15606243244732609007, 11887284596344881785, 10646863421881571398, 8146872807338919620} + Tip5ZeroZero = [5]uint64{4372149332062030091, 17876920912185183887, 13348798570422431948, 8872865212694716527, 3385176510443841516} +) + +type MasterKey struct { + PrivateKey []byte + PublicKey []byte + ChainCode []byte +} + +func (m *MasterKey) DeriveChild(index uint64) (MasterKey, error) { + idxBytes := make([]byte, 4) + binary.BigEndian.PutUint32(idxBytes, uint32(index)) + if len(m.PrivateKey) == 0 { + // Derive public key to child + if index > 1<<31 { + return MasterKey{}, fmt.Errorf("public keys can't be hardened") + } + data := m.PublicKey + data = append(data, idxBytes...) + + hash := hmac.New(sha512.New, m.ChainCode) + hash.Write(data) + hashed := hash.Sum(nil) + left := hashed[:32] + right := hashed[32:] + leftBigInt := new(big.Int).SetBytes(left) + + pkPoint, err := CheetaPointFromBytes(m.PublicKey) + if err != nil { + return MasterKey{}, err + } + + keyPoint := CheetahAdd(CheetahScaleBig(A_GEN, *leftBigInt), pkPoint) + for { + if leftBigInt.Cmp(G_ORDER) < 0 { + break + } else { + data = []byte{0x01} + data = append(data, right...) + data = append(data, idxBytes...) + + hash := hmac.New(sha512.New, m.ChainCode) + hash.Write(data) + hashed = hash.Sum(nil) + left = hashed[:32] + right = hashed[32:] + + leftBigInt = new(big.Int).SetBytes(left) + keyPoint = CheetahAdd(CheetahScaleBig(A_GEN, *leftBigInt), pkPoint) + + } + } + return MasterKey{ + PrivateKey: []byte{}, + PublicKey: keyPoint.Bytes(), + ChainCode: right, + }, nil + } else { + hash := hmac.New(sha512.New, m.ChainCode) + var data []byte + if index > 1<<31 { + // hardened + data = []byte{0x00} + data = append(data, m.PrivateKey...) + + data = append(data, idxBytes...) + } else { + data = m.PublicKey + data = append(data, idxBytes...) + } + hash.Write(data) + hashed := hash.Sum(nil) + left := hashed[:32] + right := hashed[32:] + + leftBigInt := new(big.Int).SetBytes(left) + privBigInt := new(big.Int).SetBytes(m.PrivateKey) + sum := new(big.Int).Add(leftBigInt, privBigInt) + keyBigInt := new(big.Int).Mod(sum, G_ORDER) + for { + if leftBigInt.Cmp(G_ORDER) < 0 { + break + } else { + data = []byte{0x01} + data = append(data, right...) + data = append(data, idxBytes...) + + hash := hmac.New(sha512.New, m.ChainCode) + hash.Write(data) + hashed = hash.Sum(nil) + left = hashed[:32] + right = hashed[32:] + + leftBigInt = new(big.Int).SetBytes(left) + sum = new(big.Int).Add(leftBigInt, privBigInt) + keyBigInt = new(big.Int).Mod(sum, G_ORDER) + } + } + + pkPoint := CheetahScaleBig(A_GEN, *keyBigInt) + return MasterKey{ + PrivateKey: keyBigInt.Bytes(), + PublicKey: pkPoint.Bytes(), + ChainCode: right, + }, nil + } +} + +func MasterKeyFromSeed(seed string) (*MasterKey, error) { + seedBytes, err := bip39.NewSeedWithErrorChecking(seed, "") + if err != nil { + return nil, fmt.Errorf("failed to parse seed: %v", err) + } + hash := hmac.New(sha512.New, DomainSeparator) + hash.Write(seedBytes) + hashedSeed := hash.Sum(nil) + + left := hashedSeed[:32] + right := hashedSeed[32:] + + leftBigInt := new(big.Int).SetBytes(left) + for { + if leftBigInt.Cmp(G_ORDER) < 0 { + break + } else { + hash := hmac.New(sha512.New, DomainSeparator) + hash.Write(hashedSeed) + hashedSeed = hash.Sum(nil) + left = hashedSeed[:32] + right = hashedSeed[32:] + + leftBigInt = new(big.Int).SetBytes(left) + } + } + + pkPoint := CheetahScaleBig(A_GEN, *leftBigInt) + return &MasterKey{ + PrivateKey: left, + PublicKey: pkPoint.Bytes(), + ChainCode: right, + }, nil +} + +func MasterKeyFromPrivKey(chainCode, key []byte) (*MasterKey, error) { + keyBigInt := new(big.Int).SetBytes(key) + pkPoint := CheetahScaleBig(A_GEN, *keyBigInt) + + return &MasterKey{ + PrivateKey: key, + PublicKey: pkPoint.Bytes(), + ChainCode: chainCode, + }, nil +} + +func PrivKeyToT8(data []byte) [8]uint64 { + dataBigInt := new(big.Int).SetBytes(data) + res := rip(*dataBigInt) + return [8]uint64(res) +} + +func BigIntToT8(data big.Int) [8]uint64 { + res := rip(data) + return [8]uint64(res) +} +func SerializeExtend(chainCode []byte, key []byte, version []byte) []byte { + data := version + // dep: depth in chain + // idx: index at depth + // pf: parent fingerprint + depth := 0 + idx := []byte{0, 0, 0, 0} + pf := []byte{0, 0, 0, 0} + data = append(data, byte(depth%256)) + data = append(data, pf...) + data = append(data, idx...) + data = append(data, chainCode...) + data = append(data, key...) + return AddChecksum(data) +} +func AddChecksum(data []byte) []byte { + hash1 := sha256.Sum256(data) + hash2 := sha256.Sum256(hash1[:]) + + checksum := hash2[:4] + data = append(data, checksum...) + + return data +} + +func rip(b big.Int) []uint64 { + if b.Cmp(big.NewInt(0)) == 0 { + return []uint64{} + } + res := []uint64{new(big.Int).And(&b, big.NewInt(0xFFFFFFFF)).Uint64()} + rsh := new(big.Int) + rsh.Div(&b, big.NewInt(4294967296)) + res = append(res, rip(*rsh)...) + return res +} diff --git a/crypto/tip5.go b/crypto/tip5.go new file mode 100644 index 0000000..df27761 --- /dev/null +++ b/crypto/tip5.go @@ -0,0 +1,301 @@ +package crypto + +import ( + "encoding/binary" + "fmt" + "math/big" + + "github.com/btcsuite/btcd/btcutil/base58" +) + +const ( + DIGEST_LENGTH = 5 + STATE_SIZE = 16 + NUM_SPLIT_AND_LOOKUP = 4 + LOG2_STATE_SIZE = 4 + CAPACITY = 6 + RATE = 10 + NUM_ROUNDS = 7 + R_MOD_P uint64 = 4294967295 +) + +var ( + R, _ = new(big.Int).SetString("18446744073709551616", 10) + LOOKUP_TABLE = [256]uint8{ + 0, 7, 26, 63, 124, 215, 85, 254, 214, 228, 45, 185, 140, 173, 33, 240, 29, 177, 176, 32, 8, + 110, 87, 202, 204, 99, 150, 106, 230, 14, 235, 128, 213, 239, 212, 138, 23, 130, 208, 6, 44, + 71, 93, 116, 146, 189, 251, 81, 199, 97, 38, 28, 73, 179, 95, 84, 152, 48, 35, 119, 49, 88, + 242, 3, 148, 169, 72, 120, 62, 161, 166, 83, 175, 191, 137, 19, 100, 129, 112, 55, 221, 102, + 218, 61, 151, 237, 68, 164, 17, 147, 46, 234, 203, 216, 22, 141, 65, 57, 123, 12, 244, 54, 219, + 231, 96, 77, 180, 154, 5, 253, 133, 165, 98, 195, 205, 134, 245, 30, 9, 188, 59, 142, 186, 197, + 181, 144, 92, 31, 224, 163, 111, 74, 58, 69, 113, 196, 67, 246, 225, 10, 121, 50, 60, 157, 90, + 122, 2, 250, 101, 75, 178, 159, 24, 36, 201, 11, 243, 132, 198, 190, 114, 233, 39, 52, 21, 209, + 108, 238, 91, 187, 18, 104, 194, 37, 153, 34, 200, 143, 126, 155, 236, 118, 64, 80, 172, 89, + 94, 193, 135, 183, 86, 107, 252, 13, 167, 206, 136, 220, 207, 103, 171, 160, 76, 182, 227, 217, + 158, 56, 174, 4, 66, 109, 139, 162, 184, 211, 249, 47, 125, 232, 117, 43, 16, 42, 127, 20, 241, + 25, 149, 105, 156, 51, 53, 168, 145, 247, 223, 79, 78, 226, 15, 222, 82, 115, 70, 210, 27, 41, + 1, 170, 40, 131, 192, 229, 248, 255, + } + + ROUND_CONSTANTS = [NUM_ROUNDS * STATE_SIZE]uint64{ + // 1st round constants + 1332676891236936200, 16607633045354064669, 12746538998793080786, 15240351333789289931, + 10333439796058208418, 986873372968378050, 153505017314310505, 703086547770691416, + 8522628845961587962, 1727254290898686320, 199492491401196126, 2969174933639985366, + 1607536590362293391, 16971515075282501568, 15401316942841283351, 14178982151025681389, + // 2nd round constants + 2916963588744282587, 5474267501391258599, 5350367839445462659, 7436373192934779388, + 12563531800071493891, 12265318129758141428, 6524649031155262053, 1388069597090660214, + 3049665785814990091, 5225141380721656276, 10399487208361035835, 6576713996114457203, + 12913805829885867278, 10299910245954679423, 12980779960345402499, 593670858850716490, + // 3rd round constants + 12184128243723146967, 1315341360419235257, 9107195871057030023, 4354141752578294067, + 8824457881527486794, 14811586928506712910, 7768837314956434138, 2807636171572954860, + 9487703495117094125, 13452575580428891895, 14689488045617615844, 16144091782672017853, + 15471922440568867245, 17295382518415944107, 15054306047726632486, 5708955503115886019, + // 4th round constants + 9596017237020520842, 16520851172964236909, 8513472793890943175, 8503326067026609602, + 9402483918549940854, 8614816312698982446, 7744830563717871780, 14419404818700162041, + 8090742384565069824, 15547662568163517559, 17314710073626307254, 10008393716631058961, + 14480243402290327574, 13569194973291808551, 10573516815088946209, 15120483436559336219, + // 5th round constants + 3515151310595301563, 1095382462248757907, 5323307938514209350, 14204542692543834582, + 12448773944668684656, 13967843398310696452, 14838288394107326806, 13718313940616442191, + 15032565440414177483, 13769903572116157488, 17074377440395071208, 16931086385239297738, + 8723550055169003617, 590842605971518043, 16642348030861036090, 10708719298241282592, + // 6th round constants + 12766914315707517909, 11780889552403245587, 113183285481780712, 9019899125655375514, + 3300264967390964820, 12802381622653377935, 891063765000023873, 15939045541699412539, + 3240223189948727743, 4087221142360949772, 10980466041788253952, 18199914337033135244, + 7168108392363190150, 16860278046098150740, 13088202265571714855, 4712275036097525581, + // 7th round constants + 16338034078141228133, 1455012125527134274, 5024057780895012002, 9289161311673217186, + 9401110072402537104, 11919498251456187748, 4173156070774045271, 15647643457869530627, + 15642078237964257476, 1405048341078324037, 3059193199283698832, 1605012781983592984, + 7134876918849821827, 5796994175286958720, 7251651436095127661, 4565856221886323991, + } + MDS_MATRIX = [STATE_SIZE][STATE_SIZE]uint64{ + { + 61402, 17845, 26798, 59689, 12021, 40901, 41351, 27521, 56951, 12034, 53865, 43244, 7454, + 33823, 28750, 1108, + }, + { + 1108, 61402, 17845, 26798, 59689, 12021, 40901, 41351, 27521, 56951, 12034, 53865, 43244, + 7454, 33823, 28750, + }, + { + 28750, 1108, 61402, 17845, 26798, 59689, 12021, 40901, 41351, 27521, 56951, 12034, 53865, + 43244, 7454, 33823, + }, + { + 33823, 28750, 1108, 61402, 17845, 26798, 59689, 12021, 40901, 41351, 27521, 56951, 12034, + 53865, 43244, 7454, + }, + { + 7454, 33823, 28750, 1108, 61402, 17845, 26798, 59689, 12021, 40901, 41351, 27521, 56951, + 12034, 53865, 43244, + }, + { + 43244, 7454, 33823, 28750, 1108, 61402, 17845, 26798, 59689, 12021, 40901, 41351, 27521, + 56951, 12034, 53865, + }, + { + 53865, 43244, 7454, 33823, 28750, 1108, 61402, 17845, 26798, 59689, 12021, 40901, 41351, + 27521, 56951, 12034, + }, + { + 12034, 53865, 43244, 7454, 33823, 28750, 1108, 61402, 17845, 26798, 59689, 12021, 40901, + 41351, 27521, 56951, + }, + { + 56951, 12034, 53865, 43244, 7454, 33823, 28750, 1108, 61402, 17845, 26798, 59689, 12021, + 40901, 41351, 27521, + }, + { + 27521, 56951, 12034, 53865, 43244, 7454, 33823, 28750, 1108, 61402, 17845, 26798, 59689, + 12021, 40901, 41351, + }, + { + 41351, 27521, 56951, 12034, 53865, 43244, 7454, 33823, 28750, 1108, 61402, 17845, 26798, + 59689, 12021, 40901, + }, + { + 40901, 41351, 27521, 56951, 12034, 53865, 43244, 7454, 33823, 28750, 1108, 61402, 17845, + 26798, 59689, 12021, + }, + { + 12021, 40901, 41351, 27521, 56951, 12034, 53865, 43244, 7454, 33823, 28750, 1108, 61402, + 17845, 26798, 59689, + }, + { + 59689, 12021, 40901, 41351, 27521, 56951, 12034, 53865, 43244, 7454, 33823, 28750, 1108, + 61402, 17845, 26798, + }, + { + 26798, 59689, 12021, 40901, 41351, 27521, 56951, 12034, 53865, 43244, 7454, 33823, 28750, + 1108, 61402, 17845, + }, + { + 17845, 26798, 59689, 12021, 40901, 41351, 27521, 56951, 12034, 53865, 43244, 7454, 33823, + 28750, 1108, 61402, + }, + } + INIT_SPONGE = [16]uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + INIT_SPONGE_FIX = [16]uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295} +) + +func Tip5HashBelts(input []Belt) [5]uint64 { + inputLen := len(input) + q := inputLen / RATE + r := inputLen % RATE + + for i := range input { + if !BaseCheck(input[i].Value) { + fmt.Printf("element %d must be inside the field\n", i) + } + input[i].Value = montify(input[i].Value) + } + + input = append(input, Belt{Value: montify(1)}) + for i := 0; i < (RATE-r)-1; i++ { + input = append(input, Belt{Value: montify(0)}) + } + + sponge := INIT_SPONGE + inputAbsorb := input + cntQ := q + for { + scagInput := inputAbsorb[:RATE] + slagInput := inputAbsorb[RATE:] + for i := 0; i < RATE; i++ { + sponge[i] = scagInput[i].Value + } + sponge = permute(sponge) + + if cntQ == 0 { + break + } + + cntQ-- + inputAbsorb = slagInput + } + + digest := [DIGEST_LENGTH]uint64{0, 0, 0, 0, 0} + for i := 0; i < DIGEST_LENGTH; i++ { + digest[i] = montReduction(new(big.Int).SetUint64(sponge[i])) + } + return digest +} + +func Tip5HashTenCell(input []Belt) [5]uint64 { + inputLen := len(input) + q := inputLen / RATE + r := inputLen % RATE + if q != 1 || r != 0 { + panic("input is not 10 cell") + } + + for i := range input { + if !BaseCheck(input[i].Value) { + fmt.Printf("element %d must be inside the field\n", i) + } + input[i].Value = montify(input[i].Value) + } + + sponge := INIT_SPONGE_FIX + for i := 0; i < RATE; i++ { + sponge[i] = input[i].Value + } + sponge = permute(sponge) + digest := [DIGEST_LENGTH]uint64{0, 0, 0, 0, 0} + for i := 0; i < DIGEST_LENGTH; i++ { + digest[i] = montReduction(new(big.Int).SetUint64(sponge[i])) + } + return digest +} + +func Tip5RehashTenCell(hash1 [5]uint64, hash2 [5]uint64) [5]uint64 { + belts := []Belt{} + for _, i := range hash1 { + belts = append(belts, Belt{Value: i}) + } + for _, i := range hash2 { + belts = append(belts, Belt{Value: i}) + } + return Tip5HashTenCell(belts) +} + +func permute(sponge [16]uint64) [16]uint64 { + res := sponge + for i := 0; i < NUM_ROUNDS; i++ { + a := sboxLayer(res) + b := linearLayer(a) + + for j := 0; j < STATE_SIZE; j++ { + roundConst := new(big.Int).SetUint64(ROUND_CONSTANTS[i*STATE_SIZE+j]) + product := new(big.Int).Mul(roundConst, R) + roundConst = roundConst.Mod(product, PRIME_128) + res[j] = badd(roundConst.Uint64(), b[j]) + } + } + return res +} + +func Tip5HashToBase58(hash [5]uint64) string { + result := big.NewInt(0) + + for i, value := range hash { + result.Add(result, new(big.Int).Mul(new(big.Int).SetUint64(value), new(big.Int).Exp(PRIME_128, big.NewInt(int64(i)), nil))) + } + return base58.Encode(result.Bytes()) +} + +func Base58ToTip5Hash(data string) [5]uint64 { + dataBigInt := new(big.Int).SetBytes(base58.Decode(data)) + result := [5]uint64{} + for i := 0; i < 5; i++ { + resultBigInt := new(big.Int) + result[i] = resultBigInt.Mod(dataBigInt, PRIME_128).Uint64() + dataBigInt.Div(dataBigInt, PRIME_128) + } + return result +} + +func TruncGOrder(a [5]uint64) *big.Int { + dataBigInt := new(big.Int).SetUint64(a[0]) + dataBigInt.Add(dataBigInt, new(big.Int).Mul(P_BIG, new(big.Int).SetUint64(a[1]))) + dataBigInt.Add(dataBigInt, new(big.Int).Mul(P_BIG_2, new(big.Int).SetUint64(a[2]))) + dataBigInt.Add(dataBigInt, new(big.Int).Mul(P_BIG_3, new(big.Int).SetUint64(a[3]))) + + return dataBigInt.Mod(dataBigInt, G_ORDER) +} +func sboxLayer(state [16]uint64) [16]uint64 { + res := INIT_SPONGE + for i := 0; i < NUM_SPLIT_AND_LOOKUP; i++ { + bytes := make([]byte, 8) + binary.LittleEndian.PutUint64(bytes, state[i]) + + for j := 0; j < 8; j++ { + bytes[j] = LOOKUP_TABLE[bytes[j]] + } + + res[i] = binary.LittleEndian.Uint64(bytes) + } + + for i := NUM_SPLIT_AND_LOOKUP; i < STATE_SIZE; i++ { + res[i] = bpow(state[i], 7) + } + return res +} + +func linearLayer(state [16]uint64) [16]uint64 { + res := INIT_SPONGE + for i := 0; i < 16; i++ { + for j := 0; j < 16; j++ { + matrixElement := MDS_MATRIX[i][j] + product := bmul(matrixElement, state[j]) + res[i] = badd(res[i], product) + } + } + return res +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5a310c3 --- /dev/null +++ b/go.mod @@ -0,0 +1,18 @@ +module github.com/phamminh0811/private-grpc + +go 1.24.5 + +require ( + github.com/btcsuite/btcd/btcutil v1.1.6 + github.com/cosmos/go-bip39 v1.0.0 + golang.org/x/crypto v0.39.0 + google.golang.org/grpc v1.75.1 + google.golang.org/protobuf v1.36.9 +) + +require ( + golang.org/x/net v0.41.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.26.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ca2144c --- /dev/null +++ b/go.sum @@ -0,0 +1,151 @@ +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= +github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= +github.com/btcsuite/btcd v0.24.2/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= +github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= +github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= +github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= +github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= +github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= +go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= +go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= +go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= +go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= +go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= +go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= +go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= +go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= +go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= +golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= +golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 h1:pFyd6EwwL2TqFf8emdthzeX+gZE1ElRq3iM8pui4KBY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI= +google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw= +google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go new file mode 100644 index 0000000..5c703d2 --- /dev/null +++ b/main.go @@ -0,0 +1,33 @@ +package main + +import ( + "log" + "net" + + "github.com/phamminh0811/private-grpc/nockchain" + "github.com/phamminh0811/private-grpc/wallet" + "google.golang.org/grpc" +) + +func main() { + nc, err := wallet.NewNockchainClient("nockchain-api.zorp.io:443") + if err != nil { + panic(err) + } + + // TODO: read key from env + handler := wallet.NewGprcHandler(*nc) + server := grpc.NewServer() + + nockchain.RegisterWalletServiceServer(server, &handler) + + lis, err := net.Listen("tcp", ":50051") + if err != nil { + log.Fatalf("failed to listen: %v", err) + } + + log.Println("gRPC server started on :50051") + if err := server.Serve(lis); err != nil { + log.Fatalf("failed to serve: %v", err) + } +} diff --git a/nockchain/blockchain.pb.go b/nockchain/blockchain.pb.go new file mode 100644 index 0000000..adde804 --- /dev/null +++ b/nockchain/blockchain.pb.go @@ -0,0 +1,1386 @@ +// nockchain/common/v1/blockchain.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.9 +// protoc v3.20.3 +// source: blockchain.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 WalletBalanceData struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Page of full UTXO entries for the requested wallet. Entries are ordered + // by (Name.first, Name.last) to support consistent pagination. + Notes []*BalanceEntry `protobuf:"bytes,1,rep,name=notes,proto3" json:"notes,omitempty"` // note name -> amount + // Snapshot metadata where this page was computed. Clients should include + // the returned page token to continue paging against the same snapshot. + Height *BlockHeight `protobuf:"bytes,2,opt,name=height,proto3" json:"height,omitempty"` // block height where balance was computed + BlockId *Hash `protobuf:"bytes,3,opt,name=block_id,json=blockId,proto3,oneof" json:"block_id,omitempty"` // 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. + Page *PageResponse `protobuf:"bytes,4,opt,name=page,proto3" json:"page,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WalletBalanceData) Reset() { + *x = WalletBalanceData{} + mi := &file_blockchain_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WalletBalanceData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WalletBalanceData) ProtoMessage() {} + +func (x *WalletBalanceData) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_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 WalletBalanceData.ProtoReflect.Descriptor instead. +func (*WalletBalanceData) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{0} +} + +func (x *WalletBalanceData) GetNotes() []*BalanceEntry { + if x != nil { + return x.Notes + } + return nil +} + +func (x *WalletBalanceData) GetHeight() *BlockHeight { + if x != nil { + return x.Height + } + return nil +} + +func (x *WalletBalanceData) GetBlockId() *Hash { + if x != nil { + return x.BlockId + } + return nil +} + +func (x *WalletBalanceData) GetPage() *PageResponse { + if x != nil { + return x.Page + } + return nil +} + +type BalanceEntry struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name *Name `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Note *Note `protobuf:"bytes,2,opt,name=note,proto3" json:"note,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BalanceEntry) Reset() { + *x = BalanceEntry{} + mi := &file_blockchain_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BalanceEntry) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BalanceEntry) ProtoMessage() {} + +func (x *BalanceEntry) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_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 BalanceEntry.ProtoReflect.Descriptor instead. +func (*BalanceEntry) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{1} +} + +func (x *BalanceEntry) GetName() *Name { + if x != nil { + return x.Name + } + return nil +} + +func (x *BalanceEntry) GetNote() *Note { + if x != nil { + return x.Note + } + return nil +} + +// the string key is the name of the input +// message RawTransaction { map inputs = 1; } +type RawTransaction struct { + state protoimpl.MessageState `protogen:"open.v1"` + NamedInputs []*NamedInput `protobuf:"bytes,1,rep,name=named_inputs,json=namedInputs,proto3" json:"named_inputs,omitempty"` + TimelockRange *TimeLockRangeAbsolute `protobuf:"bytes,2,opt,name=timelock_range,json=timelockRange,proto3" json:"timelock_range,omitempty"` + TotalFees *Nicks `protobuf:"bytes,3,opt,name=total_fees,json=totalFees,proto3" json:"total_fees,omitempty"` + Id *Hash `protobuf:"bytes,4,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RawTransaction) Reset() { + *x = RawTransaction{} + mi := &file_blockchain_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RawTransaction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RawTransaction) ProtoMessage() {} + +func (x *RawTransaction) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_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 RawTransaction.ProtoReflect.Descriptor instead. +func (*RawTransaction) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{2} +} + +func (x *RawTransaction) GetNamedInputs() []*NamedInput { + if x != nil { + return x.NamedInputs + } + return nil +} + +func (x *RawTransaction) GetTimelockRange() *TimeLockRangeAbsolute { + if x != nil { + return x.TimelockRange + } + return nil +} + +func (x *RawTransaction) GetTotalFees() *Nicks { + if x != nil { + return x.TotalFees + } + return nil +} + +func (x *RawTransaction) GetId() *Hash { + if x != nil { + return x.Id + } + return nil +} + +type NamedInput struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name *Name `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Input *Input `protobuf:"bytes,2,opt,name=input,proto3" json:"input,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NamedInput) Reset() { + *x = NamedInput{} + mi := &file_blockchain_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamedInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamedInput) ProtoMessage() {} + +func (x *NamedInput) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_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 NamedInput.ProtoReflect.Descriptor instead. +func (*NamedInput) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{3} +} + +func (x *NamedInput) GetName() *Name { + if x != nil { + return x.Name + } + return nil +} + +func (x *NamedInput) GetInput() *Input { + if x != nil { + return x.Input + } + return nil +} + +type Input struct { + state protoimpl.MessageState `protogen:"open.v1"` + Note *Note `protobuf:"bytes,1,opt,name=note,proto3" json:"note,omitempty"` + Spend *Spend `protobuf:"bytes,2,opt,name=spend,proto3" json:"spend,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Input) Reset() { + *x = Input{} + mi := &file_blockchain_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Input) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Input) ProtoMessage() {} + +func (x *Input) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_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 Input.ProtoReflect.Descriptor instead. +func (*Input) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{4} +} + +func (x *Input) GetNote() *Note { + if x != nil { + return x.Note + } + return nil +} + +func (x *Input) GetSpend() *Spend { + if x != nil { + return x.Spend + } + return nil +} + +type Spend struct { + state protoimpl.MessageState `protogen:"open.v1"` + Signature *Signature `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"` + Seeds []*Seed `protobuf:"bytes,2,rep,name=seeds,proto3" json:"seeds,omitempty"` + MinerFeeNicks *Nicks `protobuf:"bytes,3,opt,name=miner_fee_nicks,json=minerFeeNicks,proto3" json:"miner_fee_nicks,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Spend) Reset() { + *x = Spend{} + mi := &file_blockchain_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Spend) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Spend) ProtoMessage() {} + +func (x *Spend) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_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 Spend.ProtoReflect.Descriptor instead. +func (*Spend) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{5} +} + +func (x *Spend) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} + +func (x *Spend) GetSeeds() []*Seed { + if x != nil { + return x.Seeds + } + return nil +} + +func (x *Spend) GetMinerFeeNicks() *Nicks { + if x != nil { + return x.MinerFeeNicks + } + return nil +} + +type Seed struct { + state protoimpl.MessageState `protogen:"open.v1"` + OutputSource *OutputSource `protobuf:"bytes,1,opt,name=output_source,json=outputSource,proto3,oneof" json:"output_source,omitempty"` + Recipient *Lock `protobuf:"bytes,2,opt,name=recipient,proto3" json:"recipient,omitempty"` + TimelockIntent *TimeLockIntent `protobuf:"bytes,3,opt,name=timelock_intent,json=timelockIntent,proto3,oneof" json:"timelock_intent,omitempty"` + Gift *Nicks `protobuf:"bytes,4,opt,name=gift,proto3" json:"gift,omitempty"` + ParentHash *Hash `protobuf:"bytes,5,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Seed) Reset() { + *x = Seed{} + mi := &file_blockchain_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Seed) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Seed) ProtoMessage() {} + +func (x *Seed) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_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 Seed.ProtoReflect.Descriptor instead. +func (*Seed) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{6} +} + +func (x *Seed) GetOutputSource() *OutputSource { + if x != nil { + return x.OutputSource + } + return nil +} + +func (x *Seed) GetRecipient() *Lock { + if x != nil { + return x.Recipient + } + return nil +} + +func (x *Seed) GetTimelockIntent() *TimeLockIntent { + if x != nil { + return x.TimelockIntent + } + return nil +} + +func (x *Seed) GetGift() *Nicks { + if x != nil { + return x.Gift + } + return nil +} + +func (x *Seed) GetParentHash() *Hash { + if x != nil { + return x.ParentHash + } + return nil +} + +type OutputSource struct { + state protoimpl.MessageState `protogen:"open.v1"` + Source *Source `protobuf:"bytes,1,opt,name=source,proto3,oneof" json:"source,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *OutputSource) Reset() { + *x = OutputSource{} + mi := &file_blockchain_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OutputSource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OutputSource) ProtoMessage() {} + +func (x *OutputSource) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[7] + 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 OutputSource.ProtoReflect.Descriptor instead. +func (*OutputSource) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{7} +} + +func (x *OutputSource) GetSource() *Source { + if x != nil { + return x.Source + } + return nil +} + +type Source struct { + state protoimpl.MessageState `protogen:"open.v1"` + Hash *Hash `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Coinbase bool `protobuf:"varint,2,opt,name=coinbase,proto3" json:"coinbase,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Source) Reset() { + *x = Source{} + mi := &file_blockchain_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Source) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Source) ProtoMessage() {} + +func (x *Source) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_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 Source.ProtoReflect.Descriptor instead. +func (*Source) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{8} +} + +func (x *Source) GetHash() *Hash { + if x != nil { + return x.Hash + } + return nil +} + +func (x *Source) GetCoinbase() bool { + if x != nil { + return x.Coinbase + } + return false +} + +type TimeLockIntent struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Value: + // + // *TimeLockIntent_Absolute + // *TimeLockIntent_Relative + // *TimeLockIntent_AbsoluteAndRelative + Value isTimeLockIntent_Value `protobuf_oneof:"value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TimeLockIntent) Reset() { + *x = TimeLockIntent{} + mi := &file_blockchain_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TimeLockIntent) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TimeLockIntent) ProtoMessage() {} + +func (x *TimeLockIntent) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_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 TimeLockIntent.ProtoReflect.Descriptor instead. +func (*TimeLockIntent) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{9} +} + +func (x *TimeLockIntent) GetValue() isTimeLockIntent_Value { + if x != nil { + return x.Value + } + return nil +} + +func (x *TimeLockIntent) GetAbsolute() *TimeLockRangeAbsolute { + if x != nil { + if x, ok := x.Value.(*TimeLockIntent_Absolute); ok { + return x.Absolute + } + } + return nil +} + +func (x *TimeLockIntent) GetRelative() *TimeLockRangeRelative { + if x != nil { + if x, ok := x.Value.(*TimeLockIntent_Relative); ok { + return x.Relative + } + } + return nil +} + +func (x *TimeLockIntent) GetAbsoluteAndRelative() *TimeLockRangeAbsoluteAndRelative { + if x != nil { + if x, ok := x.Value.(*TimeLockIntent_AbsoluteAndRelative); ok { + return x.AbsoluteAndRelative + } + } + return nil +} + +type isTimeLockIntent_Value interface { + isTimeLockIntent_Value() +} + +type TimeLockIntent_Absolute struct { + Absolute *TimeLockRangeAbsolute `protobuf:"bytes,1,opt,name=absolute,proto3,oneof"` +} + +type TimeLockIntent_Relative struct { + Relative *TimeLockRangeRelative `protobuf:"bytes,2,opt,name=relative,proto3,oneof"` +} + +type TimeLockIntent_AbsoluteAndRelative struct { + AbsoluteAndRelative *TimeLockRangeAbsoluteAndRelative `protobuf:"bytes,3,opt,name=absolute_and_relative,json=absoluteAndRelative,proto3,oneof"` +} + +func (*TimeLockIntent_Absolute) isTimeLockIntent_Value() {} + +func (*TimeLockIntent_Relative) isTimeLockIntent_Value() {} + +func (*TimeLockIntent_AbsoluteAndRelative) isTimeLockIntent_Value() {} + +type TimeLockRangeAbsoluteAndRelative struct { + state protoimpl.MessageState `protogen:"open.v1"` + Absolute *TimeLockRangeAbsolute `protobuf:"bytes,1,opt,name=absolute,proto3,oneof" json:"absolute,omitempty"` + Relative *TimeLockRangeRelative `protobuf:"bytes,2,opt,name=relative,proto3,oneof" json:"relative,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TimeLockRangeAbsoluteAndRelative) Reset() { + *x = TimeLockRangeAbsoluteAndRelative{} + mi := &file_blockchain_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TimeLockRangeAbsoluteAndRelative) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TimeLockRangeAbsoluteAndRelative) ProtoMessage() {} + +func (x *TimeLockRangeAbsoluteAndRelative) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[10] + 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 TimeLockRangeAbsoluteAndRelative.ProtoReflect.Descriptor instead. +func (*TimeLockRangeAbsoluteAndRelative) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{10} +} + +func (x *TimeLockRangeAbsoluteAndRelative) GetAbsolute() *TimeLockRangeAbsolute { + if x != nil { + return x.Absolute + } + return nil +} + +func (x *TimeLockRangeAbsoluteAndRelative) GetRelative() *TimeLockRangeRelative { + if x != nil { + return x.Relative + } + return nil +} + +// min and max are absolute origin page numbers +type TimeLockRangeAbsolute struct { + state protoimpl.MessageState `protogen:"open.v1"` + Min *BlockHeight `protobuf:"bytes,1,opt,name=min,proto3,oneof" json:"min,omitempty"` + Max *BlockHeight `protobuf:"bytes,2,opt,name=max,proto3,oneof" json:"max,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TimeLockRangeAbsolute) Reset() { + *x = TimeLockRangeAbsolute{} + mi := &file_blockchain_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TimeLockRangeAbsolute) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TimeLockRangeAbsolute) ProtoMessage() {} + +func (x *TimeLockRangeAbsolute) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[11] + 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 TimeLockRangeAbsolute.ProtoReflect.Descriptor instead. +func (*TimeLockRangeAbsolute) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{11} +} + +func (x *TimeLockRangeAbsolute) GetMin() *BlockHeight { + if x != nil { + return x.Min + } + return nil +} + +func (x *TimeLockRangeAbsolute) GetMax() *BlockHeight { + if x != nil { + return x.Max + } + return nil +} + +// min and max are relative to the note's creation page +type TimeLockRangeRelative struct { + state protoimpl.MessageState `protogen:"open.v1"` + Min *BlockHeightDelta `protobuf:"bytes,1,opt,name=min,proto3,oneof" json:"min,omitempty"` + Max *BlockHeightDelta `protobuf:"bytes,2,opt,name=max,proto3,oneof" json:"max,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TimeLockRangeRelative) Reset() { + *x = TimeLockRangeRelative{} + mi := &file_blockchain_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TimeLockRangeRelative) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TimeLockRangeRelative) ProtoMessage() {} + +func (x *TimeLockRangeRelative) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[12] + 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 TimeLockRangeRelative.ProtoReflect.Descriptor instead. +func (*TimeLockRangeRelative) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{12} +} + +func (x *TimeLockRangeRelative) GetMin() *BlockHeightDelta { + if x != nil { + return x.Min + } + return nil +} + +func (x *TimeLockRangeRelative) GetMax() *BlockHeightDelta { + if x != nil { + return x.Max + } + return nil +} + +type Lock struct { + state protoimpl.MessageState `protogen:"open.v1"` + KeysRequired uint32 `protobuf:"varint,1,opt,name=keys_required,json=keysRequired,proto3" json:"keys_required,omitempty"` // threshold of keys required to spend the note + // DEPRECATED: repeated string schnorr_pubkeys_b58 = 2; + SchnorrPubkeys []*SchnorrPubkey `protobuf:"bytes,2,rep,name=schnorr_pubkeys,json=schnorrPubkeys,proto3" json:"schnorr_pubkeys,omitempty"` // schnorr pubkeys (curve: cheetah) + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Lock) Reset() { + *x = Lock{} + mi := &file_blockchain_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Lock) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Lock) ProtoMessage() {} + +func (x *Lock) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[13] + 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 Lock.ProtoReflect.Descriptor instead. +func (*Lock) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{13} +} + +func (x *Lock) GetKeysRequired() uint32 { + if x != nil { + return x.KeysRequired + } + return 0 +} + +func (x *Lock) GetSchnorrPubkeys() []*SchnorrPubkey { + if x != nil { + return x.SchnorrPubkeys + } + return nil +} + +type Name struct { + state protoimpl.MessageState `protogen:"open.v1"` + // First is the hash of whether the note has a timelock and the lock + First *Hash `protobuf:"bytes,1,opt,name=first,proto3" json:"first,omitempty"` + // Last is the hash of the actual timelock and the source + Last *Hash `protobuf:"bytes,2,opt,name=last,proto3" json:"last,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Name) Reset() { + *x = Name{} + mi := &file_blockchain_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Name) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Name) ProtoMessage() {} + +func (x *Name) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[14] + 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 Name.ProtoReflect.Descriptor instead. +func (*Name) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{14} +} + +func (x *Name) GetFirst() *Hash { + if x != nil { + return x.First + } + return nil +} + +func (x *Name) GetLast() *Hash { + if x != nil { + return x.Last + } + return nil +} + +type Note struct { + state protoimpl.MessageState `protogen:"open.v1"` + OriginPage *BlockHeight `protobuf:"bytes,1,opt,name=origin_page,json=originPage,proto3" json:"origin_page,omitempty"` // page-number when added to balance + Timelock *TimeLockIntent `protobuf:"bytes,2,opt,name=timelock,proto3,oneof" json:"timelock,omitempty"` // enforced timelock + Name *Name `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` // nname (human/name label) + Lock *Lock `protobuf:"bytes,4,opt,name=lock,proto3" json:"lock,omitempty"` // spending condition + Source *Source `protobuf:"bytes,5,opt,name=source,proto3" json:"source,omitempty"` // provenance commitment + Assets *Nicks `protobuf:"bytes,6,opt,name=assets,proto3" json:"assets,omitempty"` // coin amount (nicks) + Version *NoteVersion `protobuf:"bytes,7,opt,name=version,proto3" json:"version,omitempty"` // note version (currently 0) + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Note) Reset() { + *x = Note{} + mi := &file_blockchain_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Note) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Note) ProtoMessage() {} + +func (x *Note) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[15] + 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 Note.ProtoReflect.Descriptor instead. +func (*Note) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{15} +} + +func (x *Note) GetOriginPage() *BlockHeight { + if x != nil { + return x.OriginPage + } + return nil +} + +func (x *Note) GetTimelock() *TimeLockIntent { + if x != nil { + return x.Timelock + } + return nil +} + +func (x *Note) GetName() *Name { + if x != nil { + return x.Name + } + return nil +} + +func (x *Note) GetLock() *Lock { + if x != nil { + return x.Lock + } + return nil +} + +func (x *Note) GetSource() *Source { + if x != nil { + return x.Source + } + return nil +} + +func (x *Note) GetAssets() *Nicks { + if x != nil { + return x.Assets + } + return nil +} + +func (x *Note) GetVersion() *NoteVersion { + if x != nil { + return x.Version + } + return nil +} + +type Signature struct { + state protoimpl.MessageState `protogen:"open.v1"` + Entries []*SignatureEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Signature) Reset() { + *x = Signature{} + mi := &file_blockchain_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Signature) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Signature) ProtoMessage() {} + +func (x *Signature) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[16] + 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 Signature.ProtoReflect.Descriptor instead. +func (*Signature) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{16} +} + +func (x *Signature) GetEntries() []*SignatureEntry { + if x != nil { + return x.Entries + } + return nil +} + +type SignatureEntry struct { + state protoimpl.MessageState `protogen:"open.v1"` + SchnorrPubkey *SchnorrPubkey `protobuf:"bytes,1,opt,name=schnorr_pubkey,json=schnorrPubkey,proto3" json:"schnorr_pubkey,omitempty"` // serialized pubkey corresponding to the signer + Signature *SchnorrSignature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SignatureEntry) Reset() { + *x = SignatureEntry{} + mi := &file_blockchain_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SignatureEntry) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SignatureEntry) ProtoMessage() {} + +func (x *SignatureEntry) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[17] + 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 SignatureEntry.ProtoReflect.Descriptor instead. +func (*SignatureEntry) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{17} +} + +func (x *SignatureEntry) GetSchnorrPubkey() *SchnorrPubkey { + if x != nil { + return x.SchnorrPubkey + } + return nil +} + +func (x *SignatureEntry) GetSignature() *SchnorrSignature { + if x != nil { + return x.Signature + } + return nil +} + +type SchnorrSignature struct { + state protoimpl.MessageState `protogen:"open.v1"` + Chal *EightBelt `protobuf:"bytes,1,opt,name=chal,proto3" json:"chal,omitempty"` + Sig *EightBelt `protobuf:"bytes,2,opt,name=sig,proto3" json:"sig,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SchnorrSignature) Reset() { + *x = SchnorrSignature{} + mi := &file_blockchain_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SchnorrSignature) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SchnorrSignature) ProtoMessage() {} + +func (x *SchnorrSignature) ProtoReflect() protoreflect.Message { + mi := &file_blockchain_proto_msgTypes[18] + 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 SchnorrSignature.ProtoReflect.Descriptor instead. +func (*SchnorrSignature) Descriptor() ([]byte, []int) { + return file_blockchain_proto_rawDescGZIP(), []int{18} +} + +func (x *SchnorrSignature) GetChal() *EightBelt { + if x != nil { + return x.Chal + } + return nil +} + +func (x *SchnorrSignature) GetSig() *EightBelt { + if x != nil { + return x.Sig + } + return nil +} + +var File_blockchain_proto protoreflect.FileDescriptor + +const file_blockchain_proto_rawDesc = "" + + "\n" + + "\x10blockchain.proto\x12\x13nockchain.public.v1\x1a\x10primitives.proto\x1a\x10pagination.proto\"\x85\x02\n" + + "\x11WalletBalanceData\x127\n" + + "\x05notes\x18\x01 \x03(\v2!.nockchain.public.v1.BalanceEntryR\x05notes\x128\n" + + "\x06height\x18\x02 \x01(\v2 .nockchain.public.v1.BlockHeightR\x06height\x129\n" + + "\bblock_id\x18\x03 \x01(\v2\x19.nockchain.public.v1.HashH\x00R\ablockId\x88\x01\x01\x125\n" + + "\x04page\x18\x04 \x01(\v2!.nockchain.public.v1.PageResponseR\x04pageB\v\n" + + "\t_block_id\"l\n" + + "\fBalanceEntry\x12-\n" + + "\x04name\x18\x01 \x01(\v2\x19.nockchain.public.v1.NameR\x04name\x12-\n" + + "\x04note\x18\x02 \x01(\v2\x19.nockchain.public.v1.NoteR\x04note\"\x8d\x02\n" + + "\x0eRawTransaction\x12B\n" + + "\fnamed_inputs\x18\x01 \x03(\v2\x1f.nockchain.public.v1.NamedInputR\vnamedInputs\x12Q\n" + + "\x0etimelock_range\x18\x02 \x01(\v2*.nockchain.public.v1.TimeLockRangeAbsoluteR\rtimelockRange\x129\n" + + "\n" + + "total_fees\x18\x03 \x01(\v2\x1a.nockchain.public.v1.NicksR\ttotalFees\x12)\n" + + "\x02id\x18\x04 \x01(\v2\x19.nockchain.public.v1.HashR\x02id\"m\n" + + "\n" + + "NamedInput\x12-\n" + + "\x04name\x18\x01 \x01(\v2\x19.nockchain.public.v1.NameR\x04name\x120\n" + + "\x05input\x18\x02 \x01(\v2\x1a.nockchain.public.v1.InputR\x05input\"h\n" + + "\x05Input\x12-\n" + + "\x04note\x18\x01 \x01(\v2\x19.nockchain.public.v1.NoteR\x04note\x120\n" + + "\x05spend\x18\x02 \x01(\v2\x1a.nockchain.public.v1.SpendR\x05spend\"\xba\x01\n" + + "\x05Spend\x12<\n" + + "\tsignature\x18\x01 \x01(\v2\x1e.nockchain.public.v1.SignatureR\tsignature\x12/\n" + + "\x05seeds\x18\x02 \x03(\v2\x19.nockchain.public.v1.SeedR\x05seeds\x12B\n" + + "\x0fminer_fee_nicks\x18\x03 \x01(\v2\x1a.nockchain.public.v1.NicksR\rminerFeeNicks\"\xf1\x02\n" + + "\x04Seed\x12K\n" + + "\routput_source\x18\x01 \x01(\v2!.nockchain.public.v1.OutputSourceH\x00R\foutputSource\x88\x01\x01\x127\n" + + "\trecipient\x18\x02 \x01(\v2\x19.nockchain.public.v1.LockR\trecipient\x12Q\n" + + "\x0ftimelock_intent\x18\x03 \x01(\v2#.nockchain.public.v1.TimeLockIntentH\x01R\x0etimelockIntent\x88\x01\x01\x12.\n" + + "\x04gift\x18\x04 \x01(\v2\x1a.nockchain.public.v1.NicksR\x04gift\x12:\n" + + "\vparent_hash\x18\x05 \x01(\v2\x19.nockchain.public.v1.HashR\n" + + "parentHashB\x10\n" + + "\x0e_output_sourceB\x12\n" + + "\x10_timelock_intent\"S\n" + + "\fOutputSource\x128\n" + + "\x06source\x18\x01 \x01(\v2\x1b.nockchain.public.v1.SourceH\x00R\x06source\x88\x01\x01B\t\n" + + "\a_source\"S\n" + + "\x06Source\x12-\n" + + "\x04hash\x18\x01 \x01(\v2\x19.nockchain.public.v1.HashR\x04hash\x12\x1a\n" + + "\bcoinbase\x18\x02 \x01(\bR\bcoinbase\"\x9a\x02\n" + + "\x0eTimeLockIntent\x12H\n" + + "\babsolute\x18\x01 \x01(\v2*.nockchain.public.v1.TimeLockRangeAbsoluteH\x00R\babsolute\x12H\n" + + "\brelative\x18\x02 \x01(\v2*.nockchain.public.v1.TimeLockRangeRelativeH\x00R\brelative\x12k\n" + + "\x15absolute_and_relative\x18\x03 \x01(\v25.nockchain.public.v1.TimeLockRangeAbsoluteAndRelativeH\x00R\x13absoluteAndRelativeB\a\n" + + "\x05value\"\xd6\x01\n" + + " TimeLockRangeAbsoluteAndRelative\x12K\n" + + "\babsolute\x18\x01 \x01(\v2*.nockchain.public.v1.TimeLockRangeAbsoluteH\x00R\babsolute\x88\x01\x01\x12K\n" + + "\brelative\x18\x02 \x01(\v2*.nockchain.public.v1.TimeLockRangeRelativeH\x01R\brelative\x88\x01\x01B\v\n" + + "\t_absoluteB\v\n" + + "\t_relative\"\x99\x01\n" + + "\x15TimeLockRangeAbsolute\x127\n" + + "\x03min\x18\x01 \x01(\v2 .nockchain.public.v1.BlockHeightH\x00R\x03min\x88\x01\x01\x127\n" + + "\x03max\x18\x02 \x01(\v2 .nockchain.public.v1.BlockHeightH\x01R\x03max\x88\x01\x01B\x06\n" + + "\x04_minB\x06\n" + + "\x04_max\"\xa3\x01\n" + + "\x15TimeLockRangeRelative\x12<\n" + + "\x03min\x18\x01 \x01(\v2%.nockchain.public.v1.BlockHeightDeltaH\x00R\x03min\x88\x01\x01\x12<\n" + + "\x03max\x18\x02 \x01(\v2%.nockchain.public.v1.BlockHeightDeltaH\x01R\x03max\x88\x01\x01B\x06\n" + + "\x04_minB\x06\n" + + "\x04_max\"x\n" + + "\x04Lock\x12#\n" + + "\rkeys_required\x18\x01 \x01(\rR\fkeysRequired\x12K\n" + + "\x0fschnorr_pubkeys\x18\x02 \x03(\v2\".nockchain.public.v1.SchnorrPubkeyR\x0eschnorrPubkeys\"f\n" + + "\x04Name\x12/\n" + + "\x05first\x18\x01 \x01(\v2\x19.nockchain.public.v1.HashR\x05first\x12-\n" + + "\x04last\x18\x02 \x01(\v2\x19.nockchain.public.v1.HashR\x04last\"\x9f\x03\n" + + "\x04Note\x12A\n" + + "\vorigin_page\x18\x01 \x01(\v2 .nockchain.public.v1.BlockHeightR\n" + + "originPage\x12D\n" + + "\btimelock\x18\x02 \x01(\v2#.nockchain.public.v1.TimeLockIntentH\x00R\btimelock\x88\x01\x01\x12-\n" + + "\x04name\x18\x03 \x01(\v2\x19.nockchain.public.v1.NameR\x04name\x12-\n" + + "\x04lock\x18\x04 \x01(\v2\x19.nockchain.public.v1.LockR\x04lock\x123\n" + + "\x06source\x18\x05 \x01(\v2\x1b.nockchain.public.v1.SourceR\x06source\x122\n" + + "\x06assets\x18\x06 \x01(\v2\x1a.nockchain.public.v1.NicksR\x06assets\x12:\n" + + "\aversion\x18\a \x01(\v2 .nockchain.public.v1.NoteVersionR\aversionB\v\n" + + "\t_timelock\"J\n" + + "\tSignature\x12=\n" + + "\aentries\x18\x01 \x03(\v2#.nockchain.public.v1.SignatureEntryR\aentries\"\xa0\x01\n" + + "\x0eSignatureEntry\x12I\n" + + "\x0eschnorr_pubkey\x18\x01 \x01(\v2\".nockchain.public.v1.SchnorrPubkeyR\rschnorrPubkey\x12C\n" + + "\tsignature\x18\x02 \x01(\v2%.nockchain.public.v1.SchnorrSignatureR\tsignature\"x\n" + + "\x10SchnorrSignature\x122\n" + + "\x04chal\x18\x01 \x01(\v2\x1e.nockchain.public.v1.EightBeltR\x04chal\x120\n" + + "\x03sig\x18\x02 \x01(\v2\x1e.nockchain.public.v1.EightBeltR\x03sigB\x0eZ\f./;nockchainb\x06proto3" + +var ( + file_blockchain_proto_rawDescOnce sync.Once + file_blockchain_proto_rawDescData []byte +) + +func file_blockchain_proto_rawDescGZIP() []byte { + file_blockchain_proto_rawDescOnce.Do(func() { + file_blockchain_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_blockchain_proto_rawDesc), len(file_blockchain_proto_rawDesc))) + }) + return file_blockchain_proto_rawDescData +} + +var file_blockchain_proto_msgTypes = make([]protoimpl.MessageInfo, 19) +var file_blockchain_proto_goTypes = []any{ + (*WalletBalanceData)(nil), // 0: nockchain.public.v1.WalletBalanceData + (*BalanceEntry)(nil), // 1: nockchain.public.v1.BalanceEntry + (*RawTransaction)(nil), // 2: nockchain.public.v1.RawTransaction + (*NamedInput)(nil), // 3: nockchain.public.v1.NamedInput + (*Input)(nil), // 4: nockchain.public.v1.Input + (*Spend)(nil), // 5: nockchain.public.v1.Spend + (*Seed)(nil), // 6: nockchain.public.v1.Seed + (*OutputSource)(nil), // 7: nockchain.public.v1.OutputSource + (*Source)(nil), // 8: nockchain.public.v1.Source + (*TimeLockIntent)(nil), // 9: nockchain.public.v1.TimeLockIntent + (*TimeLockRangeAbsoluteAndRelative)(nil), // 10: nockchain.public.v1.TimeLockRangeAbsoluteAndRelative + (*TimeLockRangeAbsolute)(nil), // 11: nockchain.public.v1.TimeLockRangeAbsolute + (*TimeLockRangeRelative)(nil), // 12: nockchain.public.v1.TimeLockRangeRelative + (*Lock)(nil), // 13: nockchain.public.v1.Lock + (*Name)(nil), // 14: nockchain.public.v1.Name + (*Note)(nil), // 15: nockchain.public.v1.Note + (*Signature)(nil), // 16: nockchain.public.v1.Signature + (*SignatureEntry)(nil), // 17: nockchain.public.v1.SignatureEntry + (*SchnorrSignature)(nil), // 18: nockchain.public.v1.SchnorrSignature + (*BlockHeight)(nil), // 19: nockchain.public.v1.BlockHeight + (*Hash)(nil), // 20: nockchain.public.v1.Hash + (*PageResponse)(nil), // 21: nockchain.public.v1.PageResponse + (*Nicks)(nil), // 22: nockchain.public.v1.Nicks + (*BlockHeightDelta)(nil), // 23: nockchain.public.v1.BlockHeightDelta + (*SchnorrPubkey)(nil), // 24: nockchain.public.v1.SchnorrPubkey + (*NoteVersion)(nil), // 25: nockchain.public.v1.NoteVersion + (*EightBelt)(nil), // 26: nockchain.public.v1.EightBelt +} +var file_blockchain_proto_depIdxs = []int32{ + 1, // 0: nockchain.public.v1.WalletBalanceData.notes:type_name -> nockchain.public.v1.BalanceEntry + 19, // 1: nockchain.public.v1.WalletBalanceData.height:type_name -> nockchain.public.v1.BlockHeight + 20, // 2: nockchain.public.v1.WalletBalanceData.block_id:type_name -> nockchain.public.v1.Hash + 21, // 3: nockchain.public.v1.WalletBalanceData.page:type_name -> nockchain.public.v1.PageResponse + 14, // 4: nockchain.public.v1.BalanceEntry.name:type_name -> nockchain.public.v1.Name + 15, // 5: nockchain.public.v1.BalanceEntry.note:type_name -> nockchain.public.v1.Note + 3, // 6: nockchain.public.v1.RawTransaction.named_inputs:type_name -> nockchain.public.v1.NamedInput + 11, // 7: nockchain.public.v1.RawTransaction.timelock_range:type_name -> nockchain.public.v1.TimeLockRangeAbsolute + 22, // 8: nockchain.public.v1.RawTransaction.total_fees:type_name -> nockchain.public.v1.Nicks + 20, // 9: nockchain.public.v1.RawTransaction.id:type_name -> nockchain.public.v1.Hash + 14, // 10: nockchain.public.v1.NamedInput.name:type_name -> nockchain.public.v1.Name + 4, // 11: nockchain.public.v1.NamedInput.input:type_name -> nockchain.public.v1.Input + 15, // 12: nockchain.public.v1.Input.note:type_name -> nockchain.public.v1.Note + 5, // 13: nockchain.public.v1.Input.spend:type_name -> nockchain.public.v1.Spend + 16, // 14: nockchain.public.v1.Spend.signature:type_name -> nockchain.public.v1.Signature + 6, // 15: nockchain.public.v1.Spend.seeds:type_name -> nockchain.public.v1.Seed + 22, // 16: nockchain.public.v1.Spend.miner_fee_nicks:type_name -> nockchain.public.v1.Nicks + 7, // 17: nockchain.public.v1.Seed.output_source:type_name -> nockchain.public.v1.OutputSource + 13, // 18: nockchain.public.v1.Seed.recipient:type_name -> nockchain.public.v1.Lock + 9, // 19: nockchain.public.v1.Seed.timelock_intent:type_name -> nockchain.public.v1.TimeLockIntent + 22, // 20: nockchain.public.v1.Seed.gift:type_name -> nockchain.public.v1.Nicks + 20, // 21: nockchain.public.v1.Seed.parent_hash:type_name -> nockchain.public.v1.Hash + 8, // 22: nockchain.public.v1.OutputSource.source:type_name -> nockchain.public.v1.Source + 20, // 23: nockchain.public.v1.Source.hash:type_name -> nockchain.public.v1.Hash + 11, // 24: nockchain.public.v1.TimeLockIntent.absolute:type_name -> nockchain.public.v1.TimeLockRangeAbsolute + 12, // 25: nockchain.public.v1.TimeLockIntent.relative:type_name -> nockchain.public.v1.TimeLockRangeRelative + 10, // 26: nockchain.public.v1.TimeLockIntent.absolute_and_relative:type_name -> nockchain.public.v1.TimeLockRangeAbsoluteAndRelative + 11, // 27: nockchain.public.v1.TimeLockRangeAbsoluteAndRelative.absolute:type_name -> nockchain.public.v1.TimeLockRangeAbsolute + 12, // 28: nockchain.public.v1.TimeLockRangeAbsoluteAndRelative.relative:type_name -> nockchain.public.v1.TimeLockRangeRelative + 19, // 29: nockchain.public.v1.TimeLockRangeAbsolute.min:type_name -> nockchain.public.v1.BlockHeight + 19, // 30: nockchain.public.v1.TimeLockRangeAbsolute.max:type_name -> nockchain.public.v1.BlockHeight + 23, // 31: nockchain.public.v1.TimeLockRangeRelative.min:type_name -> nockchain.public.v1.BlockHeightDelta + 23, // 32: nockchain.public.v1.TimeLockRangeRelative.max:type_name -> nockchain.public.v1.BlockHeightDelta + 24, // 33: nockchain.public.v1.Lock.schnorr_pubkeys:type_name -> nockchain.public.v1.SchnorrPubkey + 20, // 34: nockchain.public.v1.Name.first:type_name -> nockchain.public.v1.Hash + 20, // 35: nockchain.public.v1.Name.last:type_name -> nockchain.public.v1.Hash + 19, // 36: nockchain.public.v1.Note.origin_page:type_name -> nockchain.public.v1.BlockHeight + 9, // 37: nockchain.public.v1.Note.timelock:type_name -> nockchain.public.v1.TimeLockIntent + 14, // 38: nockchain.public.v1.Note.name:type_name -> nockchain.public.v1.Name + 13, // 39: nockchain.public.v1.Note.lock:type_name -> nockchain.public.v1.Lock + 8, // 40: nockchain.public.v1.Note.source:type_name -> nockchain.public.v1.Source + 22, // 41: nockchain.public.v1.Note.assets:type_name -> nockchain.public.v1.Nicks + 25, // 42: nockchain.public.v1.Note.version:type_name -> nockchain.public.v1.NoteVersion + 17, // 43: nockchain.public.v1.Signature.entries:type_name -> nockchain.public.v1.SignatureEntry + 24, // 44: nockchain.public.v1.SignatureEntry.schnorr_pubkey:type_name -> nockchain.public.v1.SchnorrPubkey + 18, // 45: nockchain.public.v1.SignatureEntry.signature:type_name -> nockchain.public.v1.SchnorrSignature + 26, // 46: nockchain.public.v1.SchnorrSignature.chal:type_name -> nockchain.public.v1.EightBelt + 26, // 47: nockchain.public.v1.SchnorrSignature.sig:type_name -> nockchain.public.v1.EightBelt + 48, // [48:48] is the sub-list for method output_type + 48, // [48:48] is the sub-list for method input_type + 48, // [48:48] is the sub-list for extension type_name + 48, // [48:48] is the sub-list for extension extendee + 0, // [0:48] is the sub-list for field type_name +} + +func init() { file_blockchain_proto_init() } +func file_blockchain_proto_init() { + if File_blockchain_proto != nil { + return + } + file_primitives_proto_init() + file_pagination_proto_init() + file_blockchain_proto_msgTypes[0].OneofWrappers = []any{} + file_blockchain_proto_msgTypes[6].OneofWrappers = []any{} + file_blockchain_proto_msgTypes[7].OneofWrappers = []any{} + file_blockchain_proto_msgTypes[9].OneofWrappers = []any{ + (*TimeLockIntent_Absolute)(nil), + (*TimeLockIntent_Relative)(nil), + (*TimeLockIntent_AbsoluteAndRelative)(nil), + } + file_blockchain_proto_msgTypes[10].OneofWrappers = []any{} + file_blockchain_proto_msgTypes[11].OneofWrappers = []any{} + file_blockchain_proto_msgTypes[12].OneofWrappers = []any{} + file_blockchain_proto_msgTypes[15].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_blockchain_proto_rawDesc), len(file_blockchain_proto_rawDesc)), + NumEnums: 0, + NumMessages: 19, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchain_proto_goTypes, + DependencyIndexes: file_blockchain_proto_depIdxs, + MessageInfos: file_blockchain_proto_msgTypes, + }.Build() + File_blockchain_proto = out.File + file_blockchain_proto_goTypes = nil + file_blockchain_proto_depIdxs = nil +} diff --git a/nockchain/nockchain.pb.go b/nockchain/nockchain.pb.go new file mode 100644 index 0000000..3b2f331 --- /dev/null +++ b/nockchain/nockchain.pb.go @@ -0,0 +1,554 @@ +// nockchain/public/v1/nockchain.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.9 +// protoc v3.20.3 +// source: nockchain.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 WalletGetBalanceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // pubkey cheetah point; specific address, or current wallet + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // Pagination parameters. The server enforces limits and may return fewer + // entries than requested to respect message size and policy. For consistent + // paging across a stable snapshot, pass along the returned page_token from + // the previous response without modification. + Page *PageRequest `protobuf:"bytes,2,opt,name=page,proto3" json:"page,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WalletGetBalanceRequest) Reset() { + *x = WalletGetBalanceRequest{} + mi := &file_nockchain_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WalletGetBalanceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WalletGetBalanceRequest) ProtoMessage() {} + +func (x *WalletGetBalanceRequest) ProtoReflect() protoreflect.Message { + mi := &file_nockchain_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 WalletGetBalanceRequest.ProtoReflect.Descriptor instead. +func (*WalletGetBalanceRequest) Descriptor() ([]byte, []int) { + return file_nockchain_proto_rawDescGZIP(), []int{0} +} + +func (x *WalletGetBalanceRequest) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *WalletGetBalanceRequest) GetPage() *PageRequest { + if x != nil { + return x.Page + } + return nil +} + +type WalletGetBalanceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Result: + // + // *WalletGetBalanceResponse_Balance + // *WalletGetBalanceResponse_Error + Result isWalletGetBalanceResponse_Result `protobuf_oneof:"result"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WalletGetBalanceResponse) Reset() { + *x = WalletGetBalanceResponse{} + mi := &file_nockchain_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WalletGetBalanceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WalletGetBalanceResponse) ProtoMessage() {} + +func (x *WalletGetBalanceResponse) ProtoReflect() protoreflect.Message { + mi := &file_nockchain_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 WalletGetBalanceResponse.ProtoReflect.Descriptor instead. +func (*WalletGetBalanceResponse) Descriptor() ([]byte, []int) { + return file_nockchain_proto_rawDescGZIP(), []int{1} +} + +func (x *WalletGetBalanceResponse) GetResult() isWalletGetBalanceResponse_Result { + if x != nil { + return x.Result + } + return nil +} + +func (x *WalletGetBalanceResponse) GetBalance() *WalletBalanceData { + if x != nil { + if x, ok := x.Result.(*WalletGetBalanceResponse_Balance); ok { + return x.Balance + } + } + return nil +} + +func (x *WalletGetBalanceResponse) GetError() *ErrorStatus { + if x != nil { + if x, ok := x.Result.(*WalletGetBalanceResponse_Error); ok { + return x.Error + } + } + return nil +} + +type isWalletGetBalanceResponse_Result interface { + isWalletGetBalanceResponse_Result() +} + +type WalletGetBalanceResponse_Balance struct { + // Paginated wallet balance data with full entries and snapshot metadata. + // Continue paging using `balance.page.next_page_token` until empty. Clients + // should treat the page token as opaque; it may encode snapshot identity + // and the last returned key. + Balance *WalletBalanceData `protobuf:"bytes,1,opt,name=balance,proto3,oneof"` +} + +type WalletGetBalanceResponse_Error struct { + Error *ErrorStatus `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +func (*WalletGetBalanceResponse_Balance) isWalletGetBalanceResponse_Result() {} + +func (*WalletGetBalanceResponse_Error) isWalletGetBalanceResponse_Result() {} + +type WalletSendTransactionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + TxId *Hash `protobuf:"bytes,1,opt,name=tx_id,json=txId,proto3" json:"tx_id,omitempty"` // base58 encoded transaction ID for tracking + RawTx *RawTransaction `protobuf:"bytes,2,opt,name=raw_tx,json=rawTx,proto3" json:"raw_tx,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WalletSendTransactionRequest) Reset() { + *x = WalletSendTransactionRequest{} + mi := &file_nockchain_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WalletSendTransactionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WalletSendTransactionRequest) ProtoMessage() {} + +func (x *WalletSendTransactionRequest) ProtoReflect() protoreflect.Message { + mi := &file_nockchain_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 WalletSendTransactionRequest.ProtoReflect.Descriptor instead. +func (*WalletSendTransactionRequest) Descriptor() ([]byte, []int) { + return file_nockchain_proto_rawDescGZIP(), []int{2} +} + +func (x *WalletSendTransactionRequest) GetTxId() *Hash { + if x != nil { + return x.TxId + } + return nil +} + +func (x *WalletSendTransactionRequest) GetRawTx() *RawTransaction { + if x != nil { + return x.RawTx + } + return nil +} + +type WalletSendTransactionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Result: + // + // *WalletSendTransactionResponse_Ack + // *WalletSendTransactionResponse_Error + Result isWalletSendTransactionResponse_Result `protobuf_oneof:"result"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WalletSendTransactionResponse) Reset() { + *x = WalletSendTransactionResponse{} + mi := &file_nockchain_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WalletSendTransactionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WalletSendTransactionResponse) ProtoMessage() {} + +func (x *WalletSendTransactionResponse) ProtoReflect() protoreflect.Message { + mi := &file_nockchain_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 WalletSendTransactionResponse.ProtoReflect.Descriptor instead. +func (*WalletSendTransactionResponse) Descriptor() ([]byte, []int) { + return file_nockchain_proto_rawDescGZIP(), []int{3} +} + +func (x *WalletSendTransactionResponse) GetResult() isWalletSendTransactionResponse_Result { + if x != nil { + return x.Result + } + return nil +} + +func (x *WalletSendTransactionResponse) GetAck() *Acknowledged { + if x != nil { + if x, ok := x.Result.(*WalletSendTransactionResponse_Ack); ok { + return x.Ack + } + } + return nil +} + +func (x *WalletSendTransactionResponse) GetError() *ErrorStatus { + if x != nil { + if x, ok := x.Result.(*WalletSendTransactionResponse_Error); ok { + return x.Error + } + } + return nil +} + +type isWalletSendTransactionResponse_Result interface { + isWalletSendTransactionResponse_Result() +} + +type WalletSendTransactionResponse_Ack struct { + // true is request was acknowledge by node, + // this does not mean that the transaction was + // confirmed and/or accepted. + Ack *Acknowledged `protobuf:"bytes,1,opt,name=ack,proto3,oneof"` +} + +type WalletSendTransactionResponse_Error struct { + Error *ErrorStatus `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +func (*WalletSendTransactionResponse_Ack) isWalletSendTransactionResponse_Result() {} + +func (*WalletSendTransactionResponse_Error) isWalletSendTransactionResponse_Result() {} + +type TransactionAcceptedRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + TxId *Base58Hash `protobuf:"bytes,1,opt,name=tx_id,json=txId,proto3" json:"tx_id,omitempty"` // base58 encoded transaction ID for tracking + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TransactionAcceptedRequest) Reset() { + *x = TransactionAcceptedRequest{} + mi := &file_nockchain_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TransactionAcceptedRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TransactionAcceptedRequest) ProtoMessage() {} + +func (x *TransactionAcceptedRequest) ProtoReflect() protoreflect.Message { + mi := &file_nockchain_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 TransactionAcceptedRequest.ProtoReflect.Descriptor instead. +func (*TransactionAcceptedRequest) Descriptor() ([]byte, []int) { + return file_nockchain_proto_rawDescGZIP(), []int{4} +} + +func (x *TransactionAcceptedRequest) GetTxId() *Base58Hash { + if x != nil { + return x.TxId + } + return nil +} + +type TransactionAcceptedResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // true if transaction was accepted by node. this not does mean that the + // transaction was confirmed. Just that it was validated by the node and + // added to its raw-tx set. + // + // Types that are valid to be assigned to Result: + // + // *TransactionAcceptedResponse_Accepted + // *TransactionAcceptedResponse_Error + Result isTransactionAcceptedResponse_Result `protobuf_oneof:"result"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TransactionAcceptedResponse) Reset() { + *x = TransactionAcceptedResponse{} + mi := &file_nockchain_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TransactionAcceptedResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TransactionAcceptedResponse) ProtoMessage() {} + +func (x *TransactionAcceptedResponse) ProtoReflect() protoreflect.Message { + mi := &file_nockchain_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 TransactionAcceptedResponse.ProtoReflect.Descriptor instead. +func (*TransactionAcceptedResponse) Descriptor() ([]byte, []int) { + return file_nockchain_proto_rawDescGZIP(), []int{5} +} + +func (x *TransactionAcceptedResponse) GetResult() isTransactionAcceptedResponse_Result { + if x != nil { + return x.Result + } + return nil +} + +func (x *TransactionAcceptedResponse) GetAccepted() bool { + if x != nil { + if x, ok := x.Result.(*TransactionAcceptedResponse_Accepted); ok { + return x.Accepted + } + } + return false +} + +func (x *TransactionAcceptedResponse) GetError() *ErrorStatus { + if x != nil { + if x, ok := x.Result.(*TransactionAcceptedResponse_Error); ok { + return x.Error + } + } + return nil +} + +type isTransactionAcceptedResponse_Result interface { + isTransactionAcceptedResponse_Result() +} + +type TransactionAcceptedResponse_Accepted struct { + Accepted bool `protobuf:"varint,1,opt,name=accepted,proto3,oneof"` +} + +type TransactionAcceptedResponse_Error struct { + Error *ErrorStatus `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +func (*TransactionAcceptedResponse_Accepted) isTransactionAcceptedResponse_Result() {} + +func (*TransactionAcceptedResponse_Error) isTransactionAcceptedResponse_Result() {} + +var File_nockchain_proto protoreflect.FileDescriptor + +const file_nockchain_proto_rawDesc = "" + + "\n" + + "\x0fnockchain.proto\x12\x13nockchain.public.v1\x1a\x10blockchain.proto\x1a\x10primitives.proto\x1a\x10pagination.proto\"i\n" + + "\x17WalletGetBalanceRequest\x12\x18\n" + + "\aaddress\x18\x01 \x01(\tR\aaddress\x124\n" + + "\x04page\x18\x02 \x01(\v2 .nockchain.public.v1.PageRequestR\x04page\"\xa2\x01\n" + + "\x18WalletGetBalanceResponse\x12B\n" + + "\abalance\x18\x01 \x01(\v2&.nockchain.public.v1.WalletBalanceDataH\x00R\abalance\x128\n" + + "\x05error\x18\x02 \x01(\v2 .nockchain.public.v1.ErrorStatusH\x00R\x05errorB\b\n" + + "\x06result\"\x8a\x01\n" + + "\x1cWalletSendTransactionRequest\x12.\n" + + "\x05tx_id\x18\x01 \x01(\v2\x19.nockchain.public.v1.HashR\x04txId\x12:\n" + + "\x06raw_tx\x18\x02 \x01(\v2#.nockchain.public.v1.RawTransactionR\x05rawTx\"\x9a\x01\n" + + "\x1dWalletSendTransactionResponse\x125\n" + + "\x03ack\x18\x01 \x01(\v2!.nockchain.public.v1.AcknowledgedH\x00R\x03ack\x128\n" + + "\x05error\x18\x02 \x01(\v2 .nockchain.public.v1.ErrorStatusH\x00R\x05errorB\b\n" + + "\x06result\"R\n" + + "\x1aTransactionAcceptedRequest\x124\n" + + "\x05tx_id\x18\x01 \x01(\v2\x1f.nockchain.public.v1.Base58HashR\x04txId\"\x7f\n" + + "\x1bTransactionAcceptedResponse\x12\x1c\n" + + "\baccepted\x18\x01 \x01(\bH\x00R\baccepted\x128\n" + + "\x05error\x18\x02 \x01(\v2 .nockchain.public.v1.ErrorStatusH\x00R\x05errorB\b\n" + + "\x06result2\xfd\x02\n" + + "\x10NockchainService\x12o\n" + + "\x10WalletGetBalance\x12,.nockchain.public.v1.WalletGetBalanceRequest\x1a-.nockchain.public.v1.WalletGetBalanceResponse\x12~\n" + + "\x15WalletSendTransaction\x121.nockchain.public.v1.WalletSendTransactionRequest\x1a2.nockchain.public.v1.WalletSendTransactionResponse\x12x\n" + + "\x13TransactionAccepted\x12/.nockchain.public.v1.TransactionAcceptedRequest\x1a0.nockchain.public.v1.TransactionAcceptedResponseB\x0eZ\f./;nockchainb\x06proto3" + +var ( + file_nockchain_proto_rawDescOnce sync.Once + file_nockchain_proto_rawDescData []byte +) + +func file_nockchain_proto_rawDescGZIP() []byte { + file_nockchain_proto_rawDescOnce.Do(func() { + file_nockchain_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_nockchain_proto_rawDesc), len(file_nockchain_proto_rawDesc))) + }) + return file_nockchain_proto_rawDescData +} + +var file_nockchain_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_nockchain_proto_goTypes = []any{ + (*WalletGetBalanceRequest)(nil), // 0: nockchain.public.v1.WalletGetBalanceRequest + (*WalletGetBalanceResponse)(nil), // 1: nockchain.public.v1.WalletGetBalanceResponse + (*WalletSendTransactionRequest)(nil), // 2: nockchain.public.v1.WalletSendTransactionRequest + (*WalletSendTransactionResponse)(nil), // 3: nockchain.public.v1.WalletSendTransactionResponse + (*TransactionAcceptedRequest)(nil), // 4: nockchain.public.v1.TransactionAcceptedRequest + (*TransactionAcceptedResponse)(nil), // 5: nockchain.public.v1.TransactionAcceptedResponse + (*PageRequest)(nil), // 6: nockchain.public.v1.PageRequest + (*WalletBalanceData)(nil), // 7: nockchain.public.v1.WalletBalanceData + (*ErrorStatus)(nil), // 8: nockchain.public.v1.ErrorStatus + (*Hash)(nil), // 9: nockchain.public.v1.Hash + (*RawTransaction)(nil), // 10: nockchain.public.v1.RawTransaction + (*Acknowledged)(nil), // 11: nockchain.public.v1.Acknowledged + (*Base58Hash)(nil), // 12: nockchain.public.v1.Base58Hash +} +var file_nockchain_proto_depIdxs = []int32{ + 6, // 0: nockchain.public.v1.WalletGetBalanceRequest.page:type_name -> nockchain.public.v1.PageRequest + 7, // 1: nockchain.public.v1.WalletGetBalanceResponse.balance:type_name -> nockchain.public.v1.WalletBalanceData + 8, // 2: nockchain.public.v1.WalletGetBalanceResponse.error:type_name -> nockchain.public.v1.ErrorStatus + 9, // 3: nockchain.public.v1.WalletSendTransactionRequest.tx_id:type_name -> nockchain.public.v1.Hash + 10, // 4: nockchain.public.v1.WalletSendTransactionRequest.raw_tx:type_name -> nockchain.public.v1.RawTransaction + 11, // 5: nockchain.public.v1.WalletSendTransactionResponse.ack:type_name -> nockchain.public.v1.Acknowledged + 8, // 6: nockchain.public.v1.WalletSendTransactionResponse.error:type_name -> nockchain.public.v1.ErrorStatus + 12, // 7: nockchain.public.v1.TransactionAcceptedRequest.tx_id:type_name -> nockchain.public.v1.Base58Hash + 8, // 8: nockchain.public.v1.TransactionAcceptedResponse.error:type_name -> nockchain.public.v1.ErrorStatus + 0, // 9: nockchain.public.v1.NockchainService.WalletGetBalance:input_type -> nockchain.public.v1.WalletGetBalanceRequest + 2, // 10: nockchain.public.v1.NockchainService.WalletSendTransaction:input_type -> nockchain.public.v1.WalletSendTransactionRequest + 4, // 11: nockchain.public.v1.NockchainService.TransactionAccepted:input_type -> nockchain.public.v1.TransactionAcceptedRequest + 1, // 12: nockchain.public.v1.NockchainService.WalletGetBalance:output_type -> nockchain.public.v1.WalletGetBalanceResponse + 3, // 13: nockchain.public.v1.NockchainService.WalletSendTransaction:output_type -> nockchain.public.v1.WalletSendTransactionResponse + 5, // 14: nockchain.public.v1.NockchainService.TransactionAccepted:output_type -> nockchain.public.v1.TransactionAcceptedResponse + 12, // [12:15] is the sub-list for method output_type + 9, // [9:12] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_nockchain_proto_init() } +func file_nockchain_proto_init() { + if File_nockchain_proto != nil { + return + } + file_blockchain_proto_init() + file_primitives_proto_init() + file_pagination_proto_init() + file_nockchain_proto_msgTypes[1].OneofWrappers = []any{ + (*WalletGetBalanceResponse_Balance)(nil), + (*WalletGetBalanceResponse_Error)(nil), + } + file_nockchain_proto_msgTypes[3].OneofWrappers = []any{ + (*WalletSendTransactionResponse_Ack)(nil), + (*WalletSendTransactionResponse_Error)(nil), + } + file_nockchain_proto_msgTypes[5].OneofWrappers = []any{ + (*TransactionAcceptedResponse_Accepted)(nil), + (*TransactionAcceptedResponse_Error)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_nockchain_proto_rawDesc), len(file_nockchain_proto_rawDesc)), + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_nockchain_proto_goTypes, + DependencyIndexes: file_nockchain_proto_depIdxs, + MessageInfos: file_nockchain_proto_msgTypes, + }.Build() + File_nockchain_proto = out.File + file_nockchain_proto_goTypes = nil + file_nockchain_proto_depIdxs = nil +} diff --git a/nockchain/nockchain_grpc.pb.go b/nockchain/nockchain_grpc.pb.go new file mode 100644 index 0000000..50f01ed --- /dev/null +++ b/nockchain/nockchain_grpc.pb.go @@ -0,0 +1,199 @@ +// nockchain/public/v1/nockchain.proto + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v3.20.3 +// source: nockchain.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 ( + NockchainService_WalletGetBalance_FullMethodName = "/nockchain.public.v1.NockchainService/WalletGetBalance" + NockchainService_WalletSendTransaction_FullMethodName = "/nockchain.public.v1.NockchainService/WalletSendTransaction" + NockchainService_TransactionAccepted_FullMethodName = "/nockchain.public.v1.NockchainService/TransactionAccepted" +) + +// NockchainServiceClient is the client API for NockchainService 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 NockchainServiceClient interface { + WalletGetBalance(ctx context.Context, in *WalletGetBalanceRequest, opts ...grpc.CallOption) (*WalletGetBalanceResponse, error) + WalletSendTransaction(ctx context.Context, in *WalletSendTransactionRequest, opts ...grpc.CallOption) (*WalletSendTransactionResponse, error) + TransactionAccepted(ctx context.Context, in *TransactionAcceptedRequest, opts ...grpc.CallOption) (*TransactionAcceptedResponse, error) +} + +type nockchainServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewNockchainServiceClient(cc grpc.ClientConnInterface) NockchainServiceClient { + return &nockchainServiceClient{cc} +} + +func (c *nockchainServiceClient) WalletGetBalance(ctx context.Context, in *WalletGetBalanceRequest, opts ...grpc.CallOption) (*WalletGetBalanceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(WalletGetBalanceResponse) + err := c.cc.Invoke(ctx, NockchainService_WalletGetBalance_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *nockchainServiceClient) WalletSendTransaction(ctx context.Context, in *WalletSendTransactionRequest, opts ...grpc.CallOption) (*WalletSendTransactionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(WalletSendTransactionResponse) + err := c.cc.Invoke(ctx, NockchainService_WalletSendTransaction_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *nockchainServiceClient) TransactionAccepted(ctx context.Context, in *TransactionAcceptedRequest, opts ...grpc.CallOption) (*TransactionAcceptedResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(TransactionAcceptedResponse) + err := c.cc.Invoke(ctx, NockchainService_TransactionAccepted_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// NockchainServiceServer is the server API for NockchainService service. +// All implementations must embed UnimplementedNockchainServiceServer +// for forward compatibility. +type NockchainServiceServer interface { + WalletGetBalance(context.Context, *WalletGetBalanceRequest) (*WalletGetBalanceResponse, error) + WalletSendTransaction(context.Context, *WalletSendTransactionRequest) (*WalletSendTransactionResponse, error) + TransactionAccepted(context.Context, *TransactionAcceptedRequest) (*TransactionAcceptedResponse, error) + mustEmbedUnimplementedNockchainServiceServer() +} + +// UnimplementedNockchainServiceServer 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 UnimplementedNockchainServiceServer struct{} + +func (UnimplementedNockchainServiceServer) WalletGetBalance(context.Context, *WalletGetBalanceRequest) (*WalletGetBalanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WalletGetBalance not implemented") +} +func (UnimplementedNockchainServiceServer) WalletSendTransaction(context.Context, *WalletSendTransactionRequest) (*WalletSendTransactionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WalletSendTransaction not implemented") +} +func (UnimplementedNockchainServiceServer) TransactionAccepted(context.Context, *TransactionAcceptedRequest) (*TransactionAcceptedResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransactionAccepted not implemented") +} +func (UnimplementedNockchainServiceServer) mustEmbedUnimplementedNockchainServiceServer() {} +func (UnimplementedNockchainServiceServer) testEmbeddedByValue() {} + +// UnsafeNockchainServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to NockchainServiceServer will +// result in compilation errors. +type UnsafeNockchainServiceServer interface { + mustEmbedUnimplementedNockchainServiceServer() +} + +func RegisterNockchainServiceServer(s grpc.ServiceRegistrar, srv NockchainServiceServer) { + // If the following call pancis, it indicates UnimplementedNockchainServiceServer 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(&NockchainService_ServiceDesc, srv) +} + +func _NockchainService_WalletGetBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WalletGetBalanceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NockchainServiceServer).WalletGetBalance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NockchainService_WalletGetBalance_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NockchainServiceServer).WalletGetBalance(ctx, req.(*WalletGetBalanceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NockchainService_WalletSendTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WalletSendTransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NockchainServiceServer).WalletSendTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NockchainService_WalletSendTransaction_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NockchainServiceServer).WalletSendTransaction(ctx, req.(*WalletSendTransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NockchainService_TransactionAccepted_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TransactionAcceptedRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NockchainServiceServer).TransactionAccepted(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NockchainService_TransactionAccepted_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NockchainServiceServer).TransactionAccepted(ctx, req.(*TransactionAcceptedRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// NockchainService_ServiceDesc is the grpc.ServiceDesc for NockchainService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var NockchainService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "nockchain.public.v1.NockchainService", + HandlerType: (*NockchainServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "WalletGetBalance", + Handler: _NockchainService_WalletGetBalance_Handler, + }, + { + MethodName: "WalletSendTransaction", + Handler: _NockchainService_WalletSendTransaction_Handler, + }, + { + MethodName: "TransactionAccepted", + Handler: _NockchainService_TransactionAccepted_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "nockchain.proto", +} diff --git a/nockchain/pagination.pb.go b/nockchain/pagination.pb.go new file mode 100644 index 0000000..2ff4d81 --- /dev/null +++ b/nockchain/pagination.pb.go @@ -0,0 +1,211 @@ +// nockchain/common/v1/pagination.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.9 +// protoc v3.20.3 +// source: pagination.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) +) + +// Generic pagination parameters for list-style RPCs. +// These types are intended to be reused across public APIs. +// +// Contract: +// - The server may return fewer items than requested (client_page_items_limit is a hint). +// - page_token is an opaque cursor produced by the server; clients must treat +// it as a black box. Servers may encode snapshot identity and last-key. +// - For consistent pagination, clients should include the returned page_token +// in the next request without modification. +// - Servers may enforce a maximum client_page_items_limit and/or byte budget regardless of +// client hints. +type PageRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Maximum number of items to return. The server may return fewer items + // than requested. Clients should not rely on receiving exactly this count. + ClientPageItemsLimit uint32 `protobuf:"varint,1,opt,name=client_page_items_limit,json=clientPageItemsLimit,proto3" json:"client_page_items_limit,omitempty"` + // Opaque cursor returned by a previous call. When set, the server resumes + // the listing from the position described by the token. + // An empty token indicates the first page. + PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + // Optional soft limit on the uncompressed bytes to return in a single page. + // The server may ignore or cap this value according to policy. This refers + // to the gRPC payload size after protobuf encoding and decompression. + MaxBytes uint64 `protobuf:"varint,3,opt,name=max_bytes,json=maxBytes,proto3" json:"max_bytes,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PageRequest) Reset() { + *x = PageRequest{} + mi := &file_pagination_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PageRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PageRequest) ProtoMessage() {} + +func (x *PageRequest) ProtoReflect() protoreflect.Message { + mi := &file_pagination_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 PageRequest.ProtoReflect.Descriptor instead. +func (*PageRequest) Descriptor() ([]byte, []int) { + return file_pagination_proto_rawDescGZIP(), []int{0} +} + +func (x *PageRequest) GetClientPageItemsLimit() uint32 { + if x != nil { + return x.ClientPageItemsLimit + } + return 0 +} + +func (x *PageRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *PageRequest) GetMaxBytes() uint64 { + if x != nil { + return x.MaxBytes + } + return 0 +} + +type PageResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Opaque cursor for fetching the next page. Empty when there are no more + // results. + NextPageToken string `protobuf:"bytes,1,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PageResponse) Reset() { + *x = PageResponse{} + mi := &file_pagination_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PageResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PageResponse) ProtoMessage() {} + +func (x *PageResponse) ProtoReflect() protoreflect.Message { + mi := &file_pagination_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 PageResponse.ProtoReflect.Descriptor instead. +func (*PageResponse) Descriptor() ([]byte, []int) { + return file_pagination_proto_rawDescGZIP(), []int{1} +} + +func (x *PageResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +var File_pagination_proto protoreflect.FileDescriptor + +const file_pagination_proto_rawDesc = "" + + "\n" + + "\x10pagination.proto\x12\x13nockchain.public.v1\"\x80\x01\n" + + "\vPageRequest\x125\n" + + "\x17client_page_items_limit\x18\x01 \x01(\rR\x14clientPageItemsLimit\x12\x1d\n" + + "\n" + + "page_token\x18\x02 \x01(\tR\tpageToken\x12\x1b\n" + + "\tmax_bytes\x18\x03 \x01(\x04R\bmaxBytes\"6\n" + + "\fPageResponse\x12&\n" + + "\x0fnext_page_token\x18\x01 \x01(\tR\rnextPageTokenB\x0eZ\f./;nockchainb\x06proto3" + +var ( + file_pagination_proto_rawDescOnce sync.Once + file_pagination_proto_rawDescData []byte +) + +func file_pagination_proto_rawDescGZIP() []byte { + file_pagination_proto_rawDescOnce.Do(func() { + file_pagination_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_pagination_proto_rawDesc), len(file_pagination_proto_rawDesc))) + }) + return file_pagination_proto_rawDescData +} + +var file_pagination_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_pagination_proto_goTypes = []any{ + (*PageRequest)(nil), // 0: nockchain.public.v1.PageRequest + (*PageResponse)(nil), // 1: nockchain.public.v1.PageResponse +} +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 input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_pagination_proto_init() } +func file_pagination_proto_init() { + if File_pagination_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_pagination_proto_rawDesc), len(file_pagination_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_pagination_proto_goTypes, + DependencyIndexes: file_pagination_proto_depIdxs, + MessageInfos: file_pagination_proto_msgTypes, + }.Build() + File_pagination_proto = out.File + file_pagination_proto_goTypes = nil + file_pagination_proto_depIdxs = nil +} diff --git a/nockchain/primitives.pb.go b/nockchain/primitives.pb.go new file mode 100644 index 0000000..4b9fd9c --- /dev/null +++ b/nockchain/primitives.pb.go @@ -0,0 +1,1151 @@ +// nockchain/common/v1/primitives.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.9 +// protoc v3.20.3 +// source: primitives.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 ErrorCode int32 + +const ( + ErrorCode_ERROR_CODE_UNSPECIFIED ErrorCode = 0 + ErrorCode_ERROR_CODE_INVALID_REQUEST ErrorCode = 1 + ErrorCode_ERROR_CODE_PEEK_FAILED ErrorCode = 2 + ErrorCode_ERROR_CODE_PEEK_RETURNED_NO_DATA ErrorCode = 3 + ErrorCode_ERROR_CODE_POKE_FAILED ErrorCode = 4 + ErrorCode_ERROR_CODE_NACKAPP_ERROR ErrorCode = 5 + ErrorCode_ERROR_CODE_TIMEOUT ErrorCode = 6 + ErrorCode_ERROR_CODE_INTERNAL_ERROR ErrorCode = 7 + ErrorCode_ERROR_CODE_NOT_FOUND ErrorCode = 8 + ErrorCode_ERROR_CODE_PERMISSION_DENIED ErrorCode = 9 + ErrorCode_ERROR_CODE_INVALID_WIRE ErrorCode = 10 + ErrorCode_ERROR_CODE_KERNEL_ERROR ErrorCode = 11 +) + +// Enum value maps for ErrorCode. +var ( + ErrorCode_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", + } + ErrorCode_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 ErrorCode) Enum() *ErrorCode { + p := new(ErrorCode) + *p = x + return p +} + +func (x ErrorCode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ErrorCode) Descriptor() protoreflect.EnumDescriptor { + return file_primitives_proto_enumTypes[0].Descriptor() +} + +func (ErrorCode) Type() protoreflect.EnumType { + return &file_primitives_proto_enumTypes[0] +} + +func (x ErrorCode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ErrorCode.Descriptor instead. +func (ErrorCode) EnumDescriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{0} +} + +type ErrorStatus struct { + state protoimpl.MessageState `protogen:"open.v1"` + Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=nockchain.public.v1.ErrorCode" json:"code,omitempty"` + 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 *ErrorStatus) Reset() { + *x = ErrorStatus{} + mi := &file_primitives_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ErrorStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ErrorStatus) ProtoMessage() {} + +func (x *ErrorStatus) ProtoReflect() protoreflect.Message { + mi := &file_primitives_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 ErrorStatus.ProtoReflect.Descriptor instead. +func (*ErrorStatus) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{0} +} + +func (x *ErrorStatus) GetCode() ErrorCode { + if x != nil { + return x.Code + } + return ErrorCode_ERROR_CODE_UNSPECIFIED +} + +func (x *ErrorStatus) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *ErrorStatus) GetDetails() string { + if x != nil && x.Details != nil { + return *x.Details + } + return "" +} + +type Acknowledged struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Acknowledged) Reset() { + *x = Acknowledged{} + mi := &file_primitives_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Acknowledged) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Acknowledged) ProtoMessage() {} + +func (x *Acknowledged) ProtoReflect() protoreflect.Message { + mi := &file_primitives_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 Acknowledged.ProtoReflect.Descriptor instead. +func (*Acknowledged) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{1} +} + +type Wire struct { + state protoimpl.MessageState `protogen:"open.v1"` + Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"` // e.g., "http", "file", "wallet", "grpc" + Version uint64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` // wire format version + Tags []*WireTag `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty"` // operation-specific tags + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Wire) Reset() { + *x = Wire{} + mi := &file_primitives_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Wire) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Wire) ProtoMessage() {} + +func (x *Wire) ProtoReflect() protoreflect.Message { + mi := &file_primitives_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Wire.ProtoReflect.Descriptor instead. +func (*Wire) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{2} +} + +func (x *Wire) GetSource() string { + if x != nil { + return x.Source + } + return "" +} + +func (x *Wire) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *Wire) GetTags() []*WireTag { + if x != nil { + return x.Tags + } + return nil +} + +type WireTag struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Value: + // + // *WireTag_Text + // *WireTag_Number + Value isWireTag_Value `protobuf_oneof:"value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WireTag) Reset() { + *x = WireTag{} + mi := &file_primitives_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WireTag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WireTag) ProtoMessage() {} + +func (x *WireTag) ProtoReflect() protoreflect.Message { + mi := &file_primitives_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WireTag.ProtoReflect.Descriptor instead. +func (*WireTag) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{3} +} + +func (x *WireTag) GetValue() isWireTag_Value { + if x != nil { + return x.Value + } + return nil +} + +func (x *WireTag) GetText() string { + if x != nil { + if x, ok := x.Value.(*WireTag_Text); ok { + return x.Text + } + } + return "" +} + +func (x *WireTag) GetNumber() uint64 { + if x != nil { + if x, ok := x.Value.(*WireTag_Number); ok { + return x.Number + } + } + return 0 +} + +type isWireTag_Value interface { + isWireTag_Value() +} + +type WireTag_Text struct { + Text string `protobuf:"bytes,1,opt,name=text,proto3,oneof"` +} + +type WireTag_Number struct { + Number uint64 `protobuf:"varint,2,opt,name=number,proto3,oneof"` +} + +func (*WireTag_Text) isWireTag_Value() {} + +func (*WireTag_Number) isWireTag_Value() {} + +// Note: prefer using raw numeric fields in messages +// instead of these wrappers to simplify conversions. +// These remain defined for potential future use. +type NoteVersion struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NoteVersion) Reset() { + *x = NoteVersion{} + mi := &file_primitives_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NoteVersion) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NoteVersion) ProtoMessage() {} + +func (x *NoteVersion) ProtoReflect() protoreflect.Message { + mi := &file_primitives_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 NoteVersion.ProtoReflect.Descriptor instead. +func (*NoteVersion) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{4} +} + +func (x *NoteVersion) GetValue() uint32 { + if x != nil { + return x.Value + } + return 0 +} + +type BlockHeight struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BlockHeight) Reset() { + *x = BlockHeight{} + mi := &file_primitives_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BlockHeight) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockHeight) ProtoMessage() {} + +func (x *BlockHeight) ProtoReflect() protoreflect.Message { + mi := &file_primitives_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 BlockHeight.ProtoReflect.Descriptor instead. +func (*BlockHeight) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{5} +} + +func (x *BlockHeight) GetValue() uint64 { + if x != nil { + return x.Value + } + return 0 +} + +type BlockHeightDelta struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BlockHeightDelta) Reset() { + *x = BlockHeightDelta{} + mi := &file_primitives_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BlockHeightDelta) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockHeightDelta) ProtoMessage() {} + +func (x *BlockHeightDelta) ProtoReflect() protoreflect.Message { + mi := &file_primitives_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 BlockHeightDelta.ProtoReflect.Descriptor instead. +func (*BlockHeightDelta) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{6} +} + +func (x *BlockHeightDelta) GetValue() uint64 { + if x != nil { + return x.Value + } + return 0 +} + +type Nicks struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Nicks) Reset() { + *x = Nicks{} + mi := &file_primitives_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Nicks) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Nicks) ProtoMessage() {} + +func (x *Nicks) ProtoReflect() protoreflect.Message { + mi := &file_primitives_proto_msgTypes[7] + 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 Nicks.ProtoReflect.Descriptor instead. +func (*Nicks) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{7} +} + +func (x *Nicks) GetValue() uint64 { + if x != nil { + return x.Value + } + return 0 +} + +// pub chal: [Belt; 8], +// pub sig: [Belt; 8], +type EightBelt struct { + state protoimpl.MessageState `protogen:"open.v1"` + Belt_1 *Belt `protobuf:"bytes,1,opt,name=belt_1,json=belt1,proto3" json:"belt_1,omitempty"` + Belt_2 *Belt `protobuf:"bytes,2,opt,name=belt_2,json=belt2,proto3" json:"belt_2,omitempty"` + Belt_3 *Belt `protobuf:"bytes,3,opt,name=belt_3,json=belt3,proto3" json:"belt_3,omitempty"` + Belt_4 *Belt `protobuf:"bytes,4,opt,name=belt_4,json=belt4,proto3" json:"belt_4,omitempty"` + Belt_5 *Belt `protobuf:"bytes,5,opt,name=belt_5,json=belt5,proto3" json:"belt_5,omitempty"` + Belt_6 *Belt `protobuf:"bytes,6,opt,name=belt_6,json=belt6,proto3" json:"belt_6,omitempty"` + Belt_7 *Belt `protobuf:"bytes,7,opt,name=belt_7,json=belt7,proto3" json:"belt_7,omitempty"` + Belt_8 *Belt `protobuf:"bytes,8,opt,name=belt_8,json=belt8,proto3" json:"belt_8,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EightBelt) Reset() { + *x = EightBelt{} + mi := &file_primitives_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EightBelt) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EightBelt) ProtoMessage() {} + +func (x *EightBelt) ProtoReflect() protoreflect.Message { + mi := &file_primitives_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 EightBelt.ProtoReflect.Descriptor instead. +func (*EightBelt) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{8} +} + +func (x *EightBelt) GetBelt_1() *Belt { + if x != nil { + return x.Belt_1 + } + return nil +} + +func (x *EightBelt) GetBelt_2() *Belt { + if x != nil { + return x.Belt_2 + } + return nil +} + +func (x *EightBelt) GetBelt_3() *Belt { + if x != nil { + return x.Belt_3 + } + return nil +} + +func (x *EightBelt) GetBelt_4() *Belt { + if x != nil { + return x.Belt_4 + } + return nil +} + +func (x *EightBelt) GetBelt_5() *Belt { + if x != nil { + return x.Belt_5 + } + return nil +} + +func (x *EightBelt) GetBelt_6() *Belt { + if x != nil { + return x.Belt_6 + } + return nil +} + +func (x *EightBelt) GetBelt_7() *Belt { + if x != nil { + return x.Belt_7 + } + return nil +} + +func (x *EightBelt) GetBelt_8() *Belt { + if x != nil { + return x.Belt_8 + } + return nil +} + +// pub struct Hash(pub [Belt; 5]); +// Use fixed fields to avoid variable-length vectors. +type Hash struct { + state protoimpl.MessageState `protogen:"open.v1"` + Belt_1 *Belt `protobuf:"bytes,1,opt,name=belt_1,json=belt1,proto3" json:"belt_1,omitempty"` + Belt_2 *Belt `protobuf:"bytes,2,opt,name=belt_2,json=belt2,proto3" json:"belt_2,omitempty"` + Belt_3 *Belt `protobuf:"bytes,3,opt,name=belt_3,json=belt3,proto3" json:"belt_3,omitempty"` + Belt_4 *Belt `protobuf:"bytes,4,opt,name=belt_4,json=belt4,proto3" json:"belt_4,omitempty"` + Belt_5 *Belt `protobuf:"bytes,5,opt,name=belt_5,json=belt5,proto3" json:"belt_5,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Hash) Reset() { + *x = Hash{} + mi := &file_primitives_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Hash) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Hash) ProtoMessage() {} + +func (x *Hash) 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 Hash.ProtoReflect.Descriptor instead. +func (*Hash) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{9} +} + +func (x *Hash) GetBelt_1() *Belt { + if x != nil { + return x.Belt_1 + } + return nil +} + +func (x *Hash) GetBelt_2() *Belt { + if x != nil { + return x.Belt_2 + } + return nil +} + +func (x *Hash) GetBelt_3() *Belt { + if x != nil { + return x.Belt_3 + } + return nil +} + +func (x *Hash) GetBelt_4() *Belt { + if x != nil { + return x.Belt_4 + } + return nil +} + +func (x *Hash) GetBelt_5() *Belt { + if x != nil { + return x.Belt_5 + } + return nil +} + +type Base58Hash struct { + state protoimpl.MessageState `protogen:"open.v1"` + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Base58Hash) Reset() { + *x = Base58Hash{} + mi := &file_primitives_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Base58Hash) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Base58Hash) ProtoMessage() {} + +func (x *Base58Hash) ProtoReflect() protoreflect.Message { + mi := &file_primitives_proto_msgTypes[10] + 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 Base58Hash.ProtoReflect.Descriptor instead. +func (*Base58Hash) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{10} +} + +func (x *Base58Hash) GetHash() string { + if x != nil { + return x.Hash + } + return "" +} + +// pub struct SchnorrPubkey(pub CheetahPoint); +type SchnorrPubkey struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value *CheetahPoint `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SchnorrPubkey) Reset() { + *x = SchnorrPubkey{} + mi := &file_primitives_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SchnorrPubkey) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SchnorrPubkey) ProtoMessage() {} + +func (x *SchnorrPubkey) ProtoReflect() protoreflect.Message { + mi := &file_primitives_proto_msgTypes[11] + 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 SchnorrPubkey.ProtoReflect.Descriptor instead. +func (*SchnorrPubkey) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{11} +} + +func (x *SchnorrPubkey) GetValue() *CheetahPoint { + if x != nil { + return x.Value + } + return nil +} + +// pub struct CheetahPoint { +// pub x: F6lt, +// pub y: F6lt, +// pub inf: bool, +// } +type CheetahPoint struct { + state protoimpl.MessageState `protogen:"open.v1"` + X *SixBelt `protobuf:"bytes,1,opt,name=x,proto3" json:"x,omitempty"` + Y *SixBelt `protobuf:"bytes,2,opt,name=y,proto3" json:"y,omitempty"` + Inf bool `protobuf:"varint,3,opt,name=inf,proto3" json:"inf,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CheetahPoint) Reset() { + *x = CheetahPoint{} + mi := &file_primitives_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CheetahPoint) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheetahPoint) ProtoMessage() {} + +func (x *CheetahPoint) ProtoReflect() protoreflect.Message { + mi := &file_primitives_proto_msgTypes[12] + 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 CheetahPoint.ProtoReflect.Descriptor instead. +func (*CheetahPoint) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{12} +} + +func (x *CheetahPoint) GetX() *SixBelt { + if x != nil { + return x.X + } + return nil +} + +func (x *CheetahPoint) GetY() *SixBelt { + if x != nil { + return x.Y + } + return nil +} + +func (x *CheetahPoint) GetInf() bool { + if x != nil { + return x.Inf + } + return false +} + +// pub struct F6lt(pub [Belt; 6]); +type SixBelt struct { + state protoimpl.MessageState `protogen:"open.v1"` + Belt_1 *Belt `protobuf:"bytes,1,opt,name=belt_1,json=belt1,proto3" json:"belt_1,omitempty"` + Belt_2 *Belt `protobuf:"bytes,2,opt,name=belt_2,json=belt2,proto3" json:"belt_2,omitempty"` + Belt_3 *Belt `protobuf:"bytes,3,opt,name=belt_3,json=belt3,proto3" json:"belt_3,omitempty"` + Belt_4 *Belt `protobuf:"bytes,4,opt,name=belt_4,json=belt4,proto3" json:"belt_4,omitempty"` + Belt_5 *Belt `protobuf:"bytes,5,opt,name=belt_5,json=belt5,proto3" json:"belt_5,omitempty"` + Belt_6 *Belt `protobuf:"bytes,6,opt,name=belt_6,json=belt6,proto3" json:"belt_6,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SixBelt) Reset() { + *x = SixBelt{} + mi := &file_primitives_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SixBelt) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SixBelt) ProtoMessage() {} + +func (x *SixBelt) ProtoReflect() protoreflect.Message { + mi := &file_primitives_proto_msgTypes[13] + 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 SixBelt.ProtoReflect.Descriptor instead. +func (*SixBelt) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{13} +} + +func (x *SixBelt) GetBelt_1() *Belt { + if x != nil { + return x.Belt_1 + } + return nil +} + +func (x *SixBelt) GetBelt_2() *Belt { + if x != nil { + return x.Belt_2 + } + return nil +} + +func (x *SixBelt) GetBelt_3() *Belt { + if x != nil { + return x.Belt_3 + } + return nil +} + +func (x *SixBelt) GetBelt_4() *Belt { + if x != nil { + return x.Belt_4 + } + return nil +} + +func (x *SixBelt) GetBelt_5() *Belt { + if x != nil { + return x.Belt_5 + } + return nil +} + +func (x *SixBelt) GetBelt_6() *Belt { + if x != nil { + return x.Belt_6 + } + return nil +} + +// pub struct Belt(pub u64); +type Belt struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Belt) Reset() { + *x = Belt{} + mi := &file_primitives_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Belt) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Belt) ProtoMessage() {} + +func (x *Belt) ProtoReflect() protoreflect.Message { + mi := &file_primitives_proto_msgTypes[14] + 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 Belt.ProtoReflect.Descriptor instead. +func (*Belt) Descriptor() ([]byte, []int) { + return file_primitives_proto_rawDescGZIP(), []int{14} +} + +func (x *Belt) GetValue() uint64 { + if x != nil { + return x.Value + } + return 0 +} + +var File_primitives_proto protoreflect.FileDescriptor + +const file_primitives_proto_rawDesc = "" + + "\n" + + "\x10primitives.proto\x12\x13nockchain.public.v1\"\x86\x01\n" + + "\vErrorStatus\x122\n" + + "\x04code\x18\x01 \x01(\x0e2\x1e.nockchain.public.v1.ErrorCodeR\x04code\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage\x12\x1d\n" + + "\adetails\x18\x03 \x01(\tH\x00R\adetails\x88\x01\x01B\n" + + "\n" + + "\b_details\"\x0e\n" + + "\fAcknowledged\"j\n" + + "\x04Wire\x12\x16\n" + + "\x06source\x18\x01 \x01(\tR\x06source\x12\x18\n" + + "\aversion\x18\x02 \x01(\x04R\aversion\x120\n" + + "\x04tags\x18\x03 \x03(\v2\x1c.nockchain.public.v1.WireTagR\x04tags\"B\n" + + "\aWireTag\x12\x14\n" + + "\x04text\x18\x01 \x01(\tH\x00R\x04text\x12\x18\n" + + "\x06number\x18\x02 \x01(\x04H\x00R\x06numberB\a\n" + + "\x05value\"#\n" + + "\vNoteVersion\x12\x14\n" + + "\x05value\x18\x01 \x01(\rR\x05value\"#\n" + + "\vBlockHeight\x12\x14\n" + + "\x05value\x18\x01 \x01(\x04R\x05value\"(\n" + + "\x10BlockHeightDelta\x12\x14\n" + + "\x05value\x18\x01 \x01(\x04R\x05value\"\x1d\n" + + "\x05Nicks\x12\x14\n" + + "\x05value\x18\x01 \x01(\x04R\x05value\"\x9b\x03\n" + + "\tEightBelt\x120\n" + + "\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt1\x120\n" + + "\x06belt_2\x18\x02 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt2\x120\n" + + "\x06belt_3\x18\x03 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt3\x120\n" + + "\x06belt_4\x18\x04 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt4\x120\n" + + "\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt5\x120\n" + + "\x06belt_6\x18\x06 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt6\x120\n" + + "\x06belt_7\x18\a \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt7\x120\n" + + "\x06belt_8\x18\b \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt8\"\x80\x02\n" + + "\x04Hash\x120\n" + + "\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt1\x120\n" + + "\x06belt_2\x18\x02 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt2\x120\n" + + "\x06belt_3\x18\x03 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt3\x120\n" + + "\x06belt_4\x18\x04 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt4\x120\n" + + "\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt5\" \n" + + "\n" + + "Base58Hash\x12\x12\n" + + "\x04hash\x18\x01 \x01(\tR\x04hash\"H\n" + + "\rSchnorrPubkey\x127\n" + + "\x05value\x18\x01 \x01(\v2!.nockchain.public.v1.CheetahPointR\x05value\"x\n" + + "\fCheetahPoint\x12*\n" + + "\x01x\x18\x01 \x01(\v2\x1c.nockchain.public.v1.SixBeltR\x01x\x12*\n" + + "\x01y\x18\x02 \x01(\v2\x1c.nockchain.public.v1.SixBeltR\x01y\x12\x10\n" + + "\x03inf\x18\x03 \x01(\bR\x03inf\"\xb5\x02\n" + + "\aSixBelt\x120\n" + + "\x06belt_1\x18\x01 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt1\x120\n" + + "\x06belt_2\x18\x02 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt2\x120\n" + + "\x06belt_3\x18\x03 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt3\x120\n" + + "\x06belt_4\x18\x04 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt4\x120\n" + + "\x06belt_5\x18\x05 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt5\x120\n" + + "\x06belt_6\x18\x06 \x01(\v2\x19.nockchain.public.v1.BeltR\x05belt6\"\x1c\n" + + "\x04Belt\x12\x14\n" + + "\x05value\x18\x01 \x01(\x04R\x05value*\xf0\x02\n" + + "\tErrorCode\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\vB\x0eZ\f./;nockchainb\x06proto3" + +var ( + file_primitives_proto_rawDescOnce sync.Once + file_primitives_proto_rawDescData []byte +) + +func file_primitives_proto_rawDescGZIP() []byte { + file_primitives_proto_rawDescOnce.Do(func() { + file_primitives_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_primitives_proto_rawDesc), len(file_primitives_proto_rawDesc))) + }) + return file_primitives_proto_rawDescData +} + +var file_primitives_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_primitives_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_primitives_proto_goTypes = []any{ + (ErrorCode)(0), // 0: nockchain.public.v1.ErrorCode + (*ErrorStatus)(nil), // 1: nockchain.public.v1.ErrorStatus + (*Acknowledged)(nil), // 2: nockchain.public.v1.Acknowledged + (*Wire)(nil), // 3: nockchain.public.v1.Wire + (*WireTag)(nil), // 4: nockchain.public.v1.WireTag + (*NoteVersion)(nil), // 5: nockchain.public.v1.NoteVersion + (*BlockHeight)(nil), // 6: nockchain.public.v1.BlockHeight + (*BlockHeightDelta)(nil), // 7: nockchain.public.v1.BlockHeightDelta + (*Nicks)(nil), // 8: nockchain.public.v1.Nicks + (*EightBelt)(nil), // 9: nockchain.public.v1.EightBelt + (*Hash)(nil), // 10: nockchain.public.v1.Hash + (*Base58Hash)(nil), // 11: nockchain.public.v1.Base58Hash + (*SchnorrPubkey)(nil), // 12: nockchain.public.v1.SchnorrPubkey + (*CheetahPoint)(nil), // 13: nockchain.public.v1.CheetahPoint + (*SixBelt)(nil), // 14: nockchain.public.v1.SixBelt + (*Belt)(nil), // 15: nockchain.public.v1.Belt +} +var file_primitives_proto_depIdxs = []int32{ + 0, // 0: nockchain.public.v1.ErrorStatus.code:type_name -> nockchain.public.v1.ErrorCode + 4, // 1: nockchain.public.v1.Wire.tags:type_name -> nockchain.public.v1.WireTag + 15, // 2: nockchain.public.v1.EightBelt.belt_1:type_name -> nockchain.public.v1.Belt + 15, // 3: nockchain.public.v1.EightBelt.belt_2:type_name -> nockchain.public.v1.Belt + 15, // 4: nockchain.public.v1.EightBelt.belt_3:type_name -> nockchain.public.v1.Belt + 15, // 5: nockchain.public.v1.EightBelt.belt_4:type_name -> nockchain.public.v1.Belt + 15, // 6: nockchain.public.v1.EightBelt.belt_5:type_name -> nockchain.public.v1.Belt + 15, // 7: nockchain.public.v1.EightBelt.belt_6:type_name -> nockchain.public.v1.Belt + 15, // 8: nockchain.public.v1.EightBelt.belt_7:type_name -> nockchain.public.v1.Belt + 15, // 9: nockchain.public.v1.EightBelt.belt_8:type_name -> nockchain.public.v1.Belt + 15, // 10: nockchain.public.v1.Hash.belt_1:type_name -> nockchain.public.v1.Belt + 15, // 11: nockchain.public.v1.Hash.belt_2:type_name -> nockchain.public.v1.Belt + 15, // 12: nockchain.public.v1.Hash.belt_3:type_name -> nockchain.public.v1.Belt + 15, // 13: nockchain.public.v1.Hash.belt_4:type_name -> nockchain.public.v1.Belt + 15, // 14: nockchain.public.v1.Hash.belt_5:type_name -> nockchain.public.v1.Belt + 13, // 15: nockchain.public.v1.SchnorrPubkey.value:type_name -> nockchain.public.v1.CheetahPoint + 14, // 16: nockchain.public.v1.CheetahPoint.x:type_name -> nockchain.public.v1.SixBelt + 14, // 17: nockchain.public.v1.CheetahPoint.y:type_name -> nockchain.public.v1.SixBelt + 15, // 18: nockchain.public.v1.SixBelt.belt_1:type_name -> nockchain.public.v1.Belt + 15, // 19: nockchain.public.v1.SixBelt.belt_2:type_name -> nockchain.public.v1.Belt + 15, // 20: nockchain.public.v1.SixBelt.belt_3:type_name -> nockchain.public.v1.Belt + 15, // 21: nockchain.public.v1.SixBelt.belt_4:type_name -> nockchain.public.v1.Belt + 15, // 22: nockchain.public.v1.SixBelt.belt_5:type_name -> nockchain.public.v1.Belt + 15, // 23: nockchain.public.v1.SixBelt.belt_6:type_name -> nockchain.public.v1.Belt + 24, // [24:24] is the sub-list for method output_type + 24, // [24:24] is the sub-list for method input_type + 24, // [24:24] is the sub-list for extension type_name + 24, // [24:24] is the sub-list for extension extendee + 0, // [0:24] is the sub-list for field type_name +} + +func init() { file_primitives_proto_init() } +func file_primitives_proto_init() { + if File_primitives_proto != nil { + return + } + file_primitives_proto_msgTypes[0].OneofWrappers = []any{} + file_primitives_proto_msgTypes[3].OneofWrappers = []any{ + (*WireTag_Text)(nil), + (*WireTag_Number)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_primitives_proto_rawDesc), len(file_primitives_proto_rawDesc)), + NumEnums: 1, + NumMessages: 15, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_primitives_proto_goTypes, + DependencyIndexes: file_primitives_proto_depIdxs, + EnumInfos: file_primitives_proto_enumTypes, + MessageInfos: file_primitives_proto_msgTypes, + }.Build() + File_primitives_proto = out.File + file_primitives_proto_goTypes = nil + file_primitives_proto_depIdxs = nil +} diff --git a/nockchain/service.pb.go b/nockchain/service.pb.go new file mode 100644 index 0000000..c0549c4 --- /dev/null +++ b/nockchain/service.pb.go @@ -0,0 +1,954 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.9 +// protoc v3.20.3 +// source: service.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 KeygenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *KeygenRequest) Reset() { + *x = KeygenRequest{} + mi := &file_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *KeygenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KeygenRequest) ProtoMessage() {} + +func (x *KeygenRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_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 KeygenRequest.ProtoReflect.Descriptor instead. +func (*KeygenRequest) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{0} +} + +type KeygenResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` + Seed string `protobuf:"bytes,3,opt,name=seed,proto3" json:"seed,omitempty"` + ChainCode string `protobuf:"bytes,4,opt,name=chain_code,json=chainCode,proto3" json:"chain_code,omitempty"` + ImportPrivateKey string `protobuf:"bytes,5,opt,name=import_private_key,json=importPrivateKey,proto3" json:"import_private_key,omitempty"` + ImportPublicKey string `protobuf:"bytes,6,opt,name=import_public_key,json=importPublicKey,proto3" json:"import_public_key,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *KeygenResponse) Reset() { + *x = KeygenResponse{} + mi := &file_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *KeygenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KeygenResponse) ProtoMessage() {} + +func (x *KeygenResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_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 KeygenResponse.ProtoReflect.Descriptor instead. +func (*KeygenResponse) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{1} +} + +func (x *KeygenResponse) GetPublicKey() string { + if x != nil { + return x.PublicKey + } + return "" +} + +func (x *KeygenResponse) GetPrivateKey() string { + if x != nil { + return x.PrivateKey + } + return "" +} + +func (x *KeygenResponse) GetSeed() string { + if x != nil { + return x.Seed + } + return "" +} + +func (x *KeygenResponse) GetChainCode() string { + if x != nil { + return x.ChainCode + } + return "" +} + +func (x *KeygenResponse) GetImportPrivateKey() string { + if x != nil { + return x.ImportPrivateKey + } + return "" +} + +func (x *KeygenResponse) GetImportPublicKey() string { + if x != nil { + return x.ImportPublicKey + } + return "" +} + +type ImportKeysRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + ImportType ImportType `protobuf:"varint,2,opt,name=import_type,json=importType,proto3,enum=nockchain.public.v1.ImportType" json:"import_type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ImportKeysRequest) Reset() { + *x = ImportKeysRequest{} + mi := &file_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ImportKeysRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ImportKeysRequest) ProtoMessage() {} + +func (x *ImportKeysRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_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 ImportKeysRequest.ProtoReflect.Descriptor instead. +func (*ImportKeysRequest) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{2} +} + +func (x *ImportKeysRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *ImportKeysRequest) GetImportType() ImportType { + if x != nil { + return x.ImportType + } + return ImportType_UNDEFINED +} + +type ImportKeysResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` + Seed string `protobuf:"bytes,3,opt,name=seed,proto3" json:"seed,omitempty"` + ChainCode string `protobuf:"bytes,4,opt,name=chain_code,json=chainCode,proto3" json:"chain_code,omitempty"` + ImportPrivateKey string `protobuf:"bytes,5,opt,name=import_private_key,json=importPrivateKey,proto3" json:"import_private_key,omitempty"` + ImportPublicKey string `protobuf:"bytes,6,opt,name=import_public_key,json=importPublicKey,proto3" json:"import_public_key,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ImportKeysResponse) Reset() { + *x = ImportKeysResponse{} + mi := &file_service_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ImportKeysResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ImportKeysResponse) ProtoMessage() {} + +func (x *ImportKeysResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_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 ImportKeysResponse.ProtoReflect.Descriptor instead. +func (*ImportKeysResponse) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{3} +} + +func (x *ImportKeysResponse) GetPublicKey() string { + if x != nil { + return x.PublicKey + } + return "" +} + +func (x *ImportKeysResponse) GetPrivateKey() string { + if x != nil { + return x.PrivateKey + } + return "" +} + +func (x *ImportKeysResponse) GetSeed() string { + if x != nil { + return x.Seed + } + return "" +} + +func (x *ImportKeysResponse) GetChainCode() string { + if x != nil { + return x.ChainCode + } + return "" +} + +func (x *ImportKeysResponse) GetImportPrivateKey() string { + if x != nil { + return x.ImportPrivateKey + } + return "" +} + +func (x *ImportKeysResponse) GetImportPublicKey() string { + if x != nil { + return x.ImportPublicKey + } + return "" +} + +type DeriveChildRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + ImportedKey string `protobuf:"bytes,1,opt,name=imported_key,json=importedKey,proto3" json:"imported_key,omitempty"` + Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` + Hardened bool `protobuf:"varint,3,opt,name=hardened,proto3" json:"hardened,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeriveChildRequest) Reset() { + *x = DeriveChildRequest{} + mi := &file_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeriveChildRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeriveChildRequest) ProtoMessage() {} + +func (x *DeriveChildRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_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 DeriveChildRequest.ProtoReflect.Descriptor instead. +func (*DeriveChildRequest) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{4} +} + +func (x *DeriveChildRequest) GetImportedKey() string { + if x != nil { + return x.ImportedKey + } + return "" +} + +func (x *DeriveChildRequest) GetIndex() uint64 { + if x != nil { + return x.Index + } + return 0 +} + +func (x *DeriveChildRequest) GetHardened() bool { + if x != nil { + return x.Hardened + } + return false +} + +type DeriveChildResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + 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"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeriveChildResponse) Reset() { + *x = DeriveChildResponse{} + mi := &file_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeriveChildResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeriveChildResponse) ProtoMessage() {} + +func (x *DeriveChildResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_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 DeriveChildResponse.ProtoReflect.Descriptor instead. +func (*DeriveChildResponse) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{5} +} + +func (x *DeriveChildResponse) GetPublicKey() string { + if x != nil { + return x.PublicKey + } + return "" +} + +func (x *DeriveChildResponse) GetPrivateKey() string { + if x != nil { + return x.PrivateKey + } + return "" +} + +func (x *DeriveChildResponse) GetChainCode() string { + if x != nil { + return x.ChainCode + } + return "" +} + +type CreateTxRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Names string `protobuf:"bytes,1,opt,name=names,proto3" json:"names,omitempty"` + Recipients string `protobuf:"bytes,2,opt,name=recipients,proto3" json:"recipients,omitempty"` + Gifts string `protobuf:"bytes,3,opt,name=gifts,proto3" json:"gifts,omitempty"` + Fee uint64 `protobuf:"varint,4,opt,name=fee,proto3" json:"fee,omitempty"` + IsMasterKey bool `protobuf:"varint,5,opt,name=is_master_key,json=isMasterKey,proto3" json:"is_master_key,omitempty"` + Key string `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` + ChainCode string `protobuf:"bytes,7,opt,name=chain_code,json=chainCode,proto3" json:"chain_code,omitempty"` + Index uint64 `protobuf:"varint,8,opt,name=index,proto3" json:"index,omitempty"` + Hardened bool `protobuf:"varint,9,opt,name=hardened,proto3" json:"hardened,omitempty"` + TimelockIntent *TimelockIntent `protobuf:"bytes,10,opt,name=timelock_intent,json=timelockIntent,proto3" json:"timelock_intent,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateTxRequest) Reset() { + *x = CreateTxRequest{} + mi := &file_service_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateTxRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTxRequest) ProtoMessage() {} + +func (x *CreateTxRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_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 CreateTxRequest.ProtoReflect.Descriptor instead. +func (*CreateTxRequest) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{6} +} + +func (x *CreateTxRequest) GetNames() string { + if x != nil { + return x.Names + } + return "" +} + +func (x *CreateTxRequest) GetRecipients() string { + if x != nil { + return x.Recipients + } + return "" +} + +func (x *CreateTxRequest) GetGifts() string { + if x != nil { + return x.Gifts + } + return "" +} + +func (x *CreateTxRequest) GetFee() uint64 { + if x != nil { + return x.Fee + } + return 0 +} + +func (x *CreateTxRequest) GetIsMasterKey() bool { + if x != nil { + return x.IsMasterKey + } + return false +} + +func (x *CreateTxRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *CreateTxRequest) GetChainCode() string { + if x != nil { + return x.ChainCode + } + return "" +} + +func (x *CreateTxRequest) GetIndex() uint64 { + if x != nil { + return x.Index + } + return 0 +} + +func (x *CreateTxRequest) GetHardened() bool { + if x != nil { + return x.Hardened + } + return false +} + +func (x *CreateTxRequest) GetTimelockIntent() *TimelockIntent { + if x != nil { + return x.TimelockIntent + } + return nil +} + +type CreateTxResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + RawTx *RawTx `protobuf:"bytes,1,opt,name=rawTx,proto3" json:"rawTx,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateTxResponse) Reset() { + *x = CreateTxResponse{} + mi := &file_service_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateTxResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTxResponse) ProtoMessage() {} + +func (x *CreateTxResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_proto_msgTypes[7] + 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 CreateTxResponse.ProtoReflect.Descriptor instead. +func (*CreateTxResponse) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{7} +} + +func (x *CreateTxResponse) GetRawTx() *RawTx { + if x != nil { + return x.RawTx + } + return nil +} + +type SignTxRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UnsignedTx string `protobuf:"bytes,1,opt,name=unsigned_tx,json=unsignedTx,proto3" json:"unsigned_tx,omitempty"` + Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` + Hardened bool `protobuf:"varint,3,opt,name=hardened,proto3" json:"hardened,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SignTxRequest) Reset() { + *x = SignTxRequest{} + mi := &file_service_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SignTxRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SignTxRequest) ProtoMessage() {} + +func (x *SignTxRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SignTxRequest.ProtoReflect.Descriptor instead. +func (*SignTxRequest) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{8} +} + +func (x *SignTxRequest) GetUnsignedTx() string { + if x != nil { + return x.UnsignedTx + } + return "" +} + +func (x *SignTxRequest) GetIndex() uint64 { + if x != nil { + return x.Index + } + return 0 +} + +func (x *SignTxRequest) GetHardened() bool { + if x != nil { + return x.Hardened + } + return false +} + +type SignTxResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + SignedTx string `protobuf:"bytes,1,opt,name=signed_tx,json=signedTx,proto3" json:"signed_tx,omitempty"` + Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SignTxResponse) Reset() { + *x = SignTxResponse{} + mi := &file_service_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SignTxResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SignTxResponse) ProtoMessage() {} + +func (x *SignTxResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SignTxResponse.ProtoReflect.Descriptor instead. +func (*SignTxResponse) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{9} +} + +func (x *SignTxResponse) GetSignedTx() string { + if x != nil { + return x.SignedTx + } + return "" +} + +func (x *SignTxResponse) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +type ScanRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + MasterPubkey string `protobuf:"bytes,1,opt,name=master_pubkey,json=masterPubkey,proto3" json:"master_pubkey,omitempty"` + ChainCode string `protobuf:"bytes,2,opt,name=chain_code,json=chainCode,proto3" json:"chain_code,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"` + IncludeMultisig bool `protobuf:"varint,5,opt,name=include_multisig,json=includeMultisig,proto3" json:"include_multisig,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ScanRequest) Reset() { + *x = ScanRequest{} + mi := &file_service_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ScanRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ScanRequest) ProtoMessage() {} + +func (x *ScanRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_proto_msgTypes[10] + 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 ScanRequest.ProtoReflect.Descriptor instead. +func (*ScanRequest) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{10} +} + +func (x *ScanRequest) GetMasterPubkey() string { + if x != nil { + return x.MasterPubkey + } + return "" +} + +func (x *ScanRequest) GetChainCode() string { + if x != nil { + return x.ChainCode + } + return "" +} + +func (x *ScanRequest) GetSearchDepth() uint64 { + if x != nil { + return x.SearchDepth + } + return 0 +} + +func (x *ScanRequest) GetIncludeTimelocks() bool { + if x != nil { + return x.IncludeTimelocks + } + return false +} + +func (x *ScanRequest) GetIncludeMultisig() bool { + if x != nil { + return x.IncludeMultisig + } + return false +} + +type ScanResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + ScanData []*ScanData `protobuf:"bytes,1,rep,name=scan_data,json=scanData,proto3" json:"scan_data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ScanResponse) Reset() { + *x = ScanResponse{} + mi := &file_service_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ScanResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ScanResponse) ProtoMessage() {} + +func (x *ScanResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_proto_msgTypes[11] + 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 ScanResponse.ProtoReflect.Descriptor instead. +func (*ScanResponse) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{11} +} + +func (x *ScanResponse) GetScanData() []*ScanData { + if x != nil { + return x.ScanData + } + return nil +} + +var File_service_proto protoreflect.FileDescriptor + +const file_service_proto_rawDesc = "" + + "\n" + + "\rservice.proto\x12\x13nockchain.public.v1\x1a\vtypes.proto\"\x0f\n" + + "\rKeygenRequest\"\xdd\x01\n" + + "\x0eKeygenResponse\x12\x1d\n" + + "\n" + + "public_key\x18\x01 \x01(\tR\tpublicKey\x12\x1f\n" + + "\vprivate_key\x18\x02 \x01(\tR\n" + + "privateKey\x12\x12\n" + + "\x04seed\x18\x03 \x01(\tR\x04seed\x12\x1d\n" + + "\n" + + "chain_code\x18\x04 \x01(\tR\tchainCode\x12,\n" + + "\x12import_private_key\x18\x05 \x01(\tR\x10importPrivateKey\x12*\n" + + "\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\"g\n" + + "\x11ImportKeysRequest\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12@\n" + + "\vimport_type\x18\x02 \x01(\x0e2\x1f.nockchain.public.v1.ImportTypeR\n" + + "importType\"\xe1\x01\n" + + "\x12ImportKeysResponse\x12\x1d\n" + + "\n" + + "public_key\x18\x01 \x01(\tR\tpublicKey\x12\x1f\n" + + "\vprivate_key\x18\x02 \x01(\tR\n" + + "privateKey\x12\x12\n" + + "\x04seed\x18\x03 \x01(\tR\x04seed\x12\x1d\n" + + "\n" + + "chain_code\x18\x04 \x01(\tR\tchainCode\x12,\n" + + "\x12import_private_key\x18\x05 \x01(\tR\x10importPrivateKey\x12*\n" + + "\x11import_public_key\x18\x06 \x01(\tR\x0fimportPublicKey\"i\n" + + "\x12DeriveChildRequest\x12!\n" + + "\fimported_key\x18\x01 \x01(\tR\vimportedKey\x12\x14\n" + + "\x05index\x18\x02 \x01(\x04R\x05index\x12\x1a\n" + + "\bhardened\x18\x03 \x01(\bR\bhardened\"t\n" + + "\x13DeriveChildResponse\x12\x1d\n" + + "\n" + + "public_key\x18\x01 \x01(\tR\tpublicKey\x12\x1f\n" + + "\vprivate_key\x18\x02 \x01(\tR\n" + + "privateKey\x12\x1d\n" + + "\n" + + "chain_code\x18\x03 \x01(\tR\tchainCode\"\xc4\x02\n" + + "\x0fCreateTxRequest\x12\x14\n" + + "\x05names\x18\x01 \x01(\tR\x05names\x12\x1e\n" + + "\n" + + "recipients\x18\x02 \x01(\tR\n" + + "recipients\x12\x14\n" + + "\x05gifts\x18\x03 \x01(\tR\x05gifts\x12\x10\n" + + "\x03fee\x18\x04 \x01(\x04R\x03fee\x12\"\n" + + "\ris_master_key\x18\x05 \x01(\bR\visMasterKey\x12\x10\n" + + "\x03key\x18\x06 \x01(\tR\x03key\x12\x1d\n" + + "\n" + + "chain_code\x18\a \x01(\tR\tchainCode\x12\x14\n" + + "\x05index\x18\b \x01(\x04R\x05index\x12\x1a\n" + + "\bhardened\x18\t \x01(\bR\bhardened\x12L\n" + + "\x0ftimelock_intent\x18\n" + + " \x01(\v2#.nockchain.public.v1.TimelockIntentR\x0etimelockIntent\"D\n" + + "\x10CreateTxResponse\x120\n" + + "\x05rawTx\x18\x01 \x01(\v2\x1a.nockchain.public.v1.RawTxR\x05rawTx\"b\n" + + "\rSignTxRequest\x12\x1f\n" + + "\vunsigned_tx\x18\x01 \x01(\tR\n" + + "unsignedTx\x12\x14\n" + + "\x05index\x18\x02 \x01(\x04R\x05index\x12\x1a\n" + + "\bhardened\x18\x03 \x01(\bR\bhardened\"C\n" + + "\x0eSignTxResponse\x12\x1b\n" + + "\tsigned_tx\x18\x01 \x01(\tR\bsignedTx\x12\x14\n" + + "\x05error\x18\x02 \x01(\tR\x05error\"\xcc\x01\n" + + "\vScanRequest\x12#\n" + + "\rmaster_pubkey\x18\x01 \x01(\tR\fmasterPubkey\x12\x1d\n" + + "\n" + + "chain_code\x18\x02 \x01(\tR\tchainCode\x12!\n" + + "\fsearch_depth\x18\x03 \x01(\x04R\vsearchDepth\x12+\n" + + "\x11include_timelocks\x18\x04 \x01(\bR\x10includeTimelocks\x12)\n" + + "\x10include_multisig\x18\x05 \x01(\bR\x0fincludeMultisig\"J\n" + + "\fScanResponse\x12:\n" + + "\tscan_data\x18\x01 \x03(\v2\x1d.nockchain.public.v1.ScanDataR\bscanData2\x9c\x04\n" + + "\rWalletService\x12Q\n" + + "\x06Keygen\x12\".nockchain.public.v1.KeygenRequest\x1a#.nockchain.public.v1.KeygenResponse\x12]\n" + + "\n" + + "ImportKeys\x12&.nockchain.public.v1.ImportKeysRequest\x1a'.nockchain.public.v1.ImportKeysResponse\x12`\n" + + "\vDeriveChild\x12'.nockchain.public.v1.DeriveChildRequest\x1a(.nockchain.public.v1.DeriveChildResponse\x12W\n" + + "\bCreateTx\x12$.nockchain.public.v1.CreateTxRequest\x1a%.nockchain.public.v1.CreateTxResponse\x12Q\n" + + "\x06SignTx\x12\".nockchain.public.v1.SignTxRequest\x1a#.nockchain.public.v1.SignTxResponse\x12K\n" + + "\x04Scan\x12 .nockchain.public.v1.ScanRequest\x1a!.nockchain.public.v1.ScanResponseB\x0eZ\f./;nockchainb\x06proto3" + +var ( + file_service_proto_rawDescOnce sync.Once + file_service_proto_rawDescData []byte +) + +func file_service_proto_rawDescGZIP() []byte { + file_service_proto_rawDescOnce.Do(func() { + file_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_service_proto_rawDesc), len(file_service_proto_rawDesc))) + }) + return file_service_proto_rawDescData +} + +var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_service_proto_goTypes = []any{ + (*KeygenRequest)(nil), // 0: nockchain.public.v1.KeygenRequest + (*KeygenResponse)(nil), // 1: nockchain.public.v1.KeygenResponse + (*ImportKeysRequest)(nil), // 2: nockchain.public.v1.ImportKeysRequest + (*ImportKeysResponse)(nil), // 3: nockchain.public.v1.ImportKeysResponse + (*DeriveChildRequest)(nil), // 4: nockchain.public.v1.DeriveChildRequest + (*DeriveChildResponse)(nil), // 5: nockchain.public.v1.DeriveChildResponse + (*CreateTxRequest)(nil), // 6: nockchain.public.v1.CreateTxRequest + (*CreateTxResponse)(nil), // 7: nockchain.public.v1.CreateTxResponse + (*SignTxRequest)(nil), // 8: nockchain.public.v1.SignTxRequest + (*SignTxResponse)(nil), // 9: nockchain.public.v1.SignTxResponse + (*ScanRequest)(nil), // 10: nockchain.public.v1.ScanRequest + (*ScanResponse)(nil), // 11: nockchain.public.v1.ScanResponse + (ImportType)(0), // 12: nockchain.public.v1.ImportType + (*TimelockIntent)(nil), // 13: nockchain.public.v1.TimelockIntent + (*RawTx)(nil), // 14: nockchain.public.v1.RawTx + (*ScanData)(nil), // 15: nockchain.public.v1.ScanData +} +var file_service_proto_depIdxs = []int32{ + 12, // 0: nockchain.public.v1.ImportKeysRequest.import_type:type_name -> nockchain.public.v1.ImportType + 13, // 1: nockchain.public.v1.CreateTxRequest.timelock_intent:type_name -> nockchain.public.v1.TimelockIntent + 14, // 2: nockchain.public.v1.CreateTxResponse.rawTx:type_name -> nockchain.public.v1.RawTx + 15, // 3: nockchain.public.v1.ScanResponse.scan_data:type_name -> nockchain.public.v1.ScanData + 0, // 4: nockchain.public.v1.WalletService.Keygen:input_type -> nockchain.public.v1.KeygenRequest + 2, // 5: nockchain.public.v1.WalletService.ImportKeys:input_type -> nockchain.public.v1.ImportKeysRequest + 4, // 6: nockchain.public.v1.WalletService.DeriveChild:input_type -> nockchain.public.v1.DeriveChildRequest + 6, // 7: nockchain.public.v1.WalletService.CreateTx:input_type -> nockchain.public.v1.CreateTxRequest + 8, // 8: nockchain.public.v1.WalletService.SignTx:input_type -> nockchain.public.v1.SignTxRequest + 10, // 9: nockchain.public.v1.WalletService.Scan:input_type -> nockchain.public.v1.ScanRequest + 1, // 10: nockchain.public.v1.WalletService.Keygen:output_type -> nockchain.public.v1.KeygenResponse + 3, // 11: nockchain.public.v1.WalletService.ImportKeys:output_type -> nockchain.public.v1.ImportKeysResponse + 5, // 12: nockchain.public.v1.WalletService.DeriveChild:output_type -> nockchain.public.v1.DeriveChildResponse + 7, // 13: nockchain.public.v1.WalletService.CreateTx:output_type -> nockchain.public.v1.CreateTxResponse + 9, // 14: nockchain.public.v1.WalletService.SignTx:output_type -> nockchain.public.v1.SignTxResponse + 11, // 15: nockchain.public.v1.WalletService.Scan:output_type -> nockchain.public.v1.ScanResponse + 10, // [10:16] is the sub-list for method output_type + 4, // [4:10] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_service_proto_init() } +func file_service_proto_init() { + if File_service_proto != nil { + return + } + file_types_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_service_proto_rawDesc), len(file_service_proto_rawDesc)), + NumEnums: 0, + NumMessages: 12, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_service_proto_goTypes, + DependencyIndexes: file_service_proto_depIdxs, + MessageInfos: file_service_proto_msgTypes, + }.Build() + File_service_proto = out.File + file_service_proto_goTypes = nil + file_service_proto_depIdxs = nil +} diff --git a/nockchain/service_grpc.pb.go b/nockchain/service_grpc.pb.go new file mode 100644 index 0000000..33828f9 --- /dev/null +++ b/nockchain/service_grpc.pb.go @@ -0,0 +1,311 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v3.20.3 +// source: service.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 ( + WalletService_Keygen_FullMethodName = "/nockchain.public.v1.WalletService/Keygen" + WalletService_ImportKeys_FullMethodName = "/nockchain.public.v1.WalletService/ImportKeys" + WalletService_DeriveChild_FullMethodName = "/nockchain.public.v1.WalletService/DeriveChild" + WalletService_CreateTx_FullMethodName = "/nockchain.public.v1.WalletService/CreateTx" + WalletService_SignTx_FullMethodName = "/nockchain.public.v1.WalletService/SignTx" + WalletService_Scan_FullMethodName = "/nockchain.public.v1.WalletService/Scan" +) + +// WalletServiceClient is the client API for WalletService 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 WalletServiceClient interface { + Keygen(ctx context.Context, in *KeygenRequest, opts ...grpc.CallOption) (*KeygenResponse, error) + ImportKeys(ctx context.Context, in *ImportKeysRequest, opts ...grpc.CallOption) (*ImportKeysResponse, error) + DeriveChild(ctx context.Context, in *DeriveChildRequest, opts ...grpc.CallOption) (*DeriveChildResponse, error) + CreateTx(ctx context.Context, in *CreateTxRequest, opts ...grpc.CallOption) (*CreateTxResponse, error) + SignTx(ctx context.Context, in *SignTxRequest, opts ...grpc.CallOption) (*SignTxResponse, error) + Scan(ctx context.Context, in *ScanRequest, opts ...grpc.CallOption) (*ScanResponse, error) +} + +type walletServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewWalletServiceClient(cc grpc.ClientConnInterface) WalletServiceClient { + return &walletServiceClient{cc} +} + +func (c *walletServiceClient) Keygen(ctx context.Context, in *KeygenRequest, opts ...grpc.CallOption) (*KeygenResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(KeygenResponse) + err := c.cc.Invoke(ctx, WalletService_Keygen_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletServiceClient) ImportKeys(ctx context.Context, in *ImportKeysRequest, opts ...grpc.CallOption) (*ImportKeysResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ImportKeysResponse) + err := c.cc.Invoke(ctx, WalletService_ImportKeys_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletServiceClient) DeriveChild(ctx context.Context, in *DeriveChildRequest, opts ...grpc.CallOption) (*DeriveChildResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeriveChildResponse) + err := c.cc.Invoke(ctx, WalletService_DeriveChild_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletServiceClient) CreateTx(ctx context.Context, in *CreateTxRequest, opts ...grpc.CallOption) (*CreateTxResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateTxResponse) + err := c.cc.Invoke(ctx, WalletService_CreateTx_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletServiceClient) SignTx(ctx context.Context, in *SignTxRequest, opts ...grpc.CallOption) (*SignTxResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SignTxResponse) + err := c.cc.Invoke(ctx, WalletService_SignTx_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletServiceClient) Scan(ctx context.Context, in *ScanRequest, opts ...grpc.CallOption) (*ScanResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ScanResponse) + err := c.cc.Invoke(ctx, WalletService_Scan_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// WalletServiceServer is the server API for WalletService service. +// All implementations must embed UnimplementedWalletServiceServer +// for forward compatibility. +type WalletServiceServer interface { + Keygen(context.Context, *KeygenRequest) (*KeygenResponse, error) + ImportKeys(context.Context, *ImportKeysRequest) (*ImportKeysResponse, error) + DeriveChild(context.Context, *DeriveChildRequest) (*DeriveChildResponse, error) + CreateTx(context.Context, *CreateTxRequest) (*CreateTxResponse, error) + SignTx(context.Context, *SignTxRequest) (*SignTxResponse, error) + Scan(context.Context, *ScanRequest) (*ScanResponse, error) + mustEmbedUnimplementedWalletServiceServer() +} + +// UnimplementedWalletServiceServer 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 UnimplementedWalletServiceServer struct{} + +func (UnimplementedWalletServiceServer) Keygen(context.Context, *KeygenRequest) (*KeygenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Keygen not implemented") +} +func (UnimplementedWalletServiceServer) ImportKeys(context.Context, *ImportKeysRequest) (*ImportKeysResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ImportKeys not implemented") +} +func (UnimplementedWalletServiceServer) DeriveChild(context.Context, *DeriveChildRequest) (*DeriveChildResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeriveChild not implemented") +} +func (UnimplementedWalletServiceServer) CreateTx(context.Context, *CreateTxRequest) (*CreateTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateTx not implemented") +} +func (UnimplementedWalletServiceServer) SignTx(context.Context, *SignTxRequest) (*SignTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SignTx not implemented") +} +func (UnimplementedWalletServiceServer) Scan(context.Context, *ScanRequest) (*ScanResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Scan not implemented") +} +func (UnimplementedWalletServiceServer) mustEmbedUnimplementedWalletServiceServer() {} +func (UnimplementedWalletServiceServer) testEmbeddedByValue() {} + +// UnsafeWalletServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to WalletServiceServer will +// result in compilation errors. +type UnsafeWalletServiceServer interface { + mustEmbedUnimplementedWalletServiceServer() +} + +func RegisterWalletServiceServer(s grpc.ServiceRegistrar, srv WalletServiceServer) { + // If the following call pancis, it indicates UnimplementedWalletServiceServer 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(&WalletService_ServiceDesc, srv) +} + +func _WalletService_Keygen_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(KeygenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletServiceServer).Keygen(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: WalletService_Keygen_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletServiceServer).Keygen(ctx, req.(*KeygenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _WalletService_ImportKeys_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ImportKeysRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletServiceServer).ImportKeys(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: WalletService_ImportKeys_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletServiceServer).ImportKeys(ctx, req.(*ImportKeysRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _WalletService_DeriveChild_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeriveChildRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletServiceServer).DeriveChild(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: WalletService_DeriveChild_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletServiceServer).DeriveChild(ctx, req.(*DeriveChildRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _WalletService_CreateTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateTxRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletServiceServer).CreateTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: WalletService_CreateTx_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletServiceServer).CreateTx(ctx, req.(*CreateTxRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _WalletService_SignTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SignTxRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletServiceServer).SignTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: WalletService_SignTx_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletServiceServer).SignTx(ctx, req.(*SignTxRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _WalletService_Scan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ScanRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletServiceServer).Scan(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: WalletService_Scan_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletServiceServer).Scan(ctx, req.(*ScanRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// WalletService_ServiceDesc is the grpc.ServiceDesc for WalletService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var WalletService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "nockchain.public.v1.WalletService", + HandlerType: (*WalletServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Keygen", + Handler: _WalletService_Keygen_Handler, + }, + { + MethodName: "ImportKeys", + Handler: _WalletService_ImportKeys_Handler, + }, + { + MethodName: "DeriveChild", + Handler: _WalletService_DeriveChild_Handler, + }, + { + MethodName: "CreateTx", + Handler: _WalletService_CreateTx_Handler, + }, + { + MethodName: "SignTx", + Handler: _WalletService_SignTx_Handler, + }, + { + MethodName: "Scan", + Handler: _WalletService_Scan_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "service.proto", +} diff --git a/nockchain/types.pb.go b/nockchain/types.pb.go new file mode 100644 index 0000000..3581f1a --- /dev/null +++ b/nockchain/types.pb.go @@ -0,0 +1,1070 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.9 +// protoc v3.20.3 +// source: types.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 ImportType int32 + +const ( + ImportType_UNDEFINED ImportType = 0 + ImportType_EXTENDED_KEY ImportType = 1 + ImportType_SEEDPHRASE ImportType = 2 + ImportType_MASTER_PRIVKEY ImportType = 3 + ImportType_WATCH_ONLY ImportType = 4 +) + +// Enum value maps for ImportType. +var ( + ImportType_name = map[int32]string{ + 0: "UNDEFINED", + 1: "EXTENDED_KEY", + 2: "SEEDPHRASE", + 3: "MASTER_PRIVKEY", + 4: "WATCH_ONLY", + } + ImportType_value = map[string]int32{ + "UNDEFINED": 0, + "EXTENDED_KEY": 1, + "SEEDPHRASE": 2, + "MASTER_PRIVKEY": 3, + "WATCH_ONLY": 4, + } +) + +func (x ImportType) Enum() *ImportType { + p := new(ImportType) + *p = x + return p +} + +func (x ImportType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ImportType) Descriptor() protoreflect.EnumDescriptor { + return file_types_proto_enumTypes[0].Descriptor() +} + +func (ImportType) Type() protoreflect.EnumType { + return &file_types_proto_enumTypes[0] +} + +func (x ImportType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ImportType.Descriptor instead. +func (ImportType) EnumDescriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{0} +} + +type Version int32 + +const ( + Version_V0 Version = 0 + Version_V1 Version = 1 + Version_V2 Version = 2 +) + +// Enum value maps for Version. +var ( + Version_name = map[int32]string{ + 0: "V0", + 1: "V1", + 2: "V2", + } + Version_value = map[string]int32{ + "V0": 0, + "V1": 1, + "V2": 2, + } +) + +func (x Version) Enum() *Version { + p := new(Version) + *p = x + return p +} + +func (x Version) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Version) Descriptor() protoreflect.EnumDescriptor { + return file_types_proto_enumTypes[1].Descriptor() +} + +func (Version) Type() protoreflect.EnumType { + return &file_types_proto_enumTypes[1] +} + +func (x Version) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Version.Descriptor instead. +func (Version) EnumDescriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{1} +} + +type ScanData struct { + state protoimpl.MessageState `protogen:"open.v1"` + Pubkey string `protobuf:"bytes,1,opt,name=pubkey,proto3" json:"pubkey,omitempty"` + Data *WalletBalanceData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ScanData) Reset() { + *x = ScanData{} + mi := &file_types_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ScanData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ScanData) ProtoMessage() {} + +func (x *ScanData) ProtoReflect() protoreflect.Message { + mi := &file_types_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 ScanData.ProtoReflect.Descriptor instead. +func (*ScanData) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{0} +} + +func (x *ScanData) GetPubkey() string { + if x != nil { + return x.Pubkey + } + return "" +} + +func (x *ScanData) GetData() *WalletBalanceData { + if x != nil { + return x.Data + } + return nil +} + +type TimelockIntent struct { + state protoimpl.MessageState `protogen:"open.v1"` + Absolute *TimelockRange `protobuf:"bytes,1,opt,name=absolute,proto3,oneof" json:"absolute,omitempty"` + Relative *TimelockRange `protobuf:"bytes,2,opt,name=relative,proto3,oneof" json:"relative,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TimelockIntent) Reset() { + *x = TimelockIntent{} + mi := &file_types_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TimelockIntent) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TimelockIntent) ProtoMessage() {} + +func (x *TimelockIntent) ProtoReflect() protoreflect.Message { + mi := &file_types_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 TimelockIntent.ProtoReflect.Descriptor instead. +func (*TimelockIntent) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{1} +} + +func (x *TimelockIntent) GetAbsolute() *TimelockRange { + if x != nil { + return x.Absolute + } + return nil +} + +func (x *TimelockIntent) GetRelative() *TimelockRange { + if x != nil { + return x.Relative + } + return nil +} + +type TimelockRange struct { + state protoimpl.MessageState `protogen:"open.v1"` + Min *Timelock `protobuf:"bytes,1,opt,name=min,proto3,oneof" json:"min,omitempty"` + Max *Timelock `protobuf:"bytes,2,opt,name=max,proto3,oneof" json:"max,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TimelockRange) Reset() { + *x = TimelockRange{} + mi := &file_types_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TimelockRange) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TimelockRange) ProtoMessage() {} + +func (x *TimelockRange) ProtoReflect() protoreflect.Message { + mi := &file_types_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 TimelockRange.ProtoReflect.Descriptor instead. +func (*TimelockRange) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{2} +} + +func (x *TimelockRange) GetMin() *Timelock { + if x != nil { + return x.Min + } + return nil +} + +func (x *TimelockRange) GetMax() *Timelock { + if x != nil { + return x.Max + } + return nil +} + +type Timelock struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Timelock) Reset() { + *x = Timelock{} + mi := &file_types_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Timelock) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Timelock) ProtoMessage() {} + +func (x *Timelock) ProtoReflect() protoreflect.Message { + mi := &file_types_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 Timelock.ProtoReflect.Descriptor instead. +func (*Timelock) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{3} +} + +func (x *Timelock) GetValue() uint64 { + if x != nil { + return x.Value + } + return 0 +} + +type RawTx struct { + state protoimpl.MessageState `protogen:"open.v1"` + TxId string `protobuf:"bytes,1,opt,name=tx_id,json=txId,proto3" json:"tx_id,omitempty"` + Inputs []*NockchainInput `protobuf:"bytes,2,rep,name=inputs,proto3" json:"inputs,omitempty"` + TimelockRange *TimelockRange `protobuf:"bytes,3,opt,name=timelock_range,json=timelockRange,proto3" json:"timelock_range,omitempty"` + TotalFees uint64 `protobuf:"varint,4,opt,name=total_fees,json=totalFees,proto3" json:"total_fees,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RawTx) Reset() { + *x = RawTx{} + mi := &file_types_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RawTx) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RawTx) ProtoMessage() {} + +func (x *RawTx) ProtoReflect() protoreflect.Message { + mi := &file_types_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 RawTx.ProtoReflect.Descriptor instead. +func (*RawTx) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{4} +} + +func (x *RawTx) GetTxId() string { + if x != nil { + return x.TxId + } + return "" +} + +func (x *RawTx) GetInputs() []*NockchainInput { + if x != nil { + return x.Inputs + } + return nil +} + +func (x *RawTx) GetTimelockRange() *TimelockRange { + if x != nil { + return x.TimelockRange + } + return nil +} + +func (x *RawTx) GetTotalFees() uint64 { + if x != nil { + return x.TotalFees + } + return 0 +} + +type NockchainSpend struct { + state protoimpl.MessageState `protogen:"open.v1"` + Signatures []*NockchainSignature `protobuf:"bytes,1,rep,name=signatures,proto3" json:"signatures,omitempty"` + Seeds []*NockchainSeed `protobuf:"bytes,2,rep,name=seeds,proto3" json:"seeds,omitempty"` + Fee uint64 `protobuf:"varint,3,opt,name=fee,proto3" json:"fee,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NockchainSpend) Reset() { + *x = NockchainSpend{} + mi := &file_types_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NockchainSpend) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NockchainSpend) ProtoMessage() {} + +func (x *NockchainSpend) ProtoReflect() protoreflect.Message { + mi := &file_types_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 NockchainSpend.ProtoReflect.Descriptor instead. +func (*NockchainSpend) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{5} +} + +func (x *NockchainSpend) GetSignatures() []*NockchainSignature { + if x != nil { + return x.Signatures + } + return nil +} + +func (x *NockchainSpend) GetSeeds() []*NockchainSeed { + if x != nil { + return x.Seeds + } + return nil +} + +func (x *NockchainSpend) GetFee() uint64 { + if x != nil { + return x.Fee + } + return 0 +} + +type NockchainNote struct { + state protoimpl.MessageState `protogen:"open.v1"` + Version Version `protobuf:"varint,1,opt,name=version,proto3,enum=nockchain.public.v1.Version" json:"version,omitempty"` + BlockHeight uint64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + Timelock *TimelockIntent `protobuf:"bytes,3,opt,name=timelock,proto3,oneof" json:"timelock,omitempty"` + Name *NockchainName `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Lock *NockchainLock `protobuf:"bytes,5,opt,name=lock,proto3" json:"lock,omitempty"` + Source *NockchainSource `protobuf:"bytes,6,opt,name=source,proto3" json:"source,omitempty"` + Asset uint64 `protobuf:"varint,7,opt,name=asset,proto3" json:"asset,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NockchainNote) Reset() { + *x = NockchainNote{} + mi := &file_types_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NockchainNote) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NockchainNote) ProtoMessage() {} + +func (x *NockchainNote) ProtoReflect() protoreflect.Message { + mi := &file_types_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 NockchainNote.ProtoReflect.Descriptor instead. +func (*NockchainNote) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{6} +} + +func (x *NockchainNote) GetVersion() Version { + if x != nil { + return x.Version + } + return Version_V0 +} + +func (x *NockchainNote) GetBlockHeight() uint64 { + if x != nil { + return x.BlockHeight + } + return 0 +} + +func (x *NockchainNote) GetTimelock() *TimelockIntent { + if x != nil { + return x.Timelock + } + return nil +} + +func (x *NockchainNote) GetName() *NockchainName { + if x != nil { + return x.Name + } + return nil +} + +func (x *NockchainNote) GetLock() *NockchainLock { + if x != nil { + return x.Lock + } + return nil +} + +func (x *NockchainNote) GetSource() *NockchainSource { + if x != nil { + return x.Source + } + return nil +} + +func (x *NockchainNote) GetAsset() uint64 { + if x != nil { + return x.Asset + } + return 0 +} + +type NockchainName struct { + state protoimpl.MessageState `protogen:"open.v1"` + First string `protobuf:"bytes,1,opt,name=first,proto3" json:"first,omitempty"` + Last string `protobuf:"bytes,2,opt,name=last,proto3" json:"last,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NockchainName) Reset() { + *x = NockchainName{} + mi := &file_types_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NockchainName) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NockchainName) ProtoMessage() {} + +func (x *NockchainName) ProtoReflect() protoreflect.Message { + mi := &file_types_proto_msgTypes[7] + 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 NockchainName.ProtoReflect.Descriptor instead. +func (*NockchainName) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{7} +} + +func (x *NockchainName) GetFirst() string { + if x != nil { + return x.First + } + return "" +} + +func (x *NockchainName) GetLast() string { + if x != nil { + return x.Last + } + return "" +} + +type NockchainInput struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name *NockchainName `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Note *NockchainNote `protobuf:"bytes,2,opt,name=note,proto3" json:"note,omitempty"` + Spend *NockchainSpend `protobuf:"bytes,3,opt,name=spend,proto3" json:"spend,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NockchainInput) Reset() { + *x = NockchainInput{} + mi := &file_types_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NockchainInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NockchainInput) ProtoMessage() {} + +func (x *NockchainInput) ProtoReflect() protoreflect.Message { + mi := &file_types_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 NockchainInput.ProtoReflect.Descriptor instead. +func (*NockchainInput) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{8} +} + +func (x *NockchainInput) GetName() *NockchainName { + if x != nil { + return x.Name + } + return nil +} + +func (x *NockchainInput) GetNote() *NockchainNote { + if x != nil { + return x.Note + } + return nil +} + +func (x *NockchainInput) GetSpend() *NockchainSpend { + if x != nil { + return x.Spend + } + return nil +} + +type NockchainSignature struct { + state protoimpl.MessageState `protogen:"open.v1"` + Pubkey string `protobuf:"bytes,1,opt,name=pubkey,proto3" json:"pubkey,omitempty"` + Chal []uint64 `protobuf:"varint,2,rep,packed,name=chal,proto3" json:"chal,omitempty"` + Sig []uint64 `protobuf:"varint,3,rep,packed,name=sig,proto3" json:"sig,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NockchainSignature) Reset() { + *x = NockchainSignature{} + mi := &file_types_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NockchainSignature) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NockchainSignature) ProtoMessage() {} + +func (x *NockchainSignature) ProtoReflect() protoreflect.Message { + mi := &file_types_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 NockchainSignature.ProtoReflect.Descriptor instead. +func (*NockchainSignature) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{9} +} + +func (x *NockchainSignature) GetPubkey() string { + if x != nil { + return x.Pubkey + } + return "" +} + +func (x *NockchainSignature) GetChal() []uint64 { + if x != nil { + return x.Chal + } + return nil +} + +func (x *NockchainSignature) GetSig() []uint64 { + if x != nil { + return x.Sig + } + return nil +} + +type NockchainSeed struct { + state protoimpl.MessageState `protogen:"open.v1"` + OutputSource *NockchainSource `protobuf:"bytes,1,opt,name=output_source,json=outputSource,proto3,oneof" json:"output_source,omitempty"` + Recipient *NockchainLock `protobuf:"bytes,2,opt,name=recipient,proto3" json:"recipient,omitempty"` + TimelockIntent *TimelockIntent `protobuf:"bytes,3,opt,name=timelock_intent,json=timelockIntent,proto3,oneof" json:"timelock_intent,omitempty"` + Gift uint64 `protobuf:"varint,4,opt,name=gift,proto3" json:"gift,omitempty"` + ParentHash string `protobuf:"bytes,5,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NockchainSeed) Reset() { + *x = NockchainSeed{} + mi := &file_types_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NockchainSeed) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NockchainSeed) ProtoMessage() {} + +func (x *NockchainSeed) ProtoReflect() protoreflect.Message { + mi := &file_types_proto_msgTypes[10] + 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 NockchainSeed.ProtoReflect.Descriptor instead. +func (*NockchainSeed) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{10} +} + +func (x *NockchainSeed) GetOutputSource() *NockchainSource { + if x != nil { + return x.OutputSource + } + return nil +} + +func (x *NockchainSeed) GetRecipient() *NockchainLock { + if x != nil { + return x.Recipient + } + return nil +} + +func (x *NockchainSeed) GetTimelockIntent() *TimelockIntent { + if x != nil { + return x.TimelockIntent + } + return nil +} + +func (x *NockchainSeed) GetGift() uint64 { + if x != nil { + return x.Gift + } + return 0 +} + +func (x *NockchainSeed) GetParentHash() string { + if x != nil { + return x.ParentHash + } + return "" +} + +type NockchainLock struct { + state protoimpl.MessageState `protogen:"open.v1"` + KeysRequired uint64 `protobuf:"varint,1,opt,name=keys_required,json=keysRequired,proto3" json:"keys_required,omitempty"` + Pubkeys []string `protobuf:"bytes,2,rep,name=pubkeys,proto3" json:"pubkeys,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NockchainLock) Reset() { + *x = NockchainLock{} + mi := &file_types_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NockchainLock) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NockchainLock) ProtoMessage() {} + +func (x *NockchainLock) ProtoReflect() protoreflect.Message { + mi := &file_types_proto_msgTypes[11] + 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 NockchainLock.ProtoReflect.Descriptor instead. +func (*NockchainLock) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{11} +} + +func (x *NockchainLock) GetKeysRequired() uint64 { + if x != nil { + return x.KeysRequired + } + return 0 +} + +func (x *NockchainLock) GetPubkeys() []string { + if x != nil { + return x.Pubkeys + } + return nil +} + +type NockchainSource struct { + state protoimpl.MessageState `protogen:"open.v1"` + Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"` + IsCoinbase bool `protobuf:"varint,2,opt,name=is_coinbase,json=isCoinbase,proto3" json:"is_coinbase,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NockchainSource) Reset() { + *x = NockchainSource{} + mi := &file_types_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NockchainSource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NockchainSource) ProtoMessage() {} + +func (x *NockchainSource) ProtoReflect() protoreflect.Message { + mi := &file_types_proto_msgTypes[12] + 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 NockchainSource.ProtoReflect.Descriptor instead. +func (*NockchainSource) Descriptor() ([]byte, []int) { + return file_types_proto_rawDescGZIP(), []int{12} +} + +func (x *NockchainSource) GetSource() string { + if x != nil { + return x.Source + } + return "" +} + +func (x *NockchainSource) GetIsCoinbase() bool { + if x != nil { + return x.IsCoinbase + } + return false +} + +var File_types_proto protoreflect.FileDescriptor + +const file_types_proto_rawDesc = "" + + "\n" + + "\vtypes.proto\x12\x13nockchain.public.v1\x1a\x10blockchain.proto\"^\n" + + "\bScanData\x12\x16\n" + + "\x06pubkey\x18\x01 \x01(\tR\x06pubkey\x12:\n" + + "\x04data\x18\x02 \x01(\v2&.nockchain.public.v1.WalletBalanceDataR\x04data\"\xb4\x01\n" + + "\x0eTimelockIntent\x12C\n" + + "\babsolute\x18\x01 \x01(\v2\".nockchain.public.v1.TimelockRangeH\x00R\babsolute\x88\x01\x01\x12C\n" + + "\brelative\x18\x02 \x01(\v2\".nockchain.public.v1.TimelockRangeH\x01R\brelative\x88\x01\x01B\v\n" + + "\t_absoluteB\v\n" + + "\t_relative\"\x8b\x01\n" + + "\rTimelockRange\x124\n" + + "\x03min\x18\x01 \x01(\v2\x1d.nockchain.public.v1.TimelockH\x00R\x03min\x88\x01\x01\x124\n" + + "\x03max\x18\x02 \x01(\v2\x1d.nockchain.public.v1.TimelockH\x01R\x03max\x88\x01\x01B\x06\n" + + "\x04_minB\x06\n" + + "\x04_max\" \n" + + "\bTimelock\x12\x14\n" + + "\x05value\x18\x01 \x01(\x04R\x05value\"\xc3\x01\n" + + "\x05RawTx\x12\x13\n" + + "\x05tx_id\x18\x01 \x01(\tR\x04txId\x12;\n" + + "\x06inputs\x18\x02 \x03(\v2#.nockchain.public.v1.NockchainInputR\x06inputs\x12I\n" + + "\x0etimelock_range\x18\x03 \x01(\v2\".nockchain.public.v1.TimelockRangeR\rtimelockRange\x12\x1d\n" + + "\n" + + "total_fees\x18\x04 \x01(\x04R\ttotalFees\"\xa5\x01\n" + + "\x0eNockchainSpend\x12G\n" + + "\n" + + "signatures\x18\x01 \x03(\v2'.nockchain.public.v1.NockchainSignatureR\n" + + "signatures\x128\n" + + "\x05seeds\x18\x02 \x03(\v2\".nockchain.public.v1.NockchainSeedR\x05seeds\x12\x10\n" + + "\x03fee\x18\x03 \x01(\x04R\x03fee\"\x81\x03\n" + + "\rNockchainNote\x126\n" + + "\aversion\x18\x01 \x01(\x0e2\x1c.nockchain.public.v1.VersionR\aversion\x12!\n" + + "\fblock_height\x18\x02 \x01(\x04R\vblockHeight\x12D\n" + + "\btimelock\x18\x03 \x01(\v2#.nockchain.public.v1.TimelockIntentH\x00R\btimelock\x88\x01\x01\x126\n" + + "\x04name\x18\x04 \x01(\v2\".nockchain.public.v1.NockchainNameR\x04name\x126\n" + + "\x04lock\x18\x05 \x01(\v2\".nockchain.public.v1.NockchainLockR\x04lock\x12<\n" + + "\x06source\x18\x06 \x01(\v2$.nockchain.public.v1.NockchainSourceR\x06source\x12\x14\n" + + "\x05asset\x18\a \x01(\x04R\x05assetB\v\n" + + "\t_timelock\"9\n" + + "\rNockchainName\x12\x14\n" + + "\x05first\x18\x01 \x01(\tR\x05first\x12\x12\n" + + "\x04last\x18\x02 \x01(\tR\x04last\"\xbb\x01\n" + + "\x0eNockchainInput\x126\n" + + "\x04name\x18\x01 \x01(\v2\".nockchain.public.v1.NockchainNameR\x04name\x126\n" + + "\x04note\x18\x02 \x01(\v2\".nockchain.public.v1.NockchainNoteR\x04note\x129\n" + + "\x05spend\x18\x03 \x01(\v2#.nockchain.public.v1.NockchainSpendR\x05spend\"R\n" + + "\x12NockchainSignature\x12\x16\n" + + "\x06pubkey\x18\x01 \x01(\tR\x06pubkey\x12\x12\n" + + "\x04chal\x18\x02 \x03(\x04R\x04chal\x12\x10\n" + + "\x03sig\x18\x03 \x03(\x04R\x03sig\"\xcf\x02\n" + + "\rNockchainSeed\x12N\n" + + "\routput_source\x18\x01 \x01(\v2$.nockchain.public.v1.NockchainSourceH\x00R\foutputSource\x88\x01\x01\x12@\n" + + "\trecipient\x18\x02 \x01(\v2\".nockchain.public.v1.NockchainLockR\trecipient\x12Q\n" + + "\x0ftimelock_intent\x18\x03 \x01(\v2#.nockchain.public.v1.TimelockIntentH\x01R\x0etimelockIntent\x88\x01\x01\x12\x12\n" + + "\x04gift\x18\x04 \x01(\x04R\x04gift\x12\x1f\n" + + "\vparent_hash\x18\x05 \x01(\tR\n" + + "parentHashB\x10\n" + + "\x0e_output_sourceB\x12\n" + + "\x10_timelock_intent\"N\n" + + "\rNockchainLock\x12#\n" + + "\rkeys_required\x18\x01 \x01(\x04R\fkeysRequired\x12\x18\n" + + "\apubkeys\x18\x02 \x03(\tR\apubkeys\"J\n" + + "\x0fNockchainSource\x12\x16\n" + + "\x06source\x18\x01 \x01(\tR\x06source\x12\x1f\n" + + "\vis_coinbase\x18\x02 \x01(\bR\n" + + "isCoinbase*a\n" + + "\n" + + "ImportType\x12\r\n" + + "\tUNDEFINED\x10\x00\x12\x10\n" + + "\fEXTENDED_KEY\x10\x01\x12\x0e\n" + + "\n" + + "SEEDPHRASE\x10\x02\x12\x12\n" + + "\x0eMASTER_PRIVKEY\x10\x03\x12\x0e\n" + + "\n" + + "WATCH_ONLY\x10\x04*!\n" + + "\aVersion\x12\x06\n" + + "\x02V0\x10\x00\x12\x06\n" + + "\x02V1\x10\x01\x12\x06\n" + + "\x02V2\x10\x02B\x0eZ\f./;nockchainb\x06proto3" + +var ( + file_types_proto_rawDescOnce sync.Once + file_types_proto_rawDescData []byte +) + +func file_types_proto_rawDescGZIP() []byte { + file_types_proto_rawDescOnce.Do(func() { + file_types_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_proto_rawDesc), len(file_types_proto_rawDesc))) + }) + return file_types_proto_rawDescData +} + +var file_types_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_types_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_types_proto_goTypes = []any{ + (ImportType)(0), // 0: nockchain.public.v1.ImportType + (Version)(0), // 1: nockchain.public.v1.Version + (*ScanData)(nil), // 2: nockchain.public.v1.ScanData + (*TimelockIntent)(nil), // 3: nockchain.public.v1.TimelockIntent + (*TimelockRange)(nil), // 4: nockchain.public.v1.TimelockRange + (*Timelock)(nil), // 5: nockchain.public.v1.Timelock + (*RawTx)(nil), // 6: nockchain.public.v1.RawTx + (*NockchainSpend)(nil), // 7: nockchain.public.v1.NockchainSpend + (*NockchainNote)(nil), // 8: nockchain.public.v1.NockchainNote + (*NockchainName)(nil), // 9: nockchain.public.v1.NockchainName + (*NockchainInput)(nil), // 10: nockchain.public.v1.NockchainInput + (*NockchainSignature)(nil), // 11: nockchain.public.v1.NockchainSignature + (*NockchainSeed)(nil), // 12: nockchain.public.v1.NockchainSeed + (*NockchainLock)(nil), // 13: nockchain.public.v1.NockchainLock + (*NockchainSource)(nil), // 14: nockchain.public.v1.NockchainSource + (*WalletBalanceData)(nil), // 15: nockchain.public.v1.WalletBalanceData +} +var file_types_proto_depIdxs = []int32{ + 15, // 0: nockchain.public.v1.ScanData.data:type_name -> nockchain.public.v1.WalletBalanceData + 4, // 1: nockchain.public.v1.TimelockIntent.absolute:type_name -> nockchain.public.v1.TimelockRange + 4, // 2: nockchain.public.v1.TimelockIntent.relative:type_name -> nockchain.public.v1.TimelockRange + 5, // 3: nockchain.public.v1.TimelockRange.min:type_name -> nockchain.public.v1.Timelock + 5, // 4: nockchain.public.v1.TimelockRange.max:type_name -> nockchain.public.v1.Timelock + 10, // 5: nockchain.public.v1.RawTx.inputs:type_name -> nockchain.public.v1.NockchainInput + 4, // 6: nockchain.public.v1.RawTx.timelock_range:type_name -> nockchain.public.v1.TimelockRange + 11, // 7: nockchain.public.v1.NockchainSpend.signatures:type_name -> nockchain.public.v1.NockchainSignature + 12, // 8: nockchain.public.v1.NockchainSpend.seeds:type_name -> nockchain.public.v1.NockchainSeed + 1, // 9: nockchain.public.v1.NockchainNote.version:type_name -> nockchain.public.v1.Version + 3, // 10: nockchain.public.v1.NockchainNote.timelock:type_name -> nockchain.public.v1.TimelockIntent + 9, // 11: nockchain.public.v1.NockchainNote.name:type_name -> nockchain.public.v1.NockchainName + 13, // 12: nockchain.public.v1.NockchainNote.lock:type_name -> nockchain.public.v1.NockchainLock + 14, // 13: nockchain.public.v1.NockchainNote.source:type_name -> nockchain.public.v1.NockchainSource + 9, // 14: nockchain.public.v1.NockchainInput.name:type_name -> nockchain.public.v1.NockchainName + 8, // 15: nockchain.public.v1.NockchainInput.note:type_name -> nockchain.public.v1.NockchainNote + 7, // 16: nockchain.public.v1.NockchainInput.spend:type_name -> nockchain.public.v1.NockchainSpend + 14, // 17: nockchain.public.v1.NockchainSeed.output_source:type_name -> nockchain.public.v1.NockchainSource + 13, // 18: nockchain.public.v1.NockchainSeed.recipient:type_name -> nockchain.public.v1.NockchainLock + 3, // 19: nockchain.public.v1.NockchainSeed.timelock_intent:type_name -> nockchain.public.v1.TimelockIntent + 20, // [20:20] is the sub-list for method output_type + 20, // [20:20] is the sub-list for method input_type + 20, // [20:20] is the sub-list for extension type_name + 20, // [20:20] is the sub-list for extension extendee + 0, // [0:20] is the sub-list for field type_name +} + +func init() { file_types_proto_init() } +func file_types_proto_init() { + if File_types_proto != nil { + return + } + file_blockchain_proto_init() + file_types_proto_msgTypes[1].OneofWrappers = []any{} + file_types_proto_msgTypes[2].OneofWrappers = []any{} + file_types_proto_msgTypes[6].OneofWrappers = []any{} + file_types_proto_msgTypes[10].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_proto_rawDesc), len(file_types_proto_rawDesc)), + NumEnums: 2, + NumMessages: 13, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_proto_goTypes, + DependencyIndexes: file_types_proto_depIdxs, + EnumInfos: file_types_proto_enumTypes, + MessageInfos: file_types_proto_msgTypes, + }.Build() + File_types_proto = out.File + file_types_proto_goTypes = nil + file_types_proto_depIdxs = nil +} diff --git a/proto/blockchain.proto b/proto/blockchain.proto new file mode 100644 index 0000000..f6a847d --- /dev/null +++ b/proto/blockchain.proto @@ -0,0 +1,134 @@ +// nockchain/common/v1/blockchain.proto + +syntax = "proto3"; + +package nockchain.public.v1; + +import "primitives.proto"; +import "pagination.proto"; +option go_package = "./;nockchain"; +message WalletBalanceData { + // Page of full UTXO entries for the requested wallet. Entries are ordered + // by (Name.first, Name.last) to support consistent pagination. + repeated BalanceEntry notes = 1; // note name -> amount + + // Snapshot metadata where this page was computed. Clients should include + // the returned page token to continue paging against the same snapshot. + BlockHeight height = 2; // block height where balance was computed + optional Hash block_id = 3; // block where balance was computed + + // Pagination cursor for fetching the next page in a paginated view. + // When empty, there are no further results for this snapshot. + PageResponse page = 4; +} + +message BalanceEntry { + Name name = 1; + Note note = 2; +} + +// the string key is the name of the input +// message RawTransaction { map inputs = 1; } +message RawTransaction { + repeated NamedInput named_inputs = 1; + TimeLockRangeAbsolute timelock_range = 2; + Nicks total_fees = 3; + Hash id = 4; +} + +message NamedInput { + Name name = 1; + Input input = 2; +} + +message Input { + Note note = 1; + Spend spend = 2; +} + +message Spend { + Signature signature = 1; + repeated Seed seeds = 2; + Nicks miner_fee_nicks = 3; +} + +message Seed { + optional OutputSource output_source = 1; + Lock recipient = 2; + optional TimeLockIntent timelock_intent = 3; + Nicks gift = 4; + Hash parent_hash = 5; +} + +message OutputSource { optional Source source = 1; } + +message Source { + Hash hash = 1; + bool coinbase = 2; +} + +message TimeLockIntent { + oneof value { + TimeLockRangeAbsolute absolute = 1; + TimeLockRangeRelative relative = 2; + TimeLockRangeAbsoluteAndRelative absolute_and_relative = 3; + } +} + +message TimeLockRangeAbsoluteAndRelative { + optional TimeLockRangeAbsolute absolute = 1; + optional TimeLockRangeRelative relative = 2; +} + +// min and max are absolute origin page numbers +message TimeLockRangeAbsolute { + optional BlockHeight min = 1; + optional BlockHeight max = 2; +} + +// min and max are relative to the note's creation page +message TimeLockRangeRelative { + optional BlockHeightDelta min = 1; + optional BlockHeightDelta max = 2; +} + +// =================================================================== +// Wallet Domain Types: UTXO (nnote), Lock, and Signature (multisig) +// =================================================================== + +message Lock { + uint32 keys_required = 1; // threshold of keys required to spend the note + // DEPRECATED: repeated string schnorr_pubkeys_b58 = 2; + repeated SchnorrPubkey schnorr_pubkeys = + 2; // schnorr pubkeys (curve: cheetah) +} + +message Name { + // First is the hash of whether the note has a timelock and the lock + Hash first = 1; + // Last is the hash of the actual timelock and the source + Hash last = 2; +} + +message Note { + BlockHeight origin_page = 1; // page-number when added to balance + optional TimeLockIntent timelock = 2; // enforced timelock + Name name = 3; // nname (human/name label) + Lock lock = 4; // spending condition + Source source = 5; // provenance commitment + Nicks assets = 6; // coin amount (nicks) + NoteVersion version = 7; // note version (currently 0) +} + +message Signature { repeated SignatureEntry entries = 1; } + +message SignatureEntry { + SchnorrPubkey schnorr_pubkey = + 1; // serialized pubkey corresponding to the signer + SchnorrSignature signature = 2; +} + +message SchnorrSignature { + EightBelt chal = 1; + EightBelt sig = 2; +} diff --git a/proto/nockchain.proto b/proto/nockchain.proto new file mode 100644 index 0000000..06ed392 --- /dev/null +++ b/proto/nockchain.proto @@ -0,0 +1,91 @@ +// nockchain/public/v1/nockchain.proto + +syntax = "proto3"; + +package nockchain.public.v1; + +import "blockchain.proto"; +import "primitives.proto"; +import "pagination.proto"; +option go_package = "./;nockchain"; +service NockchainService { + rpc WalletGetBalance(WalletGetBalanceRequest) + returns (WalletGetBalanceResponse); + rpc WalletSendTransaction(WalletSendTransactionRequest) + returns (WalletSendTransactionResponse); + rpc TransactionAccepted(TransactionAcceptedRequest) + returns (TransactionAcceptedResponse); + //rpc TransactionConfirmation(TransactionConfirmationRequest) + // returns (TransactionConfirmationResponse); +} + +message WalletGetBalanceRequest { + // pubkey cheetah point; specific address, or current wallet + string address = 1; + // Pagination parameters. The server enforces limits and may return fewer + // entries than requested to respect message size and policy. For consistent + // paging across a stable snapshot, pass along the returned page_token from + // the previous response without modification. + PageRequest page = 2; +} + +message WalletGetBalanceResponse { + oneof result { + // Paginated wallet balance data with full entries and snapshot metadata. + // Continue paging using `balance.page.next_page_token` until empty. Clients + // should treat the page token as opaque; it may encode snapshot identity + // and the last returned key. + WalletBalanceData balance = 1; + ErrorStatus error = 2; + } +} + +message WalletSendTransactionRequest { + Hash tx_id = 1; // base58 encoded transaction ID for tracking + RawTransaction raw_tx = 2; +} + +message WalletSendTransactionResponse { + oneof result { + // true is request was acknowledge by node, + // this does not mean that the transaction was + // confirmed and/or accepted. + Acknowledged ack = 1; + ErrorStatus error = 2; + } +} + +message TransactionAcceptedRequest { + Base58Hash tx_id = 1; // base58 encoded transaction ID for tracking +} + +message TransactionAcceptedResponse { + // true if transaction was accepted by node. this not does mean that the + // transaction was confirmed. Just that it was validated by the node and + // added to its raw-tx set. + oneof result { + bool accepted = 1; + ErrorStatus error = 2; + } +} + + +//message TransactionConfirmationRequest { +// // base58 encoded transaction ID +// Base58Hash tx_id = 1; +//} +// +//// TODO: Handle re-orgs / orphaned transactions +//message TransactionConfirmationResponse { +// oneof result { +// // Number of blocks between the transaction's origin page and the current +// // chain tip. 0 = mempool, no block contains the transaction yet. +// // 1 = first block containing the transaction, current heaviest block. +// // > 1 = number of blocks between the transaction's origin page and the +// // current chain tip. +// BlockHeightDelta confirmations = 1; +// // Transaction not found in mempool or chain +// bool transaction_not_found = 2; +// ErrorStatus error = 3; +// } +//} diff --git a/proto/pagination.proto b/proto/pagination.proto new file mode 100644 index 0000000..0cb78e7 --- /dev/null +++ b/proto/pagination.proto @@ -0,0 +1,39 @@ +// nockchain/common/v1/pagination.proto + +syntax = "proto3"; + +package nockchain.public.v1; +option go_package = "./;nockchain"; + +// Generic pagination parameters for list-style RPCs. +// These types are intended to be reused across public APIs. +// +// Contract: +// - The server may return fewer items than requested (client_page_items_limit is a hint). +// - page_token is an opaque cursor produced by the server; clients must treat +// it as a black box. Servers may encode snapshot identity and last-key. +// - For consistent pagination, clients should include the returned page_token +// in the next request without modification. +// - Servers may enforce a maximum client_page_items_limit and/or byte budget regardless of +// client hints. +message PageRequest { + // Maximum number of items to return. The server may return fewer items + // than requested. Clients should not rely on receiving exactly this count. + uint32 client_page_items_limit = 1; + + // Opaque cursor returned by a previous call. When set, the server resumes + // the listing from the position described by the token. + // An empty token indicates the first page. + string page_token = 2; + + // Optional soft limit on the uncompressed bytes to return in a single page. + // The server may ignore or cap this value according to policy. This refers + // to the gRPC payload size after protobuf encoding and decompression. + uint64 max_bytes = 3; +} + +message PageResponse { + // Opaque cursor for fetching the next page. Empty when there are no more + // results. + string next_page_token = 1; +} diff --git a/proto/primitives.proto b/proto/primitives.proto new file mode 100644 index 0000000..47625ab --- /dev/null +++ b/proto/primitives.proto @@ -0,0 +1,108 @@ +// nockchain/common/v1/primitives.proto + +syntax = "proto3"; + +package nockchain.public.v1; +option go_package = "./;nockchain"; + +message ErrorStatus { + ErrorCode code = 1; + string message = 2; + optional string details = 3; // additional error context +} + +message Acknowledged {} + +enum ErrorCode { + 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; + } +} + +// Note: prefer using raw numeric fields in messages +// instead of these wrappers to simplify conversions. +// These remain defined for potential future use. +message NoteVersion { uint32 value = 1; } +message BlockHeight { uint64 value = 1; } +message BlockHeightDelta { uint64 value = 1; } +message Nicks { uint64 value = 1; } + +// pub chal: [Belt; 8], +// pub sig: [Belt; 8], +message EightBelt { + Belt belt_1 = 1; + Belt belt_2 = 2; + Belt belt_3 = 3; + Belt belt_4 = 4; + Belt belt_5 = 5; + Belt belt_6 = 6; + Belt belt_7 = 7; + Belt belt_8 = 8; +} + +// pub struct Hash(pub [Belt; 5]); +// Use fixed fields to avoid variable-length vectors. +message Hash { + Belt belt_1 = 1; + Belt belt_2 = 2; + Belt belt_3 = 3; + Belt belt_4 = 4; + Belt belt_5 = 5; +} + +message Base58Hash { + string hash = 1; +} + +// pub struct SchnorrPubkey(pub CheetahPoint); +message SchnorrPubkey { CheetahPoint value = 1; } + +// pub struct CheetahPoint { +// pub x: F6lt, +// pub y: F6lt, +// pub inf: bool, +// } +message CheetahPoint { + SixBelt x = 1; + SixBelt y = 2; + bool inf = 3; +} + +// pub struct F6lt(pub [Belt; 6]); +message SixBelt { + Belt belt_1 = 1; + Belt belt_2 = 2; + Belt belt_3 = 3; + Belt belt_4 = 4; + Belt belt_5 = 5; + Belt belt_6 = 6; +} + +// pub struct Belt(pub u64); +message Belt { uint64 value = 1; } diff --git a/proto/service.proto b/proto/service.proto new file mode 100644 index 0000000..5b4ded4 --- /dev/null +++ b/proto/service.proto @@ -0,0 +1,91 @@ +syntax = "proto3"; +package nockchain.public.v1; + +option go_package = "./;nockchain"; + +import "types.proto"; +service WalletService { + rpc Keygen(KeygenRequest) returns (KeygenResponse); + rpc ImportKeys(ImportKeysRequest) returns (ImportKeysResponse); + rpc DeriveChild(DeriveChildRequest) returns (DeriveChildResponse); + rpc CreateTx(CreateTxRequest) returns (CreateTxResponse); + rpc SignTx(SignTxRequest) returns (SignTxResponse); + rpc Scan(ScanRequest) returns (ScanResponse); +} + +message KeygenRequest {} + +message KeygenResponse { + string public_key = 1; + string private_key = 2; + string seed = 3; + string chain_code = 4; + string import_private_key = 5; + string import_public_key = 6; +} + +message ImportKeysRequest { + string key = 1; + ImportType import_type = 2; +} + +message ImportKeysResponse { + string public_key = 1; + string private_key = 2; + string seed = 3; + string chain_code = 4; + string import_private_key = 5; + string import_public_key = 6; +} + +message DeriveChildRequest { + string imported_key = 1; + uint64 index = 2; + bool hardened = 3; +} + +message DeriveChildResponse { + string public_key = 1; + string private_key = 2; + string chain_code = 3; +} + +message CreateTxRequest { + string names = 1; + string recipients = 2; + string gifts = 3; + uint64 fee = 4; + bool is_master_key = 5; + string key = 6; + string chain_code = 7; + uint64 index = 8; + bool hardened = 9; + TimelockIntent timelock_intent = 10; +} + +message CreateTxResponse { + RawTx rawTx = 1; +} + +message SignTxRequest { + string unsigned_tx = 1; + uint64 index = 2; + bool hardened = 3; +} + +message SignTxResponse { + string signed_tx = 1; + string error = 2; +} + +message ScanRequest { + string master_pubkey = 1; + string chain_code = 2; + uint64 search_depth = 3; + bool include_timelocks = 4; + bool include_multisig = 5; +} + +message ScanResponse { + repeated ScanData scan_data = 1; +} diff --git a/proto/types.proto b/proto/types.proto new file mode 100644 index 0000000..da7abf6 --- /dev/null +++ b/proto/types.proto @@ -0,0 +1,92 @@ +syntax = "proto3"; +package nockchain.public.v1; + +option go_package = "./;nockchain"; + +import "blockchain.proto"; +message ScanData { + string pubkey = 1; + WalletBalanceData data = 2; +} +enum ImportType { + UNDEFINED = 0; + EXTENDED_KEY = 1; + SEEDPHRASE = 2; + MASTER_PRIVKEY = 3; + WATCH_ONLY = 4; +} + +message TimelockIntent { + optional TimelockRange absolute = 1; + optional TimelockRange relative = 2; +} + +message TimelockRange { + optional Timelock min = 1; + optional Timelock max = 2; +} + +message Timelock { + uint64 value = 1; +} + +message RawTx { + string tx_id = 1; + repeated NockchainInput inputs = 2; + TimelockRange timelock_range = 3; + uint64 total_fees = 4; +} + +message NockchainSpend { + repeated NockchainSignature signatures = 1; + repeated NockchainSeed seeds = 2; + uint64 fee = 3; +} +message NockchainNote { + Version version = 1; + uint64 block_height = 2; + optional TimelockIntent timelock = 3; + NockchainName name = 4; + NockchainLock lock = 5; + NockchainSource source = 6; + uint64 asset =7; +} + +message NockchainName { + string first = 1; + string last = 2; +} + +message NockchainInput { + NockchainName name = 1; + NockchainNote note = 2; + NockchainSpend spend = 3; +} + +message NockchainSignature { + string pubkey = 1; + repeated uint64 chal = 2; + repeated uint64 sig = 3; +} + +message NockchainSeed { + optional NockchainSource output_source = 1; + NockchainLock recipient = 2; + optional TimelockIntent timelock_intent = 3; + uint64 gift = 4; + string parent_hash = 5; +} +message NockchainLock { + uint64 keys_required = 1; + repeated string pubkeys = 2; +} + +message NockchainSource { + string source = 1; + bool is_coinbase = 2; +} +enum Version { + V0 = 0; + V1 = 1; + V2 = 2; +} \ No newline at end of file diff --git a/wallet/nockchain_service.go b/wallet/nockchain_service.go new file mode 100644 index 0000000..5ad5aa3 --- /dev/null +++ b/wallet/nockchain_service.go @@ -0,0 +1,115 @@ +package wallet + +import ( + context "context" + "fmt" + + "github.com/phamminh0811/private-grpc/nockchain" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" +) + +type NockchainClient struct { + conn *grpc.ClientConn + client nockchain.NockchainServiceClient +} + +// NewNockchainClient creates a new gRPC client connection +func NewNockchainClient(address string) (*NockchainClient, error) { + creds := credentials.NewClientTLSFromCert(nil, "") + + conn, err := grpc.NewClient( + address, + grpc.WithTransportCredentials(creds), + ) + if err != nil { + return nil, fmt.Errorf("failed to connect: %w", err) + } + + client := nockchain.NewNockchainServiceClient(conn) + + return &NockchainClient{ + conn: conn, + client: client, + }, nil +} + +func (nc *NockchainClient) Close() error { + return nc.conn.Close() +} + +func (nc *NockchainClient) WalletGetBalance(address string) (*nockchain.WalletBalanceData, error) { + pageToken := "" + allNotes := []*nockchain.BalanceEntry{} + var height *nockchain.BlockHeight + var blockId *nockchain.Hash + for { + req := nockchain.WalletGetBalanceRequest{ + Address: address, + Page: &nockchain.PageRequest{ + ClientPageItemsLimit: 0, + PageToken: pageToken, + MaxBytes: 0, + }, + } + resp, err := nc.client.WalletGetBalance(context.Background(), &req) + if err != nil { + return nil, err + } + + balance := nockchain.WalletBalanceData{} + switch resp.Result.(type) { + case *nockchain.WalletGetBalanceResponse_Balance: + balance = *resp.GetBalance() + case *nockchain.WalletGetBalanceResponse_Error: + return nil, fmt.Errorf("error: %s", resp.GetError().Message) + default: + return nil, fmt.Errorf("invalid result type") + } + + if height == nil { + height = balance.Height + blockId = balance.BlockId + } + + if balance.Height != height || balance.BlockId != blockId { + return nil, fmt.Errorf("snapshot changed during pagination; retry") + } + + allNotes = append(allNotes, balance.Notes...) + if balance.Page.NextPageToken == "" { + break + } else { + pageToken = balance.Page.NextPageToken + } + } + return &nockchain.WalletBalanceData{ + Notes: allNotes, + Height: height, + BlockId: blockId, + Page: &nockchain.PageResponse{ + NextPageToken: "", + }, + }, nil +} + +func (nc *NockchainClient) TxAccepted(txId string) (*nockchain.TransactionAcceptedResponse, error) { + req := nockchain.TransactionAcceptedRequest{ + TxId: &nockchain.Base58Hash{ + Hash: txId, + }, + } + + resp, err := nc.client.TransactionAccepted(context.Background(), &req) + if err != nil { + return nil, err + } + switch resp.Result.(type) { + case *nockchain.TransactionAcceptedResponse_Accepted: + return resp, nil + case *nockchain.TransactionAcceptedResponse_Error: + return nil, fmt.Errorf("error: %s", resp.GetError().Message) + default: + return nil, fmt.Errorf("invalid result type") + } +} diff --git a/wallet/nockhash.go b/wallet/nockhash.go new file mode 100644 index 0000000..5153097 --- /dev/null +++ b/wallet/nockhash.go @@ -0,0 +1,294 @@ +package wallet + +import ( + "fmt" + "math/big" + + "github.com/btcsuite/btcd/btcutil/base58" + "github.com/phamminh0811/private-grpc/crypto" + "github.com/phamminh0811/private-grpc/nockchain" +) + +var LastName = [5]uint64{9541855607561054508, 12383849149342406623, 11220017934615522559, 678840671137489369, 8985908938884028381} + +func HashPubkey(pkPoint crypto.CheetahPoint) [5]uint64 { + belts := []crypto.Belt{{Value: 13}} + belts = append(belts, pkPoint.X[:]...) + belts = append(belts, pkPoint.Y[:]...) + belts = append(belts, crypto.BELT_ONE) + for _, i := range crypto.MagicDyckForPoint { + belts = append(belts, crypto.Belt{Value: i}) + } + return crypto.Tip5HashBelts(belts) +} + +func HashSignature(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) + sigHash = crypto.Tip5RehashTenCell(sigHash, crypto.Tip5ZeroZero) + return crypto.Tip5RehashTenCell(crypto.Tip5Zero, sigHash), nil +} + +func HashOwner(pkPoint crypto.CheetahPoint) [5]uint64 { + pkHashedBelts := HashPubkey(pkPoint) + pkHashedZeroZero := crypto.Tip5RehashTenCell(pkHashedBelts, crypto.Tip5ZeroZero) + return crypto.Tip5RehashTenCell(crypto.Tip5One, pkHashedZeroZero) +} + +func NockName(ownerHash [5]uint64) ([5]uint64, [5]uint64) { + firstName := first(ownerHash) + return firstName, LastName +} + +func HashName(name *nockchain.NockchainName) [5]uint64 { + firstNameHash := crypto.Base58ToTip5Hash(name.First) + lastNameHash := crypto.Base58ToTip5Hash(name.Last) + return crypto.Tip5RehashTenCell(firstNameHash, crypto.Tip5RehashTenCell(lastNameHash, crypto.Tip5Zero)) +} + +func HashNote(note *nockchain.NockchainNote) ([5]uint64, error) { + versionHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: uint64(note.Version)}}) + blockHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: note.BlockHeight}}) + timelockHash := HashTimelockIntent(note.Timelock) + hashBlockTimeLock := crypto.Tip5RehashTenCell(blockHash, timelockHash) + + p := crypto.Tip5RehashTenCell(versionHash, hashBlockTimeLock) + nameHash := HashName(note.Name) + lockHash, err := HashLock(note.Lock) + if err != nil { + return [5]uint64{}, err + } + + sourceHash := HashSource(note.Source) + assetHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: uint64(note.Asset)}}) + + hashSourceAsset := crypto.Tip5RehashTenCell(sourceHash, assetHash) + + q := crypto.Tip5RehashTenCell(nameHash, crypto.Tip5RehashTenCell(lockHash, hashSourceAsset)) + return crypto.Tip5RehashTenCell(p, q), nil +} + +func HashTimelockIntent(timelock *nockchain.TimelockIntent) [5]uint64 { + if timelock == nil { + return crypto.Tip5Zero + } + if timelock.Absolute == nil && timelock.Relative == nil { + return crypto.Tip5ZeroZero + } + + absoluteHash := HashTimelockRange(timelock.Absolute) + relativeHash := HashTimelockRange(timelock.Relative) + + return crypto.Tip5RehashTenCell(absoluteHash, relativeHash) +} + +func HashTimelockRange(timelockRange *nockchain.TimelockRange) [5]uint64 { + hash := crypto.Tip5Zero + if timelockRange != nil { + minHash := crypto.Tip5Zero + if timelockRange.Min != nil { + minHash = crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: timelockRange.Min.Value}}) + } + + maxHash := crypto.Tip5Zero + if timelockRange.Max != nil { + maxHash = crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: timelockRange.Max.Value}}) + } + + hash = crypto.Tip5RehashTenCell(minHash, maxHash) + } + + return hash +} +func HashLock(lock *nockchain.NockchainLock) ([5]uint64, error) { + keysRequiredHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: lock.KeysRequired}}) + + finalPk := base58.Decode(lock.Pubkeys[lock.KeysRequired-1]) + finalPkPoint, err := crypto.CheetaPointFromBytes(finalPk) + if err != nil { + return [5]uint64{}, err + } + finalPkHash := HashPubkey(finalPkPoint) + finalHash := crypto.Tip5RehashTenCell(finalPkHash, crypto.Tip5ZeroZero) + if lock.KeysRequired != 1 { + for i := uint64(1); i < lock.KeysRequired; i++ { + pk := base58.Decode(lock.Pubkeys[lock.KeysRequired-1-i]) + pkPoint, err := crypto.CheetaPointFromBytes(pk) + if err != nil { + return [5]uint64{}, err + } + + pkHash := HashPubkey(pkPoint) + finalHash = crypto.Tip5RehashTenCell(pkHash, finalHash) + } + } + + return crypto.Tip5RehashTenCell(keysRequiredHash, finalHash), nil +} + +func HashSource(source *nockchain.NockchainSource) [5]uint64 { + if source == nil { + return crypto.Tip5Zero + } + sourceHash := crypto.Base58ToTip5Hash(source.Source) + if source.IsCoinbase { + return crypto.Tip5RehashTenCell(sourceHash, crypto.Tip5One) + } else { + return crypto.Tip5RehashTenCell(sourceHash, crypto.Tip5Zero) + } +} + +func HashSeedWithoutSource(seed *nockchain.NockchainSeed) ([5]uint64, error) { + 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}}) + + parentHash := crypto.Base58ToTip5Hash(seed.ParentHash) + assetHashparentHash := crypto.Tip5RehashTenCell(assetHash, parentHash) + + timelockHashAssetParentHash := crypto.Tip5RehashTenCell(timelockIntentHash, assetHashparentHash) + + seedHash := crypto.Tip5RehashTenCell(lockHash, timelockHashAssetParentHash) + return seedHash, nil +} +func HashSeed(seed *nockchain.NockchainSeed) ([5]uint64, error) { + seedHash, err := HashSeedWithoutSource(seed) + if err != nil { + return [5]uint64{}, nil + } + sourceHash := HashSource(seed.OutputSource) + return crypto.Tip5RehashTenCell(sourceHash, seedHash), nil +} + +func HashNonce(pkPoint crypto.CheetahPoint, message [5]uint64) ([]crypto.Belt, [5]uint64) { + belts := []crypto.Belt{} + for _, belt := range pkPoint.X { + belts = append(belts, belt) + } + + for _, belt := range pkPoint.Y { + belts = append(belts, belt) + } + + for _, belt := range message { + belts = append(belts, crypto.Belt{Value: belt}) + } + resBelts := make([]crypto.Belt, len(belts)) + copy(resBelts, belts) + return resBelts, crypto.Tip5HashBelts(belts) +} + +func HashSpend(spend *nockchain.NockchainSpend) ([5]uint64, error) { + // TODO: handle multiple sig + sigHash, err := HashSignature(spend.Signatures[0]) + if err != nil { + return [5]uint64{}, err + } + seedsCount := len(spend.Seeds) + finalSeedHash, err := HashSeedWithoutSource(spend.Seeds[seedsCount-1]) + + if err != nil { + return [5]uint64{}, err + } + finalSeedHash = crypto.Tip5RehashTenCell(finalSeedHash, crypto.Tip5ZeroZero) + finalSeedHash = crypto.Tip5RehashTenCell(finalSeedHash, crypto.Tip5Zero) + + if seedsCount != 1 { + for i := 1; i < seedsCount; i++ { + seedHash, err := HashSeedWithoutSource(spend.Seeds[seedsCount-1-i]) + if err != nil { + return [5]uint64{}, err + } + fmt.Println("") + finalSeedHash = crypto.Tip5RehashTenCell(seedHash, finalSeedHash) + } + } + feeHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: spend.Fee}}) + seedHashFee := crypto.Tip5RehashTenCell(finalSeedHash, feeHash) + return crypto.Tip5RehashTenCell(sigHash, seedHashFee), nil + +} + +func HashInput(input *nockchain.NockchainInput) ([5]uint64, error) { + nameHash := HashName(input.Name) + + noteHash, err := HashNote(input.Note) + if err != nil { + return [5]uint64{}, err + + } + spendHash, err := HashSpend(input.Spend) + if err != nil { + return [5]uint64{}, err + + } + hashNoteSpend := crypto.Tip5RehashTenCell(noteHash, spendHash) + inputHash := crypto.Tip5RehashTenCell(nameHash, hashNoteSpend) + return crypto.Tip5RehashTenCell(inputHash, crypto.Tip5ZeroZero), nil +} + +func ComputeTxId(inputs []*nockchain.NockchainInput, timelockRange *nockchain.TimelockRange, totalFees uint64) ([5]uint64, error) { + // TODO: do it with multiple intputs + input := inputs[0] + inputHash, err := HashInput(input) + if err != nil { + return [5]uint64{}, err + } + + timelockHash := HashTimelockRange(timelockRange) + + totalFeesHash := crypto.Tip5HashBelts([]crypto.Belt{{Value: 1}, {Value: totalFees}}) + + q := crypto.Tip5RehashTenCell(timelockHash, totalFeesHash) + return crypto.Tip5RehashTenCell(inputHash, q), nil +} + +func ComputeSig(m crypto.MasterKey, msg [5]uint64) ([8]uint64, [8]uint64, error) { + pkPoint, err := crypto.CheetaPointFromBytes(m.PublicKey) + if err != nil { + return [8]uint64{}, [8]uint64{}, err + } + belts, nonce := HashNonce(pkPoint, msg) + nonceBigInt := crypto.TruncGOrder(nonce) + scalar := crypto.CheetahScaleBig(crypto.A_GEN, *nonceBigInt) + + scalarBelts := []crypto.Belt{} + scalarBelts = append(scalarBelts, scalar.X[:]...) + scalarBelts = append(scalarBelts, scalar.Y[:]...) + belts = append(scalarBelts, belts...) + chal := crypto.Tip5HashBelts(belts) + chalBigInt := crypto.TruncGOrder(chal) + + skBigInt := new(big.Int).SetBytes(m.PrivateKey) + sig := new(big.Int).Mul(chalBigInt, skBigInt) + sig.Add(sig, nonceBigInt) + sig.Mod(sig, crypto.G_ORDER) + + chalT8 := crypto.BigIntToT8(*chalBigInt) + sigT8 := crypto.BigIntToT8(*sig) + return chalT8, sigT8, nil +} + +func first(ownerHash [5]uint64) [5]uint64 { + ownerHashZero := crypto.Tip5RehashTenCell(ownerHash, crypto.Tip5Zero) + ownerHashZeroOne := crypto.Tip5RehashTenCell(crypto.Tip5One, ownerHashZero) + return crypto.Tip5RehashTenCell(crypto.Tip5Zero, ownerHashZeroOne) +} diff --git a/wallet/service.go b/wallet/service.go new file mode 100644 index 0000000..23c4ae3 --- /dev/null +++ b/wallet/service.go @@ -0,0 +1,425 @@ +package wallet + +import ( + context "context" + "crypto/rand" + "crypto/sha256" + "fmt" + "slices" + "strconv" + "strings" + + "github.com/btcsuite/btcd/btcutil/base58" + "github.com/cosmos/go-bip39" + "github.com/phamminh0811/private-grpc/crypto" + "github.com/phamminh0811/private-grpc/nockchain" +) + +type GprcHandler struct { + nockchain.UnimplementedWalletServiceServer + client NockchainClient +} + +func NewGprcHandler(client NockchainClient) GprcHandler { + return GprcHandler{ + client: client, + } +} +func (h *GprcHandler) Keygen(ctx context.Context, req *nockchain.KeygenRequest) (*nockchain.KeygenResponse, error) { + var entropy [32]byte + _, err := rand.Read(entropy[:]) // Fill the slice with random bytes + if err != nil { + return nil, err + } + + var salt [16]byte + _, err = rand.Read(salt[:]) + if err != nil { + return nil, err + } + + argonBytes := crypto.DeriveKey(0, entropy[:], salt[:], nil, nil, 6, 786432, 4, 32) + slices.Reverse(argonBytes) + mnemonic, err := bip39.NewMnemonic(argonBytes) + if err != nil { + return nil, fmt.Errorf("failed to generate mnemonic: %v", err) + } + masterKey, err := crypto.MasterKeyFromSeed(mnemonic) + if err != nil { + return nil, err + } + privBytes := append([]byte{0x00}, masterKey.PrivateKey...) + return &nockchain.KeygenResponse{ + Seed: mnemonic, + PrivateKey: base58.Encode(masterKey.PrivateKey), + PublicKey: base58.Encode(masterKey.PublicKey), + ChainCode: base58.Encode(masterKey.ChainCode), + ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.PrivateKeyStart)), + ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.PublicKeyStart)), + }, nil +} + +func (h *GprcHandler) ImportKeys(ctx context.Context, req *nockchain.ImportKeysRequest) (*nockchain.ImportKeysResponse, error) { + switch req.ImportType { + case nockchain.ImportType_UNDEFINED: + return nil, fmt.Errorf("invalid import type") + case nockchain.ImportType_EXTENDED_KEY: + // metadata layout: [version][depth][parent-fp][index][chain-code][key-data][checksum] + data := base58.Decode(req.Key) + switch { + case strings.HasPrefix(req.Key, "zprv"): + if len(data) != 82 { + return nil, fmt.Errorf("invalid extended private key length: %d (expected 82)", len(data)) + } + if data[45] != 0x00 { + return nil, fmt.Errorf("invalid private key prefix at byte 45: 0x%02x (expected 0x00)", data[45]) + } + hash := sha256.Sum256(data[:78]) + hash = sha256.Sum256(hash[:]) + if !slices.Equal(hash[:4], data[78:]) { + return nil, fmt.Errorf("invalid checksum") + } + chainCode := make([]byte, 32) + copy(chainCode, data[13:45]) + privateKey := make([]byte, 32) + copy(privateKey, data[46:78]) + masterKey, err := crypto.MasterKeyFromPrivKey(chainCode, privateKey) + if err != nil { + return nil, err + } + privBytes := append([]byte{0x00}, masterKey.PrivateKey...) + return &nockchain.ImportKeysResponse{ + Seed: "", + PrivateKey: base58.Encode(masterKey.PrivateKey), + PublicKey: base58.Encode(masterKey.PublicKey), + ChainCode: base58.Encode(masterKey.ChainCode), + ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.PrivateKeyStart)), + ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.PublicKeyStart)), + }, nil + case strings.HasPrefix(req.Key, "zpub"): + if len(data) != 145 { + return nil, fmt.Errorf("invalid extended public key length: %d (expected 145)", len(data)) + } + + hash := sha256.Sum256(data[:141]) + hash = sha256.Sum256(hash[:]) + if !slices.Equal(hash[:4], data[141:]) { + return nil, fmt.Errorf("invalid checksum") + } + + chainCode := make([]byte, 32) + copy(chainCode, data[13:45]) + publicKey := make([]byte, 97) + copy(publicKey, data[45:141]) + return &nockchain.ImportKeysResponse{ + Seed: "", + PrivateKey: "", + PublicKey: base58.Encode(publicKey), + ChainCode: base58.Encode(chainCode), + ImportPrivateKey: "", + ImportPublicKey: base58.Encode(crypto.SerializeExtend(chainCode, publicKey, crypto.PublicKeyStart)), + }, nil + default: + return nil, fmt.Errorf("invalid extended key") + } + case nockchain.ImportType_MASTER_PRIVKEY: + splits := strings.Split(req.Key, ",") + if len(splits) != 2 { + return nil, fmt.Errorf("master key must be in [chain_code],[key] format") + } + chainCode := base58.Decode(splits[0]) + key := base58.Decode(splits[1]) + masterKey, err := crypto.MasterKeyFromPrivKey(chainCode, key) + if err != nil { + return nil, err + } + privBytes := append([]byte{0x00}, masterKey.PrivateKey...) + return &nockchain.ImportKeysResponse{ + Seed: "", + PrivateKey: base58.Encode(masterKey.PrivateKey), + PublicKey: base58.Encode(masterKey.PublicKey), + ChainCode: base58.Encode(masterKey.ChainCode), + ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.PrivateKeyStart)), + ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.PublicKeyStart)), + }, nil + case nockchain.ImportType_SEEDPHRASE: + masterKey, err := crypto.MasterKeyFromSeed(req.Key) + if err != nil { + return nil, err + } + privBytes := append([]byte{0x00}, masterKey.PrivateKey...) + return &nockchain.ImportKeysResponse{ + Seed: "", + PrivateKey: base58.Encode(masterKey.PrivateKey), + PublicKey: base58.Encode(masterKey.PublicKey), + ChainCode: base58.Encode(masterKey.ChainCode), + ImportPrivateKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, privBytes, crypto.PrivateKeyStart)), + ImportPublicKey: base58.Encode(crypto.SerializeExtend(masterKey.ChainCode, masterKey.PublicKey, crypto.PublicKeyStart)), + }, nil + case nockchain.ImportType_WATCH_ONLY: + pubKey := base58.Decode(req.Key) + return &nockchain.ImportKeysResponse{ + Seed: "", + PrivateKey: "", + PublicKey: base58.Encode(pubKey), + ChainCode: "", + ImportPrivateKey: "", + ImportPublicKey: "", + }, nil + default: + return nil, fmt.Errorf("invalid import type") + } +} + +func (h *GprcHandler) DeriveChild(ctx context.Context, req *nockchain.DeriveChildRequest) (*nockchain.DeriveChildResponse, error) { + data := base58.Decode(req.ImportedKey) + index := req.Index + if index > 1<<32 { + return nil, fmt.Errorf("child index %d out of range, child indices are capped to values between [0, 2^32)", index) + } + if req.Hardened { + index += 1 << 31 + } + switch { + case strings.HasPrefix(req.ImportedKey, "zprv"): + if len(data) != 82 { + return nil, fmt.Errorf("invalid extended private key length: %d (expected 82)", len(data)) + } + if data[45] != 0x00 { + return nil, fmt.Errorf("invalid private key prefix at byte 45: 0x%02x (expected 0x00)", data[45]) + } + hash := sha256.Sum256(data[:78]) + hash = sha256.Sum256(hash[:]) + if !slices.Equal(hash[:4], data[78:]) { + return nil, fmt.Errorf("invalid checksum") + } + chainCode := make([]byte, 32) + copy(chainCode, data[13:45]) + privateKey := make([]byte, 32) + copy(privateKey, data[46:78]) + masterKey, err := crypto.MasterKeyFromPrivKey(chainCode, privateKey) + if err != nil { + return nil, err + } + + childKey, err := masterKey.DeriveChild(index) + if err != nil { + return nil, err + } + return &nockchain.DeriveChildResponse{ + PublicKey: base58.Encode(childKey.PublicKey), + PrivateKey: base58.Encode(childKey.PrivateKey), + ChainCode: base58.Encode(childKey.ChainCode), + }, nil + + case strings.HasPrefix(req.ImportedKey, "zpub"): + if len(data) != 145 { + return nil, fmt.Errorf("invalid extended public key length: %d (expected 145)", len(data)) + } + + hash := sha256.Sum256(data[:141]) + hash = sha256.Sum256(hash[:]) + if !slices.Equal(hash[:4], data[141:]) { + return nil, fmt.Errorf("invalid checksum") + } + + chainCode := make([]byte, 32) + copy(chainCode, data[13:45]) + publicKey := make([]byte, 97) + copy(publicKey, data[45:141]) + + masterKey := crypto.MasterKey{ + PublicKey: publicKey, + ChainCode: chainCode, + PrivateKey: []byte{}, + } + childKey, err := masterKey.DeriveChild(index) + if err != nil { + return nil, err + } + return &nockchain.DeriveChildResponse{ + PublicKey: base58.Encode(childKey.PublicKey), + PrivateKey: "", + ChainCode: base58.Encode(childKey.ChainCode), + }, nil + default: + return nil, fmt.Errorf("invalid extended key") + } +} + +// - `names` - Comma-separated list of note name pairs in format "[first last]" +// Example: "[first1 last1],[first2 last2]" +// +// - `recipients` - Comma-separated list of recipient $locks +// Example: "[1 pk1],[2 pk2,pk3,pk4]" +// A simple comma-separated list is also supported: "pk1,pk2,pk3", +// where it is presumed that all recipients are single-signature, +// that is to say, it is the same as "[1 pk1],[1 pk2],[1 pk3]" +// +// - `gifts` - Comma-separated list of amounts to send to each recipient +// Example: "100,200" +// +// - `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) { + firstNames := [][5]uint64{} + lastNames := [][5]uint64{} + for _, name := range strings.Split(req.Names, ",") { + name = strings.TrimSpace(name) + if strings.HasPrefix(name, "[") && strings.HasSuffix(name, "]") { + inner := name[1 : len(name)-1] + part := strings.Split(inner, " ") + if len(part) == 2 { + firstNames = append(firstNames, crypto.Base58ToTip5Hash(part[0])) + lastNames = append(lastNames, crypto.Base58ToTip5Hash(part[1])) + } + } + } + + type Recipent struct { + index uint64 + pubkeys [][]byte + } + recipents := []Recipent{} + if strings.Contains(req.Recipients, "[") { + pairs := strings.Split(req.Recipients, ",") + for _, pair := range pairs { + pair = strings.TrimSpace(pair) + + if strings.HasPrefix(pair, "[") && strings.HasSuffix(pair, "]") { + inner := pair[1 : len(pair)-1] + parts := strings.SplitN(inner, " ", 2) + + if len(parts) == 2 { + number, err := strconv.ParseUint(parts[0], 10, 64) + if err != nil { + continue + } + + pubkeyStrs := strings.Split(parts[1], ",") + var pubkeys [][]byte + for _, s := range pubkeyStrs { + pubkeys = append(pubkeys, base58.Decode(strings.TrimSpace(s))) + } + + recipents = append(recipents, Recipent{index: number, pubkeys: pubkeys}) + } + } + } + } else { + // Parse simple format: "pk1,pk2,pk3" + addrs := strings.Split(req.Recipients, ",") + + for _, addr := range addrs { + recipents = append(recipents, Recipent{index: uint64(1), pubkeys: [][]byte{base58.Decode(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(firstNames) != len(recipents) || len(firstNames) != 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) + _, err := crypto.CheetaPointFromBytes(key) + if err != nil { + // priv key + masterKey, err = crypto.MasterKeyFromPrivKey(chainCode, key) + if err != nil { + return nil, err + } + } else { + masterKey = &crypto.MasterKey{ + PrivateKey: []byte{}, + PublicKey: key, + ChainCode: chainCode, + } + } + if !req.IsMasterKey { + index := req.Index + if index > 1<<32 { + return nil, fmt.Errorf("child index %d out of range, child indices are capped to values between [0, 2^32)", index) + } + if req.Hardened { + index += 1 << 31 + } + childKey, err := masterKey.DeriveChild(index) + if err != nil { + return nil, err + } + masterKey = &childKey + } + + // Scan key to get notes + masterKeyScan, err := h.client.WalletGetBalance(base58.Encode(masterKey.PublicKey)) + if err != nil { + return nil, err + } + if len(masterKeyScan.Notes) != 0 { + // TODO: check notes by first and last name + } + return nil, nil +} + +func (h *GprcHandler) Scan(ctx context.Context, req *nockchain.ScanRequest) (*nockchain.ScanResponse, error) { + scanData := []*nockchain.ScanData{} + keyBytes := base58.Decode(req.MasterPubkey) + + chainCode := base58.Decode(req.ChainCode) + masterKey := crypto.MasterKey{ + PublicKey: keyBytes, + ChainCode: chainCode, + PrivateKey: []byte{}, + } + + masterKeyScan, err := h.client.WalletGetBalance(req.MasterPubkey) + if err != nil { + return nil, err + } + if len(masterKeyScan.Notes) != 0 { + scanData = append(scanData, &nockchain.ScanData{ + Pubkey: req.MasterPubkey, + Data: masterKeyScan, + }) + } + for i := uint64(0); i < req.SearchDepth; i++ { + childKey, err := masterKey.DeriveChild(i) + if err != nil { + continue + } + childKeyScan, err := h.client.WalletGetBalance(base58.Encode(childKey.PublicKey)) + if err != nil { + continue + } + if len(childKeyScan.Notes) != 0 { + scanData = append(scanData, &nockchain.ScanData{ + Pubkey: base58.Encode(childKey.PublicKey), + Data: childKeyScan, + }) + } + } + + return &nockchain.ScanResponse{ + ScanData: scanData, + }, nil +} + +func (h *GprcHandler) SignTx(context.Context, *nockchain.SignTxRequest) (*nockchain.SignTxResponse, error) { + return nil, nil +}