virtualeconomyTransaction

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: GPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TxTypeTransfer  = byte(2)
	DefaultFeeScale = uint16(100)
	DefaultFixedFee = uint64(10000000)
)
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 CreateEmptyTransaction

func CreateEmptyTransaction(ts TxStruct) (string, error)

创建空交易单 only transfer for now

func CreateJSONRawForSendTransaction

func CreateJSONRawForSendTransaction(emptyTrans string, sp *SignaturePubkey) (*gjson.Result, error)

发送交易单

func Decode

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

Decode docode with custom alphabet

func DecodeCheck

func DecodeCheck(address string) ([]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 VerifyTransaction

func VerifyTransaction(emptyTrans string, sp *SignaturePubkey) bool

对签名结果进行验证

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 SignaturePubkey

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

func SignTransaction

func SignTransaction(emptyTrans string, prikey []byte) (*SignaturePubkey, error)

对空交易单进行签名

type TxStruct

type TxStruct struct {
	TxType     byte
	To         string
	Amount     uint64
	Fee        uint64
	FeeScale   uint16
	Attachment string
}

func TxStructDecode

func TxStructDecode(tx []byte) (*TxStruct, uint64, error)

Jump to

Keyboard shortcuts

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