xmr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package xmr provides datastructures for dealing with XMR from a client (wallet) perspective.

Index

Constants

View Source
const (
	MethodGetAddress            = "get_address"
	MethodGetHeight             = "get_height"
	MethodGetTransfers          = "get_transfers"
	MethodMakeIntegratedAddress = "make_integrated_address"
	MethodAutoRefresh           = "auto_refresh"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoRefreshParams

type AutoRefreshParams struct {
	Enable bool `json:"enable,omitempty"`
	Period uint `json:"period,omitempty"`
}

type Client

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

Client is a wallet RPC client instance.

func NewClient

func NewClient(cfg *Config, parentLogger *slog.Logger) *Client

NewClient creates a new Client with the destination URL.

func (*Client) AutoRefresh

func (cli *Client) AutoRefresh(ctx context.Context, p *AutoRefreshParams) error

func (*Client) Close

func (cli *Client) Close() error

func (*Client) GetAddress

func (cli *Client) GetAddress(ctx context.Context, p *GetAddressParams) (*GetAddressResult, error)

func (*Client) GetHeight

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

func (*Client) GetTransfers

func (cli *Client) GetTransfers(ctx context.Context, p *GetTransfersParams) (*GetTransfersResult, error)

func (*Client) MakeIntegratedAddress

func (cli *Client) MakeIntegratedAddress(ctx context.Context, p *MakeIntegratedAddressParams) (*MakeIntegratedAddressResult, error)

func (*Client) WatchTransfers

func (cli *Client) WatchTransfers(ctx context.Context, cfg *Config)

func (*Client) XfersCh

func (cli *Client) XfersCh() <-chan *GetTransfersResult

type Config

type Config struct {
	// Daemon is the XMR wallet daemon configuration.
	Daemon DaemonConfig `yaml:"daemon"`

	// RecoveryHeight is the height to start scanning for transactions.
	// This value is only used on first launch.
	RecoveryHeight uint64 `yaml:"recovery_height"`

	// URL is the `monero-wallet-rpc` URL.
	URL string `yaml:"url"`

	// PollInterval is the wallet poll interval in seconds.
	PollInterval uint `yaml:"poll_interval"`

	// DisablePool disables treating transfers in the `pool` state as
	// complete (More secure, but less responsive).
	DisablePool bool `yaml:"disable_pool"`

	// TrackNSF enables tracking transfers that are lower than the
	// minimum donation threshold.
	TrackNSF bool `yaml:"track_insufficient_funds"`
}

Config is a XMR wallet client configuration.

func (*Config) ApplyDefaults

func (cfg *Config) ApplyDefaults(def *Config)

func (*Config) Validate

func (cfg *Config) Validate() error

Validate checks if a Config appears to be valid.

type Daemon

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

Daemon is a wallet RPC daemon instance.

func NewDaemon

func NewDaemon(cfg *DaemonConfig, parentLogger *slog.Logger) *Daemon

NewDaemon creates a new Daemon with the configuration.

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context)

Run starts the daemon instance.

type DaemonConfig

type DaemonConfig struct {
	// Enable makes the shadowchat executable handle launching the
	// `monero-wallet-rpc` daemon.
	Enable bool `yaml:"enable"`
	// ExecutablePath is the path to the `monero-wallet-rpc` binary.
	ExecutablePath string `yaml:"executable_path"`
	// WalletPath is the path to the (view only) wallet.
	WalletPath string `yaml:"wallet_path"`
	// LogPath is the path to the `moneor-wallet-rpc` log file.
	LogPath string `yaml:"log_path"`
	// BindPort is the TCP port to bind to.
	BindPort uint16 `yaml:"bind_port"`
	// NodeURL is the upstream Mondero node to connect to.
	NodeURL string `yaml:"node_url"`
	// Stagenet indicates if the wallet is a stagenet wallet.
	Stagenet bool `yaml:"stagenet"`
}

DaemonConfig is a XMR wallet RPC daemon configuration.

func (*DaemonConfig) ApplyDefaults

func (cfg *DaemonConfig) ApplyDefaults(def *DaemonConfig)

func (*DaemonConfig) ToCmd

func (cfg *DaemonConfig) ToCmd(ctx context.Context) *exec.Cmd

ToCmd builds a os/exec.Cmd from a DaemonConfig.

func (*DaemonConfig) Validate

func (cfg *DaemonConfig) Validate() error

Validate checks if a Config appears to be valid.

type GetAddressParams

type GetAddressParams struct {
	AccountIndex uint   `json:"account_index"`
	AddressIndex []uint `json:"address_index,omitempty"`
}

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 GetHeightResult

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

type GetTransfersParams

type GetTransfersParams struct {
	In      bool `json:"in,omitempty"`
	Out     bool `json:"out,omitempty"`
	Pending bool `json:"pending,omitempty"`
	Failed  bool `json:"failed,omitempty"`
	Pool    bool `json:"pool,omitempty"`

	FilterByHeight bool   `json:"filter_by_height,omitempty"`
	MinHeight      uint64 `json:"min_height,omitempty"`
	MaxHeight      uint64 `json:"max_height,omitempty"`

	AccountIndex   uint   `json:"account_index,omitempty"`
	SubaddrIndices []uint `json:"subaddr_indices,omitempty"`

	AllAccounts bool `json:"all_accounts,omitempty"`
}

type GetTransfersResult

type GetTransfersResult struct {
	In      []*Transfer `json:"in,omitempty"`
	Out     []*Transfer `json:"out,omitempty"`
	Pending []*Transfer `json:"pending,omitempty"`
	Failed  []*Transfer `json:"failed,omitempty"`
	Pool    []*Transfer `json:"pool,omitempty"`

	MaxHeight uint64 `json:"-"` // For our use, not part of the API.
}

type MakeIntegratedAddressParams

type MakeIntegratedAddressParams struct {
	StandardAddress string `json:"standard_address,omitempty"`
	PaymentID       string `json:"payment_id,omitempty"`
}

type MakeIntegratedAddressResult

type MakeIntegratedAddressResult struct {
	IntegratedAddress string `json:"integrated_address"`
	PaymentID         string `json:"payment_id"`
}

type Quantity

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

Quantity is a fixed-point representation of XMR.

func MustNewQuantity

func MustNewQuantity(s string) *Quantity

MustNewQuantity constructs a new Quantity from the text representation or panics.

func NewQuantity

func NewQuantity(s string) (*Quantity, error)

NewQuantity constructs a new Quantity from the text representation.

func NewQuantityFrom

func NewQuantityFrom(other *Quantity) *Quantity

NewQuantityFrom constructs a new Quantity from another.

func NewQuantityFromAtomic

func NewQuantityFromAtomic(v uint64) *Quantity

NewQuantityFromAtomic constructs a new Quantity from Atomic units.

func (*Quantity) Cmp

func (q *Quantity) Cmp(other *Quantity) int

Cmp compares `q` and `other`, and returns `-1` iff `q < other`, `0` iff `q == other`, and `1` iff `q > other`.

func (*Quantity) IsZero

func (q *Quantity) IsZero() bool

IsZero returns true iff `q` is `0`.

func (*Quantity) MarshalText

func (q *Quantity) MarshalText() ([]byte, error)

MarshalText returns the text representation of a quantity (in XMR).

func (*Quantity) Set

func (q *Quantity) Set(other *Quantity) *Quantity

Set sets `q` to `other`.

func (*Quantity) String

func (q *Quantity) String() string

String returns the quantity as a string (in XMR).

func (*Quantity) UnmarshalText

func (q *Quantity) UnmarshalText(s []byte) error

UnmarshalText decodes the text representation of a quantity (in XMR) and sets `q` to the value. On error, `q` is set to `0`.

func (*Quantity) UnmarshalYAML

func (q *Quantity) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML decodes the YAML representation of a quantity in (XMR) from a YAML, and sets `q` to the value.

type Transfer

type Transfer struct {
	Address         string `json:"address"`
	Amount          uint64 `json:"amount"`
	Confirmations   uint64 `json:"confirmations"`
	DoubleSpendSeen bool   `json:"double_spend_seen"`
	Fee             uint64 `json:"fee"`
	Height          uint64 `json:"height"`
	Locked          bool   `json:"locked"`
	Note            string `json:"note"`
	PaymentID       string `json:"payment_id"`
	SubaddrIndex    struct {
		Major uint `json:"major"`
		Minor uint `json:"minor"`
	} `json:"subaddr_index"`
	SubaddrIndices []struct {
		Major int `json:"major"`
		Minor int `json:"minor"`
	} `json:"subaddr_indices"`
	SuggestedConfirmationsThreshold uint64 `json:"suggested_confirmations_threshold"`
	Timestamp                       uint64 `json:"timestamp"`
	TxID                            string `json:"txid"`
	Type                            string `json:"type"`
	UnlockTime                      uint64 `json:"unlock_time"`
}

func (*Transfer) AmountXMR

func (xfer *Transfer) AmountXMR() *Quantity

func (*Transfer) FeeXMR

func (xfer *Transfer) FeeXMR() *Quantity

Jump to

Keyboard shortcuts

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