uphold

package
v0.0.0-...-f003305 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 39 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SettlementDestination is the address of the settlement wallet
	SettlementDestination = os.Getenv("BAT_SETTLEMENT_ADDRESS")

	// AnonCardSettlementAddress is the address of the settlement wallet
	AnonCardSettlementAddress = os.Getenv("ANON_CARD_SETTLEMENT_ADDRESS")
	// UpholdSettlementAddress is the address of the settlement wallet
	UpholdSettlementAddress = os.Getenv("UPHOLD_SETTLEMENT_ADDRESS")
)

Functions

func FundWallet

func FundWallet(ctx context.Context, destWallet *Wallet, amount decimal.Decimal) (decimal.Decimal, error)

FundWallet should fund a given wallet from the donor card (only used in wallet testing)

Types

type Beneficiary

type Beneficiary struct {
	Address struct {
		City    string `json:"city,omitempty"`
		Country string `json:"country,omitempty"`
		Line1   string `json:"line1,omitempty"`
		State   string `json:"state,omitempty"`
		ZipCode string `json:"zipCode,omitempty"`
	} `json:"address,omitempty"`
	Name         string `json:"name,omitempty"`
	Relationship string `json:"relationship"`
}

Beneficiary includes information about the recipient of the transaction

type CardDetails

type CardDetails struct {
	AvailableBalance decimal.Decimal         `json:"available"`
	Balance          decimal.Decimal         `json:"balance"`
	Currency         altcurrency.AltCurrency `json:"currency"`
	ID               uuid.UUID               `json:"id"`
	Settings         CardSettings            `json:"settings"`
}

CardDetails contains details corresponding to the Uphold card

type CardSettings

type CardSettings struct {
	Protected bool `json:"protected,omitempty"`
}

CardSettings contains settings corresponding to the Uphold card

type Coded

type Coded interface {
	GetCode() string
}

Coded - interface for things that have codes, such as errors

type DrainData

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

DrainData - uphold specific drain error "data" wrapper for errorutils

func NewDrainData

func NewDrainData(c Coded) *DrainData

NewDrainData - get uphold specific drain data from the coded error

func (*DrainData) DrainCode

func (dd *DrainData) DrainCode() (string, bool)

DrainCode - implement the drain code rendering of the error

type HTTPSignedRequest

type HTTPSignedRequest struct {
	Headers map[string]string `json:"headers" valid:"-"`
	Body    string            `json:"octets" valid:"json"`
}

HTTPSignedRequest encapsulates a signed HTTP request

type Wallet

type Wallet struct {
	walletutils.Info
	Logger  *zerolog.Logger
	PrivKey crypto.Signer
	PubKey  httpsignature.Verifier
}

Wallet a wallet information using Uphold as the provider A wallet corresponds to a single Uphold "card"

func FromWalletInfo

func FromWalletInfo(ctx context.Context, info walletutils.Info) (*Wallet, error)

FromWalletInfo returns an uphold wallet matching the provided wallet info

func New

func New(ctx context.Context, info walletutils.Info, privKey crypto.Signer, pubKey httpsignature.Verifier) (*Wallet, error)

New returns an uphold wallet constructed using the provided parameters NOTE that it does not register a wallet with Uphold if it does not already exist

func (*Wallet) ConfirmTransaction

func (w *Wallet) ConfirmTransaction(ctx context.Context, id string) (*walletutils.TransactionInfo, error)

ConfirmTransaction confirms a previously submitted transaction, moving funds

func (*Wallet) CreateCardAddress

func (w *Wallet) CreateCardAddress(ctx context.Context, network string) (string, error)

CreateCardAddress on network, returning the address

func (*Wallet) GetBalance

func (w *Wallet) GetBalance(ctx context.Context, refresh bool) (*walletutils.Balance, error)

GetBalance returns the last known balance, if refresh is true then the current balance is fetched

func (*Wallet) GetCardDetails

func (w *Wallet) GetCardDetails(ctx context.Context) (*CardDetails, error)

GetCardDetails returns the details associated with the wallet's backing Uphold card

func (*Wallet) GetTransaction

func (w *Wallet) GetTransaction(ctx context.Context, id string) (*walletutils.TransactionInfo, error)

GetTransaction returns info about a previously confirmed transaction

func (*Wallet) GetWalletInfo

func (w *Wallet) GetWalletInfo() walletutils.Info

GetWalletInfo returns the info associated with the wallet

func (*Wallet) IsUserKYC

func (w *Wallet) IsUserKYC(ctx context.Context, destination string) (string, bool, string, error)

IsUserKYC - is this user a "member"

func (*Wallet) ListTransactions

func (w *Wallet) ListTransactions(ctx context.Context, limit int, startDate time.Time) ([]walletutils.TransactionInfo, error)

ListTransactions for this wallet, pagination not yet supported

func (*Wallet) PrepareRegistration

func (w *Wallet) PrepareRegistration(label string) (string, error)

PrepareRegistration returns a b64 encoded serialized signed registration suitable for SubmitRegistration

func (*Wallet) PrepareTransaction

func (w *Wallet) PrepareTransaction(altcurrency altcurrency.AltCurrency, probi decimal.Decimal, destination string, message string, purpose string, beneficiary *Beneficiary) (string, error)

PrepareTransaction returns a b64 encoded serialized signed transaction suitable for SubmitTransaction

func (*Wallet) Register

func (w *Wallet) Register(ctx context.Context, label string) error

Register a wallet with Uphold with label

func (*Wallet) SubmitRegistration

func (w *Wallet) SubmitRegistration(ctx context.Context, registrationB64 string) error

SubmitRegistration from a b64 encoded signed string

func (*Wallet) SubmitTransaction

func (w *Wallet) SubmitTransaction(ctx context.Context, transactionB64 string, confirm bool) (*walletutils.TransactionInfo, error)

SubmitTransaction submits the base64 encoded transaction for verification but does not move funds

unless confirm is set to true.

func (*Wallet) Transfer

func (w *Wallet) Transfer(ctx context.Context, altcurrency altcurrency.AltCurrency, probi decimal.Decimal, destination string) (*walletutils.TransactionInfo, error)

Transfer moves funds out of the associated wallet and to the specific destination

func (*Wallet) VerifyAnonCardTransaction

func (w *Wallet) VerifyAnonCardTransaction(ctx context.Context, transactionB64 string, requiredDestination string) (*walletutils.TransactionInfo, error)

VerifyAnonCardTransaction calls VerifyTransaction and checks the currency, amount and destination

func (*Wallet) VerifyTransaction

func (w *Wallet) VerifyTransaction(ctx context.Context, transactionB64 string) (*walletutils.TransactionInfo, error)

VerifyTransaction verifies that the transaction is valid NOTE VerifyTransaction guards against transactions that seek to exploit parser differences such as including additional fields that are not understood by this implementation but may be understood by the upstream wallet provider. See DecodeTransaction for details.

Jump to

Keyboard shortcuts

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