wallet

package
v0.0.0-...-33f7a36 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MPL-2.0 Imports: 11 Imported by: 7

Documentation

Overview

Package wallet defines common datastructures and an interface for cryptocurrency wallets

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	TotalProbi       decimal.Decimal
	SpendableProbi   decimal.Decimal
	ConfirmedProbi   decimal.Decimal
	UnconfirmedProbi decimal.Decimal
}

Balance holds balance information for a wallet

type ByTime

type ByTime []TransactionInfo

ByTime implements sort.Interface for []TransactionInfo based on the Time field.

func (ByTime) Len

func (a ByTime) Len() int

func (ByTime) Less

func (a ByTime) Less(i, j int) bool

func (ByTime) Swap

func (a ByTime) Swap(i, j int)

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type Info

type Info struct {
	ID                         string                   `json:"paymentId" valid:"uuidv4,optional" db:"id"`
	Provider                   string                   `json:"provider" valid:"in(uphold,brave)" db:"provider"`
	ProviderID                 string                   `json:"providerId" valid:"uuidv4" db:"provider_id"`
	AltCurrency                *altcurrency.AltCurrency `json:"altcurrency" valid:"-"`
	PublicKey                  string                   `json:"publicKey,omitempty" valid:"hexadecimal,optional" db:"public_key"`
	LastBalance                *Balance                 `json:"balances,omitempty" valid:"-"`
	ProviderLinkingID          *uuid.UUID               `json:"providerLinkingId" valid:"-" db:"provider_linking_id"`
	AnonymousAddress           *uuid.UUID               `json:"anonymousAddress" valid:"-" db:"anonymous_address"`
	UserDepositAccountProvider *string                  `json:"userDepositAccountProvider" valid:"in(uphold)" db:"user_deposit_account_provider"`
	UserDepositDestination     string                   `json:"userDepositCardId" db:"user_deposit_destination"`
}

Info contains information about a wallet like associated identifiers, the denomination, the last known balance and provider

func (*Info) LinkSolanaAddress

func (w *Info) LinkSolanaAddress(_ context.Context, s SolanaLinkReq) error

type LinkSolanaAddressError

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

func (*LinkSolanaAddressError) Error

func (e *LinkSolanaAddressError) Error() string

func (*LinkSolanaAddressError) Unwrap

func (e *LinkSolanaAddressError) Unwrap() error

type SolanaLinkReq

type SolanaLinkReq struct {
	Pub   string
	Sig   string
	Msg   string
	Nonce string
}

type TransactionInfo

type TransactionInfo struct {
	Probi              decimal.Decimal          `json:"probi"`
	AltCurrency        *altcurrency.AltCurrency `json:"altcurrency"`
	Destination        string                   `json:"address"`
	TransferFee        decimal.Decimal          `json:"fee"`
	ExchangeFee        decimal.Decimal          `json:"-"`
	Status             string                   `json:"status"`
	ID                 string                   `json:"id"`
	DestCurrency       string                   `json:"-"`
	DestAmount         decimal.Decimal          `json:"-"`
	ValidUntil         time.Time                `json:"-"`
	Source             string                   `json:"-"`
	Time               time.Time                `json:"-"`
	Note               string                   `json:"-"`
	UserID             string                   `json:"-"`
	KYC                bool                     `json:"-"`
	CitizenshipCountry string                   `json:"-"`
	IdentityCountry    string                   `json:"-"`
	ResidenceCountry   string                   `json:"-"`
}

TransactionInfo contains information about a transaction like the denomination, amount in probi, destination address, status and identifier

func (TransactionInfo) String

func (t TransactionInfo) String() string

String returns the transaction info as an easily readable string

type Wallet

type Wallet interface {
	GetWalletInfo() Info
	// Transfer moves funds out of the associated wallet and to the specific destination
	Transfer(ctx context.Context, altcurrency altcurrency.AltCurrency, probi decimal.Decimal, destination string) (*TransactionInfo, error)
	// VerifyTransaction verifies that the base64 encoded transaction is valid
	// NOTE VerifyTransaction must guard against transactions that seek to exploit parser differences
	// such as including additional fields that are not understood by local implementation but may
	// be understood by the upstream wallet provider.
	VerifyTransaction(ctx context.Context, transactionB64 string) (*TransactionInfo, error)
	// SubmitTransaction submits the base64 encoded transaction for verification but does not move funds
	SubmitTransaction(ctx context.Context, transactionB64 string, confirm bool) (*TransactionInfo, error)
	// ConfirmTransaction confirms a previously submitted transaction, moving funds
	ConfirmTransaction(ctx context.Context, id string) (*TransactionInfo, error)
	// GetBalance returns the last known balance, if refresh is true then the current balance is fetched
	GetBalance(ctx context.Context, refresh bool) (*Balance, error)
	// ListTransactions for this wallet, limit number of transactions returned
	ListTransactions(ctx context.Context, limit int, startDate time.Time) ([]TransactionInfo, error)
}

Wallet is an interface for a cryptocurrency wallet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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