Documentation ¶
Index ¶
- Constants
- Variables
- func IsNoPeerErr(err error) bool
- func NewGater(accept peer.ID) connmgr.ConnectionGater
- func NewHost(ctx context.Context, secret string, filteredID string) (host.Host, routing.PeerRouting, error)
- type Blockheight
- type Bridge
- type BridgeConfig
- type BridgeContract
- func (bridge *BridgeContract) AccountAddress() (common.Address, error)
- func (bridge *BridgeContract) ConfirmTransaction(txid *big.Int) error
- func (bridge *BridgeContract) EthBalance() (*big.Int, error)
- func (bridge *BridgeContract) FilterWithdraw(wc chan<- WithdrawEvent, startHeight uint64, endHeight uint64) error
- func (bridge *BridgeContract) GetContractAdress() common.Address
- func (bridge *BridgeContract) GetTransactionByID(txID *big.Int) (struct{ ... }, error)
- func (bridge *BridgeContract) IsConfirmedTxID(txID *big.Int) (bool, error)
- func (bridge *BridgeContract) IsMintTxID(txID string) (bool, error)
- func (bridge *BridgeContract) LightClient() *LightClient
- func (bridge *BridgeContract) Loop(ch chan<- *types.Header)
- func (bridge *BridgeContract) Mint(receiver ERC20Address, amount *big.Int, txID string) error
- func (bridge *BridgeContract) Refresh(head *types.Header) error
- func (bridge *BridgeContract) SubscribeMint() error
- func (bridge *BridgeContract) SubscribeSubmission(submitChan chan<- SubmissionEvent) error
- func (bridge *BridgeContract) SubscribeTransfers() error
- func (bridge *BridgeContract) SubscribeWithdraw(wc chan<- WithdrawEvent, startHeight uint64) error
- func (bridge *BridgeContract) TokenBalance(address common.Address) (*big.Int, error)
- func (bridge *BridgeContract) TransferFunds(recipient common.Address, amount *big.Int) error
- func (bridge *BridgeContract) WatchWithdraw(opts *bind.WatchOpts, sink chan<- *contract.TokenWithdraw, ...) (event.Subscription, error)
- type ChainPersistency
- type Contract
- type Data
- type ERC20Address
- type ERC20BalanceInfo
- type LightClient
- func (lc *LightClient) AccountAddress() (common.Address, error)
- func (lc *LightClient) AccountBalanceAt(ctx context.Context, blockNumber *big.Int) (*big.Int, error)
- func (lc *LightClient) GetBalanceInfo() (*ERC20BalanceInfo, error)
- func (lc *LightClient) LoadAccount(accountJSON, accountPass string) error
- func (lc *LightClient) SignTx(tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
- type LightClientConfig
- type MsContract
- type SignRequest
- type SignResponse
- type SignerConfig
- type SignerService
- type SignersClient
- type StellarConfig
- type StellarTransactionStorage
- func (s *StellarTransactionStorage) FetchTransactions(ctx context.Context, cursor string, handler func(op hProtocol.Transaction)) error
- func (s *StellarTransactionStorage) ScanBridgeAccount() error
- func (s *StellarTransactionStorage) StoreTransactionWithMemo(txn *txnbuild.Transaction) error
- func (s *StellarTransactionStorage) TransactionWithMemoExists(txn *txnbuild.Transaction) (exists bool, err error)
- func (s *StellarTransactionStorage) TransactionWithMemoExistsAndScan(txn *txnbuild.Transaction) (exists bool, err error)
- type SubmissionEvent
- 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 * stellarPrecision) BridgeNetwork = "stellar" )
const ( TFTMainnet = "TFT:GBOVQKJYHXRR3DX6NOX2RRYFRCUMSADGDESTDNBDS6CDVLGVESRTAC47" TFTTest = "TFT:GA47YZA3PKFUZMPLQ3B5F2E3CJIB57TGGU7SPCQT2WAEYKN766PWIMB3" )
const ERC20AddressLength = 20
const (
Protocol = protocol.ID("/p2p/rpc/signer")
)
Variables ¶
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 IsNoPeerErr ¶
IsNoPeerErr checks if an error is means an ethereum client could not execute a call because it has no valid peers
Types ¶
type Blockheight ¶
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, config *BridgeConfig, host host.Host, router routing.PeerRouting) (bridge *Bridge, err error)
NewBridge creates a new Bridge.
func (*Bridge) GetBridgeContract ¶
func (bridge *Bridge) GetBridgeContract() *BridgeContract
GetBridgeContract returns this bridge's contract.
func (*Bridge) GetClient ¶
func (bridge *Bridge) GetClient() *LightClient
GetClient returns bridgecontract lightclient
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(bridgeConfig *BridgeConfig) (*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) ConfirmTransaction ¶
func (bridge *BridgeContract) ConfirmTransaction(txid *big.Int) error
func (*BridgeContract) EthBalance ¶
func (bridge *BridgeContract) EthBalance() (*big.Int, error)
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) GetTransactionByID ¶
func (*BridgeContract) IsConfirmedTxID ¶
func (bridge *BridgeContract) IsConfirmedTxID(txID *big.Int) (bool, error)
func (*BridgeContract) IsMintTxID ¶
func (bridge *BridgeContract) IsMintTxID(txID string) (bool, error)
func (*BridgeContract) LightClient ¶
func (bridge *BridgeContract) LightClient() *LightClient
LightClient returns the LightClient driving this bridge contract
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 ERC20Address, amount *big.Int, txID string) 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) SubscribeSubmission ¶
func (bridge *BridgeContract) SubscribeSubmission(submitChan chan<- SubmissionEvent) error
SubscribeSubmission subscribes to new submission event on the given multisig contract.
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) TokenBalance ¶
func (*BridgeContract) TransferFunds ¶
TransferFunds transfers funds from one address to another
func (*BridgeContract) WatchWithdraw ¶
func (bridge *BridgeContract) WatchWithdraw(opts *bind.WatchOpts, sink chan<- *contract.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
type ChainPersistency ¶
type ChainPersistency struct {
// contains filtered or unexported fields
}
func (*ChainPersistency) GetHeight ¶
func (b *ChainPersistency) GetHeight() (*Blockheight, error)
func (*ChainPersistency) Save ¶
func (b *ChainPersistency) Save(blockheight *Blockheight) error
type ERC20Address ¶
type ERC20Address [ERC20AddressLength]byte
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 LightClient ¶
type LightClient struct { *ethclient.Client // Client connection to the Ethereum chain // contains filtered or unexported fields }
LightClient creates a light client that can be used to interact with the Ethereum network, for ERC20 purposes. By default it is read-only, in order to also write to the network, you'll need load an account using the LoadAccount method.
func NewLightClient ¶
func NewLightClient(lccfg LightClientConfig) (*LightClient, error)
NewLightClient creates a new light client that can be used to interact with the ETH network. See `LightClient` for more information.
func (*LightClient) AccountAddress ¶
func (lc *LightClient) AccountAddress() (common.Address, error)
AccountAddress returns the address of the loaded account, returning an error only if no account was loaded.
func (*LightClient) AccountBalanceAt ¶
func (lc *LightClient) AccountBalanceAt(ctx context.Context, blockNumber *big.Int) (*big.Int, error)
AccountBalanceAt returns the balance for the account at the given block height.
func (*LightClient) GetBalanceInfo ¶
func (lc *LightClient) GetBalanceInfo() (*ERC20BalanceInfo, error)
GetBalanceInfo returns bridge ethereum address and balance
func (*LightClient) LoadAccount ¶
func (lc *LightClient) LoadAccount(accountJSON, accountPass string) error
LoadAccount loads an account into this light client, allowing writeable operations using the loaded account. An error is returned in case no account could be loaded.
func (*LightClient) SignTx ¶
func (lc *LightClient) 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 LightClientConfig ¶
type LightClientConfig struct { DataDir string NetworkName string EthUrl string NetworkID uint64 GenesisBlock *core.Genesis }
LightClientConfig combines all configuration required for creating and configuring a LightClient.
type MsContract ¶
type MsContract struct {
// contains filtered or unexported fields
}
type SignRequest ¶
type SignResponse ¶
type SignerConfig ¶
func (*SignerConfig) Valid ¶
func (c *SignerConfig) Valid() error
type SignerService ¶
type SignerService struct { StellarTransactionStorage *StellarTransactionStorage // contains filtered or unexported fields }
func NewSignerServer ¶
func NewSignerServer(host host.Host, config StellarConfig, bridgeMasterAddress string, bridgeContract *BridgeContract) (*SignerService, error)
func (*SignerService) Sign ¶
func (s *SignerService) Sign(ctx context.Context, request SignRequest, response *SignResponse) error
type SignersClient ¶
type SignersClient struct {
// contains filtered or unexported fields
}
func NewSignersClient ¶
func NewSignersClient(ctx context.Context, host host.Host, router routing.PeerRouting, addresses []string) (*SignersClient, error)
NewSignersClient creates a signer client with given stellar addresses the addresses are going to be used to get libp2p ID where we connect to and ask them to sign
func (*SignersClient) Sign ¶
func (s *SignersClient) Sign(ctx context.Context, signRequest SignRequest) ([]SignResponse, error)
type StellarConfig ¶
type StellarConfig struct { // network for the stellar config StellarNetwork string // seed for the stellar bridge wallet StellarSeed string // stellar fee wallet address StellarFeeWallet string // deposit fee in TFT units DepositFee int64 }
func (*StellarConfig) DepositFeeInStroops ¶
func (c *StellarConfig) DepositFeeInStroops() int64
DepositFeeInStroops returns the DepositFee in the Stellar base unit
type StellarTransactionStorage ¶
type StellarTransactionStorage struct {
// contains filtered or unexported fields
}
func NewStellarTransactionStorage ¶
func NewStellarTransactionStorage(network, addressToScan string) *StellarTransactionStorage
func (*StellarTransactionStorage) FetchTransactions ¶
func (s *StellarTransactionStorage) FetchTransactions(ctx context.Context, cursor string, handler func(op hProtocol.Transaction)) error
func (*StellarTransactionStorage) ScanBridgeAccount ¶
func (s *StellarTransactionStorage) ScanBridgeAccount() error
func (*StellarTransactionStorage) StoreTransactionWithMemo ¶
func (s *StellarTransactionStorage) StoreTransactionWithMemo(txn *txnbuild.Transaction) error
func (*StellarTransactionStorage) TransactionWithMemoExists ¶
func (s *StellarTransactionStorage) TransactionWithMemoExists(txn *txnbuild.Transaction) (exists bool, err error)
func (*StellarTransactionStorage) TransactionWithMemoExistsAndScan ¶
func (s *StellarTransactionStorage) TransactionWithMemoExistsAndScan(txn *txnbuild.Transaction) (exists bool, err error)
type SubmissionEvent ¶
type SubmissionEvent struct {
// contains filtered or unexported fields
}
SubmissionEvent holds relevant information about a submission event
func (SubmissionEvent) TransactionId ¶
func (c SubmissionEvent) TransactionId() *big.Int
Receiver of the withdraw
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