Documentation ¶
Overview ¶
Package internal implements the ethereum related backend functionality. It is shared by both ethereum, ethereumtest and can be configured to use the backend in real programs and in tests.
Index ¶
- Constants
- type ChainBackend
- func (cb *ChainBackend) DeployAdjudicator(txSender pwallet.Address) (pwallet.Address, error)
- func (cb *ChainBackend) DeployAssetERC20(adj, tokenERC20, txSender pwallet.Address) (pwallet.Address, error)
- func (cb *ChainBackend) DeployAssetETH(adjAddr, txSender pwallet.Address) (pwallet.Address, error)
- func (cb *ChainBackend) DeployPerunToken(initAccs []pwallet.Address, initBal *big.Int, txSender pwallet.Address) (pwallet.Address, error)
- func (cb *ChainBackend) ERC20Info(addr pwallet.Address) (symbol string, decimal uint8, _ error)
- func (cb *ChainBackend) NewAdjudicator(adjAddr, txSender pwallet.Address) pchannel.Adjudicator
- func (cb *ChainBackend) NewFunder(assetETHAddr pwallet.Address, txSender pwallet.Address) perun.Funder
- func (cb *ChainBackend) ValidateAdjudicator(adjAddr pwallet.Address) error
- func (cb *ChainBackend) ValidateAssetERC20(adj, tokenERC20, assetERC20 pwallet.Address) (symbol string, decimals uint8, _ error)
- func (cb *ChainBackend) ValidateAssetETH(adjAddr, assetETHAddr pwallet.Address) error
- type Funder
- type ScryptParams
- type WalletBackend
Constants ¶
const ( StandardScryptN = keystore.StandardScryptN StandardScryptP = keystore.StandardScryptP WeakScryptN = 2 WeakScryptP = 1 )
Standard encryption parameters should be uses for real wallets. Using these parameters will cause the decryption to use 256MB of RAM and takes approx 1s on a modern processor.
Weak encryption parameters should be used for test wallets. Using these parameters will cause the can be decrypted and unlocked faster.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainBackend ¶
type ChainBackend struct { // Cb is the instance of contract backend that will be used for all on-chain communications. Cb *pethchannel.ContractBackend // TxTimeout is the max time to wait for confirmation of transactions on blockchain. // If this expires, a transactions is considered failed. // Use sufficiently large values when connecting to mainnet. TxTimeout time.Duration }
ChainBackend provides ethereum specific contract backend functionality.
func (*ChainBackend) DeployAdjudicator ¶
DeployAdjudicator deploys the adjudicator contract.
func (*ChainBackend) DeployAssetERC20 ¶ added in v0.6.0
func (cb *ChainBackend) DeployAssetERC20(adj, tokenERC20, txSender pwallet.Address) (pwallet.Address, error)
DeployAssetERC20 deploys the asset ERC20 contract, setting the adjudicator and erc20 token addresses to given values.
func (*ChainBackend) DeployAssetETH ¶ added in v0.6.0
DeployAssetETH deploys the asset ETH contract, setting the adjudicator address to given value.
func (*ChainBackend) DeployPerunToken ¶ added in v0.6.0
func (cb *ChainBackend) DeployPerunToken(initAccs []pwallet.Address, initBal *big.Int, txSender pwallet.Address) ( pwallet.Address, error)
DeployPerunToken deploys the perun ERC20 token contract.
func (*ChainBackend) ERC20Info ¶ added in v0.6.0
ERC20Info reads the symbol and number of decimal values decimals for the ERC20 token from the blockchain.
func (*ChainBackend) NewAdjudicator ¶
func (cb *ChainBackend) NewAdjudicator(adjAddr, txSender pwallet.Address) pchannel.Adjudicator
NewAdjudicator initializes and returns an instance of ethereum adjudicator.
func (*ChainBackend) NewFunder ¶
func (cb *ChainBackend) NewFunder(assetETHAddr pwallet.Address, txSender pwallet.Address) perun.Funder
NewFunder initializes and returns an instance of ethereum funder.
func (*ChainBackend) ValidateAdjudicator ¶ added in v0.6.0
func (cb *ChainBackend) ValidateAdjudicator(adjAddr pwallet.Address) error
ValidateAdjudicator validates the integrity of adjudicator contract at the given address.
func (*ChainBackend) ValidateAssetERC20 ¶ added in v0.6.0
func (cb *ChainBackend) ValidateAssetERC20(adj, tokenERC20, assetERC20 pwallet.Address) ( symbol string, decimals uint8, _ error)
ValidateAssetERC20 validates the integrity of adjudicator and asset ERC20 contracts at the given addresses. TokenERC20 is the address of ERC20 token contract.
func (*ChainBackend) ValidateAssetETH ¶ added in v0.6.0
func (cb *ChainBackend) ValidateAssetETH(adjAddr, assetETHAddr pwallet.Address) error
ValidateAssetETH validates the integrity of adjudicator and asset ETH contracts at the given addresses.
type Funder ¶ added in v0.6.0
type Funder struct {
*pethchannel.Funder
}
Funder implements a wrapper around ETH Funder.
See perun.Funder for more info.
func (*Funder) IsAssetRegistered ¶ added in v0.6.0
IsAssetRegistered wraps the IsAssetRegistered on the actual ETH funder implementation with abstract types defined in go-perun core.
func (*Funder) RegisterAssetERC20 ¶ added in v0.6.0
func (f *Funder) RegisterAssetERC20(asset pwallet.Address, token pwallet.Address, onChainAcc pwallet.Address) bool
RegisterAssetERC20 wraps the RegisterAssetERC20 on the actual ETH funder implementation with abstract types defined in go-perun core.
type ScryptParams ¶
type ScryptParams struct {
N, P int
}
ScryptParams defines the parameters for scrypt encryption algorithm, used or storage encryption of keys.
Weak values should be used only for testing purposes (enables faster unlockcing). Use standard values otherwise.
type WalletBackend ¶
type WalletBackend struct {
EncParams ScryptParams
}
WalletBackend provides ethereum specific wallet backend functionality.
func (*WalletBackend) NewWallet ¶
func (wb *WalletBackend) NewWallet(keystorePath, password string) (pwallet.Wallet, error)
NewWallet initializes an ethereum keystore at the given path and checks if all the keys in the keystore can be unlocked with the given password.
func (*WalletBackend) ParseAddr ¶
func (wb *WalletBackend) ParseAddr(str string) (pwallet.Address, error)
ParseAddr parses the ethereum address from the given string. It should be in hexadecimal representation of the address, optionally prefixed by "0x" or "0X". It pads zeros in the beginning if the address string is less than required length and returns an error if it is greater than required length.
func (*WalletBackend) UnlockAccount ¶
func (wb *WalletBackend) UnlockAccount(w pwallet.Wallet, addr pwallet.Address) (pwallet.Account, error)
UnlockAccount retrieves the account corresponding to the given address, unlocks and returns it.