txlogic

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 13 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 GetContractVout added in v0.5.0

func GetContractVout(tx *types.Transaction) *corepb.TxOut

GetContractVout return contract out if tx has a vout with contract creation or call

func HasContractSpend added in v0.5.0

func HasContractSpend(tx *types.Transaction) bool

HasContractSpend return true if tx has a vin with Op Spend script sig

func HasContractVout added in v0.5.0

func HasContractVout(tx *types.Transaction) bool

HasContractVout return true if tx has a vout with contract creation or call

func MakeContractCallVout added in v0.5.0

func MakeContractCallVout(
	from, to *types.AddressHash, amount uint64, gas, gasPrice, nonce uint64, code []byte,
) (*corepb.TxOut, error)

MakeContractCallVout makes txOut

func MakeContractCreationVout added in v0.5.0

func MakeContractCreationVout(
	from *types.AddressHash, amount, gas, gasPrice, nonce uint64, code []byte,
) (*corepb.TxOut, error)

MakeContractCreationVout makes txOut

func MakeContractVin added in v0.5.0

func MakeContractVin(op *types.OutPoint, seq uint32) *types.TxIn

MakeContractVin makes txIn

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(op *corepb.OutPoint, seq uint32) *corepb.TxIn

MakePbVin makes txIn

func MakeSplitAddrVout

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

MakeSplitAddrVout make split addr vout

func MakeSplitAddress added in v0.5.0

func MakeSplitAddress(
	txHash *crypto.HashType, idx uint32, addrs []types.Address, weights []uint64,
) types.Address

MakeSplitAddress make split addr

func MakeTokenVout

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

MakeTokenVout make token tx vout

func MakeUnsignedContractCallTx added in v0.5.0

func MakeUnsignedContractCallTx(
	from string, amount, changeAmt, gasLimit, gasPrice, nonce uint64,
	to string, byteCode []byte, utxos ...*rpcpb.Utxo,
) (*types.Transaction, error)

MakeUnsignedContractCallTx call a contract tx without signature

func MakeUnsignedContractDeployTx added in v0.5.0

func MakeUnsignedContractDeployTx(
	from string, amount, changeAmt, gasLimit, gasPrice, nonce uint64,
	byteCode []byte, utxos ...*rpcpb.Utxo,
) (*types.Transaction, error)

MakeUnsignedContractDeployTx make a contract tx without signature

func MakeUnsignedSplitAddrTx

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

MakeUnsignedSplitAddrTx make unsigned split addr tx

func MakeUnsignedTokenIssueTx

func MakeUnsignedTokenIssueTx(
	issuer string, Owner 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 *types.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(op *types.OutPoint, seq uint32) *types.TxIn

MakeVin makes txIn

func MakeVinForTest added in v0.5.0

func MakeVinForTest(tx *types.Transaction, index uint32) []*types.TxIn

MakeVinForTest use for testcase

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 NewContractTxWithUtxos added in v0.5.0

func NewContractTxWithUtxos(
	fromAcc *acc.Account, contractAddr string, amount, changeAmt, gasPrice,
	gasLimit, nonce uint64, byteCode []byte, utxos ...*rpcpb.Utxo,
) (*types.Transaction, *rpcpb.Utxo, error)

NewContractTxWithUtxos new a contract transaction

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, change *rpcpb.Utxo, err error)

NewSplitAddrTxWithUtxos new split address tx

func NewTokenID

func NewTokenID(hash *crypto.HashType, index uint32) *types.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, *types.TokenID, *rpcpb.Utxo, error)

NewTokenIssueTxWithUtxos new token issue tx with utxos

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 *types.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 *types.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 ParseUtxoAmount

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

ParseUtxoAmount parse amount from utxo and return amount, is token

func SignTx added in v0.5.0

func SignTx(tx *types.Transaction, privKey *crypto.PrivateKey, pubKey *crypto.PublicKey) error

SignTx use for testcase

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)

Jump to

Keyboard shortcuts

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