Help us shape the future of Go! Take the 2026 Go Developer Survey

txlogic

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInsufficientBalance = errors.New("insufficient account balance")
	ErrInvalidArguments    = errors.New("invalid arguments")
)

Functions

func ConvOutPoint

func ConvOutPoint(op *types.OutPoint) *corepb.OutPoint

ConvOutPoint constructs a protobuf OutPoint

func ConvPbOutPoint

func ConvPbOutPoint(op *corepb.OutPoint) *types.OutPoint

ConvPbOutPoint constructs a types OutPoint

func DecodeOutPoint added in v0.3.1

func DecodeOutPoint(id string) (*corepb.OutPoint, error)

DecodeOutPoint string token id to TokenID

func EncodeOutPoint added in v0.3.1

func EncodeOutPoint(op *corepb.OutPoint) string

EncodeOutPoint encode token to string

func IsCoinBaseTxIn

func IsCoinBaseTxIn(txIn *types.TxIn) bool

IsCoinBaseTxIn check whether tx in is coin base tx in

func MakeIssueTokenScript

func MakeIssueTokenScript(addr string, tag *rpcpb.TokenTag) ([]byte, error)

MakeIssueTokenScript make issue token script for addr with supply and tokent ag

func MakeIssueTokenVout

func MakeIssueTokenVout(addr string, tag *rpcpb.TokenTag) (*corepb.TxOut, error)

MakeIssueTokenVout make issue token vout

func MakePbUtxo

func MakePbUtxo(op *types.OutPoint, uw *types.UtxoWrap) *rpcpb.Utxo

MakePbUtxo make pb.Utxo from Op and utxo wrap

func MakePbVin

func MakePbVin(utxo *rpcpb.Utxo, seq uint32) *corepb.TxIn

MakePbVin makes txIn

func MakeSplitAddr

func MakeSplitAddr(addrs []string, weights []uint64) (string, error)

MakeSplitAddr make split addr

func MakeSplitAddrPubkey

func MakeSplitAddrPubkey(addrs []string, weights []uint64) []byte

MakeSplitAddrPubkey make split addr

func MakeSplitAddrVout

func MakeSplitAddrVout(addrs []string, weights []uint64) *corepb.TxOut

MakeSplitAddrVout make split addr vout

func MakeTokenVout

func MakeTokenVout(addr string, tokenID *TokenID, amount uint64) (*corepb.TxOut, error)

MakeTokenVout make token tx vout

func MakeUnsignedSplitAddrTx

func MakeUnsignedSplitAddrTx(
	from string, addrs []string, weights []uint64, changeAmt uint64, utxos ...*rpcpb.Utxo,
) (*types.Transaction, string, error)

MakeUnsignedSplitAddrTx make unsigned split addr tx

func MakeUnsignedTokenIssueTx

func MakeUnsignedTokenIssueTx(
	issuer string, issuee string, tag *rpcpb.TokenTag, changeAmt uint64,
	utxos ...*rpcpb.Utxo,
) (*types.Transaction, uint32, error)

MakeUnsignedTokenIssueTx make unsigned token issue tx

func MakeUnsignedTokenTransferTx

func MakeUnsignedTokenTransferTx(
	from string, to []string, amounts []uint64, tid *TokenID, changeAmt uint64,
	utxos ...*rpcpb.Utxo,
) (*types.Transaction, uint64, error)

MakeUnsignedTokenTransferTx make unsigned token transfer tx

func MakeUnsignedTx

func MakeUnsignedTx(
	from string, to []string, amounts []uint64, changeAmt uint64, utxos ...*rpcpb.Utxo,
) (*types.Transaction, error)

MakeUnsignedTx make a tx without signature

func MakeVin

func MakeVin(utxo *rpcpb.Utxo, seq uint32) *types.TxIn

MakeVin makes txIn

func MakeVout

func MakeVout(addr string, amount uint64) *corepb.TxOut

MakeVout makes txOut

func MakeVoutWithSPk

func MakeVoutWithSPk(amount uint64, scriptPk []byte) *corepb.TxOut

MakeVoutWithSPk makes txOut

func NewCoinBaseTxIn

func NewCoinBaseTxIn() *types.TxIn

NewCoinBaseTxIn new a coinbase tx in

func NewIssueTokenUtxoWrap

func NewIssueTokenUtxoWrap(
	addr string, tag *rpcpb.TokenTag, height uint32,
) (*types.UtxoWrap, error)

NewIssueTokenUtxoWrap makes a UtxoWrap

func NewPbOutPoint

func NewPbOutPoint(hash *crypto.HashType, index uint32) *corepb.OutPoint

NewPbOutPoint constructs a OutPoint

func NewSplitAddrTxWithUtxos

func NewSplitAddrTxWithUtxos(
	acc *acc.Account, addrs []string, weights []uint64, utxos []*rpcpb.Utxo, fee uint64,
) (tx *types.Transaction, splitAddr string, change *rpcpb.Utxo, err error)

NewSplitAddrTxWithUtxos new split address tx

func NewTokenTag

func NewTokenTag(name, sym string, decimal uint32, supply uint64) *rpcpb.TokenTag

NewTokenTag news a TokenTag

func NewTokenTransferTxWithUtxos

func NewTokenTransferTxWithUtxos(
	fromAcc *acc.Account, to []string, amounts []uint64, tid *TokenID,
	changeAmt uint64, utxos ...*rpcpb.Utxo,
) (*types.Transaction, *rpcpb.Utxo, *rpcpb.Utxo, error)

NewTokenTransferTxWithUtxos new token Transfer tx with utxos it returns tx, box change and token change

func NewTokenUtxoWrap

func NewTokenUtxoWrap(
	addr string, tid *TokenID, height uint32, value uint64,
) (*types.UtxoWrap, error)

NewTokenUtxoWrap makes a UtxoWrap

func NewTxWithUtxos

func NewTxWithUtxos(
	fromAcc *acc.Account, utxos []*rpcpb.Utxo, toAddrs []string,
	amounts []uint64, changeAmt uint64,
) (*types.Transaction, *rpcpb.Utxo, error)

NewTxWithUtxos new a transaction

func NewUtxoWrap

func NewUtxoWrap(addr string, height uint32, value uint64) *types.UtxoWrap

NewUtxoWrap makes a UtxoWrap

func ParseTokenAmount

func ParseTokenAmount(spk []byte) (uint64, error)

ParseTokenAmount parse token amount from script pubkey

func SignTxWithUtxos

func SignTxWithUtxos(
	tx *types.Transaction, utxos []*rpcpb.Utxo, acc *acc.Account,
) error

SignTxWithUtxos sign tx with utxo

Types

type SortByTokenUTXOValue

type SortByTokenUTXOValue []*rpcpb.Utxo

SortByTokenUTXOValue defines a type suited for sort

func (SortByTokenUTXOValue) Len

func (x SortByTokenUTXOValue) Len() int

func (SortByTokenUTXOValue) Less

func (x SortByTokenUTXOValue) Less(i, j int) bool

func (SortByTokenUTXOValue) Swap

func (x SortByTokenUTXOValue) Swap(i, j int)

type SortByUTXOValue

type SortByUTXOValue []*rpcpb.Utxo

SortByUTXOValue defines a type suited for sort

func (SortByUTXOValue) Len

func (x SortByUTXOValue) Len() int

func (SortByUTXOValue) Less

func (x SortByUTXOValue) Less(i, j int) bool

func (SortByUTXOValue) Swap

func (x SortByUTXOValue) Swap(i, j int)

type TokenID

type TokenID types.OutPoint

TokenID defines token id

func NewTokenID

func NewTokenID(hash *crypto.HashType, index uint32) *TokenID

NewTokenID constructs a token id

func NewTokenIssueTxWithUtxos

func NewTokenIssueTxWithUtxos(
	fromAcc *acc.Account, to string, tag *rpcpb.TokenTag, changeAmt uint64,
	utxos ...*rpcpb.Utxo,
) (*types.Transaction, *TokenID, *rpcpb.Utxo, error)

NewTokenIssueTxWithUtxos new token issue tx with utxos

func ParseUtxoAmount

func ParseUtxoAmount(utxo *rpcpb.Utxo) (uint64, *TokenID, error)

ParseUtxoAmount parse amount from utxo and return amount, is token

Jump to

Keyboard shortcuts

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