eth

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package eth contains interface for interaction with an ethereum blockchain along with structures reflecting events emitted on an ethereum blockchain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SerializePublicKey

func SerializePublicKey(publicKey *ecdsa.PublicKey) ([64]byte, error)

SerializePublicKey takes X and Y coordinates of a signer's public key and concatenates it to a 64-byte long array. If any of coordinates is shorter than 32-byte it is preceded with zeros.

Types

type BondedECDSAKeep

type BondedECDSAKeep interface {
	// OnSignatureRequested installs a callback that is invoked when an on-chain
	// notification of a new signing request for a given keep is seen.
	OnSignatureRequested(
		keepAddress common.Address,
		handler func(event *SignatureRequestedEvent),
	) (subscription.EventSubscription, error)

	// OnConflictingPublicKeySubmitted installs a callback that is invoked upon
	// notification of mismatched public keys that were submitted by keep members.
	OnConflictingPublicKeySubmitted(
		keepAddress common.Address,
		handler func(event *ConflictingPublicKeySubmittedEvent),
	) (subscription.EventSubscription, error)

	// OnPublicKeyPublished installs a callback that is invoked upon
	// notification of a published public key, which means that all members have
	// submitted the same key.
	OnPublicKeyPublished(
		keepAddress common.Address,
		handler func(event *PublicKeyPublishedEvent),
	) (subscription.EventSubscription, error)

	// SubmitKeepPublicKey submits a 64-byte serialized public key to a keep
	// contract deployed under a given address.
	SubmitKeepPublicKey(keepAddress common.Address, publicKey [64]byte) error // TODO: Add promise *async.KeepPublicKeySubmissionPromise

	// SubmitSignature submits a signature to a keep contract deployed under a
	// given address.
	SubmitSignature(
		keepAddress common.Address,
		signature *ecdsa.Signature,
	) error // TODO: Add promise *async.SignatureSubmissionPromise

	// OnKeepClosed installs a callback that will be called on closing the
	// given keep.
	OnKeepClosed(
		keepAddress common.Address,
		handler func(event *KeepClosedEvent),
	) (subscription.EventSubscription, error)

	// OnKeepTerminated installs a callback that will be called on terminating
	// the given keep.
	OnKeepTerminated(
		keepAddress common.Address,
		handler func(event *KeepTerminatedEvent),
	) (subscription.EventSubscription, error)

	// IsAwaitingSignature checks if the keep is waiting for a signature to be
	// calculated for the given digest.
	IsAwaitingSignature(keepAddress common.Address, digest [32]byte) (bool, error)

	// IsActive checks if the keep with the given address is active and responds
	// to signing request. This function returns false only for closed keeps.
	IsActive(keepAddress common.Address) (bool, error)

	// LatestDigest returns the latest digest requested to be signed.
	LatestDigest(keepAddress common.Address) ([32]byte, 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.
	SignatureRequestedBlock(keepAddress common.Address, digest [32]byte) (uint64, error)

	// GetPublicKey returns keep's public key. If there is no public key yet,
	// an empty slice is returned.
	GetPublicKey(keepAddress common.Address) ([]uint8, error)

	// GetMembers returns keep's members.
	GetMembers(keepAddress common.Address) ([]common.Address, error)

	// GetHonestThreshold returns keep's honest threshold.
	GetHonestThreshold(keepAddress common.Address) (uint64, error)

	// GetOpenedTimestamp returns timestamp when the keep was created.
	GetOpenedTimestamp(keepAddress common.Address) (time.Time, error)

	// PastSignatureSubmittedEvents returns all signature submitted events
	// for the given keep which occurred after the provided start block.
	// All implementations should returns those events sorted by the
	// block number in the ascending order.
	PastSignatureSubmittedEvents(
		keepAddress string,
		startBlock uint64,
	) ([]*SignatureSubmittedEvent, error)
}

BondedECDSAKeep is an interface that provides ability to interact with BondedECDSAKeep ethereum contracts.

type BondedECDSAKeepCreatedEvent

type BondedECDSAKeepCreatedEvent struct {
	KeepAddress     common.Address   // keep contract address
	Members         []common.Address // keep members addresses
	HonestThreshold uint64
	BlockNumber     uint64
}

BondedECDSAKeepCreatedEvent is an event emitted on a new keep creation.

func (*BondedECDSAKeepCreatedEvent) IsMember

func (e *BondedECDSAKeepCreatedEvent) IsMember(address common.Address) bool

IsMember checks if list of members contains the given address.

type BondedECDSAKeepFactory

type BondedECDSAKeepFactory interface {
	// RegisterAsMemberCandidate registers client as a candidate to be selected
	// to a keep.
	RegisterAsMemberCandidate(application common.Address) error

	// OnBondedECDSAKeepCreated installs a callback that is invoked when an
	// on-chain notification of a new bonded ECDSA keep creation is seen.
	OnBondedECDSAKeepCreated(
		handler func(event *BondedECDSAKeepCreatedEvent),
	) subscription.EventSubscription

	// IsRegisteredForApplication checks if the operator is registered
	// as a signer candidate in the factory for the given application.
	IsRegisteredForApplication(application common.Address) (bool, error)

	// IsEligibleForApplication checks if the operator is eligible to register
	// as a signer candidate for the given application.
	IsEligibleForApplication(application common.Address) (bool, error)

	// IsStatusUpToDateForApplication checks if the operator's status
	// is up to date in the signers' pool of the given application.
	IsStatusUpToDateForApplication(application common.Address) (bool, error)

	// UpdateStatusForApplication updates the operator's status in the signers'
	// pool for the given application.
	UpdateStatusForApplication(application common.Address) error

	// IsOperatorAuthorized checks if the factory has the authorization to
	// operate on stake represented by the provided operator.
	IsOperatorAuthorized(operator common.Address) (bool, error)

	// GetKeepCount returns number of keeps.
	GetKeepCount() (*big.Int, error)

	// GetKeepAtIndex returns the address of the keep at the given index.
	GetKeepAtIndex(keepIndex *big.Int) (common.Address, error)
}

BondedECDSAKeepFactory is an interface that provides ability to interact with BondedECDSAKeepFactory ethereum contracts.

type ConflictingPublicKeySubmittedEvent

type ConflictingPublicKeySubmittedEvent struct {
	SubmittingMember     common.Address
	ConflictingPublicKey []byte
	BlockNumber          uint64
}

ConflictingPublicKeySubmittedEvent is an event emitted each time when one of the members of a keep has submitted a key that does not match the keys submitted so far by other members.

type Deposit added in v1.5.0

type Deposit interface {
	// KeepAddress returns the underlying keep address for the
	// provided deposit.
	KeepAddress(depositAddress string) (string, error)

	// RetrieveSignerPubkey retrieves the signer public key for the
	// provided deposit.
	RetrieveSignerPubkey(depositAddress string) error

	// ProvideRedemptionSignature provides the redemption signature for the
	// provided deposit.
	ProvideRedemptionSignature(
		depositAddress string,
		v uint8,
		r [32]uint8,
		s [32]uint8,
	) error

	// IncreaseRedemptionFee increases the redemption fee for the
	// provided deposit.
	IncreaseRedemptionFee(
		depositAddress string,
		previousOutputValueBytes [8]uint8,
		newOutputValueBytes [8]uint8,
	) error

	// ProvideRedemptionProof provides the redemption proof for the
	// provided deposit.
	ProvideRedemptionProof(
		depositAddress string,
		txVersion [4]uint8,
		txInputVector []uint8,
		txOutputVector []uint8,
		txLocktime [4]uint8,
		merkleProof []uint8,
		txIndexInBlock *big.Int,
		bitcoinHeaders []uint8,
	) error

	// CurrentState returns the current state for the provided deposit.
	CurrentState(depositAddress string) (DepositState, error)
}

Deposit is an interface that provides ability to interact with Deposit contracts.

type DepositRedemptionRequestedEvent added in v1.5.0

type DepositRedemptionRequestedEvent struct {
	DepositAddress       string
	RequesterAddress     string
	Digest               [32]byte
	UtxoValue            *big.Int
	RedeemerOutputScript []byte
	RequestedFee         *big.Int
	Outpoint             []byte
	BlockNumber          uint64
}

DepositRedemptionRequestedEvent is an event emitted when a deposit redemption has been requested or the redemption fee has been increased.

type DepositState added in v1.5.0

type DepositState int

DepositState represents the deposit state.

const (
	Start DepositState = iota
	AwaitingSignerSetup
	AwaitingBtcFundingProof
	FailedSetup
	Active
	AwaitingWithdrawalSignature
	AwaitingWithdrawalProof
	Redeemed
	CourtesyCall
	FraudLiquidationInProgress
	LiquidationInProgress
	Liquidated
)

type Handle

type Handle interface {
	// Address returns client's ethereum address.
	Address() common.Address // TODO: use implementation-agnostic type
	// StakeMonitor returns a stake monitor.
	StakeMonitor() (chain.StakeMonitor, error)
	// BalanceMonitor returns a balance monitor.
	BalanceMonitor() (chain.BalanceMonitor, error)
	// BlockCounter returns a block counter.
	BlockCounter() chain.BlockCounter
	// Signing returns a signer interface allowing to sign and verify messages
	// using the chain implementation-specific mechanism as well as to
	// convert between public key and address.
	Signing() chain.Signing
	// BlockTimestamp returns given block's timestamp.
	// In case the block is not yet mined, an error should be returned.
	BlockTimestamp(blockNumber *big.Int) (uint64, error)

	BondedECDSAKeepFactory
	BondedECDSAKeep
}

Handle represents a handle to an ethereum blockchain.

type KeepClosedEvent

type KeepClosedEvent struct {
	BlockNumber uint64
}

KeepClosedEvent is an event emitted when a keep has been closed.

type KeepTerminatedEvent

type KeepTerminatedEvent struct {
	BlockNumber uint64
}

KeepTerminatedEvent is an event emitted when a keep has been terminated.

type PublicKeyPublishedEvent

type PublicKeyPublishedEvent struct {
	PublicKey   []byte
	BlockNumber uint64
}

PublicKeyPublishedEvent is an event emitted once all the members have submitted the same public key and it was accepted by keep as its public key.

type SignatureRequestedEvent

type SignatureRequestedEvent struct {
	Digest      [32]byte
	BlockNumber uint64
}

SignatureRequestedEvent is an event emitted when a user requests a digest to be signed.

type SignatureSubmittedEvent added in v1.5.0

type SignatureSubmittedEvent struct {
	Digest      [32]byte
	R           [32]byte
	S           [32]byte
	RecoveryID  uint8
	BlockNumber uint64
}

SignatureSubmittedEvent is an event emitted when a keep submits a signature.

type TBTCHandle added in v1.5.0

type TBTCHandle interface {
	Handle

	Deposit
	TBTCSystem
}

TBTCHandle represents a chain handle extended with TBTC-specific capabilities.

type TBTCSystem added in v1.5.0

type TBTCSystem interface {
	// OnDepositCreated installs a callback that is invoked when an
	// on-chain notification of a new deposit creation is seen.
	OnDepositCreated(
		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.
	OnDepositRegisteredPubkey(
		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.
	OnDepositRedemptionRequested(
		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.
	OnDepositGotRedemptionSignature(
		handler func(depositAddress string),
	) subscription.EventSubscription

	// OnDepositRedeemed installs a callback that is invoked when an
	// on-chain notification of a deposit redemption is seen.
	OnDepositRedeemed(
		handler func(depositAddress string),
	) subscription.EventSubscription

	// PastDepositRedemptionRequestedEvents returns all redemption requested
	// events for the given deposit which occurred after the provided start block.
	// All implementations should returns those events sorted by the
	// block number in the ascending order.
	PastDepositRedemptionRequestedEvents(
		startBlock uint64,
		depositAddress string,
	) ([]*DepositRedemptionRequestedEvent, error)
}

TBTCSystem is an interface that provides ability to interact with TBTCSystem contract.

Directories

Path Synopsis
Package ethereum contains implementation of ethereum chain interface.
Package ethereum contains implementation of ethereum chain interface.
gen
abi
cmd

Jump to

Keyboard shortcuts

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