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(onChainAddr pwallet.Address) (pwallet.Address, error)
- func (cb *ChainBackend) DeployAsset(adjAddr, onChainAddr pwallet.Address) (pwallet.Address, error)
- func (cb *ChainBackend) NewAdjudicator(adjAddr, onChainAddr pwallet.Address) pchannel.Adjudicator
- func (cb *ChainBackend) NewFunder(assetAddr pwallet.Address, onChainAddr pwallet.Address) pchannel.Funder
- func (cb *ChainBackend) ValidateContracts(adjAddr, assetAddr pwallet.Address) error
- 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) DeployAsset ¶
DeployAsset deploys the asset holder contract, setting the adjudicator address to given value.
func (*ChainBackend) NewAdjudicator ¶
func (cb *ChainBackend) NewAdjudicator(adjAddr, onChainAddr pwallet.Address) pchannel.Adjudicator
NewAdjudicator initializes and returns an instance of ethereum adjudicator.
func (*ChainBackend) NewFunder ¶
func (cb *ChainBackend) NewFunder(assetAddr pwallet.Address, onChainAddr pwallet.Address) pchannel.Funder
NewFunder initializes and returns an instance of ethereum funder.
func (*ChainBackend) ValidateContracts ¶
func (cb *ChainBackend) ValidateContracts(adjAddr, assetAddr pwallet.Address) error
ValidateContracts validates the integrity of given adjudicator and asset holder contracts.
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.