Documentation ¶
Index ¶
- Constants
- Variables
- func AppDataDir(appName string, roaming bool) string
- func DecodeProofList(proofList string) (map[int]int, error)
- func HDPrivateKeyToPublicKeyID(id []byte) ([]byte, error)
- func InitChainGenesisDoc()
- func IsBech32SegwitPrefix(prefix string) bool
- func IsPubKeyHashAddrID(id byte) bool
- func IsScriptHashAddrID(id byte) bool
- func NormalizeAddress(addr, defaultPort string) string
- func NormalizeAddresses(addrs []string, defaultPort string) []string
- func NormalizeSeed(seed, defaultPort string) (string, error)
- func NormalizeSeeds(inputs, defaultPort string) string
- func Register(params *Params) error
- func UpdateGenesisBlock(block *wire.MsgBlock)
- type Checkpoint
- type Config
- type GenesisAlloc
- type GenesisDoc
- type GenesisProof
- type GenesisSignature
- type Params
Constants ¶
const ( DefaultConfigFilename = "config.json" DefaultDataDirname = "chain" DefaultLogLevel = "info" DefaultLoggingFilename = "skt" MaxMiningPayoutAddresses = 6000 )
const ChainGenesisDocHash = "73756b686176617469b34ea2f85159fa271423fcc27496b5e2"
Variables ¶
var ( FreeTxRelayLimit = 15.0 AddrIndex = true NoRelayPriority = true BlockPrioritySize uint32 = defaultBlockPrioritySize BlockMinSize uint32 = defaultBlockMinSize BlockMaxSize uint32 = defaultBlockMaxSize MaxPeers = 50 Moniker = "anonymous" ChainTag = defaultChainTag )
var ( AppHomeDir = AppDataDir("skt", false) HDCoinTypeMainNet uint32 = 2021 )
var ChainParams = Params{ Name: defaultChainTag, DefaultPort: "43458", DNSSeeds: []string{}, GenesisBlock: &genesisBlock, ChainID: &genesisChainID, PocLimit: mainPocLimit, SubsidyHalvingInterval: consensus.SubsidyHalvingInterval, ResetMinDifficulty: false, Checkpoints: []Checkpoint{}, RelayNonStdTxs: false, Bech32HRPSegwit: "sk", PubKeyHashAddrID: 0x00, ScriptHashAddrID: 0x05, PrivateKeyID: 0x80, WitnessPubKeyHashAddrID: 0x06, WitnessScriptHashAddrID: 0x0A, HDPrivateKeyID: [4]byte{0x04, 0x88, 0xad, 0xe4}, HDPublicKeyID: [4]byte{0x04, 0x88, 0xb2, 0x1e}, HDCoinType: HDCoinTypeMainNet, CompatibleHDCoinTypes: []uint32{297}, }
ChainParams defines the network parameters for the main skt network.
var ( // ErrUnknownHDKeyID describes an error where the provided id which // is intended to identify the network for a hierarchical deterministic // private extended key is not registered. ErrUnknownHDKeyID = errors.New("unknown hd private extended key bytes") )
var RunServiceCommand func(string) error
RunServiceCommand is only set to a real function on Windows. It is used to parse and execute service commands specified via the -s flag.
Functions ¶
func AppDataDir ¶
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 DecodeProofList ¶
DecodeProofList decodes config proof list in format like this: "<BL>:<Count>,<BL>:<Count>". Example: 3 spaces of BL = 24, 4 spaces of BL= 26, 5 spaces of BL = 28 would be like "24:3, 26:4, 28:5". Duplicate BL would be added together, "24:1, 24:2, 26:5" equals to "24:3, 26:5".
func HDPrivateKeyToPublicKeyID ¶
HDPrivateKeyToPublicKeyID accepts a private hierarchical deterministic extended key id and returns the associated public key id. When the provided id is not registered, the ErrUnknownHDKeyID error will be returned.
func InitChainGenesisDoc ¶
func InitChainGenesisDoc()
func IsBech32SegwitPrefix ¶
IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit addresses on any default or registered network. This is used when decoding an wallet string into a specific wallet type.
func IsPubKeyHashAddrID ¶
IsPubKeyHashAddrID returns whether the id is an identifier known to prefix a pay-to-pubkey-hash address on any default or registered network. This is used when decoding an wallet string into a specific wallet type. It is up to the caller to check both this and IsScriptHashAddrID and decide whether an wallet is a pubkey hash wallet, script hash wallet, neither, or undeterminable (if both return true).
func IsScriptHashAddrID ¶
IsScriptHashAddrID returns whether the id is an identifier known to prefix a pay-to-script-hash address on any default or registered network. This is used when decoding an wallet string into a specific wallet type. It is up to the caller to check both this and IsPubKeyHashAddrID and decide whether an wallet is a pubkey hash wallet, script hash wallet, neither, or undeterminable (if both return true).
func NormalizeAddress ¶
NormalizeAddress returns addr with the passed default port appended if there is not already a port specified.
func NormalizeAddresses ¶
normalizeAddresses returns a new slice with all the passed peer addresses normalized with the given default port, and all duplicates removed.
func NormalizeSeed ¶
NormalizeSeed accepts four types of params:
(1) [IPV4/IPV6] (2) [IPV4/IPV6]:[PORT] (3) [DOMAIN] (4) [DOMAIN]:[PORT]
It returns error if receive other types of params.
Run step:
(1) check if Seed has port, then split Host and Port; (2) check validity of Port, then assign default value to empty Port; (3) randomly select an IP if Host is a domain; (4) join host and port.
func NormalizeSeeds ¶
Normalize Seeds joined with ','.
func Register ¶
Register registers the network parameters for a Skt network. This may error with ErrDuplicateNet if the network is already registered (either due to a previous Register call, or the network being one of the default networks).
Network parameters should be registered into this package by a main package as early as possible. Then, library packages may lookup networks or network parameters based on inputs and work regardless of the network being standard or not.
func UpdateGenesisBlock ¶
Must call this func when mock chain.
Types ¶
type Checkpoint ¶
Checkpoint identifies a known good point in the block chain. Using checkpoints allows a few optimizations for old blocks during initial download and also prevents forks from old blocks.
Each checkpoint is selected based upon several factors. See the documentation for blockchain.IsCheckpointCandidate for details on the selection criteria.
type Config ¶
type Config struct { *configpb.Config ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"` ShowVersion bool `short:"V" long:"version" description:"Display Version information and exit"` Generate bool `long:"generate" description:"Generate (mine) coins when start"` Init bool `long:"init" description:"Init miner keystore"` PrivatePass string `short:"P" long:"privpass" description:"Private passphrase for miner"` }
func CheckConfig ¶
func LoadConfig ¶
func ParseConfig ¶
ParseConfig reads and parses the config using a Config file and command line options. This func proceeds as follows:
- Start with a default config with sane settings
- Pre-parse the command line to check for an alternative config file
type GenesisAlloc ¶
type GenesisDoc ¶
type GenesisDoc struct { Version uint64 `json: "version"` InitHeight uint64 `json:"init_height"` Timestamp uint64 `json:"timestamp"` Target string `json:"target"` Challenge string `json:"challenge"` PublicKey string `json:"public_key"` Proof GenesisProof `json:"proof"` Signature GenesisSignature `json:"signature"` AllocTxOut []*wire.TxOut // contains filtered or unexported fields }
GenesisDoc defines the initial conditions for a sukhavati blockchain, in particular its validator set.
var ChainGenesisDoc GenesisDoc
func (GenesisDoc) IsHashEqual ¶
func (genDoc GenesisDoc) IsHashEqual(sha string) bool
func (GenesisDoc) SaveAs ¶
func (genDoc GenesisDoc) SaveAs(file string) error
SaveAs is a utility method for saving GenesisDoc as a JSON file.
type GenesisProof ¶
type GenesisProof struct { BitLength int `json:"bit_length"` // contains filtered or unexported fields }
type GenesisSignature ¶
type GenesisSignature struct {
// contains filtered or unexported fields
}
type Params ¶
type Params struct { Name string DefaultPort string DNSSeeds []string // Chain parameters GenesisBlock *wire.MsgBlock GenesisHash *wire.Hash ChainID *wire.Hash PocLimit *big.Int SubsidyHalvingInterval uint64 ResetMinDifficulty bool // Checkpoints ordered from oldest to newest. Checkpoints []Checkpoint // Mempool parameters RelayNonStdTxs bool // Human-readable part for Bech32 encoded segwit addresses, as defined // in BIP 173. Bech32HRPSegwit string // Address encoding magics PubKeyHashAddrID byte // First byte of a P2PKH address ScriptHashAddrID byte // First byte of a P2SH address PrivateKeyID byte // First byte of a WIF private key WitnessPubKeyHashAddrID byte // First byte of a P2WPKH address WitnessScriptHashAddrID byte // First byte of a P2WSH address // BIP32 hierarchical deterministic extended key magics HDPrivateKeyID [4]byte HDPublicKeyID [4]byte // BIP44 coin type used in the hierarchical deterministic path for // address generation. HDCoinType uint32 // compatible hd cointype for mine CompatibleHDCoinTypes []uint32 }
Params defines a chain network by its parameters. These parameters may be used by skt applications to differentiate networks as well as addresses and keys for one network from those intended for use on another network.