Documentation
¶
Index ¶
- Variables
- func CtxSender(signer CtxSigner, tx *CrossTransaction) (common.Address, error)
- type AnchorEvent
- type CTxByPrice
- type ConfirmedFinishEvent
- type ConfirmedMakerEvent
- type ConfirmedTakerEvent
- type CrossTransaction
- func (tx *CrossTransaction) BlockHash() common.Hash
- func (tx *CrossTransaction) ChainId() *big.Int
- func (tx CrossTransaction) DestinationId() *big.Int
- func (tx *CrossTransaction) Hash() (h common.Hash)
- func (tx *CrossTransaction) ID() common.Hash
- func (tx *CrossTransaction) SignHash() (h common.Hash)
- func (tx *CrossTransaction) WithSignature(signer CtxSigner, sig []byte) (*CrossTransaction, error)
- type CrossTransactionModifier
- type CrossTransactionWithSignatures
- func (cws *CrossTransactionWithSignatures) AddSignature(ctx *CrossTransaction) error
- func (cws *CrossTransactionWithSignatures) BlockHash() common.Hash
- func (cws *CrossTransactionWithSignatures) ChainId() *big.Int
- func (cws *CrossTransactionWithSignatures) Copy() *CrossTransactionWithSignatures
- func (cws *CrossTransactionWithSignatures) CrossTransaction() *CrossTransaction
- func (cws *CrossTransactionWithSignatures) DestinationId() *big.Int
- func (cws *CrossTransactionWithSignatures) Hash() (h common.Hash)
- func (cws *CrossTransactionWithSignatures) ID() common.Hash
- func (cws *CrossTransactionWithSignatures) Price() *big.Rat
- func (cws *CrossTransactionWithSignatures) RemoveSignature(index int)
- func (cws *CrossTransactionWithSignatures) Resolution() []*CrossTransaction
- func (cws *CrossTransactionWithSignatures) SignaturesLength() int
- func (cws *CrossTransactionWithSignatures) Size() common.StorageSize
- type CrossTransactions
- type CrossTrigger
- func (t *CrossTrigger) ConfirmedFinishFeedSend(tx ConfirmedFinishEvent) int
- func (t *CrossTrigger) ConfirmedMakerFeedSend(ctx ConfirmedMakerEvent) int
- func (t *CrossTrigger) ConfirmedTakerSend(transaction ConfirmedTakerEvent) int
- func (t *CrossTrigger) Stop()
- func (t *CrossTrigger) StoreCrossContractLog(blockNumber uint64, hash common.Hash, logs []*types.Log)
- func (t *CrossTrigger) SubscribeConfirmedFinishEvent(ch chan<- ConfirmedFinishEvent) event.Subscription
- func (t *CrossTrigger) SubscribeConfirmedMakerEvent(ch chan<- ConfirmedMakerEvent) event.Subscription
- func (t *CrossTrigger) SubscribeConfirmedTakerEvent(ch chan<- ConfirmedTakerEvent) event.Subscription
- func (t *CrossTrigger) SubscribeNewFinishEvent(ch chan<- NewFinishEvent) event.Subscription
- func (t *CrossTrigger) SubscribeNewTakerEvent(ch chan<- NewTakerEvent) event.Subscription
- func (t *CrossTrigger) SubscribeUpdateAnchorEvent(ch chan<- AnchorEvent) event.Subscription
- type CtxDatas
- type CtxSigner
- type CtxStatus
- type EIP155CtxSigner
- func (s EIP155CtxSigner) Equal(s2 CtxSigner) bool
- func (s EIP155CtxSigner) Hash(tx *CrossTransaction) (h common.Hash)
- func (s EIP155CtxSigner) Sender(tx *CrossTransaction) (common.Address, error)
- func (s EIP155CtxSigner) SignatureValues(tx *CrossTransaction, sig []byte) (R, S, V *big.Int, err error)
- type NewFinishEvent
- type NewTakerEvent
- type OwnerCrossTransactionWithSignatures
- type Recept
- type ReceptTransaction
- type RemoteChainInfo
- type SignHash
- type SignedCtxEvent
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateSign = errors.New("signatures already exist")
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 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 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 (cws *CrossTransactionWithSignatures) Copy() *CrossTransactionWithSignatures
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 (cws *CrossTransactionWithSignatures) ID() common.Hash
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 ¶
func (cws *CrossTransactionWithSignatures) Size() common.StorageSize
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) 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 (*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 )
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 (s EIP155CtxSigner) Sender(tx *CrossTransaction) (common.Address, error)
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 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 (*ReceptTransaction) ConstructData ¶
func (rws *ReceptTransaction) ConstructData(crossContract abi.ABI) ([]byte, error)
type RemoteChainInfo ¶
type SignedCtxEvent ¶
type SignedCtxEvent struct {
Tws *CrossTransactionWithSignatures
CallBack func(cws *CrossTransactionWithSignatures, invalidSigIndex ...int)
}