Documentation ¶
Overview ¶
alias.go holds some type aliases from go-ethereum
ecdsa.go contains some utility functions for reading and saving ECDSA keys
Index ¶
- Constants
- Variables
- func DecodeTransaction(data []byte) (*types.Transaction, error)
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func ReadUnsafeKeyDump(location string) (*ecdsa.PrivateKey, error)
- func SaveUnsafeKeyDump(key *ecdsa.PrivateKey, location string) error
- func StringTOABI(contractAbi string) (*abi.ABI, error)
- func VerfiyERC20Lock(rawTx []byte, tokenabi_ string, erc20contractaddr common.Address) (bool, error)
- func VerifyLock(tx *types.Transaction, contractabi string) (bool, error)
- type Address
- type BalanceReply
- type BalanceRequest
- type CallOpts
- type ChainDriver
- type ChainDriverOption
- type CheckFinalityStatus
- type Client
- type Contract
- type ContractType
- type ERC20LRContract
- func (E ERC20LRContract) HasValidatorSigned(opts *bind.CallOpts, recipient_ common.Address) (bool, error)
- func (E ERC20LRContract) IsRedeemAvailable(opts *bind.CallOpts, recipient common.Address) (bool, error)
- func (E ERC20LRContract) IsValidator(opts *bind.CallOpts, addr common.Address) (bool, error)
- func (E ERC20LRContract) Sign(opts *bind.TransactOpts, amount_ *big.Int, recipient_ common.Address) (*types.Transaction, error)
- func (E ERC20LRContract) VerifyRedeem(opts *bind.CallOpts, recipient_ common.Address) (int8, error)
- type ERC20Token
- type ETHChainDriver
- func (acc ETHChainDriver) Balance(addr Address) (*big.Int, error)
- func (acc *ETHChainDriver) BroadcastTx(tx *types.Transaction) (TransactionHash, error)
- func (acc *ETHChainDriver) CallOpts(addr Address) *CallOpts
- func (acc *ETHChainDriver) ChainId() (*big.Int, error)
- func (acc *ETHChainDriver) CheckFinality(txHash TransactionHash, blockConfirmation int64) CheckFinalityStatus
- func (acc *ETHChainDriver) DecodeTransaction(rawBytes []byte) (*types.Transaction, error)
- func (acc *ETHChainDriver) GetClient() *Client
- func (acc *ETHChainDriver) GetContract() Contract
- func (acc *ETHChainDriver) GetTransactionMessage(tx *types.Transaction) (*types.Message, error)
- func (acc *ETHChainDriver) HasValidatorSigned(validatorAddress common.Address, recipient common.Address) (bool, error)
- func (acc ETHChainDriver) Nonce(addr Address) (uint64, error)
- func (Acc *ETHChainDriver) ParseERC20Redeem(rawTx []byte, lockredeemERCAbi string) (*RedeemErcRequest, error)
- func (acc *ETHChainDriver) ParseRedeem(data []byte, abi string) (req *RedeemRequest, err error)
- func (acc *ETHChainDriver) PrepareUnsignedETHLock(addr common.Address, lockAmount *big.Int) ([]byte, error)
- func (acc *ETHChainDriver) SignRedeem(fromaddr common.Address, redeemAmount *big.Int, recipient common.Address) (*Transaction, error)
- func (acc *ETHChainDriver) VerifyReceipt(txHash TransactionHash) (VerifyReceiptStatus, error)
- func (acc *ETHChainDriver) VerifyRedeem(validatorAddress common.Address, recipient common.Address) RedeemStatus
- type ETHLRContract
- func (E ETHLRContract) HasValidatorSigned(opts *bind.CallOpts, recipient_ common.Address) (bool, error)
- func (E ETHLRContract) IsRedeemAvailable(opts *bind.CallOpts, recipient common.Address) (bool, error)
- func (E ETHLRContract) IsValidator(opts *bind.CallOpts, addr common.Address) (bool, error)
- func (E ETHLRContract) Sign(opts *bind.TransactOpts, amount_ *big.Int, recipient_ common.Address) (*types.Transaction, error)
- func (E ETHLRContract) VerifyRedeem(opts *bind.CallOpts, recipient_ common.Address) (int8, error)
- type Genesis
- type LRContract
- type LockErcRequest
- type LockReply
- type LockRequest
- type OfflineETHChainDriver
- type OfflineLockRawTX
- type OfflineLockRequest
- type OnlineLockRequest
- type RedeemErcRequest
- type RedeemRequest
- type RedeemStatus
- type Service
- type SignReply
- type SignRequest
- type TrackerName
- type TransactOpts
- type Transaction
- type TransactionHash
- type VerifyReceiptStatus
Constants ¶
const DefaultKeyDumpFilename = "ecdsa.json"
const DefaultTimeout = 5 * time.Second
Variables ¶
var ( IsHexAddress = common.IsHexAddress FromHex = common.FromHex Wei = params.Wei GWei = params.GWei Ether = params.Ether )
Alias some helper funcs
var ( ErrTxFailed = errors.New("ethereum tx status failed") ErrRedeemExpired = errors.New("ethereum redeem request expired") )
Functions ¶
func DecodeTransaction ¶
func DecodeTransaction(data []byte) (*types.Transaction, error)
DecodeTransaction takes a rawTx bytearray as input and returns a transaction
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
GenerateKey returns an secp256k1 key for use with Ethereum
func ReadUnsafeKeyDump ¶
func ReadUnsafeKeyDump(location string) (*ecdsa.PrivateKey, error)
ReadUnsafeKeyDump reads a privateKeyDump from a given JSON file, and unmarshals the contents into an ecdsa.PrivateKey
func SaveUnsafeKeyDump ¶
func SaveUnsafeKeyDump(key *ecdsa.PrivateKey, location string) error
SaveUnsafeKeyDump saves a given ecdsa.PrivateKey into a JSON file at the given location
func StringTOABI ¶ added in v0.14.0
StringTOABI takes string as an input and converts it into an ABI
func VerfiyERC20Lock ¶ added in v0.14.0
func VerfiyERC20Lock(rawTx []byte, tokenabi_ string, erc20contractaddr common.Address) (bool, error)
VerifyLock verifies ERC lock transaction to check whether the ERC20 Token is being sent to our Smart Contract Address.
func VerifyLock ¶
func VerifyLock(tx *types.Transaction, contractabi string) (bool, error)
VerifyLock verifies ETHER lock transaction to check whether the ETHER is being sent to our Smart Contract Address.
Types ¶
type BalanceReply ¶
type BalanceRequest ¶
type BalanceRequest struct {
Address Address `json:"address"`
}
type ChainDriver ¶
type ChainDriver interface { }
type ChainDriverOption ¶
type CheckFinalityStatus ¶ added in v0.14.0
type CheckFinalityStatus int8
const ( TxBlockNotFound CheckFinalityStatus = 0x01 BlockHashFailed CheckFinalityStatus = 0x02 UnabletoGetHeader CheckFinalityStatus = 0x03 NotEnoughConfirmations CheckFinalityStatus = 0x04 ReciptNotFound CheckFinalityStatus = 0x05 TransactionNotMined CheckFinalityStatus = 0x06 TXSuccess CheckFinalityStatus = 0x07 )
type Contract ¶
type Contract interface { IsValidator(opts *bind.CallOpts, addr common.Address) (bool, error) VerifyRedeem(opts *bind.CallOpts, recipient_ common.Address) (int8, error) HasValidatorSigned(opts *bind.CallOpts, recipient_ common.Address) (bool, error) Sign(opts *bind.TransactOpts, amount_ *big.Int, recipient_ common.Address) (*types.Transaction, error) IsRedeemAvailable(opts *bind.CallOpts, recipient common.Address) (bool, error) }
type ContractType ¶ added in v0.14.0
type ContractType int8
const ( ETH ContractType = 0x00 ERC ContractType = 0x01 )
type ERC20LRContract ¶ added in v0.14.0
type ERC20LRContract struct {
// contains filtered or unexported fields
}
func GetERCContract ¶ added in v0.14.0
func GetERCContract(contract contract.LockRedeemERC) *ERC20LRContract
func (ERC20LRContract) HasValidatorSigned ¶ added in v0.14.0
func (ERC20LRContract) IsRedeemAvailable ¶ added in v0.14.0
func (ERC20LRContract) IsValidator ¶ added in v0.14.0
func (ERC20LRContract) Sign ¶ added in v0.14.0
func (E ERC20LRContract) Sign(opts *bind.TransactOpts, amount_ *big.Int, recipient_ common.Address) (*types.Transaction, error)
func (ERC20LRContract) VerifyRedeem ¶ added in v0.14.0
type ERC20Token ¶ added in v0.14.0
type ERC20Token struct { TokName string TokAddr common.Address TokAbi string TokTotalSupply string }
func GetToken ¶ added in v0.14.0
func GetToken(erc20list []ERC20Token, tokAddr common.Address) (*ERC20Token, error)
GetToken takes a tokenlist and token address as input . It iterates over the Tokenlist and returns the token which matches the token address
func ParseERC20RedeemToken ¶ added in v0.14.0
func ParseERC20RedeemToken(rawTx []byte, tokenList []ERC20Token, lockredeemERCAbi string) (*ERC20Token, error)
ParseERC20RedeemToken Parses the ERC Redeem Request and returns the Token which is being redeemed
type ETHChainDriver ¶
type ETHChainDriver struct { ContractAddress Address ContractABI string ContractType ContractType // contains filtered or unexported fields }
func NewChainDriver ¶
func NewChainDriver(cfg *config.EthereumChainDriverConfig, logger *log.Logger, contractAddress common.Address, contractAbi string, contractType ContractType) (*ETHChainDriver, error)
func (ETHChainDriver) Balance ¶
func (acc ETHChainDriver) Balance(addr Address) (*big.Int, error)
Balance returns the current balance of address
func (*ETHChainDriver) BroadcastTx ¶
func (acc *ETHChainDriver) BroadcastTx(tx *types.Transaction) (TransactionHash, error)
BroadcastTx takes a signed transaction as input and broadcasts it to the network
func (*ETHChainDriver) CallOpts ¶
func (acc *ETHChainDriver) CallOpts(addr Address) *CallOpts
CallOpts creates a CallOpts object for contract calls (Only call no write )
func (*ETHChainDriver) ChainId ¶
func (acc *ETHChainDriver) ChainId() (*big.Int, error)
ChainID returns the ID for the current ethereum chain (Mainet/Ropsten/Ganache)
func (*ETHChainDriver) CheckFinality ¶
func (acc *ETHChainDriver) CheckFinality(txHash TransactionHash, blockConfirmation int64) CheckFinalityStatus
CheckFinalityStatus verifies the finality of a transaction on the ethereum blockchain , waits for 12 block confirmations
func (*ETHChainDriver) DecodeTransaction ¶
func (acc *ETHChainDriver) DecodeTransaction(rawBytes []byte) (*types.Transaction, error)
DecodeTransaction is an online wrapper for DecodeTransaction
func (*ETHChainDriver) GetClient ¶
func (acc *ETHChainDriver) GetClient() *Client
func (*ETHChainDriver) GetContract ¶
func (acc *ETHChainDriver) GetContract() Contract
GetContract returns instance of an already deployed ETH/ERC LockRedeem Contract
func (*ETHChainDriver) GetTransactionMessage ¶
func (acc *ETHChainDriver) GetTransactionMessage(tx *types.Transaction) (*types.Message, error)
GetTransactionMessage takes a trasaction as input and returns the message
func (*ETHChainDriver) HasValidatorSigned ¶
func (acc *ETHChainDriver) HasValidatorSigned(validatorAddress common.Address, recipient common.Address) (bool, error)
HasValidatorSigned takes validator address and recipient address as input and verifies if the validator has already signed
func (ETHChainDriver) Nonce ¶
func (acc ETHChainDriver) Nonce(addr Address) (uint64, error)
Nonce returns the nonce of the address
func (*ETHChainDriver) ParseERC20Redeem ¶ added in v0.14.0
func (Acc *ETHChainDriver) ParseERC20Redeem(rawTx []byte, lockredeemERCAbi string) (*RedeemErcRequest, error)
ParseERC20Redeem is the online wrapper for ParseERC20RedeemParams
func (*ETHChainDriver) ParseRedeem ¶
func (acc *ETHChainDriver) ParseRedeem(data []byte, abi string) (req *RedeemRequest, err error)
ParseERC20Redeem is the online wrapper for ParseRedeem
func (*ETHChainDriver) PrepareUnsignedETHLock ¶
func (acc *ETHChainDriver) PrepareUnsignedETHLock(addr common.Address, lockAmount *big.Int) ([]byte, error)
PrepareUnsignedETHLock creates a raw Transaction to lock ether.
func (*ETHChainDriver) SignRedeem ¶
func (acc *ETHChainDriver) SignRedeem(fromaddr common.Address, redeemAmount *big.Int, recipient common.Address) (*Transaction, error)
SignRedeem creates an Ethereum transaction used by Validators to sign a redeem Request
func (*ETHChainDriver) VerifyReceipt ¶ added in v0.14.0
func (acc *ETHChainDriver) VerifyReceipt(txHash TransactionHash) (VerifyReceiptStatus, error)
Bool value is for recipt status Err is to handle error , we need to ignore NotFound and wait for the tx
func (*ETHChainDriver) VerifyRedeem ¶
func (acc *ETHChainDriver) VerifyRedeem(validatorAddress common.Address, recipient common.Address) RedeemStatus
type ETHLRContract ¶ added in v0.14.0
type ETHLRContract struct {
// contains filtered or unexported fields
}
func GetETHContract ¶ added in v0.14.0
func GetETHContract(contract contract.LockRedeem) *ETHLRContract
func (ETHLRContract) HasValidatorSigned ¶ added in v0.14.0
func (ETHLRContract) IsRedeemAvailable ¶ added in v0.14.0
func (ETHLRContract) IsValidator ¶ added in v0.14.0
func (ETHLRContract) Sign ¶ added in v0.14.0
func (E ETHLRContract) Sign(opts *bind.TransactOpts, amount_ *big.Int, recipient_ common.Address) (*types.Transaction, error)
func (ETHLRContract) VerifyRedeem ¶ added in v0.14.0
type LRContract ¶
type LRContract interface { Lock(*big.Int) (*Transaction, error) Redeem(*big.Int) (*Transaction, error) ProposeAddValidator(Address) (*Transaction, error) ProposeRemoveValidator(Address) (*Transaction, error) IsValidator(Address) (bool, error) NumValidators() (uint, *Transaction, error) Epoch() (uint, *Transaction, error) DoNewEpoch() (uint, *Transaction, error) }
TODO: embed and implement SContract is the stub implementation thereof the
type LockErcRequest ¶ added in v0.14.0
func ParseErc20Lock ¶ added in v0.14.0
func ParseErc20Lock(erc20list []ERC20Token, rawEthTx []byte) (*LockErcRequest, error)
ParseErc20Lock parses the the ERC20 Lock transaction and returns LockErcRequest . LockErcRequest contains the parameters passed to the lock function function of LockRedeem contract.
type LockRequest ¶
func ParseLock ¶
func ParseLock(data []byte) (req *LockRequest, err error)
ParseLock takes a rawTX byteArray as input and returns a LockRequest struct LockRequest struct contains the amount which the user is trying to lock .
type OfflineETHChainDriver ¶ added in v0.14.0
type OfflineETHChainDriver struct { }
type OfflineLockRawTX ¶
type OfflineLockRawTX struct {
UnsignedRawTx []byte `json:"unsignedRawTx"`
}
type OfflineLockRequest ¶
type OnlineLockRequest ¶
type OnlineLockRequest struct { // RawTransaction of a Lock call from the user to the smart contract // This should be signed and RLP encoded with the ethereum address of the user //OLTAddress common.Address `json:"oltAddress"` RawTx []byte `json:"rawTx"` }
type RedeemErcRequest ¶ added in v0.14.0
func ParseERC20RedeemParams ¶ added in v0.14.0
func ParseERC20RedeemParams(rawTx []byte, lockredeemERCAbi string) (*RedeemErcRequest, error)
ParseERC20RedeemParams Parses the ERC Redeem Request and returns the RedeemERCRequest struct RedeemERCRequest contains the parameters that were passed when the redeem function in the LOCKREDEEMERC smart contract was called by the user
type RedeemRequest ¶
func ParseRedeem ¶
func ParseRedeem(data []byte, lockredeemAbi string) (req *RedeemRequest, err error)
ParseRedeem Parses the ERC Redeem Request and returns the RedeemRequest struct RedeemRequest contains the parameters that were passed when the redeem function in the LOCKREDEEM smart contract was called by the user
type RedeemStatus ¶ added in v0.14.0
type RedeemStatus int8
const ( NewRedeem RedeemStatus = -1 Ongoing RedeemStatus = 0 Success RedeemStatus = 1 Expired RedeemStatus = 2 ErrorConnecting RedeemStatus = -2 )
func (RedeemStatus) String ¶ added in v0.14.0
func (r RedeemStatus) String() string
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(access *ETHChainDriver) *Service
Returns a new Service, should be passed as an RPC handler
type SignRequest ¶
type SignRequest struct {
// contains filtered or unexported fields
}
type TrackerName ¶
type TransactOpts ¶
type TransactOpts = bind.TransactOpts
type Transaction ¶
type Transaction = types.Transaction
type TransactionHash ¶
type VerifyReceiptStatus ¶ added in v0.14.2
type VerifyReceiptStatus int8
const ( NotFound VerifyReceiptStatus = 0 Found VerifyReceiptStatus = 1 Failed VerifyReceiptStatus = 2 ConnectionError VerifyReceiptStatus = 3 Other VerifyReceiptStatus = 4 )