chainnode

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusNotFound              = 0
	StatusPending               = 1
	StatusFailed                = 2
	StatusSuccess               = 3
	StatusContractExecuteFailed = 4
	StatusOther                 = 5
)

Transaction status

Variables

View Source
var (
	ErrorNotSupported     = errors.New("Chain is not supported")
	ErrorInvalidSignature = errors.New("Signature is invalid")
	ErrorInvalidInput     = errors.New("invalid input")
)

Errors

Functions

This section is empty.

Types

type Chainnode

type Chainnode interface {
	SupportChain(chain string) bool
	ConvertAddress(chain string, pubKey []byte) (string, error)
	ValidAddress(chain, symbol, address string) (bool, string)
	QueryBalance(chain, symbol, address, contractAddress string, blockHeight uint64) (sdk.Int, error) //will be obsoleted later, please use ValidateAsset
	QueryUtxo(chain, symbol string, vin *sdk.UtxoIn) (bool, error)
	QueryNonce(chain, address string) (uint64, error)
	QueryGasPrice(chain string) (sdk.Int, error)
	QueryUtxoTransaction(chain, symbol, hash string, asynMode bool) (*ExtUtxoTransaction, error)
	QueryAccountTransaction(chain, symbol, hash string, asynMode bool) (*ExtAccountTransaction, error)
	CreateUtxoTransaction(chain, symbol string, transaction *ExtUtxoTransaction) ([]byte, [][]byte, error)
	CreateAccountTransaction(chain, symbol, contractAddress string, transaction *ExtAccountTransaction) ([]byte, []byte, error)
	CreateUtxoSignedTransaction(chain, symbol string, raw []byte, signatures, pubKeys [][]byte) ([]byte, []byte, error)
	CreateAccountSignedTransaction(chain, symbol string, raw []byte, signatures, pubKeys []byte) ([]byte, []byte, error)
	VerifyUtxoSignedTransaction(chain, symbol string, address []string, signedTxData []byte, vins []*sdk.UtxoIn) (bool, error)
	VerifyAccountSignedTransaction(chain, symbol string, address string, signedTxData []byte) (bool, error)
	QueryAccountTransactionFromSignedData(chain, symbol string, signedTxData []byte) (*ExtAccountTransaction, error)
	QueryUtxoTransactionFromSignedData(chain, symbol string, signedTxData []byte, vins []*sdk.UtxoIn) (*ExtUtxoTransaction, error)
	QueryAccountTransactionFromData(chain, symbol string, rawData []byte) (*ExtAccountTransaction, []byte, error)
	QueryUtxoTransactionFromData(chain, symbol string, rawData []byte, vins []*sdk.UtxoIn) (*ExtUtxoTransaction, [][]byte, error)
	BroadcastTransaction(chain, symbol string, signedTxData []byte) (transactionHash string, err error)
	QueryUtxoInsFromData(chain, symbol string, data []byte) ([]*sdk.UtxoIn, error)
}

Chainnode interface

type ExtAccountTransaction

type ExtAccountTransaction struct {
	Hash            string
	Status          uint64
	From            string
	To              string
	Amount          sdk.Int
	Memo            string
	Nonce           uint64
	GasLimit        sdk.Int
	GasPrice        sdk.Int
	CostFee         sdk.Int
	BlockHeight     uint64
	BlockTime       uint64
	ContractAddress string
}

type ExtUtxoTransaction

type ExtUtxoTransaction struct {
	Hash        string
	Status      uint64
	Vins        []*sdk.UtxoIn
	Vouts       []*sdk.UtxoOut
	CostFee     sdk.Int
	BlockHeight uint64
	BlockTime   uint64
}

ExtTransaction for external chain connected by the chainnode

type MockChainnode

type MockChainnode struct {
	mock.Mock
}

func (*MockChainnode) BroadcastTransaction

func (m *MockChainnode) BroadcastTransaction(chain, symbol string, signedTxData []byte) (string, error)

func (*MockChainnode) ConvertAddress

func (m *MockChainnode) ConvertAddress(chain string, publicKey []byte) (string, error)

func (*MockChainnode) ConvertAddressFromSerializedPubKey

func (m *MockChainnode) ConvertAddressFromSerializedPubKey(chain string, publicKey []byte) (string, error)

func (*MockChainnode) CreateAccountSignedTransaction

func (m *MockChainnode) CreateAccountSignedTransaction(chain, symbol string, raw []byte, signatures, pubKeys []byte) ([]byte, []byte, error)

func (*MockChainnode) CreateAccountTransaction

func (m *MockChainnode) CreateAccountTransaction(chain, symbol, contractAddress string, transaction *ExtAccountTransaction) (
	[]byte, []byte, error)

func (*MockChainnode) CreateUtxoSignedTransaction

func (m *MockChainnode) CreateUtxoSignedTransaction(chain, symbol string, raw []byte, signatures, pubKeys [][]byte) ([]byte, []byte, error)

func (*MockChainnode) CreateUtxoTransaction

func (m *MockChainnode) CreateUtxoTransaction(chain, symbol string, transaction *ExtUtxoTransaction) ([]byte, [][]byte, error)

func (*MockChainnode) QueryAccountTransaction

func (m *MockChainnode) QueryAccountTransaction(chain, symbol, hash string, asynMode bool) (*ExtAccountTransaction, error)

func (*MockChainnode) QueryAccountTransactionFromData

func (m *MockChainnode) QueryAccountTransactionFromData(chain, symbol string, rawData []byte) (*ExtAccountTransaction, []byte, error)

func (*MockChainnode) QueryAccountTransactionFromSignedData

func (m *MockChainnode) QueryAccountTransactionFromSignedData(chain, symbol string, signedTxData []byte) (*ExtAccountTransaction, error)

func (*MockChainnode) QueryBalance

func (m *MockChainnode) QueryBalance(chain, symbol string, address, contractAddress string, blockHeight uint64) (sdk.Int, error)

func (*MockChainnode) QueryGasPrice

func (m *MockChainnode) QueryGasPrice(chain string) (sdk.Int, error)

func (*MockChainnode) QueryNonce

func (m *MockChainnode) QueryNonce(chain, address string) (uint64, error)

func (*MockChainnode) QueryUtxo

func (m *MockChainnode) QueryUtxo(chain, symbol string, vin *sdk.UtxoIn) (bool, error)

func (*MockChainnode) QueryUtxoInsFromData

func (m *MockChainnode) QueryUtxoInsFromData(chain, symbol string, data []byte) ([]*sdk.UtxoIn, error)

func (*MockChainnode) QueryUtxoTransaction

func (m *MockChainnode) QueryUtxoTransaction(chain, symbol, hash string, asynMode bool) (*ExtUtxoTransaction, error)

func (*MockChainnode) QueryUtxoTransactionFromData

func (m *MockChainnode) QueryUtxoTransactionFromData(chain, symbol string, rawData []byte, vins []*sdk.UtxoIn) (*ExtUtxoTransaction, [][]byte, error)

func (*MockChainnode) QueryUtxoTransactionFromSignedData

func (m *MockChainnode) QueryUtxoTransactionFromSignedData(chain, symbol string, signedTxData []byte, vins []*sdk.UtxoIn) (*ExtUtxoTransaction, error)

func (*MockChainnode) SupportChain

func (m *MockChainnode) SupportChain(chain string) bool

func (*MockChainnode) ValidAddress

func (m *MockChainnode) ValidAddress(chain, symbol, address string) (bool, string)

func (*MockChainnode) VerifyAccountSignedTransaction

func (m *MockChainnode) VerifyAccountSignedTransaction(chain, symbol, address string, signedTxData []byte) (bool, error)

func (*MockChainnode) VerifyUtxoSignedTransaction

func (m *MockChainnode) VerifyUtxoSignedTransaction(chain, symbol string, address []string, signedTxData []byte, vins []*sdk.UtxoIn) (bool, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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