mconfig

package
v3.1.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 8 Imported by: 7

Documentation

Index

Constants

View Source
const (
	AppName            = "Metchain"
	DbDir              = "data"
	DbDirTestnet       = "dataverify"
	MainnetPortRPC     = "14041"
	MainnetPortP2p     = "14031"
	RPCMaxClients      = 125
	MinimumStaking     = 15000
	Lock3Month         = 131400
	Lock6Month         = 262800
	Lock9Month         = 350400
	Lock12Month        = 525600
	DeadWallet         = "metchain:000000000000000000000000000000000000000000000000000000000000DEAD"
	MINING_SENDER      = "METCHAIN_Blockchain"
	MINING_REWARD      = 0.3
	MINING_REWARD_MEGA = 3
	MINING_REWARD_MET  = 15
	MINING_TIMER_SEC   = 10

	STAKING_SENDER = "Coinbase"
)
View Source
const (
	PubkeyAddrId = 0x00
)
View Source
const PublicKeySize = 64

PublicKeySize is the public key size for a schnorr public key

View Source
const PublicKeySizeECDSA = 33

PublicKeySizeECDSA is the public key size for an ECDSA public key

Variables

View Source
var Bech32toVersion = map[string]Bech32Prefix{
	"metchain": Bech32PrefixMet,
}
View Source
var CoinBaseHex = []byte{
	0xf4, 0xbb, 0x75, 0x2e, 0x7f, 0x3b, 0xec, 0x33,
	0xe0, 0xf0, 0x3c, 0xec, 0xe2, 0x0a, 0x68, 0x44,
	0xd5, 0x84, 0xa5, 0xfa, 0x3e, 0xd5, 0x47, 0xf5,
	0x17, 0xae,
	0xb8, 0xc1, 0xcb, 0xd5, 0x22, 0x41, 0xd2, 0xac,
	0xe4, 0xd5,
	0x0f, 0x1c, 0xe9, 0xc7, 0xe7, 0x92, 0xd5, 0x9f,
	0xef, 0x77, 0x9b, 0x6e, 0xb7, 0x3c, 0xb0, 0x1f,
	0xd5, 0xd0,
	0x7f, 0x9c, 0xaa, 0x89, 0x97, 0xd5, 0x06, 0x19,
	0xd0, 0xea, 0x4d, 0x2b, 0x91, 0x60, 0x02, 0xd9,
	0xb5,
}
View Source
var (
	// ErrUnknownAddressType describes an error where an address can not
	// decoded as a specific address type due to the string encoding
	// begining with an identifier byte unknown to any standard or
	// registered (via dagconfig.Register) network.
	ErrUnknownAddressType = errors.New("unknown address type")
)
View Source
var Hexmsg = []byte{

	0x0e, 0xb7, 0x00, 0x42, 0x8e, 0x02, 0x81, 0x9e, 0xd5,
	0xce, 0x63, 0x0b, 0x4a, 0xd5, 0xcf, 0x51, 0x04, 0xe1,
	0x2c, 0xd5, 0xbb, 0x1a, 0x9f, 0xb1, 0x24, 0x11, 0x4f,
	0xea, 0x34, 0x5b, 0x52, 0xd5, 0xd5, 0xc9, 0xae, 0x85,
	0x5a,
}
View Source
var MerkleHex = []byte{
	0x27, 0xd6, 0x48, 0xa9, 0x0f, 0xe1, 0x46, 0x8d,
	0x83, 0x9a, 0x92, 0x7d, 0xce, 0x36, 0x99, 0xa6,
	0xac, 0x80, 0xad, 0x8a, 0x12, 0x69, 0xef, 0xc4,
	0xd2, 0xd0, 0xc2, 0xb4, 0x6c, 0xc1, 0xc4, 0x1e,
}
View Source
var NewTxBase = []byte{}/* 128 elements not displayed */
View Source
var NonceHex = []byte{
	0xb6, 0x08, 0x16, 0x39, 0x85, 0xc5, 0x0c, 0xe4,
	0x9a, 0xbc, 0xc7, 0x47, 0xfe, 0x67, 0xb7, 0xe7,
	0xb3, 0x2f, 0x9f, 0x84, 0x54, 0x85, 0x22, 0x9c,
	0xe1, 0xde, 0x9f, 0xd7, 0xd4, 0xb7, 0xc0, 0xf2,
}
View Source
var Prevhash = [32]byte{
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
View Source
var TimestampHex = []byte{
	0xbc, 0xf7, 0xff, 0x36, 0x41, 0x04, 0x8d, 0xfd,
	0xe9, 0x33, 0x1f, 0xd1, 0xa2, 0x16, 0xff, 0x0f,
	0x7a, 0x7f, 0x3f, 0xa0, 0xb2, 0xab, 0x1c, 0x19,
	0xa2, 0x7d, 0x62, 0x82, 0x00, 0x60, 0x93, 0x06,
}

Functions

func GetDBDir

func GetDBDir() string

func GetDBDirTestnet

func GetDBDirTestnet() string

func GetDatadir

func GetDatadir() string

func GetLocalIP

func GetLocalIP() string

func GetLocalIPs

func GetLocalIPs() net.IP

func HashBlake2b

func HashBlake2b(buf []byte) []byte

func ParsePubkey

func ParsePubkey(version []byte) (int, error)

func VerifyDomainIp

func VerifyDomainIp(domain string) string

Types

type Address

type Address interface {
	// String returns the string encoding of the transaction output
	// destination.
	//
	// Please note that String differs subtly from EncodeAddress: String
	// will return the value as a string without any conversion, while
	// EncodeAddress may convert destination types (for example,
	// converting pubkeys to P2PK addresses) before encoding as a
	// payment address string.
	String() string

	//Get Version of the address to verify
	Version() []byte

	// EncodeAddress returns the string encoding of the payment address
	// associated with the Address value. See the comment on String
	// for how this method differs from String.
	EncodeAddress() string

	// ScriptAddress returns the raw bytes of the address to be used
	// when inserting the address into a txout's script.
	ScriptAddress() []byte

	// Prefix returns the prefix for this address
	Prefix() Bech32Prefix

	// IsForPrefix returns whether or not the address is associated with the
	// passed Metchain network.
	IsForPrefix(prefix Bech32Prefix) bool
}

Address is an interface type for any type of destination a transaction output may spend to. This includes pay-to-pubkey (P2PK) and pay-to-script-hash (P2SH). Address is designed to be generic enough that other kinds of addresses may be added in the future without changing the decoding and encoding API.

func DecodeAddress

func DecodeAddress(addr string, expectedPrefix Bech32Prefix) (Address, error)

DecodeAddress decodes the string encoding of an address and returns the Address if addr is a valid encoding for a known address type.

If any expectedPrefix except Bech32PrefixUnknown is passed, it is compared to the prefix extracted from the address, and if the two do not match - an error is returned

type AddressPublicKey

type AddressPublicKey struct {
	// contains filtered or unexported fields
}

AddressPublicKey is an Address for a pay-to-pubkey (P2PK) transaction.

func NewAddressPublicKey

func NewAddressPublicKey(publicKey []byte, prefix Bech32Prefix) (*AddressPublicKey, error)

NewAddressPublicKey returns a new AddressPublicKey. publicKey must be 32 bytes.

func (*AddressPublicKey) EncodeAddress

func (a *AddressPublicKey) EncodeAddress() string

EncodeAddress returns the string encoding of a pay-to-pubkey address. Part of the Address interface.

func (*AddressPublicKey) IsForPrefix

func (a *AddressPublicKey) IsForPrefix(prefix Bech32Prefix) bool

IsForPrefix returns whether or not the pay-to-pubkey address is associated with the passed Metchain network.

func (*AddressPublicKey) Prefix

func (a *AddressPublicKey) Prefix() Bech32Prefix

Prefix returns the prefix for this address

func (*AddressPublicKey) ScriptAddress

func (a *AddressPublicKey) ScriptAddress() []byte

ScriptAddress returns the bytes to be included in a txout script to pay to a pubkey. Part of the Address interface.

func (*AddressPublicKey) String

func (a *AddressPublicKey) String() string

String returns a human-readable string for the pay-to-pubkey address. This is equivalent to calling EncodeAddress, but is provided so the type can be used as a fmt.Stringer.

func (*AddressPublicKey) Version

func (a *AddressPublicKey) Version() []byte

Return bytes for version

type AddressPublicKeyECDSA

type AddressPublicKeyECDSA struct {
	// contains filtered or unexported fields
}

AddressPublicKeyECDSA is an Address for a pay-to-pubkey (P2PK) ECDSA transaction.

func NewAddressPublicKeyECDSA

func NewAddressPublicKeyECDSA(publicKey []byte, prefix Bech32Prefix) (*AddressPublicKeyECDSA, error)

NewAddressPublicKeyECDSA returns a new AddressPublicKeyECDSA. publicKey must be 33 bytes.

func (*AddressPublicKeyECDSA) EncodeAddress

func (a *AddressPublicKeyECDSA) EncodeAddress() string

EncodeAddress returns the string encoding of a pay-to-pubkey address. Part of the Address interface.

func (*AddressPublicKeyECDSA) IsForPrefix

func (a *AddressPublicKeyECDSA) IsForPrefix(prefix Bech32Prefix) bool

IsForPrefix returns whether or not the pay-to-pubkey address is associated with the passed Metchain network.

func (*AddressPublicKeyECDSA) Prefix

func (a *AddressPublicKeyECDSA) Prefix() Bech32Prefix

Prefix returns the prefix for this address

func (*AddressPublicKeyECDSA) ScriptAddress

func (a *AddressPublicKeyECDSA) ScriptAddress() []byte

ScriptAddress returns the bytes to be included in a txout script to pay to a pubkey. Part of the Address interface.

func (*AddressPublicKeyECDSA) String

func (a *AddressPublicKeyECDSA) String() string

String returns a human-readable string for the pay-to-pubkey address. This is equivalent to calling EncodeAddress, but is provided so the type can be used as a fmt.Stringer.

func (*AddressPublicKeyECDSA) Version

func (a *AddressPublicKeyECDSA) Version() []byte

type AddressScriptHash

type AddressScriptHash struct {
	// contains filtered or unexported fields
}

AddressScriptHash is an Address for a pay-to-script-publicKey (P2SH) transaction.

func NewAddressScriptHash

func NewAddressScriptHash(serializedScript []byte, prefix Bech32Prefix) (*AddressScriptHash, error)

NewAddressScriptHash returns a new AddressScriptHash.

func NewAddressScriptHashFromHash

func NewAddressScriptHashFromHash(scriptHash []byte, prefix Bech32Prefix) (*AddressScriptHash, error)

NewAddressScriptHashFromHash returns a new AddressScriptHash. scriptHash must be 20 bytes.

func (*AddressScriptHash) EncodeAddress

func (a *AddressScriptHash) EncodeAddress() string

EncodeAddress returns the string encoding of a pay-to-script-hash address. Part of the Address interface.

func (*AddressScriptHash) HashBlake2b

func (a *AddressScriptHash) HashBlake2b() *[blake2b.Size256]byte

HashBlake2b returns the underlying array of the script hash. This can be useful when an array is more appropiate than a slice (for example, when used as map keys).

func (*AddressScriptHash) IsForPrefix

func (a *AddressScriptHash) IsForPrefix(prefix Bech32Prefix) bool

IsForPrefix returns whether or not the pay-to-script-hash address is associated with the passed Metchain network.

func (*AddressScriptHash) Prefix

func (a *AddressScriptHash) Prefix() Bech32Prefix

Prefix returns the prefix for this address

func (*AddressScriptHash) ScriptAddress

func (a *AddressScriptHash) ScriptAddress() []byte

ScriptAddress returns the bytes to be included in a txout script to pay to a script hash. Part of the Address interface.

func (*AddressScriptHash) String

func (a *AddressScriptHash) String() string

String returns a human-readable string for the pay-to-script-hash address. This is equivalent to calling EncodeAddress, but is provided so the type can be used as a fmt.Stringer.

func (*AddressScriptHash) Version

func (a *AddressScriptHash) Version() []byte

type Bech32Prefix

type Bech32Prefix int

Bech32Prefix is the human-readable prefix for a Bech32 address.

const (
	// Unknown/Erroneous prefix
	Bech32PrefixUnknown Bech32Prefix = iota

	// Prefix for the main network.
	Bech32PrefixMet
)

Constants that define Bech32 address prefixes. Every network is assigned a unique prefix.

func ParsePrefix

func ParsePrefix(prefixString string) (Bech32Prefix, error)

ParsePrefix attempts to parse a Bech32 address prefix.

func (Bech32Prefix) String

func (prefix Bech32Prefix) String() string

Converts from Bech32 address prefixes to their string values

type Config

type Config struct {
	RPCPORT       []string
	RPCListeners  []string
	RPCMaxClients int
	Listeners     []string
}

type Genesis

type Genesis struct {
	Timestamp    int64
	Nonce        int
	PreviousHash [32]byte //As per the Hash size
	Merkleroot   []byte
	Height       int64
	Transaction  *Txtransaction
}

func NewGen

func NewGen() *Genesis

type PubVersionkey

type PubVersionkey int

type Txtransaction

type Txtransaction struct {
	Txhex      []byte
	Txcoinbase []byte
}

func (*Txtransaction) MarshalJSON

func (tx *Txtransaction) MarshalJSON() ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL