ethereum

package
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package ethereum contains implementation of ethereum chain interface.

Index

Constants

View Source
const (
	BondedECDSAKeepFactoryContractName = "BondedECDSAKeepFactory"
)

Definitions of contract names.

Variables

View Source
var (
	// DefaultMiningCheckInterval is the default interval in which transaction
	// mining status is checked. If the transaction is not mined within this
	// time, the gas price is increased and transaction is resubmitted.
	// This value can be overwritten in the configuration file.
	DefaultMiningCheckInterval = 60 * time.Second

	// DefaultMaxGasPrice specifies the default maximum gas price the client is
	// willing to pay for the transaction to be mined. The offered transaction
	// gas price can not be higher than the max gas price value. If the maximum
	// allowed gas price is reached, no further resubmission attempts are
	// performed. This value can be overwritten in the configuration file.
	DefaultMaxGasPrice = big.NewInt(1000000000000) // 1000 Gwei
)

Functions

This section is empty.

Types

type EthereumChain

type EthereumChain struct {
	// contains filtered or unexported fields
}

EthereumChain is an implementation of ethereum blockchain interface.

func Connect

func Connect(accountKey *keystore.Key, config *ethereum.Config) (*EthereumChain, error)

Connect performs initialization for communication with Ethereum blockchain based on provided config.

func (*EthereumChain) Address

func (ec *EthereumChain) Address() common.Address

Address returns client's ethereum address.

func (*EthereumChain) BalanceMonitor added in v1.5.0

func (ec *EthereumChain) BalanceMonitor() (chain.BalanceMonitor, error)

BalanceMonitor returns a balance monitor.

func (*EthereumChain) BalanceOf

func (ec *EthereumChain) BalanceOf(address common.Address) (*big.Int, error)

BalanceOf returns the stake balance of the specified address.

func (*EthereumChain) BlockCounter

func (ec *EthereumChain) BlockCounter() chain.BlockCounter

BlockCounter returns a block counter.

func (*EthereumChain) BlockTimestamp added in v1.5.0

func (ec *EthereumChain) BlockTimestamp(blockNumber *big.Int) (uint64, error)

BlockTimestamp returns given block's timestamp.

func (*EthereumChain) GetHonestThreshold

func (ec *EthereumChain) GetHonestThreshold(
	keepAddress common.Address,
) (uint64, error)

GetHonestThreshold returns keep's honest threshold.

func (*EthereumChain) GetKeepAtIndex

func (ec *EthereumChain) GetKeepAtIndex(
	keepIndex *big.Int,
) (common.Address, error)

GetKeepAtIndex returns the address of the keep at the given index.

func (*EthereumChain) GetKeepCount

func (ec *EthereumChain) GetKeepCount() (*big.Int, error)

GetKeepCount returns number of keeps.

func (*EthereumChain) GetMembers

func (ec *EthereumChain) GetMembers(
	keepAddress common.Address,
) ([]common.Address, error)

GetMembers returns keep's members.

func (*EthereumChain) GetOpenedTimestamp added in v1.2.0

func (ec *EthereumChain) GetOpenedTimestamp(keepAddress common.Address) (time.Time, error)

GetOpenedTimestamp returns timestamp when the keep was created.

func (*EthereumChain) GetPublicKey

func (ec *EthereumChain) GetPublicKey(keepAddress common.Address) ([]uint8, error)

GetPublicKey returns keep's public key. If there is no public key yet, an empty slice is returned.

func (*EthereumChain) HasMinimumStake

func (ec *EthereumChain) HasMinimumStake(address common.Address) (bool, error)

HasMinimumStake returns true if the specified address is staked. False will be returned if not staked. If err != nil then it was not possible to determine if the address is staked or not.

func (*EthereumChain) IsActive

func (ec *EthereumChain) IsActive(keepAddress common.Address) (bool, error)

IsActive checks for current state of a keep on-chain.

func (*EthereumChain) IsAwaitingSignature

func (ec *EthereumChain) IsAwaitingSignature(keepAddress common.Address, digest [32]byte) (bool, error)

IsAwaitingSignature checks if the keep is waiting for a signature to be calculated for the given digest.

func (*EthereumChain) IsEligibleForApplication

func (ec *EthereumChain) IsEligibleForApplication(application common.Address) (bool, error)

IsEligibleForApplication checks if the operator is eligible to register as a signer candidate for the given application.

func (*EthereumChain) IsOperatorAuthorized

func (ec *EthereumChain) IsOperatorAuthorized(operator common.Address) (bool, error)

IsOperatorAuthorized checks if the factory has the authorization to operate on stake represented by the provided operator.

func (*EthereumChain) IsRegisteredForApplication

func (ec *EthereumChain) IsRegisteredForApplication(application common.Address) (bool, error)

IsRegisteredForApplication checks if the operator is registered as a signer candidate in the factory for the given application.

func (*EthereumChain) IsStatusUpToDateForApplication

func (ec *EthereumChain) IsStatusUpToDateForApplication(application common.Address) (bool, error)

IsStatusUpToDateForApplication checks if the operator's status is up to date in the signers' pool of the given application.

func (*EthereumChain) LatestDigest

func (ec *EthereumChain) LatestDigest(keepAddress common.Address) ([32]byte, error)

LatestDigest returns the latest digest requested to be signed.

func (*EthereumChain) OnBondedECDSAKeepCreated

func (ec *EthereumChain) OnBondedECDSAKeepCreated(
	handler func(event *eth.BondedECDSAKeepCreatedEvent),
) subscription.EventSubscription

OnBondedECDSAKeepCreated installs a callback that is invoked when an on-chain notification of a new ECDSA keep creation is seen.

func (*EthereumChain) OnConflictingPublicKeySubmitted

func (ec *EthereumChain) OnConflictingPublicKeySubmitted(
	keepAddress common.Address,
	handler func(event *eth.ConflictingPublicKeySubmittedEvent),
) (subscription.EventSubscription, error)

OnConflictingPublicKeySubmitted installs a callback that is invoked when an on-chain notification of a conflicting public key submission is seen.

func (*EthereumChain) OnKeepClosed

func (ec *EthereumChain) OnKeepClosed(
	keepAddress common.Address,
	handler func(event *eth.KeepClosedEvent),
) (subscription.EventSubscription, error)

OnKeepClosed installs a callback that is invoked on-chain when keep is closed.

func (*EthereumChain) OnKeepTerminated

func (ec *EthereumChain) OnKeepTerminated(
	keepAddress common.Address,
	handler func(event *eth.KeepTerminatedEvent),
) (subscription.EventSubscription, error)

OnKeepTerminated installs a callback that is invoked on-chain when keep is terminated.

func (*EthereumChain) OnPublicKeyPublished

func (ec *EthereumChain) OnPublicKeyPublished(
	keepAddress common.Address,
	handler func(event *eth.PublicKeyPublishedEvent),
) (subscription.EventSubscription, error)

OnPublicKeyPublished installs a callback that is invoked when an on-chain event of a published public key was emitted.

func (*EthereumChain) OnSignatureRequested

func (ec *EthereumChain) OnSignatureRequested(
	keepAddress common.Address,
	handler func(event *eth.SignatureRequestedEvent),
) (subscription.EventSubscription, error)

OnSignatureRequested installs a callback that is invoked on-chain when a keep's signature is requested.

func (*EthereumChain) PastSignatureSubmittedEvents added in v1.5.0

func (ec *EthereumChain) PastSignatureSubmittedEvents(
	keepAddress string,
	startBlock uint64,
) ([]*eth.SignatureSubmittedEvent, error)

PastSignatureSubmittedEvents returns all signature submitted events for the given keep which occurred after the provided start block. Returned events are sorted by the block number in the ascending order.

func (*EthereumChain) RegisterAsMemberCandidate

func (ec *EthereumChain) RegisterAsMemberCandidate(application common.Address) error

RegisterAsMemberCandidate registers client as a candidate to be selected to a keep.

func (*EthereumChain) SignatureRequestedBlock

func (ec *EthereumChain) SignatureRequestedBlock(
	keepAddress common.Address,
	digest [32]byte,
) (uint64, error)

SignatureRequestedBlock returns block number from the moment when a signature was requested for the given digest from a keep. If a signature was not requested for the given digest, returns 0.

func (*EthereumChain) Signing added in v1.6.0

func (ec *EthereumChain) Signing() chain.Signing

Signing returns signing interface for creating and verifying signatures.

func (*EthereumChain) StakeMonitor

func (ec *EthereumChain) StakeMonitor() (chain.StakeMonitor, error)

func (*EthereumChain) SubmitKeepPublicKey

func (ec *EthereumChain) SubmitKeepPublicKey(
	keepAddress common.Address,
	publicKey [64]byte,
) error

SubmitKeepPublicKey submits a public key to a keep contract deployed under a given address.

func (*EthereumChain) SubmitSignature

func (ec *EthereumChain) SubmitSignature(
	keepAddress common.Address,
	signature *ecdsa.Signature,
) error

SubmitSignature submits a signature to a keep contract deployed under a given address.

func (*EthereumChain) UpdateStatusForApplication

func (ec *EthereumChain) UpdateStatusForApplication(application common.Address) error

UpdateStatusForApplication updates the operator's status in the signers' pool for the given application.

func (*EthereumChain) WeiBalanceOf added in v1.5.0

func (ec *EthereumChain) WeiBalanceOf(address common.Address) (*big.Int, error)

WeiBalanceOf returns the wei balance of the given address from the latest known block.

type TBTCEthereumChain added in v1.5.0

type TBTCEthereumChain struct {
	*EthereumChain
	// contains filtered or unexported fields
}

TBTCEthereumChain represents an Ethereum chain handle with TBTC-specific capabilities.

func WithTBTCExtension added in v1.5.0

func WithTBTCExtension(
	ethereumChain *EthereumChain,
	tbtcSystemContractAddress string,
) (*TBTCEthereumChain, error)

WithTBTCExtension extends the Ethereum chain handle with TBTC-specific capabilities.

func (*TBTCEthereumChain) CurrentState added in v1.5.0

func (tec *TBTCEthereumChain) CurrentState(
	depositAddress string,
) (chain.DepositState, error)

CurrentState returns the current state for the provided deposit.

func (*TBTCEthereumChain) IncreaseRedemptionFee added in v1.5.0

func (tec *TBTCEthereumChain) IncreaseRedemptionFee(
	depositAddress string,
	previousOutputValueBytes [8]uint8,
	newOutputValueBytes [8]uint8,
) error

IncreaseRedemptionFee increases the redemption fee for the provided deposit.

func (*TBTCEthereumChain) KeepAddress added in v1.5.0

func (tec *TBTCEthereumChain) KeepAddress(
	depositAddress string,
) (string, error)

KeepAddress returns the underlying keep address for the provided deposit.

func (*TBTCEthereumChain) OnDepositCreated added in v1.5.0

func (tec *TBTCEthereumChain) OnDepositCreated(
	handler func(depositAddress string),
) subscription.EventSubscription

OnDepositCreated installs a callback that is invoked when an on-chain notification of a new deposit creation is seen.

func (*TBTCEthereumChain) OnDepositGotRedemptionSignature added in v1.5.0

func (tec *TBTCEthereumChain) OnDepositGotRedemptionSignature(
	handler func(depositAddress string),
) subscription.EventSubscription

OnDepositGotRedemptionSignature installs a callback that is invoked when an on-chain notification of a deposit receiving a redemption signature is seen.

func (*TBTCEthereumChain) OnDepositRedeemed added in v1.5.0

func (tec *TBTCEthereumChain) OnDepositRedeemed(
	handler func(depositAddress string),
) subscription.EventSubscription

OnDepositRedeemed installs a callback that is invoked when an on-chain notification of a deposit redemption is seen.

func (*TBTCEthereumChain) OnDepositRedemptionRequested added in v1.5.0

func (tec *TBTCEthereumChain) OnDepositRedemptionRequested(
	handler func(depositAddress string),
) subscription.EventSubscription

OnDepositRedemptionRequested installs a callback that is invoked when an on-chain notification of a deposit redemption request is seen.

func (*TBTCEthereumChain) OnDepositRegisteredPubkey added in v1.5.0

func (tec *TBTCEthereumChain) OnDepositRegisteredPubkey(
	handler func(depositAddress string),
) subscription.EventSubscription

OnDepositRegisteredPubkey installs a callback that is invoked when an on-chain notification of a deposit's pubkey registration is seen.

func (*TBTCEthereumChain) PastDepositRedemptionRequestedEvents added in v1.5.0

func (tec *TBTCEthereumChain) PastDepositRedemptionRequestedEvents(
	startBlock uint64,
	depositAddress string,
) ([]*chain.DepositRedemptionRequestedEvent, error)

PastDepositRedemptionRequestedEvents returns all redemption requested events for the given deposit which occurred after the provided start block. Returned events are sorted by the block number in the ascending order.

func (*TBTCEthereumChain) ProvideRedemptionProof added in v1.5.0

func (tec *TBTCEthereumChain) ProvideRedemptionProof(
	depositAddress string,
	txVersion [4]uint8,
	txInputVector []uint8,
	txOutputVector []uint8,
	txLocktime [4]uint8,
	merkleProof []uint8,
	txIndexInBlock *big.Int,
	bitcoinHeaders []uint8,
) error

ProvideRedemptionProof provides the redemption proof for the provided deposit.

func (*TBTCEthereumChain) ProvideRedemptionSignature added in v1.5.0

func (tec *TBTCEthereumChain) ProvideRedemptionSignature(
	depositAddress string,
	v uint8,
	r [32]uint8,
	s [32]uint8,
) error

ProvideRedemptionSignature provides the redemption signature for the provided deposit.

func (*TBTCEthereumChain) RetrieveSignerPubkey added in v1.5.0

func (tec *TBTCEthereumChain) RetrieveSignerPubkey(
	depositAddress string,
) error

RetrieveSignerPubkey retrieves the signer public key for the provided deposit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL