walletmanager

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenesisAccountAlias = "genesis-account"
	FaucetRequestsAlias = "faucet-requests"
)
View Source
const (
	MaxFaucetRequestsForOneOperation = 10
)

Variables

This section is empty.

Functions

func AvailableCommands

func AvailableCommands(cmd string) bool

func BIP32PathForIndex

func BIP32PathForIndex(index uint32) string

func WithAccountStatesFile

func WithAccountStatesFile(fileName string) options.Option[Manager]

func WithClientURL

func WithClientURL(url string) options.Option[Manager]

WithClientURL sets the client bind address.

func WithFaucetAccountParams

func WithFaucetAccountParams(params *GenesisAccountParams) options.Option[Manager]

func WithFaucetURL

func WithFaucetURL(url string) options.Option[Manager]

func WithSilence

func WithSilence() options.Option[Manager]

Types

type AccountOperation

type AccountOperation string
const (
	OperationCreateAccount  AccountOperation = "create"
	OperationConvertAccount AccountOperation = "convert"
	OperationDestroyAccount AccountOperation = "destroy"
	OperationAllotAccount   AccountOperation = "allot"
	OperationDelegate       AccountOperation = "delegate"
	OperationStakeAccount   AccountOperation = "stake"
	OperationClaim          AccountOperation = "claim"
	OperationUpdateAccount  AccountOperation = "update"
)

func (AccountOperation) String

func (a AccountOperation) String() string

type AccountState

type AccountState struct {
	Alias      string             `serix:"Alias,lenPrefix=uint8"`
	AccountID  iotago.AccountID   `serix:"AccountID"`
	PrivateKey ed25519.PrivateKey `serix:",lenPrefix=uint8"`
	OutputID   iotago.OutputID    `serix:"OutputID"`
	Index      uint32             `serix:"Index"`
}

func AccountStateFromAccountData

func AccountStateFromAccountData(acc *models.AccountData) *AccountState

func (*AccountState) ToAccountData

func (a *AccountState) ToAccountData() *models.AccountData

type AccountSubcommands

type AccountSubcommands interface {
	Type() AccountOperation
}

type AllotAccountParams

type AllotAccountParams struct {
	Alias  string
	Amount iotago.Mana
}

func (*AllotAccountParams) Type

type ClaimAccountParams

type ClaimAccountParams struct {
	Alias string
}

func (*ClaimAccountParams) Type

type ConvertAccountParams

type ConvertAccountParams struct {
	AccountAlias string
}

func (*ConvertAccountParams) Type

type CreateAccountParams

type CreateAccountParams struct {
	Alias      string
	NoBIF      bool
	Implicit   bool
	Transition bool
}

func (*CreateAccountParams) Type

type DelegateAccountParams

type DelegateAccountParams struct {
	Amount    iotago.BaseToken
	ToAddress string
	FromAlias string
	CheckPool bool
}

func (*DelegateAccountParams) Type

type Delegation

type Delegation struct {
	Alias                  string           `serix:"Alias,lenPrefix=uint8"`
	OutputID               iotago.OutputID  `serix:"OutputID"`
	AddressIndex           uint32           `serix:"AddressIndex"`
	Amount                 iotago.BaseToken `serix:"Amount"`
	DelegatedToBechAddress string           `serix:"DelegatedToBechAddress,lenPrefix=uint8"`
}

type DestroyAccountParams

type DestroyAccountParams struct {
	AccountAlias string
	ExpirySlot   uint64
}

func (*DestroyAccountParams) Type

type GenesisAccountParams

type GenesisAccountParams struct {
	GenesisPrivateKey string
	GenesisAccountID  string
	FaucetPrivateKey  string
	FaucetAccountID   string
}

func NewGenesisAccountParams

func NewGenesisAccountParams(params *models.ParametersTool) *GenesisAccountParams

type Manager

type Manager struct {
	RequestTokenAmount iotago.BaseToken
	RequestManaAmount  iotago.Mana

	Client *models.WebClient
	API    iotago.API
	sync.RWMutex
	log.Logger
	// contains filtered or unexported fields
}

func RunManager

func RunManager(logger log.Logger, opts ...options.Option[Manager]) (*Manager, error)

func (*Manager) AddAccount

func (m *Manager) AddAccount(alias string, data *models.AccountData)

func (*Manager) AddWallet

func (m *Manager) AddWallet(alias string, wallet *Wallet)

func (*Manager) AllotToAccount

func (m *Manager) AllotToAccount(ctx context.Context, params *AllotAccountParams) error

func (*Manager) Claim

func (m *Manager) Claim(ctx context.Context, params *ClaimAccountParams) error

func (*Manager) CreateAccount

func (m *Manager) CreateAccount(ctx context.Context, params *CreateAccountParams) (iotago.AccountID, error)

CreateAccount creates an implicit account and immediately transition it to a regular account.

func (*Manager) CreateBlock

func (m *Manager) CreateBlock(clt models.Client, payload iotago.Payload, issuer wallet.Account, congestionResp *api.CongestionResponse, issuerResp *api.IssuanceBlockHeaderResponse, version iotago.Version, strongParents ...iotago.BlockID) (*iotago.Block, error)

func (*Manager) DelegateToAccount

func (m *Manager) DelegateToAccount(ctx context.Context, params *DelegateAccountParams) error

func (*Manager) Delegators

func (m *Manager) Delegators() []string

func (*Manager) DestroyAccount

func (m *Manager) DestroyAccount(ctx context.Context, params *DestroyAccountParams) error

func (*Manager) FaucetRequestsAccount

func (m *Manager) FaucetRequestsAccount() wallet.Account

func (*Manager) GenesisAccount

func (m *Manager) GenesisAccount() wallet.Account

func (*Manager) GetAccount

func (m *Manager) GetAccount(alias string) (*models.AccountData, error)

func (*Manager) GetDelegations

func (m *Manager) GetDelegations(alias string) ([]*Delegation, error)

func (*Manager) GetReadyAccount

func (m *Manager) GetReadyAccount(ctx context.Context, clt models.Client, alias string) (*models.AccountData, error)

func (*Manager) GetWallet

func (m *Manager) GetWallet(alias string) (*Wallet, error)

func (*Manager) ListAccount

func (m *Manager) ListAccount() error

func (*Manager) LoadStateFromFile

func (m *Manager) LoadStateFromFile() (loaded bool, err error)

func (*Manager) PostWithBlock

func (m *Manager) PostWithBlock(ctx context.Context, clt models.Client, payload iotago.Payload, issuer wallet.Account, congestionResp *api.CongestionResponse, issuerResp *api.IssuanceBlockHeaderResponse, version iotago.Version, strongParents ...iotago.BlockID) (iotago.BlockID, error)

func (*Manager) RequestBlockIssuanceData

func (*Manager) RequestFaucetFunds

func (m *Manager) RequestFaucetFunds(ctx context.Context, clt models.Client, receiveAddr iotago.Address) (iotago.OutputID, iotago.Output, error)

func (*Manager) RequestManaAndFundsFromTheFaucet

func (m *Manager) RequestManaAndFundsFromTheFaucet(ctx context.Context, w *Wallet, minManaAmount iotago.Mana, minTokensAmount iotago.BaseToken) ([]*models.OutputData, error)

func (*Manager) SaveStateToFile

func (m *Manager) SaveStateToFile() error

type ManagerState

type ManagerState struct {
	AccountState       []*AccountState  `serix:"accounts,lenPrefix=uint8"`
	Wallets            []*Wallet        `serix:"wallets,lenPrefix=uint8"`
	Delegation         []*Delegation    `serix:"delegations,lenPrefix=uint8"`
	RequestTokenAmount iotago.BaseToken `serix:"RequestTokenAmount"`
	RequestManaAmount  iotago.Mana      `serix:"RequestManaAmount"`
}

type NoAccountParams

type NoAccountParams struct {
	Operation AccountOperation
}

func (*NoAccountParams) Type

type StakeAccountParams

type StakeAccountParams struct {
	Alias      string
	Amount     uint64
	FixedCost  uint64
	StartEpoch uint64
	EndEpoch   uint64
}

func (*StakeAccountParams) Type

type UpdateAccountParams

type UpdateAccountParams struct {
	Alias          string
	BlockIssuerKey string
	Mana           uint64
	Amount         uint64
	ExpirySlot     uint64
}

func (*UpdateAccountParams) Type

type Wallet

type Wallet struct {
	Alias           string   `serix:"alias,lenPrefix=uint8"`
	Seed            [32]byte `serix:"seed"`
	LatestUsedIndex uint32   `serix:"LatestUsedIndex"`
}

func (*Wallet) GetAddrSignerForIndexes

func (w *Wallet) GetAddrSignerForIndexes(outputs ...*models.OutputData) (iotago.AddressSigner, error)

Jump to

Keyboard shortcuts

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