fiiiTransaction

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: 1

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 CreateEmptyTransactionAndMessage

func CreateEmptyTransactionAndMessage(inputs []Vin, outputs []Vout, version int, locktime, expiredtime int64) (string, []string, error)

func Decode

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

Decode docode with custom alphabet

func DecodeCheck

func DecodeCheck(address string, prefix []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 SignTransactionMessage

func SignTransactionMessage(message string, prikey []byte) ([]byte, error)

func VerifyAndCombineTransaction

func VerifyAndCombineTransaction(emptyTrans string, sigPub []SigPub) (bool, string, error)

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 InputMsg

type InputMsg struct {
	OutputTransactionHash string `json:"OutputTransactionHash"`
	OutputIndex           int    `json:"OutputIndex"`
	Size                  int    `json:"Size"`
	UnlockScript          string `json:"UnlockScript"`
	// contains filtered or unexported fields
}

func (InputMsg) ToBytes

func (in InputMsg) ToBytes() []byte

type OutputMsg

type OutputMsg struct {
	Index      int    `json:"Index"`
	Amount     int64  `json:"Amount"`
	Size       int    `json:"Size"`
	LockScript string `json:"LockScript"`
}

func (OutputMsg) ToBytes

func (out OutputMsg) ToBytes() []byte

type SigPub

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

func (SigPub) GenUnlockScript

func (sp SigPub) GenUnlockScript() (string, error)

type TransactionMsg

type TransactionMsg struct {
	Version     int         `json:"Version"`
	Hash        string      `json:"Hash"`
	Timestamp   int64       `json:"Timestamp"`
	LockTime    int64       `json:"Locktime"`
	ExpiredTime int64       `json:"ExpiredTime"`
	InputCount  int         `json:"InputCount"`
	OutputCount int         `json:"OutputCount"`
	Inputs      []InputMsg  `json:"Inputs"`
	Outputs     []OutputMsg `json:"Outputs"`
	Size        int         `json:"Size"`
}

func (*TransactionMsg) Complete

func (tm *TransactionMsg) Complete()

type Vin

type Vin struct {
	TxID string
	Vout int
}

func (Vin) NewInputMsg

func (in Vin) NewInputMsg() (*InputMsg, error)

type Vout

type Vout struct {
	AddressPrefix []byte
	Address       string
	Amount        int64
}

func (Vout) NewOutputMsg

func (out Vout) NewOutputMsg(index int) (*OutputMsg, error)

Jump to

Keyboard shortcuts

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