gateway

package
v0.0.0-...-89a1428 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Owner                 *types.Address `protobuf:"bytes,1,opt,name=owner" json:"owner,omitempty"`
	Timestamp             int64          `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	TotalWithdrawalAmount *types.BigUInt `protobuf:"bytes,3,opt,name=total_withdrawal_amount,json=totalWithdrawalAmount" json:"total_withdrawal_amount,omitempty"`
	XXX_NoUnkeyedLiteral  struct{}       `json:"-"`
	XXX_unrecognized      []byte         `json:"-"`
	XXX_sizecache         int32          `json:"-"`
}

func (*Account) Descriptor

func (*Account) Descriptor() ([]byte, []int)

func (*Account) GetOwner

func (m *Account) GetOwner() *types.Address

func (*Account) GetTimestamp

func (m *Account) GetTimestamp() int64

func (*Account) GetTotalWithdrawalAmount

func (m *Account) GetTotalWithdrawalAmount() *types.BigUInt

func (*Account) ProtoMessage

func (*Account) ProtoMessage()

func (*Account) Reset

func (m *Account) Reset()

func (*Account) String

func (m *Account) String() string

func (*Account) XXX_DiscardUnknown

func (m *Account) XXX_DiscardUnknown()

func (*Account) XXX_Marshal

func (m *Account) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Account) XXX_Merge

func (dst *Account) XXX_Merge(src proto.Message)

func (*Account) XXX_Size

func (m *Account) XXX_Size() int

func (*Account) XXX_Unmarshal

func (m *Account) XXX_Unmarshal(b []byte) error

type BatchSignWithdrawalFn

type BatchSignWithdrawalFn struct {
}

func CreateBatchSignWithdrawalFn

func CreateBatchSignWithdrawalFn(isLoomcoinFn bool, chainID string, tgConfig *TransferGatewayConfig, signer auth.Signer) (*BatchSignWithdrawalFn, error)

func (*BatchSignWithdrawalFn) GetMessageAndSignature

func (b *BatchSignWithdrawalFn) GetMessageAndSignature(ctx []byte) ([]byte, []byte, error)

func (*BatchSignWithdrawalFn) MapMessage

func (b *BatchSignWithdrawalFn) MapMessage(ctx, key, message []byte) error

func (*BatchSignWithdrawalFn) PrepareContext

func (b *BatchSignWithdrawalFn) PrepareContext() (bool, []byte, error)

func (*BatchSignWithdrawalFn) SubmitMultiSignedMessage

func (b *BatchSignWithdrawalFn) SubmitMultiSignedMessage(ctx []byte, key []byte, signatures [][]byte)

type BatchWithdrawalFnMessage

type BatchWithdrawalFnMessage struct {
	WithdrawalMessages   []*WithdrawalMessage `protobuf:"bytes,1,rep,name=withdrawal_messages,json=withdrawalMessages" json:"withdrawal_messages,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

func (*BatchWithdrawalFnMessage) Descriptor

func (*BatchWithdrawalFnMessage) Descriptor() ([]byte, []int)

func (*BatchWithdrawalFnMessage) GetWithdrawalMessages

func (m *BatchWithdrawalFnMessage) GetWithdrawalMessages() []*WithdrawalMessage

func (*BatchWithdrawalFnMessage) ProtoMessage

func (*BatchWithdrawalFnMessage) ProtoMessage()

func (*BatchWithdrawalFnMessage) Reset

func (m *BatchWithdrawalFnMessage) Reset()

func (*BatchWithdrawalFnMessage) String

func (m *BatchWithdrawalFnMessage) String() string

func (*BatchWithdrawalFnMessage) XXX_DiscardUnknown

func (m *BatchWithdrawalFnMessage) XXX_DiscardUnknown()

func (*BatchWithdrawalFnMessage) XXX_Marshal

func (m *BatchWithdrawalFnMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BatchWithdrawalFnMessage) XXX_Merge

func (dst *BatchWithdrawalFnMessage) XXX_Merge(src proto.Message)

func (*BatchWithdrawalFnMessage) XXX_Size

func (m *BatchWithdrawalFnMessage) XXX_Size() int

func (*BatchWithdrawalFnMessage) XXX_Unmarshal

func (m *BatchWithdrawalFnMessage) XXX_Unmarshal(b []byte) error

type BatchWithdrawalSignFnConfig

type BatchWithdrawalSignFnConfig struct {
	Enabled                     bool
	LogLevel                    string
	LogDestination              string
	MainnetPrivateKeyPath       string
	MainnetPrivateKeyHsmEnabled bool
}

type DAppChainGateway

type DAppChainGateway struct {
	Address loom.Address
	// Timestamp of the last successful response from the DAppChain
	LastResponseTime time.Time

	// Allow to set hot wallet address
	HotWalletAddress loom.Address
	// contains filtered or unexported fields
}

DAppChainGateway is a partial client-side binding of the Gateway Go contract

func ConnectToDAppChainBinanceGateway

func ConnectToDAppChainBinanceGateway(
	loomClient *client.DAppChainRPCClient, caller loom.Address, signer auth.Signer,
	logger *loom.Logger,
	mainnetGatewayAddress loom.Address,
) (*DAppChainGateway, error)

func ConnectToDAppChainGateway

func ConnectToDAppChainGateway(
	loomClient *client.DAppChainRPCClient, caller loom.Address, signer auth.Signer,
	logger *loom.Logger,
	mainnetGatewayAddress loom.Address,
) (*DAppChainGateway, error)

func ConnectToDAppChainLoomCoinGateway

func ConnectToDAppChainLoomCoinGateway(
	loomClient *client.DAppChainRPCClient, caller loom.Address, signer auth.Signer,
	logger *loom.Logger,
	mainnetGatewayAddress loom.Address,
) (*DAppChainGateway, error)

func ConnectToDAppChainTronGateway

func ConnectToDAppChainTronGateway(
	loomClient *client.DAppChainRPCClient, caller loom.Address, signer auth.Signer,
	logger *loom.Logger,
	mainnetGatewayAddress loom.Address,
) (*DAppChainGateway, error)

func (*DAppChainGateway) ClearInvalidHotWalletDepositTxHashes

func (gw *DAppChainGateway) ClearInvalidHotWalletDepositTxHashes(txHashes [][]byte) error

func (*DAppChainGateway) ConfirmWithdrawalReceipt

func (gw *DAppChainGateway) ConfirmWithdrawalReceipt(req *ConfirmWithdrawalReceiptRequest) error

func (*DAppChainGateway) ConfirmWithdrawalReceiptV2

func (gw *DAppChainGateway) ConfirmWithdrawalReceiptV2(req *ConfirmWithdrawalReceiptRequestV2) error

func (*DAppChainGateway) GetPendingHotWalletDepositTxHashes

func (gw *DAppChainGateway) GetPendingHotWalletDepositTxHashes() (*PendingHotWalletDepositTxHashesResponse, error)

func (*DAppChainGateway) GetPendingWithdrawals

func (gw *DAppChainGateway) GetPendingWithdrawals() ([]*PendingWithdrawalSummary, error)

func (*DAppChainGateway) GetProcessedWithdrawals

func (gw *DAppChainGateway) GetProcessedWithdrawals(mainnetGatewayAddr loom.Address) ([]*PendingWithdrawalSummary, error)

func (*DAppChainGateway) GetWithdrawalReceipt

func (gw *DAppChainGateway) GetWithdrawalReceipt(owner loom.Address) (*WithdrawalReceipt, error)

func (*DAppChainGateway) LastMainnetBlockNum

func (gw *DAppChainGateway) LastMainnetBlockNum() (uint64, error)

func (*DAppChainGateway) PendingWithdrawals

func (gw *DAppChainGateway) PendingWithdrawals() ([]*PendingWithdrawalSummary, error)

func (*DAppChainGateway) PendingWithdrawalsV2

func (gw *DAppChainGateway) PendingWithdrawalsV2() ([]*PendingWithdrawalSummary, error)

func (*DAppChainGateway) ProcessEventBatch

func (gw *DAppChainGateway) ProcessEventBatch(events []*MainnetEvent) error

func (*DAppChainGateway) ProcessHotWalletEventBatch

func (gw *DAppChainGateway) ProcessHotWalletEventBatch(events []*MainnetEvent) error

func (*DAppChainGateway) UnverifiedContractCreators

func (gw *DAppChainGateway) UnverifiedContractCreators() ([]*UnverifiedContractCreator, error)

func (*DAppChainGateway) UpdateWithdrawalReceipt

func (gw *DAppChainGateway) UpdateWithdrawalReceipt(req *ConfirmWithdrawalReceiptRequest) error

func (*DAppChainGateway) VerifyContractCreators

func (gw *DAppChainGateway) VerifyContractCreators(verifiedCreators []*VerifiedContractCreator) error

type GatewayStateRequest

type GatewayStateRequest = tgtypes.TransferGatewayStateRequest

type GatewayStateResponse

type GatewayStateResponse = tgtypes.TransferGatewayStateResponse

type Metrics

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

func NewMetrics

func NewMetrics(subsystem string) *Metrics

func (*Metrics) ContractCreatorsVerified

func (m *Metrics) ContractCreatorsVerified(numCreators int)

func (*Metrics) DAppChainGatewayLastSeen

func (m *Metrics) DAppChainGatewayLastSeen(lastSeen time.Time)

func (*Metrics) FetchedMainnetEvents

func (m *Metrics) FetchedMainnetEvents(numEvents int, kind string)

func (*Metrics) MethodCalled

func (m *Metrics) MethodCalled(begin time.Time, method string, err error)

func (*Metrics) NextMainnetBlockNum

func (m *Metrics) NextMainnetBlockNum(blockNum uint64)

func (*Metrics) SubmittedMainnetEvents

func (m *Metrics) SubmittedMainnetEvents(numEvents int)

func (*Metrics) WithdrawalsSigned

func (m *Metrics) WithdrawalsSigned(numWithdrawals int)

type Oracle

type Oracle struct {
}

func CreateLoomCoinOracle

func CreateLoomCoinOracle(cfg *TransferGatewayConfig, chainID string) (*Oracle, error)

func CreateOracle

func CreateOracle(cfg *TransferGatewayConfig, chainID string) (*Oracle, error)

func CreateTronOracle

func CreateTronOracle(cfg *TransferGatewayConfig, chainID string) (*Oracle, error)

func (*Oracle) Run

func (orc *Oracle) Run()

func (*Oracle) RunWithRecovery

func (orc *Oracle) RunWithRecovery()

type OracleState

type OracleState struct {
	Timestamp             int64          `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	TotalWithdrawalAmount *types.BigUInt `protobuf:"bytes,2,opt,name=total_withdrawal_amount,json=totalWithdrawalAmount" json:"total_withdrawal_amount,omitempty"`
	XXX_NoUnkeyedLiteral  struct{}       `json:"-"`
	XXX_unrecognized      []byte         `json:"-"`
	XXX_sizecache         int32          `json:"-"`
}

func (*OracleState) Descriptor

func (*OracleState) Descriptor() ([]byte, []int)

func (*OracleState) GetTimestamp

func (m *OracleState) GetTimestamp() int64

func (*OracleState) GetTotalWithdrawalAmount

func (m *OracleState) GetTotalWithdrawalAmount() *types.BigUInt

func (*OracleState) ProtoMessage

func (*OracleState) ProtoMessage()

func (*OracleState) Reset

func (m *OracleState) Reset()

func (*OracleState) String

func (m *OracleState) String() string

func (*OracleState) XXX_DiscardUnknown

func (m *OracleState) XXX_DiscardUnknown()

func (*OracleState) XXX_Marshal

func (m *OracleState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OracleState) XXX_Merge

func (dst *OracleState) XXX_Merge(src proto.Message)

func (*OracleState) XXX_Size

func (m *OracleState) XXX_Size() int

func (*OracleState) XXX_Unmarshal

func (m *OracleState) XXX_Unmarshal(b []byte) error

type TransferGatewayConfig

type TransferGatewayConfig struct {
	// Enables the Transfer Gateway Go contract on the node, must be the same on all nodes.
	ContractEnabled bool
	// Loads the Unsafe gateway methods
	Unsafe bool
	// Specifies which signing function to use for the gateway
	WithdrawalSig WithdrawalSigType
	// Enables the in-process Transfer Gateway Oracle.
	// If this is enabled ContractEnabled must be set to true.
	OracleEnabled bool
	// URI of Ethereum node the Oracle should connect to, and retrieve Mainnet events from.
	EthereumURI string
	// Address of Transfer Gateway contract on Mainnet
	// e.g. 0x3599a0abda08069e8e66544a2860e628c5dc1190
	MainnetContractHexAddress string
	// Path to Ethereum private key on disk or YubiHSM that should be used by the Oracle to sign withdrawals,
	// can be a relative, or absolute path
	MainnetPrivateKeyHsmEnabled bool
	MainnetPrivateKeyPath       string
	// Path to DAppChain private key on disk that should be used by the Oracle to sign txs send to
	// the DAppChain Transfer Gateway contract
	DappChainPrivateKeyHsmEnabled bool
	DAppChainPrivateKeyPath       string
	DAppChainReadURI              string
	DAppChainWriteURI             string
	// Websocket URI that should be used to subscribe to DAppChain events (only used for tests)
	DAppChainEventsURI    string
	DAppChainPollInterval int
	MainnetPollInterval   int
	// Number of Ethereum block confirmations the Oracle should wait for before forwarding events
	// from the Ethereum Gateway contract to the DAppChain Gateway contract.
	NumMainnetBlockConfirmations int
	// Oracle log verbosity (debug, info, error, etc.)
	OracleLogLevel       string
	OracleLogDestination string
	// Number of seconds to wait before starting the Oracle.
	OracleStartupDelay int32
	// Number of seconds to wait between reconnection attempts.
	OracleReconnectInterval int32
	// Address on from which the out-of-process Oracle should expose the status & metrics endpoints.
	OracleQueryAddress string

	BatchSignFnConfig *BatchWithdrawalSignFnConfig

	// List of DAppChain addresses that aren't allowed to withdraw to the Mainnet Gateway
	WithdrawerAddressBlacklist []string

	// URI of Tron node the Oracle should connect to, and retrieve Mainnet events from.
	TronURI string
	// Number of seconds ot wait before polling the next page if event server supports pagination
	OracleEventPollDelay int32

	// URI of Binance explorer the Oracle should connect to, and retrieve Mainnet events from.
	BinanceEventURI string
	// URI of Binance node the Oracle should connect to, for initializing Binance SDK client
	BinanceNodeURI string

	// When this flag is enabled the Oracle will fetch deposit events from MainnetHotWalletAddress by tx hash.
	VerifyHotWalletDeposits bool
	// Generic mainnet hot wallet address in case mainnet does not have smart contract
	MainnetHotWalletAddress string
	// Asset symbol for Binance-dex gateway (mainnet contract address)
	BinanceLoomToken string

	// Enforce withdrawal limits
	WithdrawalLimitsEnabled bool
	// The give amount will convert to big.Int with 18 zero appended
	// e.g. 314 is equal 314 * 10^18
	MaxTotalDailyWithdrawalAmount      int64
	MaxPerAccountDailyWithdrawalAmount int64
}

func DefaultConfig

func DefaultConfig(rpcProxyPort int32) *TransferGatewayConfig

func DefaultLoomCoinTGConfig

func DefaultLoomCoinTGConfig(rpcProxyPort int32) *TransferGatewayConfig

func DefaultTronConfig

func DefaultTronConfig(rpcProxyPort int32) *TransferGatewayConfig

func (*TransferGatewayConfig) Clone

Clone returns a deep clone of the config.

func (*TransferGatewayConfig) GetWithdrawerAddressBlacklist

func (c *TransferGatewayConfig) GetWithdrawerAddressBlacklist() ([]loom.Address, error)

func (*TransferGatewayConfig) Validate

func (c *TransferGatewayConfig) Validate() error

Validate does a basic sanity check of the config.

type WithdrawalMessage

type WithdrawalMessage struct {
	TokenOwner           *types.Address `protobuf:"bytes,1,opt,name=token_owner,json=tokenOwner" json:"token_owner,omitempty"`
	WithdrawalHash       []byte         `protobuf:"bytes,2,opt,name=withdrawal_hash,json=withdrawalHash,proto3" json:"withdrawal_hash,omitempty"`
	XXX_NoUnkeyedLiteral struct{}       `json:"-"`
	XXX_unrecognized     []byte         `json:"-"`
	XXX_sizecache        int32          `json:"-"`
}

func (*WithdrawalMessage) Descriptor

func (*WithdrawalMessage) Descriptor() ([]byte, []int)

func (*WithdrawalMessage) GetTokenOwner

func (m *WithdrawalMessage) GetTokenOwner() *types.Address

func (*WithdrawalMessage) GetWithdrawalHash

func (m *WithdrawalMessage) GetWithdrawalHash() []byte

func (*WithdrawalMessage) ProtoMessage

func (*WithdrawalMessage) ProtoMessage()

func (*WithdrawalMessage) Reset

func (m *WithdrawalMessage) Reset()

func (*WithdrawalMessage) String

func (m *WithdrawalMessage) String() string

func (*WithdrawalMessage) XXX_DiscardUnknown

func (m *WithdrawalMessage) XXX_DiscardUnknown()

func (*WithdrawalMessage) XXX_Marshal

func (m *WithdrawalMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WithdrawalMessage) XXX_Merge

func (dst *WithdrawalMessage) XXX_Merge(src proto.Message)

func (*WithdrawalMessage) XXX_Size

func (m *WithdrawalMessage) XXX_Size() int

func (*WithdrawalMessage) XXX_Unmarshal

func (m *WithdrawalMessage) XXX_Unmarshal(b []byte) error

type WithdrawalSigType

type WithdrawalSigType int
const (
	UnprefixedWithdrawalSigType WithdrawalSigType = 1
	PrefixedWithdrawalSigType   WithdrawalSigType = 2
)

Jump to

Keyboard shortcuts

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