Documentation ¶
Index ¶
- Constants
- Variables
- func InitExtCodeParts()
- func InitExtCodePartsWithFlag(isMbtc bool)
- func PackData(args ...interface{}) []byte
- func PackDataWithFuncHash(funcHash []byte, args ...interface{}) []byte
- func ParseErc20SwapinTxInput(input *[]byte, checkToAddress string) (from, to string, value *big.Int, err error)
- func ParseErc20SwapinTxLogs(logs []*types.RPCLog, checkToAddress string) (from, to string, value *big.Int, err error)
- func ParseSwapoutTxInput(input *[]byte) (string, *big.Int, error)
- func VerifyContractCodeParts(code []byte, codePartsSlice ...map[string][]byte) (err error)
- func VerifyErc20ContractCode(code []byte) (err error)
- func VerifySwapContractCode(code []byte) (err error)
- type Bridge
- func (b *Bridge) AdjustNonce(pairID string, value uint64) (nonce uint64)
- func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
- func (b *Bridge) CallContract(contract string, data hexutil.Bytes, blockNumber string) (string, error)
- func (b *Bridge) ChainID() (*big.Int, error)
- func (b *Bridge) DcrmSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signTx interface{}, txHash string, err error)
- func (b *Bridge) GetBalance(account string) (*big.Int, error)
- func (b *Bridge) GetBlockByHash(blockHash string) (*types.RPCBlock, error)
- func (b *Bridge) GetBlockByNumber(number *big.Int) (*types.RPCBlock, error)
- func (b *Bridge) GetCode(contract string) ([]byte, error)
- func (b *Bridge) GetContractLogs(contractAddresses []common.Address, logTopics [][]common.Hash, ...) ([]*types.RPCLog, error)
- func (b *Bridge) GetErc20Balance(contract, address string) (*big.Int, error)
- func (b *Bridge) GetErc20Decimals(contract string) (uint8, error)
- func (b *Bridge) GetErc20TotalSupply(contract string) (*big.Int, error)
- func (b *Bridge) GetLatestBlockNumber() (uint64, error)
- func (b *Bridge) GetLatestBlockNumberOf(apiAddress string) (uint64, error)
- func (b *Bridge) GetLogs(filterQuery *types.FilterQuery) (result []*types.RPCLog, err error)
- func (b *Bridge) GetPendingTransactions() (result []*types.RPCTransaction, err error)
- func (b *Bridge) GetPoolNonce(address, height string) (uint64, error)
- func (b *Bridge) GetTokenBalance(tokenType, tokenAddress, accountAddress string) (*big.Int, error)
- func (b *Bridge) GetTokenSupply(tokenType, tokenAddress string) (*big.Int, error)
- func (b *Bridge) GetTransaction(txHash string) (interface{}, error)
- func (b *Bridge) GetTransactionByHash(txHash string) (*types.RPCTransaction, error)
- func (b *Bridge) GetTransactionReceipt(txHash string) (*types.RPCTxReceipt, error)
- func (b *Bridge) GetTransactionStatus(txHash string) *tokens.TxStatus
- func (b *Bridge) IncreaseNonce(pairID string, value uint64)
- func (b *Bridge) Init()
- func (b *Bridge) InitLatestBlockNumber()
- func (b *Bridge) IsContractAddress(address string) (bool, error)
- func (b *Bridge) IsValidAddress(address string) bool
- func (b *Bridge) NetworkID() (*big.Int, error)
- func (b *Bridge) SendSignedTransaction(tx *types.Transaction) error
- func (b *Bridge) SendTransaction(signedTx interface{}) (txHash string, err error)
- func (b *Bridge) SetChainAndGateway(chainCfg *tokens.ChainConfig, gatewayCfg *tokens.GatewayConfig)
- func (b *Bridge) SetNonce(pairID string, value uint64)
- func (b *Bridge) SignTransaction(rawTx interface{}, pairID string) (signTx interface{}, txHash string, err error)
- func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, privKey *ecdsa.PrivateKey) (signTx interface{}, txHash string, err error)
- func (b *Bridge) StartChainTransactionScanJob()
- func (b *Bridge) StartPoolTransactionScanJob()
- func (b *Bridge) SuggestPrice() (*big.Int, error)
- func (b *Bridge) VerifyChainID()
- func (b *Bridge) VerifyContractCode(contract string, codePartsSlice ...map[string][]byte) (err error)
- func (b *Bridge) VerifyErc20ContractAddress(contract, codeHash string, isProxy bool) (err error)
- func (b *Bridge) VerifyMbtcContractAddress(contract string) (err error)
- func (b *Bridge) VerifyMsgHash(rawTx interface{}, msgHashes []string) error
- func (b *Bridge) VerifyTokenConfig(tokenCfg *tokens.TokenConfig) (err error)
- func (b *Bridge) VerifyTransaction(pairID, txHash string, allowUnstable bool) (*tokens.TxSwapInfo, error)
- type NonceSetterBase
Constants ¶
const (
ERC20TokenType = "ERC20"
)
token types (should be all upper case)
Variables ¶
var ( // ExtCodeParts extended func hashes and log topics ExtCodeParts map[string][]byte )
Functions ¶
func InitExtCodePartsWithFlag ¶ added in v0.3.0
func InitExtCodePartsWithFlag(isMbtc bool)
InitExtCodePartsWithFlag init extended code parts with flag
func PackDataWithFuncHash ¶
PackDataWithFuncHash pack data with func hash
func ParseErc20SwapinTxInput ¶
func ParseErc20SwapinTxInput(input *[]byte, checkToAddress string) (from, to string, value *big.Int, err error)
ParseErc20SwapinTxInput parse erc20 swapin tx input
func ParseErc20SwapinTxLogs ¶
func ParseErc20SwapinTxLogs(logs []*types.RPCLog, checkToAddress string) (from, to string, value *big.Int, err error)
ParseErc20SwapinTxLogs parse erc20 swapin tx logs
func ParseSwapoutTxInput ¶
ParseSwapoutTxInput parse swapout tx input
func VerifyContractCodeParts ¶
VerifyContractCodeParts verify contract code parts
func VerifyErc20ContractCode ¶
VerifyErc20ContractCode verify erc20 contract code
func VerifySwapContractCode ¶
VerifySwapContractCode verify swap contract code
Types ¶
type Bridge ¶
type Bridge struct { *tokens.CrossChainBridgeBase *NonceSetterBase Signer types.Signer }
Bridge eth bridge
func NewCrossChainBridge ¶
NewCrossChainBridge new bridge
func (*Bridge) AdjustNonce ¶
AdjustNonce adjust account nonce (eth like chain)
func (*Bridge) BuildRawTransaction ¶
func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
BuildRawTransaction build raw tx
func (*Bridge) CallContract ¶
func (b *Bridge) CallContract(contract string, data hexutil.Bytes, blockNumber string) (string, error)
CallContract call eth_call
func (*Bridge) ChainID ¶
ChainID call eth_chainId Notice: eth_chainId return 0x0 for mainnet which is wrong (use net_version instead)
func (*Bridge) DcrmSignTransaction ¶
func (b *Bridge) DcrmSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signTx interface{}, txHash string, err error)
DcrmSignTransaction dcrm sign raw tx
func (*Bridge) GetBalance ¶
GetBalance call eth_getBalance
func (*Bridge) GetBlockByHash ¶
GetBlockByHash call eth_getBlockByHash
func (*Bridge) GetBlockByNumber ¶
GetBlockByNumber call eth_getBlockByNumber
func (*Bridge) GetContractLogs ¶
func (b *Bridge) GetContractLogs(contractAddresses []common.Address, logTopics [][]common.Hash, blockHeight uint64) ([]*types.RPCLog, error)
GetContractLogs get contract logs
func (*Bridge) GetErc20Balance ¶
GetErc20Balance get erc20 balacne of address
func (*Bridge) GetErc20Decimals ¶
GetErc20Decimals get erc20 decimals
func (*Bridge) GetErc20TotalSupply ¶
GetErc20TotalSupply get erc20 total supply of address
func (*Bridge) GetLatestBlockNumber ¶
GetLatestBlockNumber call eth_blockNumber
func (*Bridge) GetLatestBlockNumberOf ¶
GetLatestBlockNumberOf call eth_blockNumber
func (*Bridge) GetPendingTransactions ¶
func (b *Bridge) GetPendingTransactions() (result []*types.RPCTransaction, err error)
GetPendingTransactions call eth_pendingTransactions
func (*Bridge) GetPoolNonce ¶
GetPoolNonce call eth_getTransactionCount
func (*Bridge) GetTokenBalance ¶
GetTokenBalance api
func (*Bridge) GetTokenSupply ¶
GetTokenSupply impl
func (*Bridge) GetTransaction ¶
GetTransaction impl
func (*Bridge) GetTransactionByHash ¶
func (b *Bridge) GetTransactionByHash(txHash string) (*types.RPCTransaction, error)
GetTransactionByHash call eth_getTransactionByHash
func (*Bridge) GetTransactionReceipt ¶
func (b *Bridge) GetTransactionReceipt(txHash string) (*types.RPCTxReceipt, error)
GetTransactionReceipt call eth_getTransactionReceipt
func (*Bridge) GetTransactionStatus ¶
GetTransactionStatus impl
func (*Bridge) IncreaseNonce ¶
IncreaseNonce decrease account nonce (eth like chain)
func (*Bridge) InitLatestBlockNumber ¶
func (b *Bridge) InitLatestBlockNumber()
InitLatestBlockNumber init latest block number
func (*Bridge) IsContractAddress ¶
IsContractAddress is contract address
func (*Bridge) IsValidAddress ¶
IsValidAddress check address
func (*Bridge) SendSignedTransaction ¶
func (b *Bridge) SendSignedTransaction(tx *types.Transaction) error
SendSignedTransaction call eth_sendRawTransaction
func (*Bridge) SendTransaction ¶
SendTransaction send signed tx
func (*Bridge) SetChainAndGateway ¶ added in v0.3.0
func (b *Bridge) SetChainAndGateway(chainCfg *tokens.ChainConfig, gatewayCfg *tokens.GatewayConfig)
SetChainAndGateway set chain and gateway config
func (*Bridge) SignTransaction ¶ added in v0.3.0
func (b *Bridge) SignTransaction(rawTx interface{}, pairID string) (signTx interface{}, txHash string, err error)
SignTransaction sign tx with pairID
func (*Bridge) SignTransactionWithPrivateKey ¶ added in v0.3.0
func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, privKey *ecdsa.PrivateKey) (signTx interface{}, txHash string, err error)
SignTransactionWithPrivateKey sign tx with ECDSA private key
func (*Bridge) StartChainTransactionScanJob ¶
func (b *Bridge) StartChainTransactionScanJob()
StartChainTransactionScanJob scan job
func (*Bridge) StartPoolTransactionScanJob ¶
func (b *Bridge) StartPoolTransactionScanJob()
StartPoolTransactionScanJob scan job
func (*Bridge) SuggestPrice ¶
SuggestPrice call eth_gasPrice
func (*Bridge) VerifyContractCode ¶
func (b *Bridge) VerifyContractCode(contract string, codePartsSlice ...map[string][]byte) (err error)
VerifyContractCode verify contract code
func (*Bridge) VerifyErc20ContractAddress ¶
VerifyErc20ContractAddress verify erc20 contract For proxy contract delegating erc20 contract, verify its contract code hash
func (*Bridge) VerifyMbtcContractAddress ¶
VerifyMbtcContractAddress verify mbtc contract
func (*Bridge) VerifyMsgHash ¶
VerifyMsgHash verify msg hash
func (*Bridge) VerifyTokenConfig ¶ added in v0.3.0
func (b *Bridge) VerifyTokenConfig(tokenCfg *tokens.TokenConfig) (err error)
VerifyTokenConfig verify token config
func (*Bridge) VerifyTransaction ¶
func (b *Bridge) VerifyTransaction(pairID, txHash string, allowUnstable bool) (*tokens.TxSwapInfo, error)
VerifyTransaction impl
type NonceSetterBase ¶
NonceSetterBase base nonce setter
func NewNonceSetterBase ¶
func NewNonceSetterBase() *NonceSetterBase
NewNonceSetterBase new base nonce setter