wallet

package
v0.0.0-...-910450c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package wallet provides a client that encapsulates RPC methods that can be hit in a wallet rpc server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoRefreshResult

type AutoRefreshResult struct {
}

type Client

type Client struct {
	Requester
}

Client provides access to the daemon's JSONRPC methods and regular endpoints.

func NewClient

func NewClient(c Requester) *Client

NewClient instantiates a new client for interacting with monero's daemon api.

func (*Client) AutoRefresh

func (c *Client) AutoRefresh(
	ctx context.Context, enable bool, period int64,
) (*AutoRefreshResult, error)

func (*Client) CreateAddress

func (c *Client) CreateAddress(
	ctx context.Context, accountIndex uint, count uint, label string,
) (*CreateAddressResult, error)

func (*Client) GetAccounts

func (c *Client) GetAccounts(
	ctx context.Context, params GetAccountsRequestParameters,
) (*GetAccountsResult, error)

func (*Client) GetAddress

func (c *Client) GetAddress(
	ctx context.Context, params GetAddressRequestParameters,
) (*GetAddressResult, error)

func (*Client) GetBalance

func (c *Client) GetBalance(
	ctx context.Context, params GetBalanceRequestParameters,
) (*GetBalanceResult, error)

GetBalance gets the balance of the wallet configured for the wallet rpc server.

func (*Client) GetHeight

func (c *Client) GetHeight(ctx context.Context) (*GetHeightResult, error)

func (*Client) Refresh

func (c *Client) Refresh(
	ctx context.Context, startHeight uint64,
) (*RefreshResult, error)

type CreateAddressResult

type CreateAddressResult struct {
	Address        string   `json:"address"`
	AddressIndex   uint     `json:"address_index"`
	AddressIndices []uint   `json:"address_indices"`
	Addresses      []string `json:"addresses"`
}

type GetAccountsRequestParameters

type GetAccountsRequestParameters struct {
	Tag            string `json:"tag,omitempty"`
	StrictBalances bool   `json:"strict_balances,omitempty"`
}

type GetAccountsResult

type GetAccountsResult struct {
	SubaddressAccounts []struct {
		AccountIndex    uint   `json:"account_index"`
		Balance         uint64 `json:"balance"`
		BaseAddress     string `json:"base_address"`
		Label           string `json:"label"`
		Tag             string `json:"tag"`
		UnlockedBalance uint64 `json:"unlocked_balance"`
	} `json:"subaddress_accounts"`

	TotalBalance         uint64 `json:"total_balance"`
	TotalUnlockedBalance uint64 `json:"total_unlocked_balance"`
}

type GetAddressRequestParameters

type GetAddressRequestParameters struct {
	AccountIndex   uint   `json:"account_index"`
	AddressIndices []uint `json:"address_indices"`
}

type GetAddressResult

type GetAddressResult struct {
	Address   string `json:"address"`
	Addresses []struct {
		Address      string `json:"address"`
		AddressIndex uint   `json:"address_index"`
		Label        string `json:"label"`
		Used         bool   `json:"used"`
	} `json:"addresses"`
}

type GetBalanceRequestParameters

type GetBalanceRequestParameters struct {
	AccountIndex   uint   `json:"account_index"`
	AddressIndices []uint `json:"address_indices"`
	AllAccounts    bool   `json:"all_accounts"`
	Strict         bool   `json:"strict"`
}

type GetBalanceResult

type GetBalanceResult struct {
	// Balance is the total balance of the current monero-wallet-rpc in
	// session.
	//
	Balance uint64 `json:"balance"`

	// BlocksToUnlock indicates how many blocks are necessary for all the
	// funds to be unclocked.
	//
	BlocksToUnlock uint `json:"blocks_to_unlock"`

	// MultisigImportNeeded is True if importing multisig data is needed
	// for returning a correct balance
	//
	MultisigImportNeeded bool `json:"multisig_import_needed"`

	// PerSubaddress is an array of subaddress information; Balance
	// information for each subaddress in an account.
	//
	PerSubaddress []SubAddress `json:"per_subaddress"`

	// TimeToUnlock TODO
	//
	TimeToUnlock int `json:"time_to_unlock"`

	// UnlockedBalance TODO
	//
	UnlockedBalance int64 `json:"unlocked_balance"`
}

type GetHeightResult

type GetHeightResult struct {
	Height uint64 `json:"height"`
}

type RefreshResult

type RefreshResult struct {
	BlocksFetched uint64 `json:"blocks_fetched"`
	ReceivedMoney bool   `json:"received_money"`
}

type Requester

type Requester interface {
	// JSONRPC is used for callind methods under `/json_rpc` that follow
	// monero's `v2` response and error encapsulation.
	//
	JSONRPC(
		ctx context.Context, method string, params, result interface{},
	) error
}

Requester is responsible for making HTTP requests to `monero-wallet-rpc` JSONRPC endpoints.

type SubAddress

type SubAddress struct {
	// AccountIndex is the index of the account.
	//
	AccountIndex uint `json:"account_index"`

	// Address at this index. Base58 representation of the public
	// keys.
	//
	Address string `json:"address"`

	// AddressIndex  is the index of the subaddress in the account.
	//
	AddressIndex uint `json:"address_index"`

	// Balance is the balance for the subaddress.
	//
	Balance uint64 `json:"balance"`

	// BlocksToUnlock TODO
	//
	BlocksToUnlock uint `json:"blocks_to_unlock"`

	// Label TODO
	//
	Label string `json:"label"`

	// NumUnspentOutputs TODO
	//
	NumUnspentOutputs uint `json:"num_unspent_outputs"`

	// TimeToUnlock TODO
	//
	TimeToUnlock uint `json:"time_to_unlock"`

	// UnlockedBalance TODO
	//
	UnlockedBalance int64 `json:"unlocked_balance"`
}

Jump to

Keyboard shortcuts

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