ethereum

package
v0.0.0-...-369a1d7 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LightRelayContractName                = "LightRelay"
	LightRelayMaintainerProxyContractName = "LightRelayMaintainerProxy"
)

Definitions of contract names.

View Source
const (
	// TODO: The WalletRegistry address is taken from the Bridge contract.
	//       Remove the possibility of passing it through the config.
	WalletRegistryContractName          = "WalletRegistry"
	BridgeContractName                  = "Bridge"
	MaintainerProxyContractName         = "MaintainerProxy"
	WalletProposalValidatorContractName = "WalletProposalValidator"
)

Definitions of contract names.

View Source
const (
	RandomBeaconContractName = "RandomBeacon"
)

Definitions of contract names.

View Source
const (
	TokenStakingContractName = "TokenStaking"
)

Definitions of contract names.

Variables

View Source
var DefaultCurve elliptic.Curve = crypto.S256()

DefaultCurve is the default elliptic curve implementation used in the chain/ethereum package. Ethereum uses the secp256k1 curve and the specific implementation is provided by the go-ethereum package.

Functions

func ChainPrivateKeyToOperatorKeyPair

func ChainPrivateKeyToOperatorKeyPair(
	chainPrivateKey *ecdsa.PrivateKey,
) (*operator.PrivateKey, *operator.PublicKey, error)

ChainPrivateKeyToOperatorKeyPair converts the Ethereum chain private key to a universal operator key pair. This conversion decouples the key from the chain-specific curve implementation while preserving the curve.

func Connect

Connect creates Random Beacon and TBTC Ethereum chain handles.

Types

type BeaconChain

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

BeaconChain represents a beacon-specific chain handle.

func (BeaconChain) AverageBlockTime

func (bc BeaconChain) AverageBlockTime() time.Duration

func (BeaconChain) BlockCounter

func (bc BeaconChain) BlockCounter() (chain.BlockCounter, error)

func (*BeaconChain) CalculateDKGResultHash

func (bc *BeaconChain) CalculateDKGResultHash(
	dkgResult *beaconchain.DKGResult,
) (beaconchain.DKGResultHash, error)

CalculateDKGResultHash calculates Keccak-256 hash of the DKG result. Operation is performed off-chain.

It first encodes the result using solidity ABI and then calculates Keccak-256 hash over it. This corresponds to the DKG result hash calculation on-chain. Hashes calculated off-chain and on-chain must always match.

func (*BeaconChain) CanRestoreRewardEligibility

func (bc *BeaconChain) CanRestoreRewardEligibility() (bool, error)

Checks whether the operator is able to restore their eligibility for rewards right away.

func (*BeaconChain) CurrentRequestGroupPublicKey

func (bc *BeaconChain) CurrentRequestGroupPublicKey() ([]byte, error)

TODO: Implement a real CurrentRequestGroupPublicKey function.

func (*BeaconChain) CurrentRequestPreviousEntry

func (bc *BeaconChain) CurrentRequestPreviousEntry() ([]byte, error)

TODO: Implement a real CurrentRequestPreviousEntry function.

func (*BeaconChain) CurrentRequestStartBlock

func (bc *BeaconChain) CurrentRequestStartBlock() (*big.Int, error)

TODO: Implement a real CurrentRequestStartBlock function.

func (*BeaconChain) EligibleStake

func (bc *BeaconChain) EligibleStake(stakingProvider chain.Address) (*big.Int, error)

EligibleStake returns the current value of the staking provider's eligible stake. Eligible stake is defined as the currently authorized stake minus the pending authorization decrease. Eligible stake is what is used for operator's weight in the sortition pool. If the authorized stake minus the pending authorization decrease is below the minimum authorization, eligible stake is 0.

func (BeaconChain) GetBlockHashByNumber

func (bc BeaconChain) GetBlockHashByNumber(blockNumber uint64) (
	[32]byte,
	error,
)

GetBlockHashByNumber gets the block hash for the given block number.

func (BeaconChain) GetBlockNumberByTimestamp

func (bc BeaconChain) GetBlockNumberByTimestamp(
	timestamp uint64,
) (uint64, error)

GetBlockNumberByTimestamp gets the block number for the given timestamp. In the best case, the block with the exact same timestamp is returned. If the aforementioned is not possible, it tries to return the closest possible block.

WARNING: THIS FUNCTION MAY NOT BE PERFORMANT FOR BLOCKS EARLIER THAN 15537393 (SEPTEMBER 15, 2022, AT 1:42:42 EST) BEFORE THE ETH2 MERGE. PRE-MERGE AVERAGE BLOCK TIME WAS HIGHER THAN THE VALUE ASSUMED WITHIN THIS FUNCTION SO MORE OVERSHOOTS WILL BE DONE DURING THE BLOCK PREDICTION. OVERSHOOTS MUST BE COMPENSATED BY ADDITIONAL CLIENT CALLS THAT TAKE TIME.

func (*BeaconChain) GetConfig

func (bc *BeaconChain) GetConfig() *beaconchain.Config

GetConfig returns the expected configuration of the random beacon. TODO: Adjust to the random beacon v2 requirements.

func (*BeaconChain) GetOperatorID

func (bc *BeaconChain) GetOperatorID(
	operatorAddress chain.Address,
) (chain.OperatorID, error)

GetOperatorID returns the ID number of the given operator address. An ID number of 0 means the operator has not been allocated an ID number yet.

func (*BeaconChain) IsBetaOperator

func (bc *BeaconChain) IsBetaOperator() (bool, error)

Returns true if operator is a beta operator, false otherwise. Chaosnet status does not matter.

func (*BeaconChain) IsChaosnetActive

func (bc *BeaconChain) IsChaosnetActive() (bool, error)

Returns true if the chaosnet phase is active, false otherwise.

func (*BeaconChain) IsEligibleForRewards

func (bc *BeaconChain) IsEligibleForRewards() (bool, error)

IsEligibleForRewards checks whether the operator is eligible for rewards or not.

func (*BeaconChain) IsEntryInProgress

func (bc *BeaconChain) IsEntryInProgress() (bool, error)

TODO: Implement a real IsEntryInProgress function.

func (*BeaconChain) IsGroupRegistered

func (bc *BeaconChain) IsGroupRegistered(groupPublicKey []byte) (bool, error)

TODO: Implement a real IsGroupRegistered function.

func (*BeaconChain) IsOperatorInPool

func (bc *BeaconChain) IsOperatorInPool() (bool, error)

IsOperatorInPool returns true if the operator is registered in the sortition pool.

func (*BeaconChain) IsOperatorUpToDate

func (bc *BeaconChain) IsOperatorUpToDate() (bool, error)

IsOperatorUpToDate checks if the operator's authorized stake is in sync with operator's weight in the sortition pool. If the operator's authorized stake is not in sync with sortition pool weight, function returns false. If the operator is not in the sortition pool and their authorized stake is non-zero, function returns false.

func (*BeaconChain) IsPoolLocked

func (bc *BeaconChain) IsPoolLocked() (bool, error)

IsPoolLocked returns true if the sortition pool is locked and no state changes are allowed.

func (*BeaconChain) IsRecognized

func (bc *BeaconChain) IsRecognized(operatorPublicKey *operator.PublicKey) (bool, error)

IsRecognized checks whether the given operator is recognized by the BeaconChain as eligible to join the network. If the operator has a stake delegation or had a stake delegation in the past, it will be recognized.

func (*BeaconChain) IsStaleGroup

func (bc *BeaconChain) IsStaleGroup(groupPublicKey []byte) (bool, error)

TODO: Implement a real IsStaleGroup function.

func (*BeaconChain) JoinSortitionPool

func (bc *BeaconChain) JoinSortitionPool() error

JoinSortitionPool executes a transaction to have the operator join the sortition pool.

func (*BeaconChain) OnDKGResultSubmitted

func (bc *BeaconChain) OnDKGResultSubmitted(
	handler func(event *event.DKGResultSubmission),
) subscription.EventSubscription

TODO: Implement a real OnDKGResultSubmitted event subscription. The current implementation just pipes the DKG submission event generated within SubmitDKGResult to the handlers registered in the dkgResultSubmissionHandlers map.

func (*BeaconChain) OnDKGStarted

func (bc *BeaconChain) OnDKGStarted(
	handler func(event *event.DKGStarted),
) subscription.EventSubscription

TODO: Implement a real OnDKGStarted event subscription. The current implementation generates a fake event every 500th block where the seed is the keccak256 of the block number.

func (*BeaconChain) OnGroupRegistered

func (bc *BeaconChain) OnGroupRegistered(
	handler func(groupRegistration *event.GroupRegistration),
) subscription.EventSubscription

TODO: Implement a real OnGroupRegistered function.

func (*BeaconChain) OnRelayEntryRequested

func (bc *BeaconChain) OnRelayEntryRequested(
	handler func(request *event.RelayEntryRequested),
) subscription.EventSubscription

TODO: Implement a real OnRelayEntryRequested function.

func (*BeaconChain) OnRelayEntrySubmitted

func (bc *BeaconChain) OnRelayEntrySubmitted(
	handler func(entry *event.RelayEntrySubmitted),
) subscription.EventSubscription

TODO: Implement a real OnRelayEntrySubmitted function.

func (BeaconChain) OperatorKeyPair

func (bc BeaconChain) OperatorKeyPair() (
	*operator.PrivateKey,
	*operator.PublicKey,
	error,
)

OperatorKeyPair returns the key pair of the operator assigned to this chain handle.

func (*BeaconChain) OperatorToStakingProvider

func (bc *BeaconChain) OperatorToStakingProvider() (chain.Address, bool, error)

OperatorToStakingProvider returns the staking provider address for the operator. If the staking provider has not been registered for the operator, the returned address is empty and the boolean flag is set to false If the staking provider has been registered, the address is not empty and the boolean flag indicates true.

func (*BeaconChain) ReportRelayEntryTimeout

func (bc *BeaconChain) ReportRelayEntryTimeout() error

TODO: Implement a real ReportRelayEntryTimeout function.

func (*BeaconChain) RestoreRewardEligibility

func (bc *BeaconChain) RestoreRewardEligibility() error

Restores reward eligibility for the operator.

func (BeaconChain) RolesOf

func (bc BeaconChain) RolesOf(stakingProvider chain.Address) (
	owner, beneficiary, authorizer chain.Address, hasStake bool, err error,
)

RolesOf returns the stake owner, the beneficiary and the authorizer for the specified staking provider address. If the owner is set, the function considers the staking provider to have a stake delegation and returns the boolean flag set to true.

func (*BeaconChain) SelectGroup

func (bc *BeaconChain) SelectGroup(seed *big.Int) (chain.Addresses, error)

SelectGroup returns the group members for the group generated by the given seed. This function can return an error if the beacon chain's state does not allow for group selection at the moment.

func (BeaconChain) Signing

func (bc BeaconChain) Signing() chain.Signing

func (*BeaconChain) Staking

func (bc *BeaconChain) Staking() (chain.Address, error)

Staking returns address of the TokenStaking contract the RandomBeacon is connected to.

func (*BeaconChain) SubmitDKGResult

func (bc *BeaconChain) SubmitDKGResult(
	participantIndex beaconchain.GroupMemberIndex,
	dkgResult *beaconchain.DKGResult,
	signatures map[beaconchain.GroupMemberIndex][]byte,
) error

TODO: Implement a real SubmitDKGResult action. The current implementation just creates and pipes the DKG submission event to the handlers registered in the dkgResultSubmissionHandlers map.

func (*BeaconChain) SubmitRelayEntry

func (bc *BeaconChain) SubmitRelayEntry(
	entry []byte,
) error

TODO: Implement a real SubmitRelayEntry function.

func (*BeaconChain) UpdateOperatorStatus

func (bc *BeaconChain) UpdateOperatorStatus() error

UpdateOperatorStatus executes a transaction to update the operator's state in the sortition pool.

type BitcoinDifficultyChain

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

BitcoinDifficultyChain represents a Bitcoin difficulty-specific chain handle.

func ConnectBitcoinDifficulty

func ConnectBitcoinDifficulty(
	ctx context.Context,
	ethereumConfig ethereum.Config,
	maintainerConfig maintainer.Config,
) (
	*BitcoinDifficultyChain,
	error,
)

ConnectBitcoinDifficulty creates Bitcoin difficulty chain handle.

func NewBitcoinDifficultyChain

func NewBitcoinDifficultyChain(
	ethereumConfig ethereum.Config,
	maintainerConfig maintainer.Config,
	baseChain *baseChain,
) (*BitcoinDifficultyChain, error)

NewBitcoinDifficultyChain construct a new instance of the Bitcoin difficulty - specific Ethereum chain handle.

func (BitcoinDifficultyChain) AverageBlockTime

func (bc BitcoinDifficultyChain) AverageBlockTime() time.Duration

func (BitcoinDifficultyChain) BlockCounter

func (bc BitcoinDifficultyChain) BlockCounter() (chain.BlockCounter, error)

func (*BitcoinDifficultyChain) CurrentEpoch

func (bdc *BitcoinDifficultyChain) CurrentEpoch() (uint64, error)

CurrentEpoch returns the number of the latest difficulty epoch which is proven to the relay. If the genesis epoch's number is set correctly, and retargets along the way have been legitimate, this equals the height of the block starting the most recent epoch, divided by 2016.

func (BitcoinDifficultyChain) GetBlockHashByNumber

func (bc BitcoinDifficultyChain) GetBlockHashByNumber(blockNumber uint64) (
	[32]byte,
	error,
)

GetBlockHashByNumber gets the block hash for the given block number.

func (BitcoinDifficultyChain) GetBlockNumberByTimestamp

func (bc BitcoinDifficultyChain) GetBlockNumberByTimestamp(
	timestamp uint64,
) (uint64, error)

GetBlockNumberByTimestamp gets the block number for the given timestamp. In the best case, the block with the exact same timestamp is returned. If the aforementioned is not possible, it tries to return the closest possible block.

WARNING: THIS FUNCTION MAY NOT BE PERFORMANT FOR BLOCKS EARLIER THAN 15537393 (SEPTEMBER 15, 2022, AT 1:42:42 EST) BEFORE THE ETH2 MERGE. PRE-MERGE AVERAGE BLOCK TIME WAS HIGHER THAN THE VALUE ASSUMED WITHIN THIS FUNCTION SO MORE OVERSHOOTS WILL BE DONE DURING THE BLOCK PREDICTION. OVERSHOOTS MUST BE COMPENSATED BY ADDITIONAL CLIENT CALLS THAT TAKE TIME.

func (*BitcoinDifficultyChain) GetCurrentAndPrevEpochDifficulty

func (bdc *BitcoinDifficultyChain) GetCurrentAndPrevEpochDifficulty() (
	*big.Int, *big.Int, error,
)

GetCurrentAndPrevEpochDifficulty returns the difficulties of the current and previous Bitcoin epochs.

func (*BitcoinDifficultyChain) IsAuthorized

func (bdc *BitcoinDifficultyChain) IsAuthorized(address chain.Address) (bool, error)

IsAuthorized checks whether the given address has been authorized to submit a retarget directly to LightRelay. This function should be used when retargetting via LightRelayMaintainerProxy is disabled.

func (*BitcoinDifficultyChain) IsAuthorizedForRefund

func (bdc *BitcoinDifficultyChain) IsAuthorizedForRefund(address chain.Address) (bool, error)

IsAuthorizedForRefund checks whether the given address has been authorized to submit a retarget via LightRelayMaintainerProxy. This function should be used when retargetting via LightRelayMaintainerProxy is not disabled.

func (BitcoinDifficultyChain) OperatorKeyPair

func (bc BitcoinDifficultyChain) OperatorKeyPair() (
	*operator.PrivateKey,
	*operator.PublicKey,
	error,
)

OperatorKeyPair returns the key pair of the operator assigned to this chain handle.

func (*BitcoinDifficultyChain) ProofLength

func (bdc *BitcoinDifficultyChain) ProofLength() (uint64, error)

ProofLength returns the number of blocks required for each side of a retarget proof.

func (*BitcoinDifficultyChain) Ready

func (bdc *BitcoinDifficultyChain) Ready() (bool, error)

Ready checks whether the relay is active (i.e. genesis has been performed). Note that if the relay is used by querying the current and previous epoch difficulty, at least one retarget needs to be provided after genesis; otherwise the prevEpochDifficulty will be uninitialised and zero.

func (*BitcoinDifficultyChain) Retarget

func (bdc *BitcoinDifficultyChain) Retarget(headers []*bitcoin.BlockHeader) error

Retarget adds a new epoch to the relay by providing a proof of the difficulty before and after the retarget. The cost of calling this function is not refunded to the caller.

func (*BitcoinDifficultyChain) RetargetWithRefund

func (bdc *BitcoinDifficultyChain) RetargetWithRefund(headers []*bitcoin.BlockHeader) error

RetargetWithRefund adds a new epoch to the relay by providing a proof of the difficulty before and after the retarget. The cost of calling this function is refunded to the caller.

func (BitcoinDifficultyChain) RolesOf

func (bc BitcoinDifficultyChain) RolesOf(stakingProvider chain.Address) (
	owner, beneficiary, authorizer chain.Address, hasStake bool, err error,
)

RolesOf returns the stake owner, the beneficiary and the authorizer for the specified staking provider address. If the owner is set, the function considers the staking provider to have a stake delegation and returns the boolean flag set to true.

func (BitcoinDifficultyChain) Signing

func (bc BitcoinDifficultyChain) Signing() chain.Signing

type Command

type Command struct {
	cobra.Command
	// contains filtered or unexported fields
}

Command if a wrapper for cobra.Command that holds Ethereum config used by the generated sub-commands to initialize the Ethereum chain connection.

func (*Command) GetConfig

func (c *Command) GetConfig() *commonEthereum.Config

GetConfig returns the Ethereum config.

func (*Command) SetConfig

func (c *Command) SetConfig(config *commonEthereum.Config)

SetConfig is used to set the ethereum configuration that is used by the generated sub-commands to initialize the Ethereum chain connection.

type TbtcChain

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

TbtcChain represents a TBTC-specific chain handle.

func (*TbtcChain) ApproveDKGResult

func (tc *TbtcChain) ApproveDKGResult(dkgResult *tbtc.DKGChainResult) error

func (*TbtcChain) AssembleDKGResult

func (tc *TbtcChain) AssembleDKGResult(
	submitterMemberIndex group.MemberIndex,
	groupPublicKey *ecdsa.PublicKey,
	operatingMembersIndexes []group.MemberIndex,
	misbehavedMembersIndexes []group.MemberIndex,
	signatures map[group.MemberIndex][]byte,
	groupSelectionResult *tbtc.GroupSelectionResult,
) (*tbtc.DKGChainResult, error)

AssembleDKGResult assembles the DKG chain result according to the rules expected by the given chain.

func (*TbtcChain) AssembleInactivityClaim

func (tc *TbtcChain) AssembleInactivityClaim(
	walletID [32]byte,
	inactiveMembersIndices []group.MemberIndex,
	signatures map[group.MemberIndex][]byte,
	heartbeatFailed bool,
) (
	*tbtc.InactivityClaim,
	error,
)

func (TbtcChain) AverageBlockTime

func (bc TbtcChain) AverageBlockTime() time.Duration

func (TbtcChain) BlockCounter

func (bc TbtcChain) BlockCounter() (chain.BlockCounter, error)

func (*TbtcChain) BuildDepositKey

func (tc *TbtcChain) BuildDepositKey(
	fundingTxHash bitcoin.Hash,
	fundingOutputIndex uint32,
) *big.Int

func (*TbtcChain) BuildRedemptionKey

func (tc *TbtcChain) BuildRedemptionKey(
	walletPublicKeyHash [20]byte,
	redeemerOutputScript bitcoin.Script,
) (*big.Int, error)

func (*TbtcChain) CalculateDKGResultSignatureHash

func (tc *TbtcChain) CalculateDKGResultSignatureHash(
	groupPublicKey *ecdsa.PublicKey,
	misbehavedMembersIndexes []group.MemberIndex,
	startBlock uint64,
) (dkg.ResultSignatureHash, error)

CalculateDKGResultSignatureHash calculates a 32-byte hash that is used to produce a signature supporting the given groupPublicKey computed as result of the given DKG process. The misbehavedMembersIndexes parameter should contain indexes of members that were considered as misbehaved during the DKG process. The startBlock argument is the block at which the given DKG process started.

func (*TbtcChain) CalculateInactivityClaimHash

func (tc *TbtcChain) CalculateInactivityClaimHash(
	claim *inactivity.ClaimPreimage,
) (inactivity.ClaimHash, error)

func (*TbtcChain) CalculateWalletID

func (tc *TbtcChain) CalculateWalletID(
	walletPublicKey *ecdsa.PublicKey,
) ([32]byte, error)

func (*TbtcChain) CanRestoreRewardEligibility

func (tc *TbtcChain) CanRestoreRewardEligibility() (bool, error)

Checks whether the operator is able to restore their eligibility for rewards right away.

func (*TbtcChain) ChallengeDKGResult

func (tc *TbtcChain) ChallengeDKGResult(dkgResult *tbtc.DKGChainResult) error

func (*TbtcChain) ComputeMainUtxoHash

func (tc *TbtcChain) ComputeMainUtxoHash(
	mainUtxo *bitcoin.UnspentTransactionOutput,
) [32]byte

func (*TbtcChain) ComputeMovingFundsCommitmentHash

func (tc *TbtcChain) ComputeMovingFundsCommitmentHash(
	targetWallets [][20]byte,
) [32]byte

func (*TbtcChain) DKGParameters

func (tc *TbtcChain) DKGParameters() (*tbtc.DKGParameters, error)

func (*TbtcChain) EligibleStake

func (tc *TbtcChain) EligibleStake(stakingProvider chain.Address) (*big.Int, error)

EligibleStake returns the current value of the staking provider's eligible stake. Eligible stake is defined as the currently authorized stake minus the pending authorization decrease. Eligible stake is what is used for operator's weight in the sortition pool. If the authorized stake minus the pending authorization decrease is below the minimum authorization, eligible stake is 0.

func (TbtcChain) GetBlockHashByNumber

func (bc TbtcChain) GetBlockHashByNumber(blockNumber uint64) (
	[32]byte,
	error,
)

GetBlockHashByNumber gets the block hash for the given block number.

func (TbtcChain) GetBlockNumberByTimestamp

func (bc TbtcChain) GetBlockNumberByTimestamp(
	timestamp uint64,
) (uint64, error)

GetBlockNumberByTimestamp gets the block number for the given timestamp. In the best case, the block with the exact same timestamp is returned. If the aforementioned is not possible, it tries to return the closest possible block.

WARNING: THIS FUNCTION MAY NOT BE PERFORMANT FOR BLOCKS EARLIER THAN 15537393 (SEPTEMBER 15, 2022, AT 1:42:42 EST) BEFORE THE ETH2 MERGE. PRE-MERGE AVERAGE BLOCK TIME WAS HIGHER THAN THE VALUE ASSUMED WITHIN THIS FUNCTION SO MORE OVERSHOOTS WILL BE DONE DURING THE BLOCK PREDICTION. OVERSHOOTS MUST BE COMPENSATED BY ADDITIONAL CLIENT CALLS THAT TAKE TIME.

func (*TbtcChain) GetDKGState

func (tc *TbtcChain) GetDKGState() (tbtc.DKGState, error)

func (*TbtcChain) GetDepositMinAge

func (tc *TbtcChain) GetDepositMinAge() (uint32, error)

func (*TbtcChain) GetDepositParameters

func (tc *TbtcChain) GetDepositParameters() (
	dustThreshold uint64,
	treasuryFeeDivisor uint64,
	txMaxFee uint64,
	revealAheadPeriod uint32,
	err error,
)

func (*TbtcChain) GetDepositRequest

func (tc *TbtcChain) GetDepositRequest(
	fundingTxHash bitcoin.Hash,
	fundingOutputIndex uint32,
) (*tbtc.DepositChainRequest, bool, error)

func (*TbtcChain) GetDepositSweepMaxSize

func (tc *TbtcChain) GetDepositSweepMaxSize() (uint16, error)

func (*TbtcChain) GetInactivityClaimNonce

func (tc *TbtcChain) GetInactivityClaimNonce(
	walletID [32]byte,
) (*big.Int, error)

func (*TbtcChain) GetLiveWalletsCount

func (tc *TbtcChain) GetLiveWalletsCount() (uint32, error)

func (*TbtcChain) GetMovedFundsSweepRequest

func (tc *TbtcChain) GetMovedFundsSweepRequest(
	movingFundsTxHash bitcoin.Hash,
	movingFundsTxOutpointIndex uint32,
) (*tbtc.MovedFundsSweepRequest, bool, error)

func (*TbtcChain) GetMovingFundsParameters

func (tc *TbtcChain) GetMovingFundsParameters() (
	txMaxTotalFee uint64,
	dustThreshold uint64,
	timeoutResetDelay uint32,
	timeout uint32,
	timeoutSlashingAmount *big.Int,
	timeoutNotifierRewardMultiplier uint32,
	commitmentGasOffset uint16,
	sweepTxMaxTotalFee uint64,
	sweepTimeout uint32,
	sweepTimeoutSlashingAmount *big.Int,
	sweepTimeoutNotifierRewardMultiplier uint32,
	err error,
)

func (*TbtcChain) GetOperatorID

func (tc *TbtcChain) GetOperatorID(
	operatorAddress chain.Address,
) (chain.OperatorID, error)

GetOperatorID returns the ID number of the given operator address. An ID number of 0 means the operator has not been allocated an ID number yet.

func (*TbtcChain) GetPendingRedemptionRequest

func (tc *TbtcChain) GetPendingRedemptionRequest(
	walletPublicKeyHash [20]byte,
	redeemerOutputScript bitcoin.Script,
) (*tbtc.RedemptionRequest, bool, error)

func (*TbtcChain) GetRedemptionDelay

func (tc *TbtcChain) GetRedemptionDelay(
	walletPublicKeyHash [20]byte,
	redeemerOutputScript bitcoin.Script,
) (time.Duration, error)

func (*TbtcChain) GetRedemptionMaxSize

func (tc *TbtcChain) GetRedemptionMaxSize() (uint16, error)

func (*TbtcChain) GetRedemptionParameters

func (tc *TbtcChain) GetRedemptionParameters() (
	dustThreshold uint64,
	treasuryFeeDivisor uint64,
	txMaxFee uint64,
	txMaxTotalFee uint64,
	timeout uint32,
	timeoutSlashingAmount *big.Int,
	timeoutNotifierRewardMultiplier uint32,
	err error,
)

func (*TbtcChain) GetRedemptionRequestMinAge

func (tc *TbtcChain) GetRedemptionRequestMinAge() (uint32, error)

func (*TbtcChain) GetWallet

func (tc *TbtcChain) GetWallet(
	walletPublicKeyHash [20]byte,
) (*tbtc.WalletChainData, error)

func (*TbtcChain) GetWalletParameters

func (tc *TbtcChain) GetWalletParameters() (
	creationPeriod uint32,
	creationMinBtcBalance uint64,
	creationMaxBtcBalance uint64,
	closureMinBtcBalance uint64,
	maxAge uint32,
	maxBtcTransfer uint64,
	closingPeriod uint32,
	err error,
)

func (*TbtcChain) IsBetaOperator

func (tc *TbtcChain) IsBetaOperator() (bool, error)

Returns true if operator is a beta operator, false otherwise. Chaosnet status does not matter.

func (*TbtcChain) IsChaosnetActive

func (tc *TbtcChain) IsChaosnetActive() (bool, error)

Returns true if the chaosnet phase is active, false otherwise.

func (*TbtcChain) IsDKGResultValid

func (tc *TbtcChain) IsDKGResultValid(
	dkgResult *tbtc.DKGChainResult,
) (bool, error)

func (*TbtcChain) IsEligibleForRewards

func (tc *TbtcChain) IsEligibleForRewards() (bool, error)

IsEligibleForRewards checks whether the operator is eligible for rewards or not.

func (*TbtcChain) IsOperatorInPool

func (tc *TbtcChain) IsOperatorInPool() (bool, error)

IsOperatorInPool returns true if the operator is registered in the sortition pool.

func (*TbtcChain) IsOperatorUpToDate

func (tc *TbtcChain) IsOperatorUpToDate() (bool, error)

IsOperatorUpToDate checks if the operator's authorized stake is in sync with operator's weight in the sortition pool. If the operator's authorized stake is not in sync with sortition pool weight, function returns false. If the operator is not in the sortition pool and their authorized stake is non-zero, function returns false.

func (*TbtcChain) IsPoolLocked

func (tc *TbtcChain) IsPoolLocked() (bool, error)

IsPoolLocked returns true if the sortition pool is locked and no state changes are allowed.

func (*TbtcChain) IsRecognized

func (tc *TbtcChain) IsRecognized(operatorPublicKey *operator.PublicKey) (bool, error)

IsRecognized checks whether the given operator is recognized by the TbtcChain as eligible to join the network. If the operator has a stake delegation or had a stake delegation in the past, it will be recognized.

func (*TbtcChain) IsWalletRegistered

func (tc *TbtcChain) IsWalletRegistered(EcdsaWalletID [32]byte) (bool, error)

func (*TbtcChain) JoinSortitionPool

func (tc *TbtcChain) JoinSortitionPool() error

JoinSortitionPool executes a transaction to have the operator join the sortition pool.

func (*TbtcChain) OnDKGResultApproved

func (tc *TbtcChain) OnDKGResultApproved(
	handler func(event *tbtc.DKGResultApprovedEvent),
) subscription.EventSubscription

func (*TbtcChain) OnDKGResultChallenged

func (tc *TbtcChain) OnDKGResultChallenged(
	handler func(event *tbtc.DKGResultChallengedEvent),
) subscription.EventSubscription

func (*TbtcChain) OnDKGResultSubmitted

func (tc *TbtcChain) OnDKGResultSubmitted(
	handler func(event *tbtc.DKGResultSubmittedEvent),
) subscription.EventSubscription

func (*TbtcChain) OnDKGStarted

func (tc *TbtcChain) OnDKGStarted(
	handler func(event *tbtc.DKGStartedEvent),
) subscription.EventSubscription

func (*TbtcChain) OnInactivityClaimed

func (tc *TbtcChain) OnInactivityClaimed(
	handler func(event *tbtc.InactivityClaimedEvent),
) subscription.EventSubscription

func (*TbtcChain) OnWalletClosed

func (tc *TbtcChain) OnWalletClosed(
	handler func(event *tbtc.WalletClosedEvent),
) subscription.EventSubscription

func (TbtcChain) OperatorKeyPair

func (bc TbtcChain) OperatorKeyPair() (
	*operator.PrivateKey,
	*operator.PublicKey,
	error,
)

OperatorKeyPair returns the key pair of the operator assigned to this chain handle.

func (*TbtcChain) OperatorToStakingProvider

func (tc *TbtcChain) OperatorToStakingProvider() (chain.Address, bool, error)

OperatorToStakingProvider returns the staking provider address for the operator. If the staking provider has not been registered for the operator, the returned address is empty and the boolean flag is set to false. If the staking provider has been registered, the address is not empty and the boolean flag indicates true.

func (*TbtcChain) PastDKGStartedEvents

func (tc *TbtcChain) PastDKGStartedEvents(
	filter *tbtc.DKGStartedEventFilter,
) ([]*tbtc.DKGStartedEvent, error)

func (*TbtcChain) PastDepositRevealedEvents

func (tc *TbtcChain) PastDepositRevealedEvents(
	filter *tbtc.DepositRevealedEventFilter,
) ([]*tbtc.DepositRevealedEvent, error)

func (*TbtcChain) PastMovingFundsCommitmentSubmittedEvents

func (tc *TbtcChain) PastMovingFundsCommitmentSubmittedEvents(
	filter *tbtc.MovingFundsCommitmentSubmittedEventFilter,
) ([]*tbtc.MovingFundsCommitmentSubmittedEvent, error)

func (*TbtcChain) PastMovingFundsCompletedEvents

func (tc *TbtcChain) PastMovingFundsCompletedEvents(
	filter *tbtc.MovingFundsCompletedEventFilter,
) ([]*tbtc.MovingFundsCompletedEvent, error)

func (*TbtcChain) PastNewWalletRegisteredEvents

func (tc *TbtcChain) PastNewWalletRegisteredEvents(
	filter *tbtc.NewWalletRegisteredEventFilter,
) ([]*tbtc.NewWalletRegisteredEvent, error)

func (*TbtcChain) PastRedemptionRequestedEvents

func (tc *TbtcChain) PastRedemptionRequestedEvents(
	filter *tbtc.RedemptionRequestedEventFilter,
) ([]*tbtc.RedemptionRequestedEvent, error)

func (*TbtcChain) RestoreRewardEligibility

func (tc *TbtcChain) RestoreRewardEligibility() error

Restores reward eligibility for the operator.

func (TbtcChain) RolesOf

func (bc TbtcChain) RolesOf(stakingProvider chain.Address) (
	owner, beneficiary, authorizer chain.Address, hasStake bool, err error,
)

RolesOf returns the stake owner, the beneficiary and the authorizer for the specified staking provider address. If the owner is set, the function considers the staking provider to have a stake delegation and returns the boolean flag set to true.

func (*TbtcChain) SelectGroup

func (tc *TbtcChain) SelectGroup() (*tbtc.GroupSelectionResult, error)

SelectGroup returns the group members selected for the current group selection. The function returns an error if the chain's state does not allow for group selection at the moment.

func (TbtcChain) Signing

func (bc TbtcChain) Signing() chain.Signing

func (*TbtcChain) Staking

func (tc *TbtcChain) Staking() (chain.Address, error)

Staking returns address of the TokenStaking contract the WalletRegistry is connected to.

func (*TbtcChain) SubmitDKGResult

func (tc *TbtcChain) SubmitDKGResult(
	dkgResult *tbtc.DKGChainResult,
) error

func (*TbtcChain) SubmitDepositSweepProofWithReimbursement

func (tc *TbtcChain) SubmitDepositSweepProofWithReimbursement(
	transaction *bitcoin.Transaction,
	proof *bitcoin.SpvProof,
	mainUTXO bitcoin.UnspentTransactionOutput,
	vault common.Address,
) error

func (*TbtcChain) SubmitInactivityClaim

func (tc *TbtcChain) SubmitInactivityClaim(
	claim *tbtc.InactivityClaim,
	nonce *big.Int,
	groupMembers []uint32,
) error

func (*TbtcChain) SubmitMovedFundsSweepProofWithReimbursement

func (tc *TbtcChain) SubmitMovedFundsSweepProofWithReimbursement(
	transaction *bitcoin.Transaction,
	proof *bitcoin.SpvProof,
	mainUTXO bitcoin.UnspentTransactionOutput,
) error

func (*TbtcChain) SubmitMovingFundsCommitment

func (tc *TbtcChain) SubmitMovingFundsCommitment(
	walletPublicKeyHash [20]byte,
	walletMainUTXO bitcoin.UnspentTransactionOutput,
	walletMembersIDs []uint32,
	walletMemberIndex uint32,
	targetWallets [][20]byte,
) error

func (*TbtcChain) SubmitMovingFundsProofWithReimbursement

func (tc *TbtcChain) SubmitMovingFundsProofWithReimbursement(
	transaction *bitcoin.Transaction,
	proof *bitcoin.SpvProof,
	mainUTXO bitcoin.UnspentTransactionOutput,
	walletPublicKeyHash [20]byte,
) error

func (*TbtcChain) SubmitRedemptionProofWithReimbursement

func (tc *TbtcChain) SubmitRedemptionProofWithReimbursement(
	transaction *bitcoin.Transaction,
	proof *bitcoin.SpvProof,
	mainUTXO bitcoin.UnspentTransactionOutput,
	walletPublicKeyHash [20]byte,
) error

func (*TbtcChain) TxProofDifficultyFactor

func (tc *TbtcChain) TxProofDifficultyFactor() (*big.Int, error)

func (*TbtcChain) UpdateOperatorStatus

func (tc *TbtcChain) UpdateOperatorStatus() error

UpdateOperatorStatus executes a transaction to update the operator's state in the sortition pool.

func (*TbtcChain) ValidateDepositSweepProposal

func (tc *TbtcChain) ValidateDepositSweepProposal(
	walletPublicKeyHash [20]byte,
	proposal *tbtc.DepositSweepProposal,
	depositsExtraInfo []struct {
		*tbtc.Deposit
		FundingTx *bitcoin.Transaction
	},
) error

func (*TbtcChain) ValidateHeartbeatProposal

func (tc *TbtcChain) ValidateHeartbeatProposal(
	walletPublicKeyHash [20]byte,
	proposal *tbtc.HeartbeatProposal,
) error

func (*TbtcChain) ValidateMovedFundsSweepProposal

func (tc *TbtcChain) ValidateMovedFundsSweepProposal(
	walletPublicKeyHash [20]byte,
	proposal *tbtc.MovedFundsSweepProposal,
) error

func (*TbtcChain) ValidateMovingFundsProposal

func (tc *TbtcChain) ValidateMovingFundsProposal(
	walletPublicKeyHash [20]byte,
	mainUTXO *bitcoin.UnspentTransactionOutput,
	proposal *tbtc.MovingFundsProposal,
) error

func (*TbtcChain) ValidateRedemptionProposal

func (tc *TbtcChain) ValidateRedemptionProposal(
	walletPublicKeyHash [20]byte,
	proposal *tbtc.RedemptionProposal,
) error

Directories

Path Synopsis
beacon
gen
ecdsa
gen
tbtc
gen
threshold
gen

Jump to

Keyboard shortcuts

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