Documentation ¶
Index ¶
- Constants
- Variables
- func AbiEncodeArgs(addr common.Address, amount *big.Int, txid string) ([]byte, error)
- func IsNoPeerErr(err error) bool
- func NewHost(ctx context.Context, secret, relay string, psk string) (host.Host, routing.PeerRouting, error)
- func NewSignerServer(host host.Host, bridgeMasterAddress string, bridgeContract *BridgeContract, ...) error
- type Bridge
- type BridgeConfig
- type BridgeContract
- func (bridge *BridgeContract) AccountAddress() (common.Address, error)
- func (bridge *BridgeContract) CreateTokenSignature(receiver common.Address, amount int64, txid string) (tokenv1.Signature, error)
- func (bridge *BridgeContract) EthClient() *EthClient
- func (bridge *BridgeContract) FilterWithdraw(wc chan<- WithdrawEvent, startHeight uint64, endHeight uint64) error
- func (bridge *BridgeContract) GetContractAdress() common.Address
- func (bridge *BridgeContract) GetRequiresSignatureCount() (*big.Int, error)
- func (bridge *BridgeContract) GetSigners() ([]common.Address, error)
- func (bridge *BridgeContract) IsMintTxID(txID string) (bool, error)
- func (bridge *BridgeContract) Loop(ch chan<- *types.Header)
- func (bridge *BridgeContract) Mint(receiver tfeth.ERC20Address, amount *big.Int, txID string, ...) error
- func (bridge *BridgeContract) Refresh(head *types.Header) error
- func (bridge *BridgeContract) SubscribeMint() error
- func (bridge *BridgeContract) SubscribeTransfers() error
- func (bridge *BridgeContract) SubscribeWithdraw(wc chan<- WithdrawEvent, startHeight uint64) error
- func (bridge *BridgeContract) WatchWithdraw(opts *bind.WatchOpts, sink chan<- *tokenv1.TokenWithdraw, ...) (event.Subscription, error)
- type Contract
- type ERC20BalanceInfo
- type EthClient
- func (c *EthClient) AccountAddress() (common.Address, error)
- func (c *EthClient) AccountBalanceAt(ctx context.Context, blockNumber *big.Int) (*big.Int, error)
- func (c *EthClient) GetAddress() (common.Address, error)
- func (c *EthClient) GetBalanceInfo() (*ERC20BalanceInfo, error)
- func (c *EthClient) Sign(data []byte) ([]byte, error)
- func (c *EthClient) SignTx(tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
- type EthConfig
- type EthSignRequest
- type EthSignResponse
- type LightClientConfig
- type Signature
- type SignerConfig
- type SignerService
- type SignersClient
- type WithdrawEvent
- func (w WithdrawEvent) Amount() *big.Int
- func (w WithdrawEvent) BlockHash() common.Hash
- func (w WithdrawEvent) BlockHeight() uint64
- func (w WithdrawEvent) BlockchainAddress() string
- func (w WithdrawEvent) Network() string
- func (w WithdrawEvent) Receiver() common.Address
- func (w WithdrawEvent) TxHash() common.Hash
Constants ¶
const ( // EthBlockDelay is the amount of blocks to wait before // pushing eth transaction to the stellar network EthBlockDelay = 3 // Withdrawing from smartchain to Stellar fee WithdrawFee = int64(1 * stellar.Precision) //WithdrawFeeof 1 TFT in Stroops BridgeNetwork = "stellar" EthMessagePrefix = "\x19Ethereum Signed Message:\n32" )
const (
Protocol = protocol.ID("/p2p/rpc/signer")
)
Variables ¶
var ( ErrInvalidTransaction = errors.New("Invalid transaction") ErrTransactionAlreadyExists = errors.Wrap(ErrInvalidTransaction, "transaction already exists") ErrAlreadyRefunded = errors.Wrap(ErrInvalidTransaction, "The deposit was already refunded") ErrInvalidFeePayment = errors.Wrap(ErrInvalidTransaction, "Invalid fee payment") )
var ( // ErrNoAccountLoaded is an error returned for all Light Client methods // that require an account and for which no account is loaded. ErrNoAccountLoaded = errors.New("no account was loaded into the light client") )
Functions ¶
func AbiEncodeArgs ¶
AbiEncodeArgs encodes the arguments for the mint function TODO: better move this to eth package
func IsNoPeerErr ¶
IsNoPeerErr checks if an error is means an ethereum client could not execute a call because it has no valid peers
func NewSignerServer ¶
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge is a high lvl structure which listens on contract events and bridge-related stellar transactions, and handles them
func NewBridge ¶
func NewBridge(ctx context.Context, wallet *stellar.Wallet, contract *BridgeContract, config *BridgeConfig, host host.Host, router routing.PeerRouting) (bridge *Bridge, err error)
NewBridge creates a new Bridge. TODO: context is not used
type BridgeConfig ¶
type BridgeContract ¶
type BridgeContract struct {
// contains filtered or unexported fields
}
BridgeContract exposes a higher lvl api for specific contract bindings. In case of proxy contracts, the bridge needs to use the bindings of the implementation contract, but the address of the proxy.
func NewBridgeContract ¶
func NewBridgeContract(ethConfig *EthConfig) (*BridgeContract, error)
NewBridgeContract creates a new wrapper for an allready deployed contract
func (*BridgeContract) AccountAddress ¶
func (bridge *BridgeContract) AccountAddress() (common.Address, error)
AccountAddress returns the account address of the bridge contract
func (*BridgeContract) CreateTokenSignature ¶
func (*BridgeContract) EthClient ¶
func (bridge *BridgeContract) EthClient() *EthClient
EthClient returns the EthClient driving this bridge contract
func (*BridgeContract) FilterWithdraw ¶
func (bridge *BridgeContract) FilterWithdraw(wc chan<- WithdrawEvent, startHeight uint64, endHeight uint64) error
FilterWithdraw filters Withdraw events on the given contract. This call blocks and prints out info about any withdraw as it happened
func (*BridgeContract) GetContractAdress ¶
func (bridge *BridgeContract) GetContractAdress() common.Address
GetContractAdress returns the address of this contract
func (*BridgeContract) GetRequiresSignatureCount ¶
func (bridge *BridgeContract) GetRequiresSignatureCount() (*big.Int, error)
func (*BridgeContract) GetSigners ¶
func (bridge *BridgeContract) GetSigners() ([]common.Address, error)
GetSigners returns the list of signers for the contract
func (*BridgeContract) IsMintTxID ¶
func (bridge *BridgeContract) IsMintTxID(txID string) (bool, error)
func (*BridgeContract) Loop ¶
func (bridge *BridgeContract) Loop(ch chan<- *types.Header)
Loop subscribes to new eth heads. If a new head is received, it is passed on the given channel, after which the internal stats are updated if no update is already in progress
func (*BridgeContract) Mint ¶
func (bridge *BridgeContract) Mint(receiver tfeth.ERC20Address, amount *big.Int, txID string, signatures []tokenv1.Signature) error
func (*BridgeContract) Refresh ¶
func (bridge *BridgeContract) Refresh(head *types.Header) error
Refresh attempts to retrieve the latest header from the chain and extract the associated bridge balance and nonce for connectivity caching.
func (*BridgeContract) SubscribeMint ¶
func (bridge *BridgeContract) SubscribeMint() error
SubscribeMint subscribes to new Mint events on the given contract. This call blocks and prints out info about any mint as it happened
func (*BridgeContract) SubscribeTransfers ¶
func (bridge *BridgeContract) SubscribeTransfers() error
SubscribeTransfers subscribes to new Transfer events on the given contract. This call blocks and prints out info about any transfer as it happened
func (*BridgeContract) SubscribeWithdraw ¶
func (bridge *BridgeContract) SubscribeWithdraw(wc chan<- WithdrawEvent, startHeight uint64) error
SubscribeWithdraw subscribes to new Withdraw events on the given contract. This call blocks and prints out info about any withdraw as it happened
func (*BridgeContract) WatchWithdraw ¶
func (bridge *BridgeContract) WatchWithdraw(opts *bind.WatchOpts, sink chan<- *tokenv1.TokenWithdraw, receiver []common.Address) (event.Subscription, error)
WatchWithdraw is a free log subscription operation binding the contract event 0x884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364.
Solidity: e Withdraw(receiver indexed address, tokens uint256)
This method is copied from the generated bindings and slightly modified, so we can add logic to stay backwards compatible with the old withdraw event signature TODO: is the copy still needed or can we simply use the generated bindings?
type ERC20BalanceInfo ¶
type ERC20BalanceInfo struct { Balance *big.Int `json:"balance"` Address common.Address `json:"address"` }
ERC20BalanceInfo provides a definition for the ethereum bridge address balance
type EthClient ¶
type EthClient struct { *ethclient.Client // Client connection to the Ethereum chain // contains filtered or unexported fields }
EthClient creates a light client that can be used to interact with the Ethereum network,
func NewEthClient ¶
func NewEthClient(lccfg LightClientConfig) (*EthClient, error)
NewLiEthient creates a new light client that can be used to interact with the ETH network. See `EthClient` for more information.
func (*EthClient) AccountAddress ¶
AccountAddress returns the address of the loaded account, returning an error only if no account was loaded.
func (*EthClient) AccountBalanceAt ¶
AccountBalanceAt returns the balance for the account at the given block height.
func (*EthClient) GetBalanceInfo ¶
func (c *EthClient) GetBalanceInfo() (*ERC20BalanceInfo, error)
GetBalanceInfo returns bridge ethereum address and balance
func (*EthClient) SignTx ¶
func (c *EthClient) SignTx(tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
SignTx signs a given traction with the loaded account, returning the signed transaction and no error on success.
type EthConfig ¶
type EthConfig struct { EthNetworkName string EthUrl string EthPrivateKey string ContractAddress string }
EthConfig combines all configuration required for creating and configuring a EthClient.
type EthSignRequest ¶
type EthSignResponse ¶
type LightClientConfig ¶
type LightClientConfig struct { NetworkName string EthUrl string NetworkID uint64 EthPrivateKey string GenesisBlock *core.Genesis }
LightClientConfig combines all configuration required for creating and configuring a EthClient.
type SignerConfig ¶
func (*SignerConfig) Valid ¶
func (c *SignerConfig) Valid() error
type SignerService ¶
type SignerService struct {
// contains filtered or unexported fields
}
func (*SignerService) Sign ¶
func (s *SignerService) Sign(ctx context.Context, request multisig.StellarSignRequest, response *multisig.StellarSignResponse) error
Sign signs a stellar sign request This is calable on the libp2p network with RPC
func (*SignerService) SignMint ¶
func (s *SignerService) SignMint(ctx context.Context, request EthSignRequest, response *EthSignResponse) error
type SignersClient ¶
type SignersClient struct {
// contains filtered or unexported fields
}
func NewSignersClient ¶
func NewSignersClient(host host.Host, router routing.PeerRouting, cosigners []peer.ID, relay *peer.AddrInfo) *SignersClient
NewSignersClient creates a signer client to ask cosigners to sign
func (*SignersClient) Sign ¶
func (s *SignersClient) Sign(ctx context.Context, signRequest multisig.StellarSignRequest) ([]multisig.StellarSignResponse, error)
func (*SignersClient) SignMint ¶
func (s *SignersClient) SignMint(ctx context.Context, signRequest EthSignRequest) ([]EthSignResponse, error)
type WithdrawEvent ¶
type WithdrawEvent struct {
// contains filtered or unexported fields
}
WithdrawEvent holds relevant information about a withdraw event
func (WithdrawEvent) BlockHash ¶
func (w WithdrawEvent) BlockHash() common.Hash
BlockHash of the containing block
func (WithdrawEvent) BlockHeight ¶
func (w WithdrawEvent) BlockHeight() uint64
BlockHeight of the containing block
func (WithdrawEvent) BlockchainAddress ¶
func (w WithdrawEvent) BlockchainAddress() string
Blockchain address to withdraw to
func (WithdrawEvent) Receiver ¶
func (w WithdrawEvent) Receiver() common.Address
Receiver of the withdraw
func (WithdrawEvent) TxHash ¶
func (w WithdrawEvent) TxHash() common.Hash
TxHash hash of the transaction