evilwallet

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0, BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FaucetRequestSplitNumber defines the number of outputs to split from a faucet request.
	FaucetRequestSplitNumber = 100

	WaitForTxSolid = 150 * time.Second
)

Variables

This section is empty.

Functions

func RateSetterSleep

func RateSetterSleep(clt Client, useRateSetter bool) error

RateSetterSleep sleeps for the given rate.

func SplitBalanceEqually

func SplitBalanceEqually(splitNumber int, balance uint64) []uint64

SplitBalanceEqually splits the balance equally between `splitNumber` outputs.

Types

type AliasManager

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

AliasManager is the manager for output aliases.

func NewAliasManager

func NewAliasManager() *AliasManager

NewAliasManager creates and returns a new AliasManager.

func (*AliasManager) AddInputAlias

func (a *AliasManager) AddInputAlias(input devnetvm.Input, aliasName string)

AddInputAlias adds an input alias.

func (*AliasManager) AddInputAliases

func (a *AliasManager) AddInputAliases(inputs []*Output, aliases []string) error

AddInputAliases batch adds the inputs their respective aliases.

func (*AliasManager) AddOutputAlias

func (a *AliasManager) AddOutputAlias(output devnetvm.Output, aliasName string)

AddOutputAlias maps the given outputAliasName to output, if there's duplicate outputAliasName, it will be overwritten.

func (*AliasManager) AddOutputAliases

func (a *AliasManager) AddOutputAliases(outputs []devnetvm.Output, aliases []string) error

AddOutputAliases batch adds the outputs their respective aliases.

func (*AliasManager) ClearAliases

func (a *AliasManager) ClearAliases(aliases ScenarioAlias)

ClearAliases clears provided aliases.

func (*AliasManager) ClearAllAliases

func (a *AliasManager) ClearAllAliases()

ClearAllAliases clears all aliases.

func (*AliasManager) GetInput

func (a *AliasManager) GetInput(aliasName string) (devnetvm.Input, bool)

GetInput returns the input for the alias specified.

func (*AliasManager) GetOutput

func (a *AliasManager) GetOutput(aliasName string) devnetvm.Output

GetOutput returns the output for the alias specified.

type Client

type Client interface {
	// Url returns a client API url.
	Url() (cltID string)
	// GetRateSetterEstimate returns a rate setter estimate.
	GetRateSetterEstimate() (estimate time.Duration, err error)
	// SleepRateSetterEstimate sleeps for rate setter estimate.
	SleepRateSetterEstimate() (err error)
	// PostTransaction sends a transaction to the Mesh via a given client.
	PostTransaction(tx *devnetvm.Transaction) (utxo.TransactionID, error)
	// PostData sends the given data (payload) by creating a block in the backend.
	PostData(data []byte) (blkID string, err error)
	// GetUnspentOutputForAddress gets the first unspent outputs of a given address.
	GetUnspentOutputForAddress(addr devnetvm.Address) *jsonmodels.WalletOutput
	// GetAddressUnspentOutputs gets the unspent outputs of an address.
	GetAddressUnspentOutputs(address string) (outputIDs []utxo.OutputID, err error)
	// GetTransactionConfirmationState returns the ConfirmationState of a given transaction ID.
	GetTransactionConfirmationState(txID string) confirmation.State
	// GetOutput gets the output of a given outputID.
	GetOutput(outputID utxo.OutputID) devnetvm.Output
	// GetOutputConfirmationState gets the first unspent outputs of a given address.
	GetOutputConfirmationState(outputID utxo.OutputID) confirmation.State
	// BroadcastFaucetRequest requests funds from the faucet and returns the faucet request block ID.
	BroadcastFaucetRequest(address string) error
	// GetTransactionOutputs returns the outputs the transaction created.
	GetTransactionOutputs(txID string) (outputs devnetvm.Outputs, err error)
	// GetTransaction gets the transaction.
	GetTransaction(txID string) (resp *jsonmodels.Transaction, err error)
	// GetOutputSolidity checks if the transaction is solid.
	GetOutputSolidity(outID string) (solid bool, err error)
}

type ConflictSlice

type ConflictSlice [][]Option

ConflictSlice represents a set of conflict transactions.

type Connector

type Connector interface {
	// ServersStatuses retrieves the connected server status for each client.
	ServersStatuses() ServersStatus
	// ServerStatus retrieves the connected server status.
	ServerStatus(cltIdx int) (status *wallet.ServerStatus, err error)
	// Clients returns list of all clients.
	Clients(...bool) []Client
	// GetClients returns the numOfClt client instances that were used the longest time ago.
	GetClients(numOfClt int) []Client
	// AddClient adds client to WebClients based on provided ZIPPAPI url.
	AddClient(url string, setters ...client.Option)
	// RemoveClient removes client with the provided url from the WebClients.
	RemoveClient(url string)
	// GetClient returns the client instance that was used the longest time ago.
	GetClient() Client
	// PledgeID returns the node ID that the mana will be pledging to.
	PledgeID() *identity.ID
}

type EvilBatch

type EvilBatch [][]ScenarioAlias

func ConflictSetCircle

func ConflictSetCircle(size int) EvilBatch

ConflictSetCircle creates a circular conflict set for a given size, e.g. for size=3, conflict set: A-B-C-A.

func DoubleSpendBatch added in v0.1.2

func DoubleSpendBatch(spentNum int) EvilBatch

DoubleSpendBatch returns an EvilBatch that is a spentNum spend.

func GetScenario

func GetScenario(scenarioName string) (batch EvilBatch, ok bool)

GetScenario returns an evil batch based i=on its name.

func NSpendBatch

func NSpendBatch(nSpent int) EvilBatch

func NoConflictsScenario1

func NoConflictsScenario1() EvilBatch

NoConflictsScenario1 returns batch with no conflicts that is 3 levels deep.

func Scenario1

func Scenario1() EvilBatch

Scenario1 describes two double spends and aggregates them.

func Scenario2

func Scenario2() EvilBatch

Scenario2 is a reflection of UTXO unit test scenario example B - packages/ledgerstate/utxo_dag_test_exampleB.png

func Scenario3

func Scenario3() EvilBatch

Scenario3 is a reflection of UTXO unit test scenario example C - packages/ledgerstate/utxo_dag_test_exampleC.png

func Scenario4

func Scenario4() EvilBatch

Scenario4 is a reflection of ledgerstate unit test for conflict confirmation - packages/ledgerstate/ledgerstate_test_SetConflictConfirmed.png

func Scenario5

func Scenario5() EvilBatch

Scenario5 uses ConflictSetCircle with size 4 and aggregate its outputs.

func Scenario6

func Scenario6() EvilBatch

Scenario6 returns 5 levels deep scenario.

func Scenario7

func Scenario7() EvilBatch

Scenario7 three level deep scenario, with two separate conflict sets aggregated.

func SingleTransactionBatch

func SingleTransactionBatch() EvilBatch

SingleTransactionBatch returns an EvilBatch that is a single transaction.

type EvilScenario

type EvilScenario struct {
	ID string
	// provides a user-friendly way of listing input and output aliases
	ConflictBatch EvilBatch
	// determines whether outputs of the batch  should be reused during the spam to create deep UTXO tree structure.
	Reuse bool
	// if provided, the outputs from the spam will be saved into this wallet, accepted types of wallet: Reuse, RestrictedReuse.
	// if type == Reuse, then wallet is available for reuse spamming scenarios that did not provide RestrictedWallet.
	OutputWallet *Wallet
	// if provided and reuse set to true, outputs from this wallet will be used for deep spamming, allows for controllable building of UTXO deep structures.
	// if not provided evil wallet will use Reuse wallet if any is available. Accepts only RestrictedReuse wallet type.
	RestrictedInputWallet *Wallet
	// used together with scenario ID to create a prefix for distinct batch alias creation
	BatchesCreated     *atomic.Uint64
	NumOfClientsNeeded int
}

func NewEvilScenario

func NewEvilScenario(options ...ScenarioOption) *EvilScenario

func (*EvilScenario) ConflictBatchWithPrefix

func (e *EvilScenario) ConflictBatchWithPrefix() (prefixedBatch EvilBatch, allAliases ScenarioAlias, batchOutputs map[string]types.Empty)

ConflictBatchWithPrefix generates a new conflict batch with scenario prefix created from scenario ID and batch count. BatchOutputs are outputs of the batch that can be reused in deep spamming by collecting them in Reuse wallet.

type EvilWallet

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

EvilWallet provides a user-friendly way to do complicated double spend scenarios.

func NewEvilWallet

func NewEvilWallet(clientsUrls ...string) *EvilWallet

NewEvilWallet creates an EvilWallet instance.

func (*EvilWallet) AddClient

func (e *EvilWallet) AddClient(clientUrl string)

func (*EvilWallet) AddReuseOutputsToThePool

func (e *EvilWallet) AddReuseOutputsToThePool(outputs devnetvm.Outputs)

AddReuseOutputsToThePool adds all addresses corresponding to provided outputs to the reuse pool.

func (*EvilWallet) AwaitInputsSolidity

func (e *EvilWallet) AwaitInputsSolidity(inputs devnetvm.Inputs, clt Client) (allSolid bool)

AwaitInputsSolidity waits for all inputs to be solid for client clt.

func (*EvilWallet) ClearAliases

func (e *EvilWallet) ClearAliases(aliases ScenarioAlias)

ClearAliases remove only provided aliases from AliasManager.

func (*EvilWallet) ClearAllAliases

func (e *EvilWallet) ClearAllAliases()

ClearAllAliases remove all registered alias names.

func (*EvilWallet) Connector

func (e *EvilWallet) Connector() Connector

Connector give access to the EvilWallet connector.

func (*EvilWallet) CreateTransaction

func (e *EvilWallet) CreateTransaction(options ...Option) (tx *devnetvm.Transaction, err error)

CreateTransaction creates a transaction based on provided options. If no input wallet is provided, the next non-empty faucet wallet is used. Inputs of the transaction are determined in three ways: 1 - inputs are provided directly without associated alias, 2- alias is provided, and input is already stored in an alias manager, 3 - alias is provided, and there are no inputs assigned in Alias manager, so aliases are assigned to next ready inputs from input wallet.

func (*EvilWallet) GetClients

func (e *EvilWallet) GetClients(num int) []Client

GetClients returns the given number of clients.

func (*EvilWallet) NewWallet

func (e *EvilWallet) NewWallet(wType ...WalletType) *Wallet

NewWallet creates a new wallet of the given wallet type.

func (*EvilWallet) NumOfClient

func (e *EvilWallet) NumOfClient() int

func (*EvilWallet) PrepareCustomConflicts

func (e *EvilWallet) PrepareCustomConflicts(conflictsMaps []ConflictSlice) (conflictBatch [][]*devnetvm.Transaction, err error)

func (*EvilWallet) PrepareCustomConflictsSpam

func (e *EvilWallet) PrepareCustomConflictsSpam(scenario *EvilScenario) (txs [][]*devnetvm.Transaction, allAliases ScenarioAlias, err error)

func (*EvilWallet) RemoveClient

func (e *EvilWallet) RemoveClient(clientUrl string)

func (*EvilWallet) RequestFreshBigFaucetWallet

func (e *EvilWallet) RequestFreshBigFaucetWallet() (err error)

RequestFreshBigFaucetWallet creates a new wallet and fills the wallet with 10000 outputs created from funds requested from the Faucet.

func (*EvilWallet) RequestFreshBigFaucetWallets

func (e *EvilWallet) RequestFreshBigFaucetWallets(numberOfWallets int)

RequestFreshBigFaucetWallets creates n new wallets, each wallet is created from one faucet request and contains 10000 outputs.

func (*EvilWallet) RequestFreshFaucetWallet

func (e *EvilWallet) RequestFreshFaucetWallet() (err error)

RequestFreshFaucetWallet creates a new wallet and fills the wallet with 100 outputs created from funds requested from the Faucet.

func (*EvilWallet) RequestFundsFromFaucet

func (e *EvilWallet) RequestFundsFromFaucet(options ...FaucetRequestOption) (err error, initWallet *Wallet)

RequestFundsFromFaucet requests funds from the faucet, then track the confirmed status of unspent output, also register the alias name for the unspent output if provided.

func (*EvilWallet) SendCustomConflicts

func (e *EvilWallet) SendCustomConflicts(conflictsMaps []ConflictSlice) (err error)

SendCustomConflicts sends transactions with the given conflictsMaps.

func (*EvilWallet) SetTxOutputsSolid

func (e *EvilWallet) SetTxOutputsSolid(outputs devnetvm.Outputs, clientID string)

SetTxOutputsSolid marks all outputs as solid in OutputManager for clientID.

func (*EvilWallet) UnspentOutputsLeft

func (e *EvilWallet) UnspentOutputsLeft(walletType WalletType) int

type FaucetRequestOption

type FaucetRequestOption func(*FaucetRequestOptions)

FaucetRequestOption is an option for faucet request.

func WithOutputAlias

func WithOutputAlias(aliasName string) FaucetRequestOption

WithOutputAlias returns an Option that is used to provide the Output of the Transaction.

type FaucetRequestOptions

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

FaucetRequestOptions is options for faucet request.

func NewFaucetRequestOptions

func NewFaucetRequestOptions(options ...FaucetRequestOption) *FaucetRequestOptions

NewFaucetRequestOptions creates options for a faucet request.

type Option

type Option func(*Options)

Option is the type that is used for options that can be passed into the CreateBlock method to configure its behavior.

func WithInputs

func WithInputs(inputs interface{}) Option

WithInputs returns an Option that is used to provide the Inputs of the Transaction.

func WithIssuer

func WithIssuer(issuer *Wallet) Option

WithIssuer returns a BlockOption that is used to define the inputWallet of the Block.

func WithIssuingTime

func WithIssuingTime(issuingTime time.Time) Option

WithIssuingTime returns a BlockOption that is used to set issuing time of the Block.

func WithOutput

func WithOutput(output *OutputOption) Option

WithOutput returns an Option that is used to define a non-colored Output for the Transaction in the Block.

func WithOutputBatchAliases

func WithOutputBatchAliases(outputAliases map[string]types.Empty) Option

WithOutputBatchAliases returns a BlockOption that is used to determine which outputs should be added to the outWallet.

func WithOutputWallet

func WithOutputWallet(wallet *Wallet) Option

WithOutputWallet returns a BlockOption that is used to define the inputWallet of the Block.

func WithOutputs

func WithOutputs(outputs []*OutputOption) Option

WithOutputs returns an Option that is used to define a non-colored Outputs for the Transaction in the Block.

func WithReuseOutputs

func WithReuseOutputs() Option

WithReuseOutputs returns a BlockOption that is used to enable deep spamming with Reuse wallet outputs.

type Options

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

Options is a struct that represents a collection of options that can be set when creating a block

func NewOptions

func NewOptions(options ...Option) (option *Options, err error)

NewOptions is the constructor for the tx creation.

type Output

type Output struct {
	// *wallet.Output
	OutputID utxo.OutputID
	Address  devnetvm.Address
	Index    uint64
	Balance  *devnetvm.ColoredBalances
}

Output contains details of an output ID.

type OutputManager

type OutputManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

OutputManager keeps track of the output statuses.

func NewOutputManager

func NewOutputManager(connector Connector, wallets *Wallets) *OutputManager

NewOutputManager creates an OutputManager instance.

func (*OutputManager) AddOutput

func (o *OutputManager) AddOutput(w *Wallet, output devnetvm.Output) *Output

AddOutput adds existing output from wallet w to the OutputManager.

func (*OutputManager) AwaitOutputToBeAccepted

func (o *OutputManager) AwaitOutputToBeAccepted(outputID utxo.OutputID, waitFor time.Duration) (accepted bool)

AwaitOutputToBeAccepted awaits for output from a provided outputID is accepted. Timeout is waitFor. Useful when we have only an address and no transactionID, e.g. faucet funds request.

func (*OutputManager) AwaitOutputToBeSolid

func (o *OutputManager) AwaitOutputToBeSolid(outID string, clt Client, waitFor time.Duration) error

AwaitOutputToBeSolid awaits for solidification of a single output by provided clt.

func (*OutputManager) AwaitOutputsToBeSolid

func (o *OutputManager) AwaitOutputsToBeSolid(outputs []string, clt Client, maxGoroutines int) (allSolid bool)

AwaitOutputsToBeSolid awaits for all provided outputs are solid for a provided client.

func (*OutputManager) AwaitTransactionToBeAccepted

func (o *OutputManager) AwaitTransactionToBeAccepted(txID string, waitFor time.Duration) error

AwaitTransactionToBeAccepted awaits for acceptance of a single transaction.

func (*OutputManager) AwaitTransactionsConfirmation

func (o *OutputManager) AwaitTransactionsConfirmation(txIDs []string, maxGoroutines int)

AwaitTransactionsConfirmation awaits for transaction confirmation and updates wallet with outputIDs.

func (*OutputManager) AwaitWalletOutputsToBeConfirmed

func (o *OutputManager) AwaitWalletOutputsToBeConfirmed(wallet *Wallet)

AwaitWalletOutputsToBeConfirmed awaits for all outputs in the wallet are confirmed.

func (*OutputManager) CreateOutputFromAddress

func (o *OutputManager) CreateOutputFromAddress(w *Wallet, addr address.Address, balance *devnetvm.ColoredBalances) *Output

CreateOutputFromAddress creates output, retrieves outputID, and adds it to the wallet. Provided address should be generated from provided wallet. Considers only first output found on address.

func (*OutputManager) GetOutput

func (o *OutputManager) GetOutput(outputID utxo.OutputID) (output *Output)

GetOutput returns the Output of the given outputID. Firstly checks if output can be retrieved by outputManager from wallet, if not does an API call.

func (*OutputManager) IssuerSolidOutIDMap

func (o *OutputManager) IssuerSolidOutIDMap(issuer, outputID string) (isSolid bool)

IssuerSolidOutIDMap checks whether output was marked as solid for a given node.

func (*OutputManager) OutputIDAddrMap

func (o *OutputManager) OutputIDAddrMap(outputID string) (addr string)

OutputIDAddrMap returns address corresponding to the outputID stored in OutputManager.

func (*OutputManager) OutputIDWalletMap

func (o *OutputManager) OutputIDWalletMap(outputID string) *Wallet

OutputIDWalletMap returns wallet corresponding to the outputID stored in OutputManager.

func (*OutputManager) RequestOutputsByAddress

func (o *OutputManager) RequestOutputsByAddress(address string) (outputIDs []utxo.OutputID)

RequestOutputsByAddress finds the unspent outputs of a given address and updates the provided output status map.

func (*OutputManager) RequestOutputsByTxID

func (o *OutputManager) RequestOutputsByTxID(txID string) (outputIDs []utxo.OutputID)

RequestOutputsByTxID adds the outputs of a given transaction to the output status map.

func (*OutputManager) SetOutputIDSolidForIssuer

func (o *OutputManager) SetOutputIDSolidForIssuer(outputID string, issuer string)

SetOutputIDSolidForIssuer sets solid flag for the provided outputID and issuer.

func (*OutputManager) Track

func (o *OutputManager) Track(outputIDs []utxo.OutputID) (allConfirmed bool)

Track the confirmed statuses of the given outputIDs, it returns true if all of them are confirmed.

type OutputOption

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

type Outputs

type Outputs []*Output

Outputs is a list of Output.

type ScenarioAlias

type ScenarioAlias struct {
	Inputs  []string
	Outputs []string
}

func NewScenarioAlias

func NewScenarioAlias() ScenarioAlias

type ScenarioOption

type ScenarioOption func(scenario *EvilScenario)

func WithScenarioCustomConflicts

func WithScenarioCustomConflicts(batch EvilBatch) ScenarioOption

WithScenarioCustomConflicts specifies the EvilBatch that describes the UTXO structure that should be used for the spam.

func WithScenarioDeepSpamEnabled

func WithScenarioDeepSpamEnabled() ScenarioOption

WithScenarioDeepSpamEnabled enables deep spam, the outputs from available Reuse wallets or RestrictedReuse wallet if provided with WithReuseInputWalletForDeepSpam option will be used for spam instead fresh faucet outputs.

func WithScenarioInputWalletForDeepSpam

func WithScenarioInputWalletForDeepSpam(wallet *Wallet) ScenarioOption

WithScenarioInputWalletForDeepSpam reuse set to true, outputs from this wallet will be used for deep spamming, allows for controllable building of UTXO deep structures. Accepts only RestrictedReuse wallet type.

func WithScenarioReuseOutputWallet

func WithScenarioReuseOutputWallet(wallet *Wallet) ScenarioOption

WithScenarioReuseOutputWallet the outputs from the spam will be saved into this wallet, accepted types of wallet: Reuse, RestrictedReuse.

type ServersStatus

type ServersStatus []*wallet.ServerStatus

type Wallet

type Wallet struct {
	ID walletID

	*sync.RWMutex
	// contains filtered or unexported fields
}

Wallet is the definition of a wallet.

func NewWallet

func NewWallet(wType ...WalletType) *Wallet

NewWallet creates a wallet of a given type.

func (*Wallet) AddReuseAddress

func (w *Wallet) AddReuseAddress(addr string)

AddReuseAddress adds address to the reuse ready outputs' addresses pool for a Reuse wallet.

func (*Wallet) AddUnspentOutput

func (w *Wallet) AddUnspentOutput(addr devnetvm.Address, addrIdx uint64, outputID utxo.OutputID, balance *devnetvm.ColoredBalances) *Output

AddUnspentOutput adds an unspentOutput of a given wallet.

func (*Wallet) AddrIndexMap

func (w *Wallet) AddrIndexMap(outIndex string) uint64

AddrIndexMap returns the index for the address specified.

func (*Wallet) Address

func (w *Wallet) Address() address.Address

Address returns a new and unused address of a given wallet.

func (*Wallet) GetReuseAddress

func (w *Wallet) GetReuseAddress() string

GetReuseAddress get random address from reuse addresses reuseOutputsAddresses pool. Address is removed from the pool after selecting.

func (*Wallet) GetUnspentOutput

func (w *Wallet) GetUnspentOutput() *Output

GetUnspentOutput returns an unspent output on the oldest address ordered by index.

func (*Wallet) IndexAddrMap

func (w *Wallet) IndexAddrMap(outIndex uint64) string

IndexAddrMap returns the address for the index specified.

func (*Wallet) IsEmpty

func (w *Wallet) IsEmpty() (empty bool)

IsEmpty returns true if the wallet is empty.

func (*Wallet) Sign

Sign signs the tx essence.

func (*Wallet) Type

func (w *Wallet) Type() WalletType

Type returns the wallet type.

func (*Wallet) UnspentOutput

func (w *Wallet) UnspentOutput(addr string) *Output

UnspentOutput returns the unspent output on the address.

func (*Wallet) UnspentOutputBalance

func (w *Wallet) UnspentOutputBalance(addr string) *devnetvm.ColoredBalances

UnspentOutputBalance returns the balance on the unspent output sitting on the address specified.

func (*Wallet) UnspentOutputs

func (w *Wallet) UnspentOutputs() (outputs map[string]*Output)

UnspentOutputs returns all unspent outputs on the wallet.

func (*Wallet) UnspentOutputsLeft

func (w *Wallet) UnspentOutputsLeft() (left int)

UnspentOutputsLeft returns how many unused outputs are available in wallet.

func (*Wallet) UnspentOutputsLength

func (w *Wallet) UnspentOutputsLength() int

UnspentOutputsLength returns the number of unspent outputs on the wallet.

func (*Wallet) UpdateUnspentOutputID

func (w *Wallet) UpdateUnspentOutputID(addr string, outputID utxo.OutputID) error

UpdateUnspentOutputID updates the unspent output on the address specified.

type WalletStatus

type WalletStatus int8

type WalletType

type WalletType int8

WalletType is the type of the wallet.

const (
	Other WalletType = iota
	// Fresh is used for automatic Faucet Requests, outputs are returned one by one
	Fresh
	// Reuse stores resulting outputs of double spends or transactions issued by the evilWallet,
	// outputs from this wallet are reused in spamming scenario with flag reuse set to true and no RestrictedReuse wallet provided.
	// Reusing spammed outputs allows for creation of deeper UTXO DAG structure.
	Reuse
	// RestrictedReuse it is a reuse wallet, that will be available only to spamming scenarios that
	// will provide RestrictedWallet for the reuse spamming.
	RestrictedReuse
)

type Wallets

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

Wallets is a container of wallets.

func NewWallets

func NewWallets() *Wallets

NewWallets creates and returns a new Wallets container.

func (*Wallets) GetNextWallet

func (w *Wallets) GetNextWallet(walletType WalletType, minOutputsLeft int) (*Wallet, error)

GetNextWallet get next non-empty wallet based on provided type.

func (*Wallets) GetUnspentOutput

func (w *Wallets) GetUnspentOutput(wallet *Wallet) *Output

GetUnspentOutput gets first found unspent output for a given walletType

func (*Wallets) GetWallet

func (w *Wallets) GetWallet(walletID walletID) *Wallet

GetWallet returns the wallet with the specified ID.

func (*Wallets) IsFaucetWalletAvailable

func (w *Wallets) IsFaucetWalletAvailable() bool

IsFaucetWalletAvailable checks if there is any faucet wallet left.

func (*Wallets) NewWallet

func (w *Wallets) NewWallet(walletType WalletType) *Wallet

NewWallet adds a new wallet to Wallets and returns the created wallet.

func (*Wallets) SetWalletReady

func (w *Wallets) SetWalletReady(wallet *Wallet)

SetWalletReady makes wallet ready to use, Fresh wallet is added to freshWallets queue.

func (*Wallets) UnspentOutputsLeft

func (w *Wallets) UnspentOutputsLeft(walletType WalletType) int

type WebClient

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

WebClient contains a ZIPP web API to interact with a node.

func NewWebClient

func NewWebClient(url string, setters ...client.Option) *WebClient

NewWebClient creates Connector from provided ZIPPAPI urls.

func (*WebClient) BroadcastFaucetRequest

func (c *WebClient) BroadcastFaucetRequest(address string) (err error)

BroadcastFaucetRequest requests funds from the faucet and returns the faucet request block ID.

func (*WebClient) GetAddressUnspentOutputs

func (c *WebClient) GetAddressUnspentOutputs(address string) (outputIDs []utxo.OutputID, err error)

func (*WebClient) GetOutput

func (c *WebClient) GetOutput(outputID utxo.OutputID) devnetvm.Output

GetOutput gets the output of a given outputID.

func (*WebClient) GetOutputConfirmationState

func (c *WebClient) GetOutputConfirmationState(outputID utxo.OutputID) confirmation.State

GetOutputConfirmationState gets the first unspent outputs of a given address.

func (*WebClient) GetOutputSolidity

func (c *WebClient) GetOutputSolidity(outID string) (solid bool, err error)

func (*WebClient) GetRateSetterEstimate

func (c *WebClient) GetRateSetterEstimate() (estimate time.Duration, err error)

GetRateSetterEstimate returns a rate setter estimate.

func (*WebClient) GetTransaction

func (c *WebClient) GetTransaction(txID string) (resp *jsonmodels.Transaction, err error)

GetTransaction gets the transaction.

func (*WebClient) GetTransactionConfirmationState

func (c *WebClient) GetTransactionConfirmationState(txID string) confirmation.State

GetTransactionConfirmationState returns the ConfirmationState of a given transaction ID.

func (*WebClient) GetTransactionOutputs

func (c *WebClient) GetTransactionOutputs(txID string) (outputs devnetvm.Outputs, err error)

GetTransactionOutputs returns the outputs the transaction created.

func (*WebClient) GetUnspentOutputForAddress

func (c *WebClient) GetUnspentOutputForAddress(addr devnetvm.Address) *jsonmodels.WalletOutput

GetUnspentOutputForAddress gets the first unspent outputs of a given address.

func (*WebClient) PostData

func (c *WebClient) PostData(data []byte) (blkID string, err error)

PostData sends the given data (payload) by creating a block in the backend.

func (*WebClient) PostTransaction

func (c *WebClient) PostTransaction(tx *devnetvm.Transaction) (txID utxo.TransactionID, err error)

PostTransaction sends a transaction to the Mesh via a given client.

func (*WebClient) SleepRateSetterEstimate

func (c *WebClient) SleepRateSetterEstimate() (err error)

SleepRateSetterEstimate returns a rate setter estimate.

func (*WebClient) Url added in v0.1.2

func (c *WebClient) Url() string

Url returns a client API Url.

type WebClients

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

WebClients is responsible for handling connections via ZIPPAPI.

func NewWebClients

func NewWebClients(urls []string, setters ...client.Option) *WebClients

NewWebClients creates Connector from provided ZIPPAPI urls.

func (*WebClients) AddClient

func (c *WebClients) AddClient(url string, setters ...client.Option)

AddClient adds client to WebClients based on provided ZIPPAPI url.

func (*WebClients) Clients

func (c *WebClients) Clients(...bool) []Client

Clients returns list of all clients.

func (*WebClients) GetClient

func (c *WebClients) GetClient() Client

GetClient returns the client instance that was used the longest time ago.

func (*WebClients) GetClients

func (c *WebClients) GetClients(numOfClt int) []Client

GetClients returns the numOfClt client instances that were used the longest time ago.

func (*WebClients) PledgeID

func (c *WebClients) PledgeID() *identity.ID

PledgeID returns the node ID that the mana will be pledging to.

func (*WebClients) RemoveClient

func (c *WebClients) RemoveClient(url string)

RemoveClient removes client with the provided url from the WebClients.

func (*WebClients) ServerStatus

func (c *WebClients) ServerStatus(cltIdx int) (status *wallet.ServerStatus, err error)

ServerStatus retrieves the connected server status.

func (*WebClients) ServersStatuses

func (c *WebClients) ServersStatuses() ServersStatus

ServersStatuses retrieves the connected server status for each client.

func (*WebClients) SetPledgeID

func (c *WebClients) SetPledgeID(id *identity.ID)

SetPledgeID sets the node ID that the mana will be pledging to.

Jump to

Keyboard shortcuts

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