waykichainTransaction

package
v1.2.27 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: GPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	AddressPrefix        = byte(0x49)
	AddressPrefixTestNet = byte(0x87)
	Version              = int64(0x01)
	TxType_REWARD        = byte(0x01)
	TxType_REGACCT       = byte(0x02)
	TxType_COMMON        = byte(0x03)
	TxType_CONTRACT      = byte(0x04)
	TxType_UcoinTransfer = byte(0x0B)

	DefaultFeeSymbol = "WICC"
)

Variables

View Source
var (
	BitcoinAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
)

Alphabet: copy from https://en.wikipedia.org/wiki/Base58

View Source
var (
	ErrorInvalidBase58String = errors.New("invalid base58 string")
)

Errors

Functions

func CreateEmptyRawTransactionAndHash

func CreateEmptyRawTransactionAndHash(fromUserID, to, appID string, amount, fee, validHeight int64, txType byte) (string, string, error)

fromUserID - user id when txType is TxType_COMMON fromUserID - publick key hex when txType is TxType_REGACCT to - contract Hex when txType is TxType_CONTRACT appID - contract regID when txType is TxType_CONTRACT appID - coin name when txType is TxType_UcoinTransfer

func Decode

func Decode(input string, alphabet *Alphabet) ([]byte, error)

Decode docode with custom alphabet

func DecodeCheck

func DecodeCheck(address string) ([]byte, []byte, error)

return prefix + hash + error

func Encode

func Encode(input []byte, alphabet *Alphabet) string

Encode encode with custom alphabet

func EncodeCheck

func EncodeCheck(prefix []byte, hash []byte) string

func GetProgramHashFromAddress

func GetProgramHashFromAddress(address string) ([]byte, error)

func SignRawTransaction

func SignRawTransaction(hash string, prikey []byte) ([]byte, error)

func VerifyAndCombineRawTransaction

func VerifyAndCombineRawTransaction(emptyTrans string, sigPub SigPub) (bool, string)

Types

type Alphabet

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

Alphabet The base58 alphabet object.

func NewAlphabet

func NewAlphabet(alphabet string) *Alphabet

NewAlphabet create a custom alphabet from 58-length string. Note: len(rune(alphabet)) must be 58.

func (Alphabet) String

func (alphabet Alphabet) String() string

Alphabet's string representation

type CallContractTx added in v1.0.29

type CallContractTx struct {
	TxType      byte
	Version     []byte
	ValidHeight []byte
	FromUserID  []byte
	AppID       []byte
	Fee         []byte
	Amount      []byte
	ContractHex []byte
}

func NewCallContractTx added in v1.0.29

func NewCallContractTx(fromUserID, appID, contractHex string, validHeight, fee, amount int64) (*CallContractTx, error)

func (CallContractTx) GetHash added in v1.0.29

func (tx CallContractTx) GetHash() []byte

func (CallContractTx) ToBytes added in v1.0.29

func (tx CallContractTx) ToBytes() []byte

type CommonTx

type CommonTx struct {
	TxType      byte
	Version     []byte
	ValidHeight []byte
	FromUserID  []byte
	ToID        []byte
	Fee         []byte
	Amount      []byte
}

func NewCommonTx

func NewCommonTx(fromUserID, toAddress string, amount, fee, validHeight int64) (*CommonTx, error)

func (CommonTx) GetHash

func (tx CommonTx) GetHash() []byte

func (CommonTx) ToBytes

func (tx CommonTx) ToBytes() []byte

type RegisterAccountTx

type RegisterAccountTx struct {
	TxType      byte
	Version     []byte
	ValidHeight []byte
	UserID      []byte
	Fee         []byte
}

func NewRegisterAccountTx

func NewRegisterAccountTx(fromPubkey string, fee, validHeight int64) (*RegisterAccountTx, error)

func (RegisterAccountTx) GetHash

func (tx RegisterAccountTx) GetHash() []byte

func (RegisterAccountTx) ToBytes

func (tx RegisterAccountTx) ToBytes() []byte

type SigPub

type SigPub struct {
	PublicKey []byte
	Signature []byte
}

func (SigPub) ToBytes

func (sp SigPub) ToBytes() []byte

type UcoinTransferTx added in v1.1.20

type UcoinTransferTx struct {
	TxType      byte
	Version     []byte
	ValidHeight []byte
	FromUserID  []byte
	FeeSymbol   []byte
	FeeAmount   []byte
	To          []byte
	CoinName    []byte
	CoinAmount  []byte
}

仅实现了单币种转账

func NewUcoinTransferTx added in v1.1.20

func NewUcoinTransferTx(fromUserID, toAddress, coin string, validHeight, fee, amount int64) (*UcoinTransferTx, error)

func (UcoinTransferTx) GetHash added in v1.1.20

func (tx UcoinTransferTx) GetHash() []byte

func (UcoinTransferTx) ToBytes added in v1.1.20

func (tx UcoinTransferTx) ToBytes() []byte

Jump to

Keyboard shortcuts

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