stellar

package
v5.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: BSD-3-Clause, BSD-3-Clause Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const AccountNameMaxRunes = 24
View Source
const DefaultCurrencySetting = "USD"

Variables

View Source
var ErrAccountNotFound = errors.New("account not found for user")

ErrAccountNotFound is returned when the account is not in WalletState's accounts map.

View Source
var ErrRefreshQueueFull = errors.New("refresh queue is full")

ErrRefreshQueueFull is returned when the refresh queue is clogged up.

View Source
var ErrRelayinMultiBatch = errors.New("relay recipient not allowed in a multi-op batch")

Functions

func AccountDetails

func AccountDetails(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (stellar1.AccountDetails, error)

AccountDetails gets stellar1.AccountDetails for accountID.

It has the side effect of updating the badge state with the stellar payment unread count for accountID.

func AccountDetailsToWalletAccountLocal

func AccountDetailsToWalletAccountLocal(mctx libkb.MetaContext, accountID stellar1.AccountID, details stellar1.AccountDetails,
	isPrimary bool, accountName string, accountMode stellar1.AccountMode) (stellar1.WalletAccountLocal, error)

func AccountExchangeRate

func AccountExchangeRate(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (stellar1.OutsideExchangeRate, error)

AccountExchangeRate returns the exchange rate for an account for the logged in user. Note that it is possible that multiple users can own the same account and have different display currency preferences.

func AccountMerge

func AccountMerge(mctx libkb.MetaContext, walletState *WalletState, arg stellar1.AccountMergeCLILocalArg) (res stellarnet.SignResult, err error)

func AddTrustlineLocal

func AddTrustlineLocal(mctx libkb.MetaContext, arg stellar1.AddTrustlineLocalArg) (err error)

func AirdropStatus

func AirdropStatus(mctx libkb.MetaContext) (stellar1.AirdropStatus, error)

func AllWalletAccounts

func AllWalletAccounts(mctx libkb.MetaContext, remoter remote.Remoter) ([]stellar1.WalletAccountLocal, error)

func AssetSliceToAssetBase

func AssetSliceToAssetBase(path []stellar1.Asset) []stellarnet.AssetBase

AssetSliceToAssetBase converts []stellar1.Asset to []stellarnet.AssetBase.

func Batch

func Batch(mctx libkb.MetaContext, walletState *WalletState, arg stellar1.BatchLocalArg) (res stellar1.BatchResultLocal, err error)

Batch sends a batch of payments from the user to multiple recipients in a time-efficient manner.

func BatchMulti

func BatchMulti(mctx libkb.MetaContext, walletState *WalletState, arg stellar1.BatchLocalArg) (res stellar1.BatchResultLocal, err error)

BatchMulti sends a batch of payments from the user to multiple recipients in a single multi-operation transaction.

func ChangeAccountName

func ChangeAccountName(m libkb.MetaContext, walletState *WalletState, accountID stellar1.AccountID, newName string) (err error)

ChangeAccountName changes the name of an account. Make sure to keep this in sync with ValidateAccountNameLocal. An empty name is not allowed. Renaming an account to an already used name is blocked. Maximum length of AccountNameMaxRunes runes.

func ChangeTrustlineLimitLocal

func ChangeTrustlineLimitLocal(mctx libkb.MetaContext, arg stellar1.ChangeTrustlineLimitLocalArg) (err error)

func Claim

func Claim(mctx libkb.MetaContext, walletState *WalletState,
	txID string, into stellar1.AccountID, dir *stellar1.RelayDirection,
	autoClaimToken *string) (res stellar1.RelayClaimResult, err error)

Claim claims a waiting relay. If `dir` is nil the direction is inferred.

func CreateNewAccount

func CreateNewAccount(mctx libkb.MetaContext, accountName string) (ret stellar1.AccountID, err error)

func CreateWallet

func CreateWallet(mctx libkb.MetaContext) (created bool, err error)

CreateWallet creates and posts an initial stellar bundle for a user. Only succeeds if they do not already have one. Safe (but wasteful) to call even if the user has a bundle already.

func CreateWalletSoft added in v1.0.48

func CreateWalletSoft(mctx libkb.MetaContext)

CreateWalletSoft creates a user's initial wallet if they don't already have one. Does not get in the way of intentional user actions.

func DeleteAccount

func DeleteAccount(m libkb.MetaContext, accountID stellar1.AccountID) error

func DeleteTrustlineLocal

func DeleteTrustlineLocal(mctx libkb.MetaContext, arg stellar1.DeleteTrustlineLocalArg) (err error)

func EmptyAmountStack

func EmptyAmountStack(mctx libkb.MetaContext)

func ExportSecretKey added in v1.0.48

func ExportSecretKey(mctx libkb.MetaContext, accountID stellar1.AccountID) (res stellar1.SecretKey, err error)

func FindPaymentPath

func FindPaymentPath(mctx libkb.MetaContext, remoter remote.Remoter, source stellar1.AccountID, to string, sourceAsset, destinationAsset stellar1.Asset, amount string) (stellar1.PaymentPath, error)

func FormatAmount

func FormatAmount(mctx libkb.MetaContext, amount string, precisionTwo bool, rounding stellarnet.FmtRoundingBehavior) (string, error)

func FormatAmountDescriptionAsset

func FormatAmountDescriptionAsset(mctx libkb.MetaContext, amount string, asset stellar1.Asset) (string, error)

Example: "157.5000000 XLM" Example: "12.9000000 USD"

(where USD is a non-native asset issued by someone).

User interfaces should be careful to never give user just amount + asset code, but annotate when it's a non-native asset and make Issuer ID and Verified Domain visible. If you are coming from CLI, FormatAmountDescriptionAssetEx might be a better choice which is more verbose about non-native assets.

func FormatAmountDescriptionAssetEx

func FormatAmountDescriptionAssetEx(mctx libkb.MetaContext, amount string, asset stellar1.Asset) (string, error)

FormatAmountDescriptionAssetEx is a more verbose version of FormatAmountDescriptionAsset. In case of non-native asset, it includes issuer domain (or "Unknown") and issuer ID. Example: "157.5000000 XLM" Example: "1,000.15 CATS/catmoney.example.com (GDWVJEG7CMYKRYGB2MWSRZNSPCWIGGA4FRNFTQBIR6RAEPNEGGEH4XYZ)" Example: "1,000.15 BTC/Unknown (GBPEHURSE52GCBRPDWNV2VL3HRLCI42367OGRPBOO3AW6VAYEW5EO5PM)"

func FormatAmountDescriptionAssetEx2

func FormatAmountDescriptionAssetEx2(mctx libkb.MetaContext, amount string, asset stellar1.Asset) (string, error)

FormatAmountDescriptionAssetEx2 is like FormatAmountDescriptionAssetEx, except that it only shows one of issuer domain and issuer account ID. When issuer domain is available, the domain is shown. Otherwise account ID is used. Example: "157.5000000 XLM" Example: "1,000.15 CATS/catmoney.example.com Example: "1,000.15 BTC/GBPEHURSE52GCBRPDWNV2VL3HRLCI42367OGRPBOO3AW6VAYEW5EO5PM"

func FormatAmountDescriptionXLM

func FormatAmountDescriptionXLM(mctx libkb.MetaContext, amount string) (string, error)

Example: "157.5000000 XLM"

func FormatAmountWithSuffix

func FormatAmountWithSuffix(mctx libkb.MetaContext, amount string, precisionTwo bool, simplify bool, suffix string) (string, error)

func FormatAssetIssuerString

func FormatAssetIssuerString(asset stellar1.Asset) string

FormatAssetIssuerString returns "Unknown issuer" if asset does not have a verified domain, or returns asset verified domain if it does (e.g. "example.com").

func FormatCurrency

func FormatCurrency(mctx libkb.MetaContext, amount string, code stellar1.OutsideCurrencyCode, rounding stellarnet.FmtRoundingBehavior) (string, error)

func FormatCurrencyWithCodeSuffix

func FormatCurrencyWithCodeSuffix(mctx libkb.MetaContext, amount string, code stellar1.OutsideCurrencyCode, rounding stellarnet.FmtRoundingBehavior) (string, error)

FormatCurrencyWithCodeSuffix will return a fiat currency amount formatted with its currency code suffix at the end, like "$123.12 CLP"

func FuzzyAssetSearch

func FuzzyAssetSearch(mctx libkb.MetaContext, remoter remote.Remoter, arg stellar1.FuzzyAssetSearchArg) ([]stellar1.Asset, error)

func GetAccountDisplayCurrency

func GetAccountDisplayCurrency(mctx libkb.MetaContext, accountID stellar1.AccountID) (res string, err error)

GetAccountDisplayCurrency gets currency setting from the server, and it returned currency is empty (NULL in database), then default "USD" is used. When creating a wallet, client always sets default currency setting. Also when a new account in existing wallet is created, it will inherit currency setting from primary account (this happens serverside). Empty currency settings should only happen in very old accounts or when wallet generation was interrupted in precise moment.

func GetCurrencySetting

func GetCurrencySetting(mctx libkb.MetaContext, accountID stellar1.AccountID) (res stellar1.CurrencyLocal, err error)

func GetInflationDestination

func GetInflationDestination(mctx libkb.MetaContext, accountID stellar1.AccountID) (res stellar1.InflationDestinationResultLocal, err error)

func GetOwnPrimaryAccountID added in v1.0.48

func GetOwnPrimaryAccountID(mctx libkb.MetaContext) (res stellar1.AccountID, err error)

func GetPredefinedInflationDestinations

func GetPredefinedInflationDestinations(mctx libkb.MetaContext) (ret []stellar1.PredefinedInflationDestination, err error)

func HasAcceptedDisclaimer

func HasAcceptedDisclaimer(ctx context.Context, g *libkb.GlobalContext) (bool, error)

func ImportSecretKey added in v1.0.47

func ImportSecretKey(mctx libkb.MetaContext, secretKey stellar1.SecretKey, makePrimary bool, accountName string) (err error)

func InformAcceptedDisclaimer

func InformAcceptedDisclaimer(ctx context.Context, g *libkb.GlobalContext)

func LookupRecipient added in v1.0.48

func LookupRecipient(m libkb.MetaContext, to stellarcommon.RecipientInput, isCLI bool) (res stellarcommon.Recipient, err error)

LookupRecipient finds a recipient. `to` can be a username, social assertion, account ID, or federation address.

func LookupSenderPrimary added in v1.0.48

func LookupSenderPrimary(mctx libkb.MetaContext) (stellar1.BundleEntry, stellar1.AccountBundle, error)

func LookupUserByAccountID

func LookupUserByAccountID(m libkb.MetaContext, accountID stellar1.AccountID) (uv keybase1.UserVersion, un libkb.NormalizedUsername, err error)

Lookup a user who has the stellar account ID. Verifies the result against the user's sigchain. If there are no users, or multiple users, returns NotFoundError.

func MakeRequestCLI

func MakeRequestCLI(m libkb.MetaContext, remoter remote.Remoter, arg MakeRequestArg) (ret stellar1.KeybaseRequestID, err error)

func MakeRequestGUI

func MakeRequestGUI(m libkb.MetaContext, remoter remote.Remoter, arg MakeRequestArg) (ret stellar1.KeybaseRequestID, err error)

func NoteDecryptB64 added in v1.0.48

func NoteDecryptB64(mctx libkb.MetaContext, noteB64 string) (res stellar1.NoteContents, err error)

func NoteEncryptB64 added in v1.0.48

func NoteEncryptB64(mctx libkb.MetaContext, note stellar1.NoteContents, other *keybase1.UserVersion) (noteB64 string, err error)

func OwnAccount added in v1.0.48

func OwnAccount(mctx libkb.MetaContext, accountID stellar1.AccountID) (own, isPrimary bool, err error)

func OwnAccountCached

func OwnAccountCached(mctx libkb.MetaContext, accountID stellar1.AccountID) (own, isPrimary bool, err error)

func PathPaymentTx

PathPaymentTx reutrns a signed path payment tx.

func PaymentDetailCLILocal added in v1.0.48

func PaymentDetailCLILocal(ctx context.Context, g *libkb.GlobalContext, remoter remote.Remoter, txID string) (res stellar1.PaymentCLILocal, err error)

func RandomBuildPaymentID

func RandomBuildPaymentID() (stellar1.BuildPaymentID, error)

func RecentPaymentsCLILocal added in v1.0.48

func RecentPaymentsCLILocal(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (res []stellar1.PaymentOrErrorCLILocal, err error)

func RefreshUnreadCount

func RefreshUnreadCount(g *libkb.GlobalContext, accountID stellar1.AccountID)

func RemotePendingToLocal

func RemotePendingToLocal(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID, pending []stellar1.PaymentSummary) (payments []stellar1.PaymentOrErrorLocal, err error)

func RemoteRecentPaymentsToPage

func RemoteRecentPaymentsToPage(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID, remotePage stellar1.PaymentsPage) (page stellar1.PaymentsPageLocal, err error)

func ReviewPaymentLocal

func ReviewPaymentLocal(mctx libkb.MetaContext, stellarUI stellar1.UiInterface, arg stellar1.ReviewPaymentLocalArg) (err error)

func SendMiniChatPayments

func SendMiniChatPayments(m libkb.MetaContext, walletState *WalletState, convID chat1.ConversationID, payments []libkb.MiniChatPayment) (res []libkb.MiniChatPaymentResult, err error)

SendMiniChatPayments sends multiple payments from one sender to multiple different recipients as fast as it can. These come from chat messages like "+1XLM@alice +2XLM@charlie".

func ServiceInit added in v1.0.48

func ServiceInit(g *libkb.GlobalContext, walletState *WalletState, badger *badges.Badger)

func SetAccountAsPrimary

func SetAccountAsPrimary(m libkb.MetaContext, walletState *WalletState, accountID stellar1.AccountID) (err error)

func SetInflationDestinationLocal

func SetInflationDestinationLocal(mctx libkb.MetaContext, arg stellar1.SetInflationDestinationLocalArg) (err error)

func ShouldOfferAdvancedSend

func ShouldOfferAdvancedSend(mctx libkb.MetaContext, remoter remote.Remoter, from, to stellar1.AccountID) (shouldShow stellar1.AdvancedBanner, err error)

func SpecMiniChatPayments

func SpecMiniChatPayments(mctx libkb.MetaContext, walletState *WalletState, payments []libkb.MiniChatPayment) (*libkb.MiniChatPaymentSummary, error)

SpecMiniChatPayments returns a summary of the payment amounts for each recipient and a total.

func StartBuildPaymentLocal

func StartBuildPaymentLocal(mctx libkb.MetaContext) (res stellar1.BuildPaymentID, err error)

func StopBuildPaymentLocal

func StopBuildPaymentLocal(mctx libkb.MetaContext, bid stellar1.BuildPaymentID)

func SubtractFeeSoft

func SubtractFeeSoft(mctx libkb.MetaContext, availableStr string, baseFee uint64) string

Subtract baseFee from the available balance. This shows the real available balance assuming an intent to send a 1 op tx. Does not error out, just shows the inaccurate answer.

func TransformPaymentSummaryAccount

func TransformPaymentSummaryAccount(mctx libkb.MetaContext, p stellar1.PaymentSummary, oc OwnAccountLookupCache, accountID stellar1.AccountID) (*stellar1.PaymentLocal, error)

TransformPaymentSummaryAccount converts a stellar1.PaymentSummary (p) into a stellar1.PaymentLocal, from the perspective of an owner of accountID.

func TransformPaymentSummaryGeneric

func TransformPaymentSummaryGeneric(mctx libkb.MetaContext, p stellar1.PaymentSummary, oc OwnAccountLookupCache) (*stellar1.PaymentLocal, error)

TransformPaymentSummaryGeneric converts a stellar1.PaymentSummary (p) into a stellar1.PaymentLocal, without any modifications based on who is viewing the transaction.

func TransformToAirdropStatus

func TransformToAirdropStatus(status remote.AirdropStatusAPI) stellar1.AirdropStatus

TransformToAirdropStatus takes the result from api server status_check and transforms it into stellar1.AirdropStatus.

func Upkeep

func Upkeep(mctx libkb.MetaContext) (err error)

Upkeep makes sure the bundle is encrypted for the user's latest PUK.

func WalletAccount

func WalletAccount(mctx libkb.MetaContext, remoter remote.Remoter, accountID stellar1.AccountID) (stellar1.WalletAccountLocal, error)

WalletAccount returns stellar1.WalletAccountLocal for accountID.

Types

type AccountState

type AccountState struct {
	sync.RWMutex // protects everything that follows
	// contains filtered or unexported fields
}

AccountState holds the current data for a stellar account.

func (*AccountState) AccountSeqno

func (a *AccountState) AccountSeqno(ctx context.Context) (uint64, error)

AccountSeqno returns the seqno that has already been fetched for this account.

func (*AccountState) AccountSeqnoAndBump

func (a *AccountState) AccountSeqnoAndBump(ctx context.Context) (uint64, error)

AccountSeqnoAndBump returns the seqno that has already been fetched for this account. It bumps the seqno up by one.

func (*AccountState) AddPendingTx

func (a *AccountState) AddPendingTx(ctx context.Context, txID stellar1.TransactionID, seqno uint64) error

AddPendingTx adds information about a tx that was submitted to the network. This allows AccountState to keep track of anything pending when managing the account seqno.

func (*AccountState) Balances

func (a *AccountState) Balances(ctx context.Context) ([]stellar1.Balance, error)

Balances returns the balances that have already been fetched for this account.

func (*AccountState) Details

Details returns the account details that have already been fetched for this account.

func (*AccountState) ForceSeqnoRefresh

func (a *AccountState) ForceSeqnoRefresh(mctx libkb.MetaContext) error

ForceSeqnoRefresh refreshes the seqno for an account.

func (*AccountState) PendingPayments

func (a *AccountState) PendingPayments(ctx context.Context, limit int) ([]stellar1.PaymentSummary, error)

PendingPayments returns the pending payments that have already been fetched for this account.

func (*AccountState) RecentPayments

func (a *AccountState) RecentPayments(ctx context.Context) (stellar1.PaymentsPage, error)

RecentPayments returns the recent payments that have already been fetched for this account.

func (*AccountState) Refresh

func (a *AccountState) Refresh(mctx libkb.MetaContext, router *libkb.NotifyRouter, reason string) error

Refresh updates all the data for this account from the server.

func (*AccountState) RefreshWithDetails

func (a *AccountState) RefreshWithDetails(mctx libkb.MetaContext, router *libkb.NotifyRouter, reason string, details *stellar1.DetailsPlusPayments) error

RefreshWithDetails updates all the data for this account with the provided details data.

func (*AccountState) RemovePendingTx

func (a *AccountState) RemovePendingTx(ctx context.Context, txID stellar1.TransactionID) error

RemovePendingTx removes a pending tx from WalletState. It doesn't matter if it succeeded or failed, just that it is done.

func (*AccountState) Reset

func (a *AccountState) Reset(mctx libkb.MetaContext)

Reset sets the refreshReqs channel to nil so nothing will be put on it.

func (*AccountState) SeqnoDebug

func (a *AccountState) SeqnoDebug(mctx libkb.MetaContext)

SeqnoDebug outputs some information about the seqno state.

func (*AccountState) String

func (a *AccountState) String() string

String returns a small string representation of AccountState suitable for debug logging.

type AccountsCache

type AccountsCache struct {
	Stored   time.Time
	Revision stellar1.BundleRevision
	Accounts []stellar1.BundleEntry
}

type AutoClaimRunner

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

Claims relay payments in the background. Threadsafe.

func NewAutoClaimRunner

func NewAutoClaimRunner(walletState *WalletState) *AutoClaimRunner

func (*AutoClaimRunner) Kick

func (r *AutoClaimRunner) Kick(mctx libkb.MetaContext, trigger gregor.MsgID)

Kick the processor into gear. It will run until all relays in the queue are claimed. And then dismiss the gregor message. `trigger` is optional, and is of the gregor message that caused the kick.

func (*AutoClaimRunner) Shutdown

func (r *AutoClaimRunner) Shutdown(mctx libkb.MetaContext)

type BuildPaymentCache

type BuildPaymentCache interface {
	PrimaryAccount(libkb.MetaContext) (stellar1.AccountID, error)
	// AccountSeqno should be cached _but_ it should also be busted asap.
	// Because it is used to prevent users from sending payments twice in a row.
	AccountSeqno(libkb.MetaContext, stellar1.AccountID) (string, error)
	IsAccountFunded(libkb.MetaContext, stellar1.AccountID, stellar1.BuildPaymentID) (bool, error)
	LookupRecipient(libkb.MetaContext, stellarcommon.RecipientInput) (stellarcommon.Recipient, error)
	GetOutsideExchangeRate(libkb.MetaContext, stellar1.OutsideCurrencyCode) (stellar1.OutsideExchangeRate, error)
	AvailableXLMToSend(libkb.MetaContext, stellar1.AccountID) (string, error)
	GetOutsideCurrencyPreference(libkb.MetaContext, stellar1.AccountID, stellar1.BuildPaymentID) (stellar1.OutsideCurrencyCode, error)
	ShouldOfferAdvancedSend(mctx libkb.MetaContext, from, to stellar1.AccountID) (stellar1.AdvancedBanner, error)
	InformDefaultCurrencyChange(mctx libkb.MetaContext)
}

BuildPaymentCache has helpers for getting information quickly when building a payment. Methods should err on the side of performance rather at the cost of serialization. CORE-8119: But they don't yet.

type ClaimSeqnoProvider

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

ClaimSeqnoProvider is a build.SequenceProvider for relay claims. It should only be used for relay claims.

It only uses the network and skips any of the work in WalletState to keep track of in-use seqnos for multiple concurrent payments.

It also returns an `unlock` function that must be called after the operation that used this seqno provider has been submitted.

func NewClaimSeqnoProvider

func NewClaimSeqnoProvider(mctx libkb.MetaContext, walletState *WalletState) (seqnoProvider *ClaimSeqnoProvider, unlock func())

NewClaimSeqnoProvider creates a ClaimSeqnoProvider for use in relay claims.

func (*ClaimSeqnoProvider) SequenceForAccount

func (s *ClaimSeqnoProvider) SequenceForAccount(aid string) (xdr.SequenceNumber, error)

SequenceForAccount implements build.SequenceProvider.

type CreateWalletGatedResult

type CreateWalletGatedResult struct {
	JustCreated        bool  // whether the user's wallet was created by this call
	HasWallet          bool  // whether the user now has a wallet
	AcceptedDisclaimer bool  // whether the user has accepted the disclaimer
	ErrorCreating      error // error encountered while attempting to create the wallet
}

func CreateWalletGated

func CreateWalletGated(mctx libkb.MetaContext) (res CreateWalletGatedResult, err error)

CreateWalletGated may create a wallet for the user. Taking into account settings from the server. It should be speedy to call repeatedly _if_ the user gets a wallet.

type DisplayBalance

type DisplayBalance struct {
	Amount   string
	Currency string
}

type Loader

type Loader struct {
	libkb.Contextified

	sync.Mutex
	// contains filtered or unexported fields
}

func DefaultLoader

func DefaultLoader(g *libkb.GlobalContext) *Loader

func NewLoader

func NewLoader(g *libkb.GlobalContext) *Loader

func (*Loader) GetListener

func (p *Loader) GetListener() (id string, ch chan PaymentStatusUpdate, err error)

GetListener returns a channel and an ID for a payment status listener. The ID can be used to remove the listener from the loader.

func (*Loader) GetPaymentLocal

func (p *Loader) GetPaymentLocal(ctx context.Context, paymentID stellar1.PaymentID) (*stellar1.PaymentLocal, bool)

func (*Loader) LoadPayment

func (p *Loader) LoadPayment(ctx context.Context, convID chat1.ConversationID, msgID chat1.MessageID, senderUsername string, paymentID stellar1.PaymentID) *chat1.UIPaymentInfo

func (*Loader) LoadPaymentSync

func (p *Loader) LoadPaymentSync(ctx context.Context, paymentID stellar1.PaymentID)

func (*Loader) LoadRequest

func (p *Loader) LoadRequest(ctx context.Context, convID chat1.ConversationID, msgID chat1.MessageID, senderUsername string, requestID stellar1.KeybaseRequestID) *chat1.UIRequestInfo

func (*Loader) PaymentsLen

func (p *Loader) PaymentsLen() int

func (*Loader) RemoveListener

func (p *Loader) RemoveListener(id string)

RemoveListener removes a listener from the loader when it is no longer needed.

func (*Loader) RequestsLen

func (p *Loader) RequestsLen() int

func (*Loader) Shutdown

func (p *Loader) Shutdown() error

func (*Loader) UpdatePayment

func (p *Loader) UpdatePayment(ctx context.Context, paymentID stellar1.PaymentID)

UpdatePayment schedules a load of paymentID. Gregor status notification handlers should call this to update the payment data.

func (*Loader) UpdateRequest

func (p *Loader) UpdateRequest(ctx context.Context, requestID stellar1.KeybaseRequestID)

UpdateRequest schedules a load for requestID. Gregor status notification handlers should call this to update the request data.

type MakeRequestArg

type MakeRequestArg struct {
	To       stellarcommon.RecipientInput
	Amount   string
	Asset    *stellar1.Asset
	Currency *stellar1.OutsideCurrencyCode
	Note     string
}

type MiniPrepared

type MiniPrepared struct {
	Username libkb.NormalizedUsername
	Direct   *stellar1.PaymentDirectPost
	Relay    *stellar1.PaymentRelayPost
	TxID     stellar1.TransactionID
	Seqno    uint64
	Error    error
}

func PrepareBatchPayments

func PrepareBatchPayments(mctx libkb.MetaContext, walletState *WalletState, senderSeed stellarnet.SeedStr, payments []stellar1.BatchPaymentArg, batchID string) ([]*MiniPrepared, func(), error)

PrepareBatchPayments prepares a list of payments to be submitted. Each payment is prepared concurrently. (this is an exposed function to make testing from outside this package easier)

func PrepareMiniChatPayments

func PrepareMiniChatPayments(m libkb.MetaContext, walletState *WalletState, senderSeed stellarnet.SeedStr, convID chat1.ConversationID, payments []libkb.MiniChatPayment) ([]*MiniPrepared, func(), error)

type Options

type Options struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Options holds dynamic options for clients to use when preparing stellar transactions.

func NewOptions

func NewOptions() *Options

func (*Options) BaseFee

func (o *Options) BaseFee(mctx libkb.MetaContext, r remote.Remoter) uint64

func (*Options) NetworkOptions

func (o *Options) NetworkOptions(mctx libkb.MetaContext, r remote.Remoter) stellar1.NetworkOptions

NetworkOptions returns stellar1.NetworkOptions that is less than 1 hour old.

type OwnAccountLookupCache

type OwnAccountLookupCache interface {
	OwnAccount(ctx context.Context, accountID stellar1.AccountID) (own bool, accountName string, err error)
}

Short-lived cache for looking up whether the logged-in user owns accounts.

func NewOwnAccountLookupCache

func NewOwnAccountLookupCache(mctx libkb.MetaContext) OwnAccountLookupCache

NewOwnAccountLookupCache fetches the list of accounts in the background and stores them. Was created before Stellar.accounts, and could probably benefit from using that cache.

type PaymentStatusUpdate

type PaymentStatusUpdate struct {
	AccountID stellar1.AccountID
	TxID      stellar1.TransactionID
	Status    stellar1.PaymentStatus
}

type SendPathPaymentArg

type SendPathPaymentArg struct {
	From        stellar1.AccountID
	To          stellarcommon.RecipientInput
	Path        stellar1.PaymentPath
	SecretNote  string
	PublicMemo  *stellarnet.Memo
	QuickReturn bool
}

type SendPaymentArg

type SendPaymentArg struct {
	From           stellar1.AccountID // Optional. Defaults to primary account.
	To             stellarcommon.RecipientInput
	Amount         string // Amount of XLM to send.
	DisplayBalance DisplayBalance
	SecretNote     string           // Optional.
	PublicMemo     *stellarnet.Memo // Optional.
	ForceRelay     bool
	QuickReturn    bool
}

type SendPaymentResult

type SendPaymentResult struct {
	KbTxID stellar1.KeybaseTransactionID
	// Direct: tx ID of the payment tx
	// Relay : tx ID of the funding payment tx
	TxID    stellar1.TransactionID
	Pending bool
	// Implicit team that the relay secret is encrypted for.
	// Present if this was a relay transfer.
	RelayTeamID *keybase1.TeamID
	JumpToChat  string
}

func SendPathPaymentCLI

func SendPathPaymentCLI(mctx libkb.MetaContext, walletState *WalletState, sendArg SendPathPaymentArg) (res SendPaymentResult, err error)

SendPathPaymentCLI sends a path payment from CLI.

func SendPathPaymentGUI

func SendPathPaymentGUI(mctx libkb.MetaContext, walletState *WalletState, sendArg SendPathPaymentArg) (res SendPaymentResult, err error)

SendPathPaymentGUI sends a path payment from GUI.

func SendPaymentCLI

func SendPaymentCLI(m libkb.MetaContext, walletState *WalletState, sendArg SendPaymentArg) (res SendPaymentResult, err error)

SendPaymentCLI sends XLM from CLI.

func SendPaymentGUI

func SendPaymentGUI(m libkb.MetaContext, walletState *WalletState, sendArg SendPaymentArg) (res SendPaymentResult, err error)

SendPaymentGUI sends XLM from GUI.

type SeqnoProvider added in v1.0.48

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

SeqnoProvider implements build.SequenceProvider. It can be used for several transactions in a row.

func NewSeqnoProvider added in v1.0.48

func NewSeqnoProvider(mctx libkb.MetaContext, walletState *WalletState) (seqnoProvider *SeqnoProvider, unlock func())

NewSeqnoProvider creates a SeqnoProvider. It also returns an `unlock` function that must be called after the operation(s) that used this seqno provider have been submitted.

The idea here is to fix a race where multiple calls to send payments will make a SeqnoProvider and while they will consume seqnos in order, they are not guaranteed to be submitted in order. In particular, the `dust storm` function in the bot has a tendency to expose the race.

func (*SeqnoProvider) SequenceForAccount added in v1.0.48

func (s *SeqnoProvider) SequenceForAccount(aid string) (xdr.SequenceNumber, error)

SequenceForAccount implements build.SequenceProvider.

type Stellar added in v1.0.48

type Stellar struct {
	libkb.Contextified
	// contains filtered or unexported fields
}

func NewStellar added in v1.0.48

func NewStellar(g *libkb.GlobalContext, walletState *WalletState, badger *badges.Badger) *Stellar

func (*Stellar) BaseFee

func (s *Stellar) BaseFee(mctx libkb.MetaContext) uint64

BaseFee returns the server-suggested base fee per operation.

func (*Stellar) CachedHasWallet

func (s *Stellar) CachedHasWallet(ctx context.Context, uv keybase1.UserVersion) bool

func (*Stellar) Clear

func (s *Stellar) Clear(mctx libkb.MetaContext)

func (*Stellar) CreateWalletSoft added in v1.0.48

func (s *Stellar) CreateWalletSoft(ctx context.Context)

func (*Stellar) GetServerDefinitions

func (s *Stellar) GetServerDefinitions(ctx context.Context) (ret stellar1.StellarServerDefinitions, err error)

func (*Stellar) HandleOobm

func (s *Stellar) HandleOobm(ctx context.Context, obm gregor.OutOfBandMessage) (bool, error)

HandleOobm will handle any out of band gregor messages for stellar.

func (*Stellar) InformBundle

func (s *Stellar) InformBundle(mctx libkb.MetaContext, rev stellar1.BundleRevision, accounts []stellar1.BundleEntry)

func (*Stellar) InformDefaultCurrencyChange

func (s *Stellar) InformDefaultCurrencyChange(mctx libkb.MetaContext)

func (*Stellar) InformHasWallet

func (s *Stellar) InformHasWallet(ctx context.Context, uv keybase1.UserVersion)

func (*Stellar) KickAutoClaimRunner

func (s *Stellar) KickAutoClaimRunner(mctx libkb.MetaContext, trigger gregor.MsgID)

`trigger` is optional, and is of the gregor message that caused the kick.

func (*Stellar) KnownCurrencyCodeInstant

func (s *Stellar) KnownCurrencyCodeInstant(ctx context.Context, code string) (known, ok bool)

func (*Stellar) OnDbNuke

func (s *Stellar) OnDbNuke(mctx libkb.MetaContext) error

func (*Stellar) OnLogout added in v1.0.48

func (s *Stellar) OnLogout(mctx libkb.MetaContext) error

func (*Stellar) OwnAccountCached

func (s *Stellar) OwnAccountCached(mctx libkb.MetaContext, accountID stellar1.AccountID) (own, isPrimary bool, err error)

func (*Stellar) Refresh

func (s *Stellar) Refresh(mctx libkb.MetaContext, reason string)

func (*Stellar) RemovePendingTx

func (s *Stellar) RemovePendingTx(mctx libkb.MetaContext, accountID stellar1.AccountID, txID stellar1.TransactionID) error

func (*Stellar) SendMiniChatPayments

func (s *Stellar) SendMiniChatPayments(mctx libkb.MetaContext, convID chat1.ConversationID, payments []libkb.MiniChatPayment) ([]libkb.MiniChatPaymentResult, error)

SendMiniChatPayments sends multiple payments from one sender to multiple different recipients as fast as it can. These come from chat messages like "+1XLM@alice +2XLM@charlie".

func (*Stellar) SetFederationClientForTest

func (s *Stellar) SetFederationClientForTest(cli federation.ClientInterface)

func (*Stellar) SpecMiniChatPayments

func (s *Stellar) SpecMiniChatPayments(mctx libkb.MetaContext, payments []libkb.MiniChatPayment) (*libkb.MiniChatPaymentSummary, error)

SpecMiniChatPayments creates a summary of the amounts that a list of MiniChatPayments will result in.

func (*Stellar) UpdateUnreadCount

func (s *Stellar) UpdateUnreadCount(ctx context.Context, accountID stellar1.AccountID, unread int) error

UpdateUnreadCount will take the unread count for an account id and update the badger.

func (*Stellar) Upkeep added in v1.0.48

func (s *Stellar) Upkeep(ctx context.Context) error

func (*Stellar) WalletStateForTest

func (s *Stellar) WalletStateForTest() *WalletState

type TimeCache

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

Threadsafe cache with expiration and singleflighting.

func NewTimeCache

func NewTimeCache(name string, size int, maxAge time.Duration) *TimeCache

func (*TimeCache) Clear

func (c *TimeCache) Clear()

func (*TimeCache) Get

func (c *TimeCache) Get(mctx libkb.MetaContext, key string, into interface{}) (ok bool)

func (*TimeCache) GetWithFill

func (c *TimeCache) GetWithFill(mctx libkb.MetaContext, key string, into interface{}, fill cacheFillFunc) error

GetWithFill is prefereable to Get because it holds a locktab lock during the fill. Which prevents concurrent accesses from doing the extra work of running fill at the same time.

func (*TimeCache) Put

func (c *TimeCache) Put(mctx libkb.MetaContext, key string, val interface{})

type WalletState

type WalletState struct {
	libkb.Contextified
	remote.Remoter

	sync.Mutex
	// contains filtered or unexported fields
}

WalletState holds all the current data for all the accounts for the user. It is also a remote.Remoter and should be used in place of it so network calls can be avoided.

func NewWalletState

func NewWalletState(g *libkb.GlobalContext, r remote.Remoter) *WalletState

NewWalletState creates a wallet state with a remoter that will be used for any network calls.

func (*WalletState) AccountMode

func (w *WalletState) AccountMode(accountID stellar1.AccountID) (stellar1.AccountMode, error)

AccountMode returns the mode of the account (USER or MOBILE). MOBILE accounts can only get access to the secret key from a mobile device.

func (*WalletState) AccountName

func (w *WalletState) AccountName(accountID stellar1.AccountID) (string, error)

AccountName returns the name for an account.

func (*WalletState) AccountSeqno

func (w *WalletState) AccountSeqno(ctx context.Context, accountID stellar1.AccountID) (uint64, error)

AccountSeqno is an override of remoter's AccountSeqno that uses the stored value.

func (*WalletState) AccountSeqnoAndBump

func (w *WalletState) AccountSeqnoAndBump(ctx context.Context, accountID stellar1.AccountID) (uint64, error)

AccountSeqnoAndBump gets the current seqno for an account and increments the stored value.

func (*WalletState) AddPendingTx

func (w *WalletState) AddPendingTx(ctx context.Context, accountID stellar1.AccountID, txID stellar1.TransactionID, seqno uint64) error

AddPendingTx adds information about a tx that was submitted to the network. This allows WalletState to keep track of anything pending when managing the account seqno.

func (*WalletState) Balances

func (w *WalletState) Balances(ctx context.Context, accountID stellar1.AccountID) ([]stellar1.Balance, error)

Balances is an override of remoter's Balances that uses stored data.

func (*WalletState) BaseFee

func (w *WalletState) BaseFee(mctx libkb.MetaContext) uint64

BaseFee returns stellard's current suggestion for the base operation fee.

func (*WalletState) Details

func (w *WalletState) Details(ctx context.Context, accountID stellar1.AccountID) (stellar1.AccountDetails, error)

Details is an override of remoter's Details that uses stored data.

func (*WalletState) DumpToLog

func (w *WalletState) DumpToLog(mctx libkb.MetaContext)

DumpToLog outputs a summary of WalletState to the debug log.

func (*WalletState) ExchangeRate

func (w *WalletState) ExchangeRate(ctx context.Context, currency string) (stellar1.OutsideExchangeRate, error)

ExchangeRate is an overrider of remoter's ExchangeRate.

func (*WalletState) ForceSeqnoRefresh

func (w *WalletState) ForceSeqnoRefresh(mctx libkb.MetaContext, accountID stellar1.AccountID) error

ForceSeqnoRefresh refreshes the seqno for an account.

func (*WalletState) IsPrimary

func (w *WalletState) IsPrimary(accountID stellar1.AccountID) (bool, error)

IsPrimary returns true if an account is the primary account for the user.

func (*WalletState) MarkAsRead

func (w *WalletState) MarkAsRead(ctx context.Context, accountID stellar1.AccountID, mostRecentID stellar1.TransactionID) error

MarkAsRead is an override of remoter's MarkAsRead.

func (*WalletState) PendingPayments

func (w *WalletState) PendingPayments(ctx context.Context, accountID stellar1.AccountID, limit int) ([]stellar1.PaymentSummary, error)

PendingPayments is an override of remoter's PendingPayments that uses stored data.

func (*WalletState) Primed

func (w *WalletState) Primed() bool

Primed returns true if the WalletState has been refreshed.

func (*WalletState) RecentPayments

RecentPayments is an override of remoter's RecentPayments that uses stored data.

func (*WalletState) Refresh

func (w *WalletState) Refresh(mctx libkb.MetaContext, accountID stellar1.AccountID, reason string) error

Refresh gets all the data from the server for an account.

func (*WalletState) RefreshAll

func (w *WalletState) RefreshAll(mctx libkb.MetaContext, reason string) error

RefreshAll refreshes all the accounts.

func (*WalletState) RefreshAsync

func (w *WalletState) RefreshAsync(mctx libkb.MetaContext, accountID stellar1.AccountID, reason string) error

RefreshAsync makes a request to refresh an account in the background. It clears the refresh time to ensure that a refresh happens/

func (*WalletState) RemovePendingTx

func (w *WalletState) RemovePendingTx(ctx context.Context, accountID stellar1.AccountID, txID stellar1.TransactionID) error

RemovePendingTx removes a pending tx from WalletState. It doesn't matter if it succeeded or failed, just that it is done.

func (*WalletState) Reset

func (w *WalletState) Reset(mctx libkb.MetaContext)

Reset clears all the data in the WalletState.

func (*WalletState) SeqnoLock

func (w *WalletState) SeqnoLock()

SeqnoLock acquires a lock on seqno operations. NewSeqnoProvider calls it. After all operations with a seqno provider are done (i.e. fully submitted to stellard), then the lock should be released with SeqnoUnlock.

func (*WalletState) SeqnoUnlock

func (w *WalletState) SeqnoUnlock()

SeqnoUnlock releases the lock on seqno operations.

func (*WalletState) Shutdown

func (w *WalletState) Shutdown(mctx libkb.MetaContext) error

Shutdown terminates any background operations and cleans up.

func (*WalletState) String

func (w *WalletState) String() string

String returns a string representation of WalletState suitable for debug logging.

func (*WalletState) SubmitPayment

SubmitPayment is an override of remoter's SubmitPayment.

func (*WalletState) SubmitRelayClaim

SubmitRelayClaim is an override of remoter's SubmitRelayClaim.

func (*WalletState) SubmitRelayPayment

func (w *WalletState) SubmitRelayPayment(ctx context.Context, post stellar1.PaymentRelayPost) (stellar1.PaymentResult, error)

SubmitRelayPayment is an override of remoter's SubmitRelayPayment.

func (*WalletState) UpdateAccountEntries

func (w *WalletState) UpdateAccountEntries(mctx libkb.MetaContext, reason string) (err error)

UpdateAccountEntries gets the bundle from the server and updates the individual account entries with the server's bundle information.

func (*WalletState) UpdateAccountEntriesWithBundle

func (w *WalletState) UpdateAccountEntriesWithBundle(mctx libkb.MetaContext, reason string, bundle *stellar1.Bundle) (err error)

UpdateAccountEntriesWithBundle updates the individual account entries with the bundle information.

Directories

Path Synopsis
this file is for the implementation of all the frontend-requested service endpoints for wallets.
this file is for the implementation of all the frontend-requested service endpoints for wallets.

Jump to

Keyboard shortcuts

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