filenetTransaction

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 CreateEmptyTransactionAndHash

func CreateEmptyTransactionAndHash(in Vin, outs Vouts) (string, string, error)

func Decode

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

Decode docode with custom alphabet

func Encode

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

Encode encode with custom alphabet

func SignTransaction

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

func VerifyAndCombineTransaction

func VerifyAndCombineTransaction(emptyTrans, signature, pubkey string) (string, 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 ToStruct

type ToStruct struct {
	To     []byte
	Amount []byte
}

type Transfer

type Transfer struct {
	TxId            string           `json:"txid"`      //转账交易ID,hash(sha356)
	From            string           `json:"from"`      //转出地址/base58(hex([20]byte[:]))
	ToCount         uint64           `json:"tocount"`   //转入地址个数
	Value           uint64           `json:"value"`     //转入总金额/1e-9FN
	Timestamp       int64            `json:"timestamp"` //时间戳/秒
	TransferDetails *TransferDetails `json:"transferdetails"`
	Sign            string           `json:"sign"` //签名(secp256k1)
}

type TransferDetail

type TransferDetail struct {
	To    string `json:"to"`    //转入地址,兼具索引功能
	Value uint64 `json:"value"` //每个地址转入金额
}

type TransferDetails

type TransferDetails []*TransferDetail //按照To字段进行排序

type Transfers

type Transfers []*Transfer

type TxStruct

type TxStruct struct {
	From      []byte
	Amount    []byte
	ToCount   []byte
	TimeStamp []byte
	To        []ToStruct
}

func NewTxStruct

func NewTxStruct(in Vin, outs Vouts) (*TxStruct, error)

func (*TxStruct) ToBytes

func (t *TxStruct) ToBytes() []byte

type Vin

type Vin struct {
	Address string
}

type Vout

type Vout struct {
	Address string
	Amount  uint64
}

type Vouts

type Vouts []Vout

func (Vouts) Len

func (d Vouts) Len() int

func (Vouts) Less

func (d Vouts) Less(i, j int) bool

func (Vouts) Swap

func (d Vouts) Swap(i, j int)

Jump to

Keyboard shortcuts

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