hypercashTransaction

package
v1.1.20 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: GPL-3.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	OP_RETURN     byte = 0x6a
	TxTreeRegular byte = 0
	TxTreeStake   byte = 1
	SigHashAll    byte = 1

	DefaultTxVersion       uint16 = 1
	DefaultPkScriptVersion uint16 = 0

	NoExpiryValue uint32 = 0
)
View Source
const (
	TxSerializeFull uint16 = iota
	TxSerializeNoWitness
	TxSerializeOnlyWitness
	TxSerializeWitnessSigning
	TxSerializeWitnessValueSigning
)
View Source
const (
	PropertyID_Omni    uint32 = 1
	PropertyID_LEEK    uint32 = 11
	PropertyID_YAX     uint32 = 18
	PropertyID_ENTCASH uint32 = 19
)

Variables

View Source
var (
	CurveOrder     = []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41}
	HalfCurveOrder = []byte{0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5D, 0x57, 0x6E, 0x73, 0x57, 0xA4, 0x50, 0x1D, 0xDF, 0xE9, 0x2F, 0x46, 0x68, 0x1B, 0x20, 0xA0}
)
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

View Source
var (
	PKHAddressPrefix = []byte{0x09, 0x7f}
)

Functions

func CreateEmptyTransactionAndHash

func CreateEmptyTransactionAndHash(ins []Vin, outs []Vout, locktime, expiry uint32) (string, []string, error)

func CreateOmniEmptyTransactionAndHash

func CreateOmniEmptyTransactionAndHash(ins []Vin, to, change *Vout, amount uint64, propertyID uint32, locktime, expiry uint32) (string, []string, error)

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 SignTransaction

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

func VerifyAndCombineTransaction

func VerifyAndCombineTransaction(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 SigPub

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

type TxIn

type TxIn struct {
	TxID            []byte
	Vout            []byte
	TxTree          byte
	Sequence        []byte
	SignatureScript []byte
	LockScript      []byte
}

func (*TxIn) ToBytes

func (in *TxIn) ToBytes() []byte

type TxOut

type TxOut struct {
	Amount          []byte
	PkScriptVersion []byte
	PKScript        []byte
}

func (*TxOut) ToBytes

func (out *TxOut) ToBytes() []byte

type TxStruct

type TxStruct struct {
	TxVersion []byte
	SerType   []byte
	TxIns     []*TxIn
	TxOuts    []*TxOut
	LockTime  []byte
	Expiry    []byte
}

func NewTxStruct

func NewTxStruct(ins []Vin, outs []Vout, locktime, expiry uint32) (*TxStruct, error)

func (*TxStruct) GetHash

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

func (*TxStruct) ToBytes

func (tx *TxStruct) ToBytes(index uint64, serType uint16) ([]byte, error)

type Vin

type Vin struct {
	TxID        string
	Vout        uint32
	Tree        byte
	Amount      uint64
	LockScript  string
	BlockHeight uint32
	BlockIndex  uint32
}

func GetVinList

func GetVinList(emptyTrans string) ([]Vin, error)

func (Vin) NewTxIn

func (in Vin) NewTxIn() (*TxIn, error)

type Vout

type Vout struct {
	Amount          uint64
	PkScriptVersion uint16
	Address         string
}

func (Vout) NewTxOut

func (out Vout) NewTxOut() (*TxOut, error)

Jump to

Keyboard shortcuts

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