mirror of
https://github.com/aljazceru/ark.git
synced 2026-01-26 14:54:20 +01:00
committed by
GitHub
parent
28db168af0
commit
0210d39866
@@ -1,106 +0,0 @@
|
||||
// Copyright (c) 2013-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// appDataDir returns an operating system specific directory to be used for
|
||||
// storing application data for an application. See AppDataDir for more
|
||||
// details. This unexported version takes an operating system argument
|
||||
// primarily to enable the testing package to properly test the function by
|
||||
// forcing an operating system that is not the currently one.
|
||||
func appDataDir(goos, appName string, roaming bool) string {
|
||||
if appName == "" || appName == "." {
|
||||
return "."
|
||||
}
|
||||
|
||||
// The caller really shouldn't prepend the appName with a period, but
|
||||
// if they do, handle it gracefully by trimming it.
|
||||
appName = strings.TrimPrefix(appName, ".")
|
||||
appNameUpper := string(unicode.ToUpper(rune(appName[0]))) + appName[1:]
|
||||
appNameLower := string(unicode.ToLower(rune(appName[0]))) + appName[1:]
|
||||
|
||||
// Get the OS specific home directory via the Go standard lib.
|
||||
var homeDir string
|
||||
usr, err := user.Current()
|
||||
if err == nil {
|
||||
homeDir = usr.HomeDir
|
||||
}
|
||||
|
||||
// Fall back to standard HOME environment variable that works
|
||||
// for most POSIX OSes if the directory from the Go standard
|
||||
// lib failed.
|
||||
if err != nil || homeDir == "" {
|
||||
homeDir = os.Getenv("HOME")
|
||||
}
|
||||
|
||||
switch goos {
|
||||
// Attempt to use the LOCALAPPDATA or APPDATA environment variable on
|
||||
// Windows.
|
||||
case "windows":
|
||||
// Windows XP and before didn't have a LOCALAPPDATA, so fallback
|
||||
// to regular APPDATA when LOCALAPPDATA is not set.
|
||||
appData := os.Getenv("LOCALAPPDATA")
|
||||
if roaming || appData == "" {
|
||||
appData = os.Getenv("APPDATA")
|
||||
}
|
||||
|
||||
if appData != "" {
|
||||
return filepath.Join(appData, appNameUpper)
|
||||
}
|
||||
|
||||
case "darwin":
|
||||
if homeDir != "" {
|
||||
return filepath.Join(homeDir, "Library",
|
||||
"Application Support", appNameUpper)
|
||||
}
|
||||
|
||||
case "plan9":
|
||||
if homeDir != "" {
|
||||
return filepath.Join(homeDir, appNameLower)
|
||||
}
|
||||
|
||||
default:
|
||||
if homeDir != "" {
|
||||
return filepath.Join(homeDir, "."+appNameLower)
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to the current directory if all else fails.
|
||||
return "."
|
||||
}
|
||||
|
||||
// AppDataDir returns an operating system specific directory to be used for
|
||||
// storing application data for an application.
|
||||
//
|
||||
// The appName parameter is the name of the application the data directory is
|
||||
// being requested for. This function will prepend a period to the appName for
|
||||
// POSIX style operating systems since that is standard practice. An empty
|
||||
// appName or one with a single dot is treated as requesting the current
|
||||
// directory so only "." will be returned. Further, the first character
|
||||
// of appName will be made lowercase for POSIX style operating systems and
|
||||
// uppercase for Mac and Windows since that is standard practice.
|
||||
//
|
||||
// The roaming parameter only applies to Windows where it specifies the roaming
|
||||
// application data profile (%APPDATA%) should be used instead of the local one
|
||||
// (%LOCALAPPDATA%) that is used by default.
|
||||
//
|
||||
// Example results:
|
||||
//
|
||||
// dir := AppDataDir("myapp", false)
|
||||
// POSIX (Linux/BSD): ~/.myapp
|
||||
// Mac OS: $HOME/Library/Application Support/Myapp
|
||||
// Windows: %LOCALAPPDATA%\Myapp
|
||||
// Plan 9: $home/myapp
|
||||
func AppDataDir(appName string, roaming bool) string {
|
||||
return appDataDir(runtime.GOOS, appName, roaming)
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
SEQUENCE_LOCKTIME_MASK = 0x0000ffff
|
||||
SEQUENCE_LOCKTIME_TYPE_FLAG = 1 << 22
|
||||
SEQUENCE_LOCKTIME_GRANULARITY = 9
|
||||
SECONDS_MOD = 1 << SEQUENCE_LOCKTIME_GRANULARITY
|
||||
SECONDS_MAX = SEQUENCE_LOCKTIME_MASK << SEQUENCE_LOCKTIME_GRANULARITY
|
||||
SEQUENCE_LOCKTIME_DISABLE_FLAG = 1 << 31
|
||||
)
|
||||
|
||||
func closerToModulo512(x uint) uint {
|
||||
return x - (x % 512)
|
||||
}
|
||||
|
||||
// BIP68Encode returns the encoded sequence locktime for the given number of seconds.
|
||||
func BIP68Encode(seconds uint) ([]byte, error) {
|
||||
seconds = closerToModulo512(seconds)
|
||||
if seconds > SECONDS_MAX {
|
||||
return nil, fmt.Errorf("seconds too large, max is %d", SECONDS_MAX)
|
||||
}
|
||||
if seconds%SECONDS_MOD != 0 {
|
||||
return nil, fmt.Errorf("seconds must be a multiple of %d", SECONDS_MOD)
|
||||
}
|
||||
|
||||
asNumber := SEQUENCE_LOCKTIME_TYPE_FLAG | (seconds >> SEQUENCE_LOCKTIME_GRANULARITY)
|
||||
hexString := fmt.Sprintf("%x", asNumber)
|
||||
reversed, err := hex.DecodeString(hexString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i, j := 0, len(reversed)-1; i < j; i, j = i+1, j-1 {
|
||||
reversed[i], reversed[j] = reversed[j], reversed[i]
|
||||
}
|
||||
return reversed, nil
|
||||
}
|
||||
|
||||
func BIP68Decode(sequence []byte) (uint, error) {
|
||||
var asNumber int64
|
||||
for i := len(sequence) - 1; i >= 0; i-- {
|
||||
asNumber = asNumber<<8 | int64(sequence[i])
|
||||
}
|
||||
|
||||
if asNumber&SEQUENCE_LOCKTIME_DISABLE_FLAG != 0 {
|
||||
return 0, fmt.Errorf("sequence is disabled")
|
||||
}
|
||||
if asNumber&SEQUENCE_LOCKTIME_TYPE_FLAG != 0 {
|
||||
seconds := asNumber & SEQUENCE_LOCKTIME_MASK << SEQUENCE_LOCKTIME_GRANULARITY
|
||||
return uint(seconds), nil
|
||||
}
|
||||
return 0, fmt.Errorf("sequence is encoded as block number")
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package common_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/ark-network/ark/common"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestBIP68(t *testing.T) {
|
||||
data, err := os.ReadFile("fixtures/bip68.json")
|
||||
require.NoError(t, err)
|
||||
|
||||
var testCases []struct {
|
||||
Input uint `json:"seconds"`
|
||||
Expected int64 `json:"sequence"`
|
||||
Desc string `json:"description"`
|
||||
}
|
||||
err = json.Unmarshal(data, &testCases)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, testCases)
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.Desc, func(t *testing.T) {
|
||||
actual, err := sdk.BIP68Encode(tc.Input)
|
||||
require.NoError(t, err)
|
||||
|
||||
var asNumber int64
|
||||
for i := len(actual) - 1; i >= 0; i-- {
|
||||
asNumber = asNumber<<8 | int64(actual[i])
|
||||
}
|
||||
|
||||
require.Equal(t, tc.Expected, asNumber)
|
||||
|
||||
decoded, err := sdk.BIP68Decode(actual)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, tc.Input, decoded)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil/bech32"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
)
|
||||
|
||||
const (
|
||||
ProtoKey = "ark"
|
||||
RelayKey = "relays"
|
||||
RelaySep = "-"
|
||||
)
|
||||
|
||||
func EncodeSecKey(hrp string, key *secp256k1.PrivateKey) (seckey string, err error) {
|
||||
if key == nil {
|
||||
return "", fmt.Errorf("missing secret key")
|
||||
}
|
||||
if hrp != MainNet.SecKey && hrp != TestNet.SecKey {
|
||||
return "", fmt.Errorf("invalid prefix")
|
||||
}
|
||||
grp, err := bech32.ConvertBits(key.Serialize(), 8, 5, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
seckey, err = bech32.EncodeM(hrp, grp)
|
||||
return
|
||||
}
|
||||
|
||||
func DecodeSecKey(key string) (hrp string, seckey *secp256k1.PrivateKey, err error) {
|
||||
prefix, buf, err := bech32.DecodeNoLimit(key)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("invalid secret key: %s", err)
|
||||
return
|
||||
}
|
||||
if prefix != MainNet.SecKey && prefix != TestNet.SecKey {
|
||||
err = fmt.Errorf("invalid prefix")
|
||||
return
|
||||
}
|
||||
grp, err := bech32.ConvertBits(buf, 5, 8, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
hrp = prefix
|
||||
seckey = secp256k1.PrivKeyFromBytes(grp)
|
||||
return
|
||||
}
|
||||
|
||||
func EncodePubKey(hrp string, key *secp256k1.PublicKey) (pubkey string, err error) {
|
||||
if key == nil {
|
||||
err = fmt.Errorf("missing public key")
|
||||
return
|
||||
}
|
||||
if hrp != MainNet.PubKey && hrp != TestNet.PubKey {
|
||||
err = fmt.Errorf("invalid prefix")
|
||||
return
|
||||
}
|
||||
grp, err := bech32.ConvertBits(key.SerializeCompressed(), 8, 5, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
pubkey, err = bech32.EncodeM(hrp, grp)
|
||||
return
|
||||
}
|
||||
|
||||
func DecodePubKey(key string) (hrp string, pubkey *secp256k1.PublicKey, err error) {
|
||||
prefix, buf, err := bech32.DecodeNoLimit(key)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if prefix != MainNet.PubKey && prefix != TestNet.PubKey {
|
||||
err = fmt.Errorf("invalid prefix")
|
||||
return
|
||||
}
|
||||
grp, err := bech32.ConvertBits(buf, 5, 8, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(grp) < 32 {
|
||||
err = fmt.Errorf("invalid public key length")
|
||||
return
|
||||
}
|
||||
pubkey, err = secp256k1.ParsePubKey(grp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
hrp = prefix
|
||||
return
|
||||
}
|
||||
|
||||
func EncodeAddress(hrp string, userKey, aspKey *secp256k1.PublicKey) (addr string, err error) {
|
||||
if userKey == nil {
|
||||
err = fmt.Errorf("missing public key")
|
||||
return
|
||||
}
|
||||
if aspKey == nil {
|
||||
err = fmt.Errorf("missing asp public key")
|
||||
return
|
||||
}
|
||||
if hrp != MainNet.Addr && hrp != TestNet.Addr {
|
||||
err = fmt.Errorf("invalid prefix")
|
||||
return
|
||||
}
|
||||
combinedKey := append(aspKey.SerializeCompressed(), userKey.SerializeCompressed()...)
|
||||
grp, err := bech32.ConvertBits(combinedKey, 8, 5, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
addr, err = bech32.EncodeM(hrp, grp)
|
||||
return
|
||||
}
|
||||
|
||||
func DecodeAddress(addr string) (hrp string, userKey *secp256k1.PublicKey, aspKey *secp256k1.PublicKey, err error) {
|
||||
prefix, buf, err := bech32.DecodeNoLimit(addr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if prefix != MainNet.Addr && prefix != TestNet.Addr {
|
||||
err = fmt.Errorf("invalid prefix")
|
||||
return
|
||||
}
|
||||
grp, err := bech32.ConvertBits(buf, 5, 8, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
aKey, err := secp256k1.ParsePubKey(grp[:33])
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to parse public key: %s", err)
|
||||
return
|
||||
}
|
||||
uKey, err := secp256k1.ParsePubKey(grp[33:])
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to parse asp public key: %s", err)
|
||||
return
|
||||
}
|
||||
hrp = prefix
|
||||
userKey = uKey
|
||||
aspKey = aKey
|
||||
return
|
||||
}
|
||||
|
||||
func EncodeRelayKey(hrp string, key *secp256k1.PublicKey) (pubkey string, err error) {
|
||||
if key == nil {
|
||||
err = fmt.Errorf("missing relay key")
|
||||
return
|
||||
}
|
||||
if hrp != MainNet.RelayKey && hrp != TestNet.RelayKey {
|
||||
err = fmt.Errorf("invalid prefix")
|
||||
return
|
||||
}
|
||||
grp, err := bech32.ConvertBits(key.SerializeCompressed(), 8, 5, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
pubkey, err = bech32.EncodeM(hrp, grp)
|
||||
return
|
||||
}
|
||||
|
||||
func DecodeRelayKey(key string) (hrp string, pubkey *secp256k1.PublicKey, err error) {
|
||||
prefix, buf, err := bech32.DecodeNoLimit(key)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if prefix != MainNet.RelayKey && prefix != TestNet.RelayKey {
|
||||
err = fmt.Errorf("invalid prefix")
|
||||
return
|
||||
}
|
||||
grp, err := bech32.ConvertBits(buf, 5, 8, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(grp) < 32 {
|
||||
err = fmt.Errorf("invalid public key length")
|
||||
return
|
||||
}
|
||||
pubkey, err = secp256k1.ParsePubKey(grp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
hrp = prefix
|
||||
return
|
||||
}
|
||||
|
||||
func EncodeUrl(host string, relays ...string) (arkurl string, err error) {
|
||||
_, _, err = DecodePubKey(host)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("invalid public key: %s", err)
|
||||
return
|
||||
}
|
||||
for _, r := range relays {
|
||||
_, _, err = DecodeRelayKey(r)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("invalid relay public key: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
u := url.URL{Scheme: ProtoKey, Host: host}
|
||||
q := u.Query()
|
||||
if len(relays) > 0 {
|
||||
q.Add(RelayKey, strings.Join(relays, RelaySep))
|
||||
}
|
||||
u.RawQuery = q.Encode()
|
||||
arkurl = u.String()
|
||||
return
|
||||
}
|
||||
|
||||
func DecodeUrl(arkurl string) (host string, relays []string, err error) {
|
||||
u, err := url.Parse(arkurl)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if u.Scheme != ProtoKey {
|
||||
err = fmt.Errorf("invalid proto")
|
||||
return
|
||||
}
|
||||
_, _, err = DecodePubKey(u.Host)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("invalid public key: %s", err)
|
||||
return
|
||||
}
|
||||
list := strings.Split(u.Query().Get(RelayKey), RelaySep)
|
||||
for _, r := range list {
|
||||
_, _, err = DecodeRelayKey(r)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("invalid relay public key: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
host = u.Host
|
||||
relays = make([]string, len(list))
|
||||
copy(relays, list)
|
||||
return
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
package common_test
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
common "github.com/ark-network/ark/common"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var f []byte
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
f, err = os.ReadFile("fixtures/encoding.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecretKeyEncoding(t *testing.T) {
|
||||
fixtures := struct {
|
||||
SecretKey struct {
|
||||
Valid []struct {
|
||||
Key string `json:"key"`
|
||||
Expected string `json:"expected"`
|
||||
} `json:"valid"`
|
||||
Invalid []struct {
|
||||
Key string `json:"key"`
|
||||
ExpectedError string `json:"expectedError"`
|
||||
} `json:"invalid"`
|
||||
} `json:"secretKey"`
|
||||
}{}
|
||||
err := json.Unmarshal(f, &fixtures)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
for _, f := range fixtures.SecretKey.Valid {
|
||||
hrp, key, err := common.DecodeSecKey(f.Key)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, hrp)
|
||||
require.NotNil(t, key)
|
||||
|
||||
keyHex := hex.EncodeToString(key.Serialize())
|
||||
require.Equal(t, f.Expected, keyHex)
|
||||
|
||||
keyStr, err := common.EncodeSecKey(hrp, key)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, f.Key, keyStr)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
for _, f := range fixtures.SecretKey.Invalid {
|
||||
hrp, key, err := common.DecodeSecKey(f.Key)
|
||||
require.EqualError(t, err, f.ExpectedError)
|
||||
require.Empty(t, hrp)
|
||||
require.Nil(t, key)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestPublicKeyEncoding(t *testing.T) {
|
||||
fixtures := struct {
|
||||
PublicKey struct {
|
||||
Valid []struct {
|
||||
Key string `json:"key"`
|
||||
Expected string `json:"expected"`
|
||||
} `json:"valid"`
|
||||
Invalid []struct {
|
||||
Key string `json:"key"`
|
||||
ExpectedError string `json:"expectedError"`
|
||||
} `json:"invalid"`
|
||||
} `json:"publicKey"`
|
||||
}{}
|
||||
err := json.Unmarshal(f, &fixtures)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
for _, f := range fixtures.PublicKey.Valid {
|
||||
hrp, key, err := common.DecodePubKey(f.Key)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, hrp)
|
||||
require.NotNil(t, key)
|
||||
|
||||
keyHex := hex.EncodeToString(key.SerializeCompressed())
|
||||
require.Equal(t, f.Expected, keyHex)
|
||||
|
||||
keyStr, err := common.EncodePubKey(hrp, key)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, f.Key, keyStr)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
for _, f := range fixtures.PublicKey.Invalid {
|
||||
hrp, key, err := common.DecodePubKey(f.Key)
|
||||
require.EqualError(t, err, f.ExpectedError)
|
||||
require.Empty(t, hrp)
|
||||
require.Nil(t, key)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAddressEncoding(t *testing.T) {
|
||||
fixtures := struct {
|
||||
Address struct {
|
||||
Valid []struct {
|
||||
Addr string `json:"addr"`
|
||||
ExpectedUserKey string `json:"expectedUserKey"`
|
||||
ExpectedAspKey string `json:"expectedAspKey"`
|
||||
} `json:"valid"`
|
||||
Invalid []struct {
|
||||
Addr string `json:"addr"`
|
||||
ExpectedError string `json:"expectedError"`
|
||||
} `json:"invalid"`
|
||||
} `json:"address"`
|
||||
}{}
|
||||
err := json.Unmarshal(f, &fixtures)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
for _, f := range fixtures.Address.Valid {
|
||||
hrp, userKey, aspKey, err := common.DecodeAddress(f.Addr)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, hrp)
|
||||
require.NotNil(t, userKey)
|
||||
require.NotNil(t, aspKey)
|
||||
|
||||
userKeyStr, err := common.EncodePubKey(common.MainNet.PubKey, userKey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, f.ExpectedUserKey, userKeyStr)
|
||||
|
||||
aspKeyStr, err := common.EncodePubKey(common.MainNet.PubKey, aspKey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, f.ExpectedAspKey, aspKeyStr)
|
||||
|
||||
addr, err := common.EncodeAddress(hrp, userKey, aspKey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, f.Addr, addr)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
for _, f := range fixtures.Address.Invalid {
|
||||
hrp, userKey, aspKey, err := common.DecodeAddress(f.Addr)
|
||||
require.EqualError(t, err, f.ExpectedError)
|
||||
require.Empty(t, hrp)
|
||||
require.Nil(t, userKey)
|
||||
require.Nil(t, aspKey)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestRelayKeyEncoding(t *testing.T) {
|
||||
fixtures := struct {
|
||||
RelayKey struct {
|
||||
Valid []struct {
|
||||
Key string `json:"key"`
|
||||
Expected string `json:"expected"`
|
||||
} `json:"valid"`
|
||||
Invalid []struct {
|
||||
Key string `json:"key"`
|
||||
ExpectedError string `json:"expectedError"`
|
||||
} `json:"invalid"`
|
||||
} `json:"relayKey"`
|
||||
}{}
|
||||
err := json.Unmarshal(f, &fixtures)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
for _, f := range fixtures.RelayKey.Valid {
|
||||
hrp, key, err := common.DecodeRelayKey(f.Key)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, hrp)
|
||||
require.NotNil(t, key)
|
||||
|
||||
keyHex := hex.EncodeToString(key.SerializeCompressed())
|
||||
require.Equal(t, f.Expected, keyHex)
|
||||
|
||||
keyStr, err := common.EncodeRelayKey(hrp, key)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, f.Key, keyStr)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
for _, f := range fixtures.RelayKey.Invalid {
|
||||
hrp, key, err := common.DecodeRelayKey(f.Key)
|
||||
require.EqualError(t, err, f.ExpectedError)
|
||||
require.Empty(t, hrp)
|
||||
require.Nil(t, key)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestUrlEncoding(t *testing.T) {
|
||||
fixtures := struct {
|
||||
Url struct {
|
||||
Valid []struct {
|
||||
Url string `json:"url"`
|
||||
ExpectedPubkey string `json:"expectedPubkey"`
|
||||
ExpectedRelays []string `json:"expectedRelays"`
|
||||
} `json:"valid"`
|
||||
Invalid []struct {
|
||||
Url string `json:"url"`
|
||||
ExpectedError string `json:"expectedError"`
|
||||
} `json:"invalid"`
|
||||
} `json:"url"`
|
||||
}{}
|
||||
err := json.Unmarshal(f, &fixtures)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
for _, f := range fixtures.Url.Valid {
|
||||
pubkey, relays, err := common.DecodeUrl(f.Url)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, pubkey)
|
||||
require.NotNil(t, relays)
|
||||
|
||||
require.Equal(t, f.ExpectedPubkey, pubkey)
|
||||
require.Exactly(t, relays, f.ExpectedRelays)
|
||||
|
||||
url, err := common.EncodeUrl(pubkey, relays...)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, f.Url, url)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
for _, f := range fixtures.Url.Invalid {
|
||||
pubkey, relays, err := common.DecodeUrl(f.Url)
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), f.ExpectedError)
|
||||
require.Empty(t, pubkey)
|
||||
require.Nil(t, relays)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
[
|
||||
{
|
||||
"description": "0x00400000 (00000000010000000000000000000000)",
|
||||
"seconds": 0,
|
||||
"sequence": 4194304
|
||||
},
|
||||
{
|
||||
"description": "0x00400001 (00000000010000000000000000000001)",
|
||||
"seconds": 512,
|
||||
"sequence": 4194305
|
||||
},
|
||||
{
|
||||
"description": "0x00400002 (00000000010000000000000000000010)",
|
||||
"seconds": 1024,
|
||||
"sequence": 4194306
|
||||
},
|
||||
{
|
||||
"description": "0x00400003 (00000000010000000000000000000011)",
|
||||
"seconds": 1536,
|
||||
"sequence": 4194307
|
||||
},
|
||||
{
|
||||
"description": "0x00400004 (00000000010000000000000000000100)",
|
||||
"seconds": 2048,
|
||||
"sequence": 4194308
|
||||
},
|
||||
{
|
||||
"description": "0x00400005 (00000000010000000000000000000101)",
|
||||
"seconds": 2560,
|
||||
"sequence": 4194309
|
||||
},
|
||||
{
|
||||
"description": "0x00400006 (00000000010000000000000000000110)",
|
||||
"seconds": 3072,
|
||||
"sequence": 4194310
|
||||
},
|
||||
{
|
||||
"description": "0x00400007 (00000000010000000000000000000111)",
|
||||
"seconds": 3584,
|
||||
"sequence": 4194311
|
||||
},
|
||||
{
|
||||
"description": "0x00400008 (00000000010000000000000000001000)",
|
||||
"seconds": 4096,
|
||||
"sequence": 4194312
|
||||
},
|
||||
{
|
||||
"description": "0x00400009 (00000000010000000000000000001001)",
|
||||
"seconds": 4608,
|
||||
"sequence": 4194313
|
||||
},
|
||||
{
|
||||
"description": "0x0040000a (00000000010000000000000000001010)",
|
||||
"seconds": 5120,
|
||||
"sequence": 4194314
|
||||
},
|
||||
{
|
||||
"description": "0x0040000b (00000000010000000000000000001011)",
|
||||
"seconds": 5632,
|
||||
"sequence": 4194315
|
||||
},
|
||||
{
|
||||
"description": "0x0040000c (00000000010000000000000000001100)",
|
||||
"seconds": 6144,
|
||||
"sequence": 4194316
|
||||
}
|
||||
]
|
||||
@@ -1,85 +0,0 @@
|
||||
{
|
||||
"secretKey": {
|
||||
"valid": [
|
||||
{
|
||||
"key": "asec1n9grggypds323l5fkw4t6kpf6trz26an8wv44qqr8ctp4t3dp52q5zkzz4",
|
||||
"expected": "99503420816c22a8fe89b3aabd5829d2c6256bb33b995a80033e161aae2d0d14"
|
||||
}
|
||||
],
|
||||
"invalid": [
|
||||
{
|
||||
"key": "wrongprefix1c02kjhr4egxvh0ajua0ylv9vl3kyegxmrl2djh4pn63m948ecs4qchx9zx",
|
||||
"expectedError": "invalid prefix"
|
||||
}
|
||||
]
|
||||
},
|
||||
"publicKey": {
|
||||
"valid": [
|
||||
{
|
||||
"key": "apub1qgvdtj5ttpuhkldavhq8thtm5auyk0ec4dcmrfdgu0u5hgp9we22v3hrs4x",
|
||||
"expected": "0218d5ca8b58797b7dbd65c075dd7ba7784b3f38ab71b1a5a8e3f94ba0257654a6"
|
||||
}
|
||||
],
|
||||
"invalid": [
|
||||
{
|
||||
"key": "wrongprefix1q0yn8cskp7lv0lxq3unfynmju68smh69lu90yyv37wzetu6upp76vg4ef6n",
|
||||
"expectedError": "invalid prefix"
|
||||
}
|
||||
]
|
||||
},
|
||||
"address": {
|
||||
"valid": [
|
||||
{
|
||||
"addr": "ark1qgvdtj5ttpuhkldavhq8thtm5auyk0ec4dcmrfdgu0u5hgp9we22vqa7mdkrrulzu48law4zzvzz8k59hul0ayl2urt905we5wf6gee68sfrfj35",
|
||||
"expectedUserKey": "apub1qwldkmp3703w2nl7h23pxpprm2zm70h7j04wp4jh68v68yayvuarcc28uv5",
|
||||
"expectedAspKey": "apub1qgvdtj5ttpuhkldavhq8thtm5auyk0ec4dcmrfdgu0u5hgp9we22v3hrs4x"
|
||||
}
|
||||
],
|
||||
"invalid": [
|
||||
{
|
||||
"addr": "wrongprefix1qt9tfh7c09hlsstzq5y9tzuwyaesrwr8gpy8cn29cxv0flp64958s0n0yd0",
|
||||
"expectedError": "invalid prefix"
|
||||
}
|
||||
]
|
||||
},
|
||||
"relayKey": {
|
||||
"valid": [
|
||||
{
|
||||
"key": "arelay1qt6f8p7h5f6tm7fv2z5wg92sz92rn9desfhd5733se4lkrptqtdrq65987l",
|
||||
"expected": "02f49387d7a274bdf92c50a8e4155011543995b9826eda7a31866bfb0c2b02da30"
|
||||
}
|
||||
],
|
||||
"invalid": [
|
||||
{
|
||||
"key": "wrongprefix1q2g64uehct5zdkhdull6ultevfmuu62nzwucec6q8su85eqpezxdvsf2mfd",
|
||||
"expectedError": "invalid prefix"
|
||||
}
|
||||
]
|
||||
},
|
||||
"url": {
|
||||
"valid": [
|
||||
{
|
||||
"url": "ark://apub1qgvdtj5ttpuhkldavhq8thtm5auyk0ec4dcmrfdgu0u5hgp9we22v3hrs4x?relays=arelay1qt6f8p7h5f6tm7fv2z5wg92sz92rn9desfhd5733se4lkrptqtdrq65987l-arelay1qt6f8p7h5f6tm7fv2z5wg92sz92rn9desfhd5733se4lkrptqtdrq65987l",
|
||||
"expectedPubkey": "apub1qgvdtj5ttpuhkldavhq8thtm5auyk0ec4dcmrfdgu0u5hgp9we22v3hrs4x",
|
||||
"expectedRelays": [
|
||||
"arelay1qt6f8p7h5f6tm7fv2z5wg92sz92rn9desfhd5733se4lkrptqtdrq65987l",
|
||||
"arelay1qt6f8p7h5f6tm7fv2z5wg92sz92rn9desfhd5733se4lkrptqtdrq65987l"
|
||||
]
|
||||
}
|
||||
],
|
||||
"invalid": [
|
||||
{
|
||||
"url": "wrong://apub1qgvdtj5ttpuhkldavhq8thtm5auyk0ec4dcmrfdgu0u5hgp9we22v3hrs4x?relays=arelay1qt6f8p7h5f6tm7fv2z5wg92sz92rn9desfhd5733se4lkrptqtdrq65987l-arelay1qt6f8p7h5f6tm7fv2z5wg92sz92rn9desfhd5733se4lkrptqtdrq65987l",
|
||||
"expectedError": "invalid proto"
|
||||
},
|
||||
{
|
||||
"url": "ark://asec1n9grggypds323l5fkw4t6kpf6trz26an8wv44qqr8ctp4t3dp52qun9kjh",
|
||||
"expectedError": "invalid public key"
|
||||
},
|
||||
{
|
||||
"url": "ark://apub1qgvdtj5ttpuhkldavhq8thtm5auyk0ec4dcmrfdgu0u5hgp9we22v3hrs4x?relays=apub1qgvdtj5ttpuhkldavhq8thtm5auyk0ec4dcmrfdgu0u5hgp9we22v3hrs4x",
|
||||
"expectedError": "invalid relay public key"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
module github.com/ark-network/ark/common
|
||||
|
||||
go 1.21.0
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd/btcutil v1.1.3
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
||||
)
|
||||
@@ -1,102 +0,0 @@
|
||||
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.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
|
||||
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.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ=
|
||||
github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0=
|
||||
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/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/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/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
|
||||
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/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/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/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/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
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/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/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/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/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=
|
||||
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=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
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 h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -1,25 +0,0 @@
|
||||
package common
|
||||
|
||||
type Network struct {
|
||||
Name string
|
||||
SecKey string
|
||||
PubKey string
|
||||
RelayKey string
|
||||
Addr string
|
||||
}
|
||||
|
||||
var MainNet = Network{
|
||||
Name: "mainnet",
|
||||
SecKey: "asec",
|
||||
PubKey: "apub",
|
||||
RelayKey: "arelay",
|
||||
Addr: "ark",
|
||||
}
|
||||
|
||||
var TestNet = Network{
|
||||
Name: "testnet",
|
||||
SecKey: "tasec",
|
||||
PubKey: "tapub",
|
||||
RelayKey: "tarelay",
|
||||
Addr: "tark",
|
||||
}
|
||||
Reference in New Issue
Block a user