core

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateSign = errors.New("signatures already exist")
View Source
var ErrInvalidSign = errors.New("not same ctx")

Functions

func CtxSender

func CtxSender(signer CtxSigner, tx *CrossTransaction) (common.Address, error)

Sender returns the address derived from the signature (V, R, S) using secp256k1 elliptic curve and an error if it failed deriving or upon an incorrect signature.

Sender may cache the address, allowing it to be used regardless of signing method. The cache is invalidated if the cached signer does not match the signer used in the current call.

Types

type AnchorEvent

type AnchorEvent struct {
	ChainInfo []*RemoteChainInfo
}

type CTxByPrice

type CTxByPrice CrossTransactions

TxByPrice implements both the sort and the heap interface, making it useful for all at once sorting as well as individually adding and removing elements.

func (CTxByPrice) Len

func (s CTxByPrice) Len() int

func (CTxByPrice) Less

func (s CTxByPrice) Less(i, j int) bool

func (*CTxByPrice) Pop

func (s *CTxByPrice) Pop() interface{}

func (*CTxByPrice) Push

func (s *CTxByPrice) Push(x interface{})

func (CTxByPrice) Swap

func (s CTxByPrice) Swap(i, j int)

type ConfirmedFinishEvent

type ConfirmedFinishEvent struct {
	Finishes []*CrossTransactionModifier
}

type ConfirmedMakerEvent

type ConfirmedMakerEvent struct {
	Txs []*CrossTransaction
}

type ConfirmedTakerEvent

type ConfirmedTakerEvent struct {
	Txs []*ReceptTransaction
}

type CrossTransaction

type CrossTransaction struct {
	Data ctxdata
	// contains filtered or unexported fields
}

func NewCrossTransaction

func NewCrossTransaction(amount, charge, networkId *big.Int, id, txHash, bHash common.Hash, from common.Address, input []byte) *CrossTransaction

func SignCtx

func SignCtx(tx *CrossTransaction, s CtxSigner, signHash SignHash) (*CrossTransaction, error)

SignTx signs the transaction using the given signer and private key

func (*CrossTransaction) BlockHash

func (tx *CrossTransaction) BlockHash() common.Hash

func (*CrossTransaction) ChainId

func (tx *CrossTransaction) ChainId() *big.Int

func (CrossTransaction) DestinationId

func (tx CrossTransaction) DestinationId() *big.Int

func (*CrossTransaction) Hash

func (tx *CrossTransaction) Hash() (h common.Hash)

func (*CrossTransaction) ID

func (tx *CrossTransaction) ID() common.Hash

func (*CrossTransaction) SignHash

func (tx *CrossTransaction) SignHash() (h common.Hash)

func (*CrossTransaction) WithSignature

func (tx *CrossTransaction) WithSignature(signer CtxSigner, sig []byte) (*CrossTransaction, error)

type CrossTransactionModifier added in v1.0.4

type CrossTransactionModifier struct {
	ID            common.Hash
	ChainId       *big.Int
	Status        CtxStatus
	AtBlockNumber uint64
}

type CrossTransactionWithSignatures

type CrossTransactionWithSignatures struct {
	Data     CtxDatas
	Status   CtxStatus `json:"status" gencodec:"required"`
	BlockNum uint64    `json:"blockNum" gencodec:"required"`
	// contains filtered or unexported fields
}

func NewCrossTransactionWithSignatures

func NewCrossTransactionWithSignatures(ctx *CrossTransaction, num uint64) *CrossTransactionWithSignatures

func (*CrossTransactionWithSignatures) AddSignature

func (cws *CrossTransactionWithSignatures) AddSignature(ctx *CrossTransaction) error

func (*CrossTransactionWithSignatures) BlockHash

func (cws *CrossTransactionWithSignatures) BlockHash() common.Hash

func (*CrossTransactionWithSignatures) ChainId

func (cws *CrossTransactionWithSignatures) ChainId() *big.Int

func (*CrossTransactionWithSignatures) Copy

func (*CrossTransactionWithSignatures) CrossTransaction added in v1.0.4

func (cws *CrossTransactionWithSignatures) CrossTransaction() *CrossTransaction

func (*CrossTransactionWithSignatures) DestinationId

func (cws *CrossTransactionWithSignatures) DestinationId() *big.Int

func (*CrossTransactionWithSignatures) Hash

func (cws *CrossTransactionWithSignatures) Hash() (h common.Hash)

func (*CrossTransactionWithSignatures) ID

func (*CrossTransactionWithSignatures) Price

func (cws *CrossTransactionWithSignatures) Price() *big.Rat

func (*CrossTransactionWithSignatures) RemoveSignature

func (cws *CrossTransactionWithSignatures) RemoveSignature(index int)

func (*CrossTransactionWithSignatures) Resolution

func (cws *CrossTransactionWithSignatures) Resolution() []*CrossTransaction

func (*CrossTransactionWithSignatures) SignaturesLength

func (cws *CrossTransactionWithSignatures) SignaturesLength() int

func (*CrossTransactionWithSignatures) Size

type CrossTransactions

type CrossTransactions []*CrossTransaction

Transactions is a Transaction slice type for basic sorting.

func (CrossTransactions) GetRlp

func (s CrossTransactions) GetRlp(i int) []byte

GetRlp implements Rlpable and returns the i'th element of s in rlp.

func (CrossTransactions) Len

func (s CrossTransactions) Len() int

Len returns the length of s.

func (CrossTransactions) Swap

func (s CrossTransactions) Swap(i, j int)

Swap swaps the i'th and the j'th element in s.

type CrossTrigger

type CrossTrigger struct {
	// contains filtered or unexported fields
}

func NewCrossTrigger

func NewCrossTrigger(contract common.Address, chain chainRetriever) *CrossTrigger

func (*CrossTrigger) ConfirmedFinishFeedSend

func (t *CrossTrigger) ConfirmedFinishFeedSend(tx ConfirmedFinishEvent) int

func (*CrossTrigger) ConfirmedMakerFeedSend

func (t *CrossTrigger) ConfirmedMakerFeedSend(ctx ConfirmedMakerEvent) int

func (*CrossTrigger) ConfirmedTakerSend

func (t *CrossTrigger) ConfirmedTakerSend(transaction ConfirmedTakerEvent) int

func (*CrossTrigger) Stop

func (t *CrossTrigger) Stop()

func (*CrossTrigger) StoreCrossContractLog

func (t *CrossTrigger) StoreCrossContractLog(blockNumber uint64, hash common.Hash, logs []*types.Log)

func (*CrossTrigger) SubscribeConfirmedFinishEvent

func (t *CrossTrigger) SubscribeConfirmedFinishEvent(ch chan<- ConfirmedFinishEvent) event.Subscription

func (*CrossTrigger) SubscribeConfirmedMakerEvent

func (t *CrossTrigger) SubscribeConfirmedMakerEvent(ch chan<- ConfirmedMakerEvent) event.Subscription

func (*CrossTrigger) SubscribeConfirmedTakerEvent

func (t *CrossTrigger) SubscribeConfirmedTakerEvent(ch chan<- ConfirmedTakerEvent) event.Subscription

func (*CrossTrigger) SubscribeNewFinishEvent

func (t *CrossTrigger) SubscribeNewFinishEvent(ch chan<- NewFinishEvent) event.Subscription

func (*CrossTrigger) SubscribeNewTakerEvent

func (t *CrossTrigger) SubscribeNewTakerEvent(ch chan<- NewTakerEvent) event.Subscription

func (*CrossTrigger) SubscribeUpdateAnchorEvent

func (t *CrossTrigger) SubscribeUpdateAnchorEvent(ch chan<- AnchorEvent) event.Subscription

type CtxDatas

type CtxDatas struct {
	Value            *big.Int       `json:"value" gencodec:"required"` //Token for sell
	CTxId            common.Hash    `json:"ctxId" gencodec:"required"` //cross_transaction ID
	TxHash           common.Hash    `json:"txHash" gencodec:"required"`
	From             common.Address `json:"from" gencodec:"required"`             //Token owner
	BlockHash        common.Hash    `json:"blockHash" gencodec:"required"`        //The Hash of block in which the message resides
	DestinationId    *big.Int       `json:"destinationId" gencodec:"required"`    //Message destination networkId
	DestinationValue *big.Int       `json:"destinationValue" gencodec:"required"` //Token charge
	Input            []byte         `json:"input"    gencodec:"required"`

	// Signature values
	V []*big.Int `json:"v" gencodec:"required"` //chainId
	R []*big.Int `json:"r" gencodec:"required"`
	S []*big.Int `json:"s" gencodec:"required"`
}

type CtxSigner

type CtxSigner interface {
	// Sender returns the sender address of the transaction.
	Sender(tx *CrossTransaction) (common.Address, error)
	// SignatureValues returns the raw R, S, V values corresponding to the
	// given signature.
	SignatureValues(tx *CrossTransaction, sig []byte) (r, s, v *big.Int, err error)
	// Hash returns the hash to be signed.
	Hash(tx *CrossTransaction) common.Hash
	// Equal returns true if the given signer is the same as the receiver.
	Equal(CtxSigner) bool
}

Signer encapsulates transaction signature handling. Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.

func MakeCtxSigner

func MakeCtxSigner(config *params.ChainConfig) CtxSigner

MakeSigner returns a Signer based on the given chain config and block number.

type CtxStatus

type CtxStatus uint8
const (
	// CtxStatusWaiting is the status code of a rtx transaction if waiting for orders.
	CtxStatusWaiting CtxStatus = iota
	// CtxStatusImplementing is the status code of a rtx transaction if execution implementing.
	CtxStatusImplementing
	// CtxStatusFinished is the status code of a rtx transaction if execution finishing.
	CtxStatusFinishing
	// CtxStatusFinished is the status code of a rtx transaction if make finish confirmed.
	CtxStatusFinished
)

func (CtxStatus) String

func (s CtxStatus) String() string

type EIP155CtxSigner

type EIP155CtxSigner struct {
	// contains filtered or unexported fields
}

EIP155Transaction implements Signer using the EIP155 rules.

func NewEIP155CtxSigner

func NewEIP155CtxSigner(chainId *big.Int) EIP155CtxSigner

func (EIP155CtxSigner) Equal

func (s EIP155CtxSigner) Equal(s2 CtxSigner) bool

func (EIP155CtxSigner) Hash

func (s EIP155CtxSigner) Hash(tx *CrossTransaction) (h common.Hash)

func (EIP155CtxSigner) Sender

func (EIP155CtxSigner) SignatureValues

func (s EIP155CtxSigner) SignatureValues(tx *CrossTransaction, sig []byte) (R, S, V *big.Int, err error)

WithSignature returns a new transaction with the given signature. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type NewFinishEvent

type NewFinishEvent struct {
	Finishes []*CrossTransactionModifier
}

type NewTakerEvent

type NewTakerEvent struct {
	Takers []*CrossTransactionModifier
}

type OwnerCrossTransactionWithSignatures

type OwnerCrossTransactionWithSignatures struct {
	Cws  *CrossTransactionWithSignatures
	Time uint64
}

type Recept

type Recept struct {
	TxId  common.Hash
	From  common.Address
	To    common.Address
	Input []byte
}

type ReceptTransaction

type ReceptTransaction struct {
	CTxId         common.Hash    `json:"ctxId" gencodec:"required"`         //cross_transaction ID
	From          common.Address `json:"from" gencodec:"required"`          //Token seller
	To            common.Address `json:"to" gencodec:"required"`            //Token buyer
	DestinationId *big.Int       `json:"destinationId" gencodec:"required"` //Message destination networkId
	ChainId       *big.Int       `json:"chainId" gencodec:"required"`
}

func NewReceptTransaction

func NewReceptTransaction(id common.Hash, from, to common.Address, remoteChainId, chainId *big.Int) *ReceptTransaction

func (*ReceptTransaction) ConstructData

func (rws *ReceptTransaction) ConstructData(crossContract abi.ABI) ([]byte, error)

type RemoteChainInfo

type RemoteChainInfo struct {
	RemoteChainId uint64
	BlockNumber   uint64
}

type SignHash

type SignHash func(hash []byte) ([]byte, error)

type SignedCtxEvent

type SignedCtxEvent struct {
	Tws      *CrossTransactionWithSignatures
	CallBack func(cws *CrossTransactionWithSignatures, invalidSigIndex ...int)
}

Jump to

Keyboard shortcuts

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