Documentation ¶
Overview ¶
Package client implements a CR complient client.
The diagram below shows the major layers of the client. Depicted is Alice sending a message while Bob is receiving it.
Alice server Bob +----------+ +----------+ | Client | | Client | +----------+ +----------+ | | | | | | +------------+ +------------+ | RemoteUser | . . . . . . . . . . . . . . . . . . . . . | RemoteUser | +------------+ +------------+ | | | | | | +---------+ +-----------------+ +---------------+ | rmq | . . . . . . | subscriptions |. . . . . .| rdzvManager | +---------+ +-----------------+ +---------------+ | | | | | | | | | +-----------------+ +------------------+ +-----------------+ ---------->| serverSession | . . . . | client session | . . . . | serverSession | / +-----------------+ +------------------+ +-----------------+ / / | | | +-------------+ / | | | | connKeeper |<------- | | | +-------------+ +-------+ +-------+ +-------+ | net |-------------------| net |-------------------- | net | +-------+ +-------+ +-------+
Each layer has certain specific responsibilities and attempts to maintain certain invariants for the other layers:
`net`: Lower-level network connection (currently TLS)
`connKeeper`: Attempts to keep an open connection to the server. Whenever a new connection is made, a new instance of `serverSession` is created
`serverSession`: Maintains the tag stack invariant (max inflight, non-acked messages to the server), encrypts/decrypts the wire msgs w/ the per-session key
`rmq`: outbound RoutedMessages queue; pays for each outbound RM before sending it, encrypts each RM according to its type (clear text, kx, ratchet)
`rdzvManager`: Rendezvous Manager, is the inbound RM queue; ensures the client is subscribed to the appropriate RV points in the server as needed and decides which `remoteUser` to call for every pushed RM
`RemoteUser`: holds the ratchet state for each user the client has completed a kx flow with and progresses it as RMs are sent and received. Also implements per-user higher level calls (send/receive PMs, files, etc)
Each layer is tipically implemented as a runnable state machine, where its API is (usually) synchronous and concurrent-safe and actions are performed in its `run()` call.
The main public-facing structures of this package are `Config` and `Client`. Consumers (e.g. a GUI or CLI client app) setup a `Config` instance as needed, create a new client instance and run it. The client will maintain its operations until one of its subsystems fail (in which case `Run()` returns with an error) or the context is canceled.
Index ¶
- Constants
- Variables
- func CheckLNWalletUsable(ctx context.Context, lc lnrpc.LightningClient, svrNode string) error
- func PaymentFeeLimit(amountMAtoms uint64) *lnrpc.FeeLimit
- func TrackWalletCheckEvents(ctx context.Context, lnRPC lnrpc.LightningClient) (chan struct{}, error)
- type ChatHistoryEntry
- type Client
- func (c *Client) AcceptGroupChatInvite(iid uint64) error
- func (c *Client) AcceptInvite(invite rpc.OOBPublicIdentityInvite) error
- func (c *Client) AddInviteOnKX(initialRV, gcID zkidentity.ShortID) error
- func (c *Client) AddToGCBlockList(gcid zkidentity.ShortID, uid UserID) error
- func (c *Client) AddressBook() []*clientdb.AddressBookEntry
- func (c *Client) AddressBookEntry(uid UserID) (*clientdb.AddressBookEntry, error)
- func (c *Client) AddressBookLoaded() <-chan struct{}
- func (c *Client) AliasGC(gcID zkidentity.ShortID, newAlias string) error
- func (c *Client) AllRemoteUsers() []*RemoteUser
- func (c *Client) Backup(_ context.Context, rootDir, destPath string) (string, error)
- func (c *Client) Block(uid UserID) error
- func (c *Client) CancelDownload(fid clientdb.FileID) error
- func (c *Client) CancelOnboarding() error
- func (c *Client) ClearPayStats(uid *UserID) error
- func (c *Client) CommentPost(postFrom clientintf.UserID, pid clientintf.PostID, comment string, ...) (clientintf.ID, error)
- func (c *Client) CreatePost(post, descr string) (clientdb.PostSummary, error)
- func (c *Client) CreatePrepaidInvite(w io.Writer, funds *rpc.InviteFunds) (rpc.OOBPublicIdentityInvite, clientintf.PaidInviteKey, error)
- func (c *Client) FetchLocalResource(path []string, meta map[string]string, data json.RawMessage) error
- func (c *Client) FetchPrepaidInvite(ctx context.Context, key clientintf.PaidInviteKey, w io.Writer) (rpc.OOBPublicIdentityInvite, error)
- func (c *Client) FetchResource(uid UserID, path []string, meta map[string]string, ...) (rpc.ResourceTag, error)
- func (c *Client) FillTestInterface(i *testutils.UnsafeTestInterface)
- func (c *Client) FilterGCM(uid UserID, gcid zkidentity.ShortID, msg string) (bool, uint64)
- func (c *Client) FilterPM(uid UserID, msg string) (bool, uint64)
- func (c *Client) FilterPost(uid UserID, pid clientintf.PostID, post string) (bool, uint64)
- func (c *Client) FilterPostComment(uid, postFrom UserID, pid clientintf.PostID, comment string) (bool, uint64)
- func (c *Client) FindSharedFileID(fname string) (clientdb.FileID, error)
- func (c *Client) GCIDByName(name string) (zkidentity.ShortID, error)
- func (c *Client) GCKick(gcID zkidentity.ShortID, uid UserID, reason string) error
- func (c *Client) GCMessage(gcID zkidentity.ShortID, msg string, mode rpc.MessageMode, ...) error
- func (c *Client) GCsWithMember(uid UserID) ([]zkidentity.ShortID, error)
- func (c *Client) GCsWithPrefix(prefix string) []string
- func (c *Client) GetGC(gcID zkidentity.ShortID) (rpc.RMGroupList, error)
- func (c *Client) GetGCAlias(gcID zkidentity.ShortID) (string, error)
- func (c *Client) GetGCBlockList(gcID zkidentity.ShortID) (clientdb.GCBlockList, error)
- func (c *Client) GetKXSearch(targetID UserID) (clientdb.KXSearch, error)
- func (c *Client) GetUserContent(uid UserID, fid clientdb.FileID) error
- func (c *Client) GetUserPost(from UserID, pid clientintf.PostID, includeStatus bool) error
- func (c *Client) GoOnline()
- func (c *Client) Handshake(uid UserID) error
- func (c *Client) HasDownloadedFile(fid zkidentity.ShortID) (string, error)
- func (c *Client) HasPostSubscribers() (bool, error)
- func (c *Client) HeartPost(from clientintf.UserID, pid clientintf.PostID, heart bool) error
- func (c *Client) Ignore(uid UserID, ignore bool) error
- func (c *Client) InviteToGroupChat(gcID zkidentity.ShortID, user UserID) error
- func (c *Client) IsIgnored(uid clientintf.UserID) (bool, error)
- func (c *Client) KXSearchPostAuthor(postFrom UserID, post clientintf.PostID) error
- func (c *Client) KillGroupChat(gcID zkidentity.ShortID, reason string) error
- func (c *Client) ListContentFilters() []clientdb.ContentFilter
- func (c *Client) ListDownloads() ([]clientdb.FileDownload, error)
- func (c *Client) ListGCInvitesFor(gcid *zkidentity.ShortID) ([]*clientdb.GCInvite, error)
- func (c *Client) ListGCs() ([]rpc.RMGroupList, error)
- func (c *Client) ListKXSearches() ([]UserID, error)
- func (c *Client) ListKXs() ([]clientdb.KXData, error)
- func (c *Client) ListLocalSharedFiles() ([]clientdb.SharedFileAndShares, error)
- func (c *Client) ListMediateIDs() ([]clientdb.MediateIDRequest, error)
- func (c *Client) ListPaymentStats() (map[UserID]clientdb.UserPayStats, error)
- func (c *Client) ListPostCommentReceiveReceipts(pid clientintf.PostID, statusID zkidentity.ShortID) ([]*clientdb.ReceiveReceipt, error)
- func (c *Client) ListPostReceiveReceipts(pid clientintf.PostID) ([]*clientdb.ReceiveReceipt, error)
- func (c *Client) ListPostStatusUpdates(from UserID, pid clientintf.PostID) ([]rpc.PostMetadataStatus, error)
- func (c *Client) ListPostSubscribers() ([]clientintf.UserID, error)
- func (c *Client) ListPostSubscriptions() ([]clientdb.PostSubscription, error)
- func (c *Client) ListPosts() ([]clientdb.PostSummary, error)
- func (c *Client) ListRunningTipUserAttempts() ([]RunningTipUserAttempt, error)
- func (c *Client) ListTipUserAttempts(uid UserID) ([]clientdb.TipUserAttempt, error)
- func (c *Client) ListUserContent(uid UserID, dirs []string, filter string) error
- func (c *Client) ListUserPosts(uid UserID) error
- func (c *Client) ListUsersLastReceivedTime() ([]LastUserReceivedTime, error)
- func (c *Client) LocalNick() string
- func (c *Client) Logger() slog.Logger
- func (c *Client) ModifyGCAdmins(gcid zkidentity.ShortID, extraAdmins []zkidentity.ShortID, reason string) error
- func (c *Client) ModifyGCOwner(gcid zkidentity.ShortID, newOwner clientintf.UserID, reason string) error
- func (c *Client) NewGroupChat(name string) (zkidentity.ShortID, error)
- func (c *Client) NewGroupChatVersion(name string, version uint8) (zkidentity.ShortID, error)
- func (c *Client) NewPagesSession() (clientintf.PagesSessionID, error)
- func (c *Client) NicksWithPrefix(prefix string) []string
- func (c *Client) NotificationManager() *NotificationManager
- func (c *Client) OnchainRecvAddrForUser(uid UserID, acct string) (string, error)
- func (c *Client) PM(uid UserID, msg string) error
- func (c *Client) PartFromGC(gcID zkidentity.ShortID, reason string) error
- func (c *Client) Public() zkidentity.PublicIdentity
- func (c *Client) PublicID() UserID
- func (c *Client) RMQLen() (int, int)
- func (c *Client) RMQTimingStat() []timestats.Quantile
- func (c *Client) RVsUpToDate() bool
- func (c *Client) ReadHistoryMessages(uid UserID, isGC bool, page, pageNum int) ([]ChatHistoryEntry, time.Time, error)
- func (c *Client) ReadInvite(r io.Reader) (rpc.OOBPublicIdentityInvite, error)
- func (c *Client) ReadOnboard() (*clientintf.OnboardState, error)
- func (c *Client) ReadPost(uid clientintf.UserID, pid clientintf.PostID) (rpc.PostMetadata, error)
- func (c *Client) RelayPost(postFrom clientintf.UserID, pid clientintf.PostID, toUser clientintf.UserID) error
- func (c *Client) RelayPostToSubscribers(postFrom clientintf.UserID, pid clientintf.PostID) error
- func (c *Client) RemainOffline()
- func (c *Client) RemoveAllContentFilters() error
- func (c *Client) RemoveContentFilter(id uint64) error
- func (c *Client) RemoveFromGCBlockList(gcid zkidentity.ShortID, uid UserID) error
- func (c *Client) RenameUser(uid UserID, newNick string) error
- func (c *Client) RequestMediateIdentity(mediator, target UserID) error
- func (c *Client) RequestTransitiveReset(mediator, target UserID) error
- func (c *Client) ResendGCList(gcid zkidentity.ShortID, uid *UserID) error
- func (c *Client) ResetAllOldRatchets(limitInterval time.Duration, progrChan chan clientintf.UserID) ([]clientintf.UserID, error)
- func (c *Client) ResetRatchet(uid UserID) error
- func (c *Client) RetryOnboarding() error
- func (c *Client) Run(ctx context.Context) error
- func (c *Client) SaveEmbed(data []byte, typ string) (string, error)
- func (c *Client) SendFile(uid UserID, filepath string) error
- func (c *Client) ServerLNNode() string
- func (c *Client) ServerSession() clientintf.ServerSessionIntf
- func (c *Client) ShareFile(fname string, uid *UserID, cost uint64, descr string) (clientdb.SharedFile, rpc.FileMetadata, error)
- func (c *Client) SkipOnboardingStage() error
- func (c *Client) StartOnboarding(key clientintf.PaidInviteKey) error
- func (c *Client) StoreContentFilter(cf *clientdb.ContentFilter) error
- func (c *Client) SubscribeToAllRemotePosts(progressChan chan SendProgress) error
- func (c *Client) SubscribeToPosts(uid UserID) error
- func (c *Client) SubscribeToPostsAndFetch(uid UserID, pid clientintf.PostID) error
- func (c *Client) SuggestKX(invitee, target UserID) error
- func (c *Client) SummarizeUserPayStats(uid UserID) ([]clientdb.PayStatsSummary, error)
- func (c *Client) TipUser(uid UserID, dcrAmount float64, maxAttempts int32) error
- func (c *Client) UIDByNick(nick string) (UserID, error)
- func (c *Client) UnshareFile(fid clientdb.FileID, uid *UserID) error
- func (c *Client) UnsubscribeToPosts(uid UserID) error
- func (c *Client) UpdateLocalAvatar(avatar []byte) error
- func (c *Client) UpdateOnchainRecvAddrForUser(uid UserID, addr string) error
- func (c *Client) UpgradeGC(gcid zkidentity.ShortID, newVersion uint8) error
- func (c *Client) UserByID(uid UserID) (*RemoteUser, error)
- func (c *Client) UserByNick(nick string) (*RemoteUser, error)
- func (c *Client) UserExists(id UserID) bool
- func (c *Client) UserLogNick(uid UserID) string
- func (c *Client) UserNick(uid UserID) (string, error)
- func (c *Client) UserWithOnchainRecvAddr(addr string) *UserID
- func (c *Client) WriteNewInvite(w io.Writer, funds *rpc.InviteFunds) (rpc.OOBPublicIdentityInvite, error)
- type Config
- type DcrlnPaymentClient
- func (pc *DcrlnPaymentClient) ChainParams(ctx context.Context) (*chaincfg.Params, error)
- func (pc *DcrlnPaymentClient) CreateInviteFunds(ctx context.Context, amount dcrutil.Amount, account string) (*rpc.InviteFunds, error)
- func (pc *DcrlnPaymentClient) DecodeInvoice(ctx context.Context, invoice string) (clientintf.DecodedInvoice, error)
- func (pc *DcrlnPaymentClient) GetInvoice(ctx context.Context, mat int64, cb func(int64)) (string, error)
- func (pc *DcrlnPaymentClient) IsInvoicePaid(ctx context.Context, minMatAmt int64, invoice string) error
- func (pc *DcrlnPaymentClient) IsPaymentCompleted(ctx context.Context, invoice string) (int64, error)
- func (pc *DcrlnPaymentClient) LNChain() chainrpc.ChainNotifierClient
- func (pc *DcrlnPaymentClient) LNRPC() lnrpc.LightningClient
- func (pc *DcrlnPaymentClient) LNRouter() routerrpc.RouterClient
- func (pc *DcrlnPaymentClient) LNWallet() walletrpc.WalletKitClient
- func (pc *DcrlnPaymentClient) NewReceiveAddress(ctx context.Context, acct string) (stdaddr.Address, error)
- func (pc *DcrlnPaymentClient) PayInvoice(ctx context.Context, invoice string) (int64, error)
- func (pc *DcrlnPaymentClient) PayInvoiceAmount(ctx context.Context, invoice string, amount int64) (int64, error)
- func (pc *DcrlnPaymentClient) PayScheme() string
- func (pc *DcrlnPaymentClient) PaymentTimingStats() []timestats.Quantile
- func (pc *DcrlnPaymentClient) RedeemInviteFunds(ctx context.Context, funds *rpc.InviteFunds) (dcrutil.Amount, chainhash.Hash, error)
- func (pc *DcrlnPaymentClient) TrackInvoice(ctx context.Context, invoice string, minMAtoms int64) (int64, error)
- func (pc *DcrlnPaymentClient) UnlockWallet(ctx context.Context, pass string) error
- func (pc *DcrlnPaymentClient) WaitNextBlock(ctx context.Context) (chainhash.Hash, uint32, error)
- func (pc *DcrlnPaymentClient) WaitTxConfirmed(ctx context.Context, tx chainhash.Hash) error
- func (pc *DcrlnPaymentClient) WatchTransactions(ctx context.Context, handler func(tx *lnrpc.Transaction))
- type DcrlnPaymentClientCfg
- type ErrKXSearchNeeded
- type GCID
- type LastUserReceivedTime
- type MsgContentFilteredEvent
- type NotificationHandler
- type NotificationManager
- type NotificationRegistration
- type OnAddedGCMembersNtfn
- type OnBlockNtfn
- type OnContentListReceived
- type OnFileDownloadCompleted
- type OnFileDownloadProgress
- type OnGCAdminsChangedNtfn
- type OnGCInviteAcceptedNtfn
- type OnGCKilledNtfn
- type OnGCMNtfn
- type OnGCUpgradedNtfn
- type OnGCUserPartedNtfn
- type OnGCVersionWarning
- type OnGCWithUnkxdMemberNtfn
- type OnHandshakeStageNtfn
- type OnInvitedToGCNtfn
- type OnInvoiceGenFailedNtfn
- type OnJoinedGCNtfn
- type OnKXCompleted
- type OnKXSearchCompleted
- type OnKXSuggested
- type OnLocalClientOfflineTooLong
- type OnMsgContentFilteredNtfn
- type OnOnboardStateChangedNtfn
- type OnPMNtfn
- type OnPostRcvdNtfn
- type OnPostStatusRcvdNtfn
- type OnPostSubscriberUpdated
- type OnPostsListReceived
- type OnProfileUpdated
- type OnRMReceived
- type OnRMSent
- type OnReceiveReceipt
- type OnRemoteSubscriptionChangedNtfn
- type OnRemoteSubscriptionErrorNtfn
- type OnRemovedGCMembersNtfn
- type OnRequestingMediateID
- type OnResourceFetchedNtfn
- type OnServerSessionChangedNtfn
- type OnServerUnwelcomeError
- type OnTipAttemptProgressNtfn
- type OnTipReceivedNtfn
- type OnTipUserInvoiceGeneratedNtfn
- type OnTransitiveEvent
- type OnUnsubscribingIdleRemoteClient
- type ProfileUpdateField
- type RatchetDebugInfo
- type RemoteUser
- func (ru *RemoteUser) ID() UserID
- func (ru *RemoteUser) IsIgnored() bool
- func (ru *RemoteUser) LastRatchetTimes() (time.Time, time.Time)
- func (ru *RemoteUser) Nick() string
- func (ru *RemoteUser) RatchetDebugInfo() RatchetDebugInfo
- func (ru *RemoteUser) SetIgnored(ignored bool)
- func (ru *RemoteUser) String() string
- type RunningTipUserAttempt
- type SendProgress
- type TransitiveEvent
- type UserID
- type WalletUsableError
- type WalletUsableErrorKind
Constants ¶
const ( TEMediateID = "mediate identity" TERequestInvite = "request invite" TEReceivedInvite = "received invite" TEMsgForward = "message forward" TEResetRequest = "reset request" TEResetReply = "reset reply" )
const ( ErrUnableToQueryNode = WalletUsableErrorKind("ErrUnableToQueryNode") ErrNoPeers = WalletUsableErrorKind("ErrNoPeers") ErrLowOutboundBalance = WalletUsableErrorKind("ErrLowOutboundBalance") ErrTooOldBlockchain = WalletUsableErrorKind("ErrTooOldBlockchain") ErrNoActiveChannels = WalletUsableErrorKind("ErrNoActiveChannels") ErrNoRouteToServer = WalletUsableErrorKind("ErrNoRouteToServer") ErrUnableToPingPeers = WalletUsableErrorKind("ErrUnableToPingPeers") )
Variables ¶
var ( // ErrGCInvitationExpired is generated in situations where the // invitation to a GC expired. ErrGCInvitationExpired = errors.New("invitation to GC expired") )
Functions ¶
func CheckLNWalletUsable ¶
CheckLNWalletUsable checks whether the given ln wallet is synced and is usable for sending payments to the given server LN node.
func PaymentFeeLimit ¶
PaymentFeeLimit returns the fee limit to use when making a payment for BR nodes of the specified size.
func TrackWalletCheckEvents ¶ added in v0.1.8
func TrackWalletCheckEvents(ctx context.Context, lnRPC lnrpc.LightningClient) (chan struct{}, error)
TrackWalletCheckEvents tracks events of the lightnint wallet that are relevant for wallet checks. Once an event is detected, the chan is written to. The checks are tracked until the context is done.
Types ¶
type ChatHistoryEntry ¶ added in v0.1.8
type ChatHistoryEntry struct { Message string `json:"message"` From string `json:"from"` Timestamp int64 `json:"timestamp"` Internal bool `json:"internal"` }
ChatHistoryEntry contains information parsed from a single line in a chat log.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main state manager for a CR client connection. It attempts to maintain an active connection to a CR server and manages the internal state of a client, including remote users it's connected to.
func (*Client) AcceptGroupChatInvite ¶
AcceptGroupChatInvite accepts the given invitation, previously received from some user.
func (*Client) AcceptInvite ¶
func (c *Client) AcceptInvite(invite rpc.OOBPublicIdentityInvite) error
AcceptInvite blocks until the remote party reponds with us accepting the remote party's invitation. The invite should've been created by ReadInvite.
func (*Client) AddInviteOnKX ¶ added in v0.1.6
func (c *Client) AddInviteOnKX(initialRV, gcID zkidentity.ShortID) error
AddInviteOnKX adds a post kx action, based on the initial rv, that invites the user to the given groupchat.
func (*Client) AddToGCBlockList ¶
func (c *Client) AddToGCBlockList(gcid zkidentity.ShortID, uid UserID) error
AddToGCBlockList adds the user to the block list of the specified GC. This user will no longer be sent messages from the local client in the given GC and messages from this user will not generate GCMessage events.
func (*Client) AddressBook ¶
func (c *Client) AddressBook() []*clientdb.AddressBookEntry
AddressBook returns the full address book of remote users.
func (*Client) AddressBookEntry ¶ added in v0.1.9
func (c *Client) AddressBookEntry(uid UserID) (*clientdb.AddressBookEntry, error)
AddressBookEntry returns the address book information of a given user.
func (*Client) AddressBookLoaded ¶ added in v0.2.0
func (c *Client) AddressBookLoaded() <-chan struct{}
AddressBookLoaded returns a channel that is closed when the addressbook has been loaded for the first time, after Run() is started.
func (*Client) AliasGC ¶
func (c *Client) AliasGC(gcID zkidentity.ShortID, newAlias string) error
AliasGC replaces the local alias of a GC for a new one.
func (*Client) AllRemoteUsers ¶ added in v0.2.0
func (c *Client) AllRemoteUsers() []*RemoteUser
AllRemoteUsers returns a list of all existing remote users.
func (*Client) CancelDownload ¶ added in v0.2.2
CancelDownload cancels downloading this file.
func (*Client) CancelOnboarding ¶ added in v0.1.7
CancelOnboarding stops the currently running onboarding and removes it from the client.
func (*Client) ClearPayStats ¶
ClearPayStats removes the payment stats associated with the given user. If nil is passed, then the payment stats for all users are cleared.
func (*Client) CommentPost ¶
func (c *Client) CommentPost(postFrom clientintf.UserID, pid clientintf.PostID, comment string, parent *clientintf.ID) (clientintf.ID, error)
CommentPost sends a comment status update on the received post.
func (*Client) CreatePost ¶
func (c *Client) CreatePost(post, descr string) (clientdb.PostSummary, error)
CreatePost creates a new post and shares it with all current subscribers.
func (*Client) CreatePrepaidInvite ¶ added in v0.1.7
func (c *Client) CreatePrepaidInvite(w io.Writer, funds *rpc.InviteFunds) (rpc.OOBPublicIdentityInvite, clientintf.PaidInviteKey, error)
CreatePrepaidInvite creates a new invite and pushes it to the server, pre-paying for the remote user to download it.
func (*Client) FetchLocalResource ¶ added in v0.1.8
func (c *Client) FetchLocalResource(path []string, meta map[string]string, data json.RawMessage) error
FetchLocalResource fetches the local resource and triggers a correspoding ResourceFetched call.
func (*Client) FetchPrepaidInvite ¶ added in v0.1.7
func (c *Client) FetchPrepaidInvite(ctx context.Context, key clientintf.PaidInviteKey, w io.Writer) (rpc.OOBPublicIdentityInvite, error)
FetchPrepaidInvite fetches a pre-paid invite from the server, using the specified key as decryption key.
func (*Client) FetchResource ¶ added in v0.1.8
func (c *Client) FetchResource(uid UserID, path []string, meta map[string]string, sess, parentPage clientintf.PagesSessionID, data json.RawMessage) (rpc.ResourceTag, error)
FetchResource requests the specified resource from the client. Once the resource is returned the ResourceFetched handler will be called with the response using the returned tag.
func (*Client) FillTestInterface ¶ added in v0.1.8
func (c *Client) FillTestInterface(i *testutils.UnsafeTestInterface)
FillTestInterface prepares the unsafe test interface. This should not be used except in internal tests.
func (*Client) FilterGCM ¶ added in v0.1.8
FilterGCM returns true if the GCM sent by the specified user in the GC should be filtered.
func (*Client) FilterPM ¶ added in v0.1.8
FilterPM returns true if the pm sent by the specified user should be filtered.
func (*Client) FilterPost ¶ added in v0.1.8
FilterPost returns true if the post sent by the specified user should be filtered.
func (*Client) FilterPostComment ¶ added in v0.1.8
func (c *Client) FilterPostComment(uid, postFrom UserID, pid clientintf.PostID, comment string) (bool, uint64)
FilterPostComment returns true if the post comment sent by the specified user should be filtered.
func (*Client) FindSharedFileID ¶
FindSharedFileID finds the file ID of a shared file with the given filename.
func (*Client) GCIDByName ¶
func (c *Client) GCIDByName(name string) (zkidentity.ShortID, error)
GCIDByName returns the GC ID of the local GC with the given name. The name can be either a local GC alias or a full hex GC ID.
func (*Client) GCKick ¶
GCKick kicks the given user from the GC. This only works if we're the gc admin.
func (*Client) GCMessage ¶
func (c *Client) GCMessage(gcID zkidentity.ShortID, msg string, mode rpc.MessageMode, progressChan chan SendProgress) error
GCMessage sends a message to the given GC. If progressChan is not nil, events are sent to it as the sending process progresses. Writes to progressChan are serial, so it's important that it not block indefinitely.
func (*Client) GCsWithMember ¶ added in v0.1.8
func (c *Client) GCsWithMember(uid UserID) ([]zkidentity.ShortID, error)
GCsWithMember returns a list of GCs that have the specified UID as a member.
func (*Client) GCsWithPrefix ¶ added in v0.1.6
GCsWithPrefix returns a list of GC aliases that have the specified prefix.
func (*Client) GetGC ¶
func (c *Client) GetGC(gcID zkidentity.ShortID) (rpc.RMGroupList, error)
GetGC returns information about the given gc the local user participates in.
func (*Client) GetGCAlias ¶
func (c *Client) GetGCAlias(gcID zkidentity.ShortID) (string, error)
GetGCAlias returns the local alias for the specified GC.
func (*Client) GetGCBlockList ¶
func (c *Client) GetGCBlockList(gcID zkidentity.ShortID) (clientdb.GCBlockList, error)
GetGCBlockList returns the blocklist of the given GC.
func (*Client) GetKXSearch ¶
GetKXSearch returns the KX search status for the given target.
func (*Client) GetUserContent ¶
GetUserContent starts the process to fetch the given file from the remote user.
func (*Client) GetUserPost ¶
GetUserPost attempts to fetch the given post from the specified user. The post will be supplied in the PostReceived event of the client.
The includeStatus flag dictates whether to also request the associated status updates (comments, etc).
func (*Client) GoOnline ¶
func (c *Client) GoOnline()
GoOnline requests the client to connect to the server (if not yet connected) and to remain connected as long as possible (including by attempting to re-connect if the connection closes).
func (*Client) Handshake ¶ added in v0.1.8
Handshake starts a 3-way handshake with the specified user. When the local client receives a SYNACK, it means the ratchet with the user is fully operational.
func (*Client) HasDownloadedFile ¶
func (c *Client) HasDownloadedFile(fid zkidentity.ShortID) (string, error)
HasDownloadedFile returns the path to a downloaded file if it exists.
func (*Client) HasPostSubscribers ¶
HasPostSubscribers returns true if the local client has subscribers to our posts.
func (*Client) HeartPost ¶
func (c *Client) HeartPost(from clientintf.UserID, pid clientintf.PostID, heart bool) error
HeartPost sends a status update, either adding or removing the current user's heart on the given received post.
func (*Client) InviteToGroupChat ¶
func (c *Client) InviteToGroupChat(gcID zkidentity.ShortID, user UserID) error
InviteToGroupChat invites the given user to the given gc. The local user must be the admin of the group and the remote user must have been KX'd with.
func (*Client) IsIgnored ¶
func (c *Client) IsIgnored(uid clientintf.UserID) (bool, error)
IsIgnored indicates whether the given client has the ignored flag set.
func (*Client) KXSearchPostAuthor ¶
func (c *Client) KXSearchPostAuthor(postFrom UserID, post clientintf.PostID) error
KXSearchPostAuthor attempts to start a new kx search for the author of the specified post.
func (*Client) KillGroupChat ¶
func (c *Client) KillGroupChat(gcID zkidentity.ShortID, reason string) error
KillGroupChat completely dissolves the group chat.
func (*Client) ListContentFilters ¶ added in v0.1.8
func (c *Client) ListContentFilters() []clientdb.ContentFilter
ListContentFilters lists the active content filters.
func (*Client) ListDownloads ¶
func (c *Client) ListDownloads() ([]clientdb.FileDownload, error)
ListDownloads lists all outstanding downloads.
func (*Client) ListGCInvitesFor ¶
ListGCInvitesFor returns all GC invites. If gcid is specified, only invites for the specified GC are returned.
func (*Client) ListGCs ¶
func (c *Client) ListGCs() ([]rpc.RMGroupList, error)
ListGCs lists all local GCs the user is participating in.
func (*Client) ListKXSearches ¶
ListKXSearches lists the IDs of all outstanding KX searches.
func (*Client) ListLocalSharedFiles ¶
func (c *Client) ListLocalSharedFiles() ([]clientdb.SharedFileAndShares, error)
ListLocalSharedFiles lists all locally shared files.
func (*Client) ListMediateIDs ¶
func (c *Client) ListMediateIDs() ([]clientdb.MediateIDRequest, error)
ListMediateIDs lists mediate id requests made by the local client.
func (*Client) ListPaymentStats ¶
func (c *Client) ListPaymentStats() (map[UserID]clientdb.UserPayStats, error)
ListPaymentStats returns the general payment stats for all users.
func (*Client) ListPostCommentReceiveReceipts ¶ added in v0.1.10
func (c *Client) ListPostCommentReceiveReceipts(pid clientintf.PostID, statusID zkidentity.ShortID) ([]*clientdb.ReceiveReceipt, error)
ListPostCommentReceiveReceipts returns the receive receipts from a post comment that the local client has shared.
func (*Client) ListPostReceiveReceipts ¶ added in v0.1.10
func (c *Client) ListPostReceiveReceipts(pid clientintf.PostID) ([]*clientdb.ReceiveReceipt, error)
ListPostReceiveReceipts returns the receive receipts from a post that the local client has shared.
func (*Client) ListPostStatusUpdates ¶
func (c *Client) ListPostStatusUpdates(from UserID, pid clientintf.PostID) ([]rpc.PostMetadataStatus, error)
ListPostStatusUpdates lists the status updates of the specified post.
func (*Client) ListPostSubscribers ¶
func (c *Client) ListPostSubscribers() ([]clientintf.UserID, error)
ListPostSubscribers lists the subscribers to the local client's posts.
func (*Client) ListPostSubscriptions ¶
func (c *Client) ListPostSubscriptions() ([]clientdb.PostSubscription, error)
ListPostSubscriptions lists remote users whose posts we are subscribed to.
func (*Client) ListPosts ¶
func (c *Client) ListPosts() ([]clientdb.PostSummary, error)
ListReceivedPosts lists all posts created or received by the local client.
func (*Client) ListRunningTipUserAttempts ¶ added in v0.1.8
func (c *Client) ListRunningTipUserAttempts() ([]RunningTipUserAttempt, error)
ListRunningTipUserAttempts lists the currently running attempts at tipping remote users.
func (*Client) ListTipUserAttempts ¶ added in v0.1.7
func (c *Client) ListTipUserAttempts(uid UserID) ([]clientdb.TipUserAttempt, error)
func (*Client) ListUserContent ¶
ListUserContent lists the content shared by the given remote user. Dirs must be one of the supported dirs (rpc.RMFTDGlobal or rpc.RMFTDShared).
func (*Client) ListUserPosts ¶
ListUserPosts lists the posts made by the specified user.
func (*Client) ListUsersLastReceivedTime ¶ added in v0.1.4
func (c *Client) ListUsersLastReceivedTime() ([]LastUserReceivedTime, error)
ListUsersLastReceivedTime returns the UID and time of last received message for all users.
func (*Client) LocalNick ¶
LocalNick is the nick of this client. This is only available after the Run() method has loaded the user ID from the DB.
func (*Client) ModifyGCAdmins ¶ added in v0.1.6
func (c *Client) ModifyGCAdmins(gcid zkidentity.ShortID, extraAdmins []zkidentity.ShortID, reason string) error
ModifyGCAdmins modifies the admins of the GC.
func (*Client) ModifyGCOwner ¶ added in v0.1.10
func (c *Client) ModifyGCOwner(gcid zkidentity.ShortID, newOwner clientintf.UserID, reason string) error
ModifyGCOwner changes the owner of a GC. The old owner still remains as a member of the GC (but not as admin).
func (*Client) NewGroupChat ¶
func (c *Client) NewGroupChat(name string) (zkidentity.ShortID, error)
NewGroupChat creates a group chat with the local client as admin.
func (*Client) NewGroupChatVersion ¶ added in v0.1.8
NewGroupChatVersion creates a new gc with the local user as admin and the specified version.
func (*Client) NewPagesSession ¶ added in v0.1.8
func (c *Client) NewPagesSession() (clientintf.PagesSessionID, error)
func (*Client) NicksWithPrefix ¶ added in v0.1.6
NicksWithPrefix returns a list of nicks for users that have the specified prefix.
func (*Client) NotificationManager ¶ added in v0.1.4
func (c *Client) NotificationManager() *NotificationManager
func (*Client) OnchainRecvAddrForUser ¶ added in v0.1.8
OnchainRecvAddrForUser returns the on-chain receive address of the local wallet associated with the specified user. If acct is specified, addresses are generated from that account.
func (*Client) PM ¶
PM sends a private message to the given user, identified by its public id. The user must have been already KX'd with for this to work.
func (*Client) PartFromGC ¶
func (c *Client) PartFromGC(gcID zkidentity.ShortID, reason string) error
PartFromGC withdraws the local client from the given GC.
func (*Client) Public ¶ added in v0.2.0
func (c *Client) Public() zkidentity.PublicIdentity
Public returns the full public identity data for the local client.
func (*Client) PublicID ¶
PublicID is the public local identity of this client. This is only available after the Run() method has loaded the user ID from the DB.
func (*Client) RMQLen ¶
RMQLen is the number of outstanding messages in the outbound routed messages queue. There are two queues involved in the reply: msgs that are waiting to be sent and messages that are in the process of being paid/sent/ack.
func (*Client) RMQTimingStat ¶ added in v0.1.2
RMQTimingStat returns the latest timing stats for the outbound RMQ.
func (*Client) RVsUpToDate ¶
RVsUpToDate returns true if the subscriptions to remote RVs are up to date in the server.
func (*Client) ReadHistoryMessages ¶ added in v0.1.10
func (c *Client) ReadHistoryMessages(uid UserID, isGC bool, page, pageNum int) ([]ChatHistoryEntry, time.Time, error)
ReadHistoryMessages determines which log parsing to use based on whether a group chat name was provided in the arguments. This function will return an array of ChatHistoryEntry's that contain information from each line of saved logs.
func (*Client) ReadInvite ¶
ReadInvite decodes an invite from the given reader. Note the invite is not acted upon until AcceptInvite is called.
func (*Client) ReadOnboard ¶ added in v0.1.7
func (c *Client) ReadOnboard() (*clientintf.OnboardState, error)
ReadOnboard returns the existing onboard state.
func (*Client) ReadPost ¶
func (c *Client) ReadPost(uid clientintf.UserID, pid clientintf.PostID) (rpc.PostMetadata, error)
ReadReceivedPost returns the post data for the given user/post.
func (*Client) RelayPost ¶
func (c *Client) RelayPost(postFrom clientintf.UserID, pid clientintf.PostID, toUser clientintf.UserID) error
RelayPost sends the given post to the specified user.
func (*Client) RelayPostToSubscribers ¶
func (c *Client) RelayPostToSubscribers(postFrom clientintf.UserID, pid clientintf.PostID) error
RelayPostToSubscribers relays the specified post to all current post subscribers.
func (*Client) RemainOffline ¶
func (c *Client) RemainOffline()
RemainOffline requests the client to remain offline.
func (*Client) RemoveAllContentFilters ¶ added in v0.1.8
RemoveAllContentFilters removes all current content filters from the client.
func (*Client) RemoveContentFilter ¶ added in v0.1.8
RemoveContentFilter removes the content filter. The filter immediately stops aplying to newly received messages.
func (*Client) RemoveFromGCBlockList ¶
func (c *Client) RemoveFromGCBlockList(gcid zkidentity.ShortID, uid UserID) error
AddToGCBlockList removes the user from the block list of the specified GC.
func (*Client) RenameUser ¶
RenameUser modifies the nick for the specified user.
func (*Client) RequestMediateIdentity ¶
RequestMediateIdentity attempts to start a kx process with target by asking mediator for an introduction.
func (*Client) RequestTransitiveReset ¶
func (*Client) ResendGCList ¶ added in v0.1.5
func (c *Client) ResendGCList(gcid zkidentity.ShortID, uid *UserID) error
ResendGCList resends the GC list to a user. We must be the admin of the GC for this to be accepted by the remote user.
When the UID is not specified, the list is resent to all members.
func (*Client) ResetAllOldRatchets ¶ added in v0.1.4
func (c *Client) ResetAllOldRatchets(limitInterval time.Duration, progrChan chan clientintf.UserID) ([]clientintf.UserID, error)
ResetAllOldRatchets starts the reset ratchet procedure with all users from which no message has been received for the passed limit duration.
If the interval is zero, then a default interval of 30 days is used.
If progrChan is specified, each individual reset that is started is reported in progrChan.
func (*Client) ResetRatchet ¶
ResetRatchet requests a ratchet reset with the given user.
func (*Client) RetryOnboarding ¶ added in v0.1.7
RetryOnboarding retries the onboarding at the current stage. The onboarding must have errored before this can be called.
func (*Client) Run ¶
Run runs all client goroutines until the given context is canceled.
Must only be called once.
func (*Client) SendFile ¶
SendFile sends a file to the given user without requesting a payment for it.
func (*Client) ServerLNNode ¶
ServerLNNode returns the LN Node ID of the server we're connected to. This can be empty if we're not connected to any servers.
func (*Client) ServerSession ¶ added in v0.1.10
func (c *Client) ServerSession() clientintf.ServerSessionIntf
ServerSession returns the current server session the client is connected to. Returns nil if not connected to the server. Note this is set before a connection to the server is fully validated as usable.
func (*Client) ShareFile ¶
func (c *Client) ShareFile(fname string, uid *UserID, cost uint64, descr string, ) (clientdb.SharedFile, rpc.FileMetadata, error)
ShareFile shares the given filename with the given user (or to all users if none is specified).
Cost is in atoms.
func (*Client) SkipOnboardingStage ¶ added in v0.1.7
SkipOnboardingStage skips the current onboarding stage to the next one. Not every stage is skippable.
func (*Client) StartOnboarding ¶ added in v0.1.7
func (c *Client) StartOnboarding(key clientintf.PaidInviteKey) error
StartOnboarding starts a new onboarding procedure with the given key.
func (*Client) StoreContentFilter ¶ added in v0.1.8
func (c *Client) StoreContentFilter(cf *clientdb.ContentFilter) error
StoreContentFilter adds or updates a content filter. The filter starts applying immediately to received messages.
func (*Client) SubscribeToAllRemotePosts ¶ added in v0.2.2
func (c *Client) SubscribeToAllRemotePosts(progressChan chan SendProgress) error
SubscribeToAllRemotePosts attempts to subscribe to every remote user's posts.
func (*Client) SubscribeToPosts ¶
SubscribeToPosts attempts to subscribe to the posts of the given user.
func (*Client) SubscribeToPostsAndFetch ¶ added in v0.1.6
func (c *Client) SubscribeToPostsAndFetch(uid UserID, pid clientintf.PostID) error
SubscribeToPostsAndFetch attempts to subscribe to the posts of the given user and also (if successful) asks the user to send the specified post.
func (*Client) SuggestKX ¶
SuggestKX sends a message to invitee suggesting they KX with target (through the local client).
func (*Client) SummarizeUserPayStats ¶
func (c *Client) SummarizeUserPayStats(uid UserID) ([]clientdb.PayStatsSummary, error)
SummarizeUserPayStats reads the payment stats file of the given user and returns a summary of what the payments were made and received in relation to the specified user.
func (*Client) TipUser ¶
TipUser starts an attempt to tip the user some amount of dcr. This dispatches a request for an invoice to the remote user, which once received will be paid.
By the time the invoice is received, the local client may or may not have enough funds to pay for it, so multiple attempts will be made to fetch and pay for an invoice.
func (*Client) UnshareFile ¶
UnshareFile stops sharing the given file with the given user (or all users if unspecified).
func (*Client) UnsubscribeToPosts ¶
UnsubscribeToPosts unsubscribes the local user to the posts made by the given remote user.
It returns when the remote user replies or when the client exits.
func (*Client) UpdateLocalAvatar ¶ added in v0.2.0
UpdateLocalAvatar changes the local avatar. If set to nil or an empty slice, an update will be sent to remote clients to clear the avatar.
func (*Client) UpdateOnchainRecvAddrForUser ¶ added in v0.1.8
UpdateOnchainRecvAddrForUser updates the on-chain receive address of the local wallet associated with the specified user. If addr is nil, then the current address is removed.
func (*Client) UpgradeGC ¶ added in v0.1.6
func (c *Client) UpgradeGC(gcid zkidentity.ShortID, newVersion uint8) error
UpgradeGC upgrades the version of the GC to the specified one. The local user must have permission to upgrade the GC.
func (*Client) UserByID ¶
func (c *Client) UserByID(uid UserID) (*RemoteUser, error)
UserByID returns the remote user of the given ID.
func (*Client) UserByNick ¶
func (c *Client) UserByNick(nick string) (*RemoteUser, error)
UserByNick returns the user identified by the given nick. Nick may be the actual user nick or a prefix of the user's ID (to disambiguate between users with the same nick).
func (*Client) UserExists ¶
func (*Client) UserLogNick ¶ added in v0.2.2
UserLogNick returns the nick to use when logging a remote user. If the user does not exist, returns the UID itself as string. If this uid is for the client itself, returns the string "local client".
func (*Client) UserWithOnchainRecvAddr ¶ added in v0.1.8
UserWithOnchainRecvAddr returns the user that has the specified onchain receive address. If there is no user for the specified address, then this returns nil.
func (*Client) WriteNewInvite ¶
func (c *Client) WriteNewInvite(w io.Writer, funds *rpc.InviteFunds) (rpc.OOBPublicIdentityInvite, error)
WriteNewInvite creates a new invite and writes it to the given writer.
If the optional funds is specified, those funds will be redeemed by the remote user prior to accepting the invite.
type Config ¶
type Config struct { // ReconnectDelay is how long to wait between attempts to reconnect to // the server. ReconnectDelay time.Duration // PayClient identifies which payment scheme the client is configured // to use. PayClient clientintf.PaymentClient // LocalIDIniter is called when the client needs a new local identity. LocalIDIniter func(ctx context.Context) (*zkidentity.FullIdentity, error) // Dialer connects to the server. TLS is required. Dialer clientintf.Dialer // CompressLevel is the zlib compression level to use to compress // routed messages. Zero means no compression. CompressLevel int // DB instace for client operations. The client will call the Run() // method of the DB instance itself. DB *clientdb.DB // CertConfirmer must return nil if the given TLS certificate (outer // cert) and public key (inner cert) are accepted or an error if it any // of them are rejected. CertConfirmer clientintf.CertConfirmer // Logger is a function that generates loggers for each of the client's // subsystems. Logger func(subsys string) slog.Logger // LogPings indicates whether to log messages related to pings between // the client and the server. LogPings bool // NoLoadChatHistory indicates whether to load existing chat history from // chat log files. NoLoadChatHistory bool // CheckServerSession is called after a server session is established // but before the OnServerSessionChangedNtfn notification is called and // allows clients to check whether the connection is acceptable or if // other preconditions are met before continuing to connect with the // specified server. // // If this callback is non nil and returns an error, the connection // is dropped and another attempt at the connection is made. // // If the passed connCtx is canceled, this means the connection was // closed (either by the remote end or by the local end). CheckServerSession func(connCtx context.Context, lnNode string) error // Notifications tracks handlers for client events. If nil, the client // will initialize a new notification manager. Specifying a // notification manager in the config is useful to ensure no // notifications are lost due to race conditions in client // initialization. Notifications *NotificationManager // KXSuggestion is called when a remote user sends a suggestion to KX // with a new user. KXSuggestion func(user *RemoteUser, pii zkidentity.PublicIdentity) // FileDownloadConfirmer is called to confirm the start of a file // download with the user. FileDownloadConfirmer func(user *RemoteUser, fm rpc.FileMetadata) bool // TipUserRestartDelay is how long to wait after client start and // initial server connection to restart TipUser attempts. If unset, // a default value of 1 minute is used. TipUserRestartDelay time.Duration // TipUserReRequestInvoiceDelay is how long to wait to re-request an // invoice from the user, if one has not been received yet when // attempting to tip. If unset, a default value of 24 hours is used. TipUserReRequestInvoiceDelay time.Duration // TipUserMaxLifetime is the maximum amount of time an invoice will // be paid after received. After this delay elapses, there won't be // attempts to pay received invoices for a tip attempt. This delay is // based on the initial TipUser attempt. // // If unspecified, a default value of 72 hours is used. TipUserMaxLifetime time.Duration // TipUserPayRetryDelayFactor is the factor of the exponential delay // for retrying a payment when the payment error indicates a retry may // be possible. // // If unspecified, a default value of 12 seconds (1/5 minute) is used. TipUserPayRetryDelayFactor time.Duration // GCMQMaxLifetime is how long to wait for a message from an user, // after which the GCMQ considers no other messages from this user // will be received. // // If unspecified, a default value of 10 seconds is used. GCMQMaxLifetime time.Duration // ResourcesProvider if filled is used to respond to fetch resource // requests. ResourcesProvider resources.Provider // GCMQUpdtDelay is how often to check for GCMQ rules to emit messages. // // If unspecified, a default value of 1 second is used. GCMQUpdtDelay time.Duration // GCMQInitialDelay is how long to wait after the initial subscriptions // are done on the server to start processing GCMQ messages. // // If unspecified, a default value of 10 seconds is used. GCMQInitialDelay time.Duration // RecentMediateIDThreshold is how long to wait until attempting a new // mediate ID request for a given target. // // If unspecified, a default value of 7 days is used. RecentMediateIDThreshold time.Duration // UnkxdWarningTimeout is how long to wait between warnings about // trying to perform an action with unkxd people (for example, trying // to send a GC message to an unkxd GC member). // // If unspecified, a default value of 24 hours is used. UnkxdWarningTimeout time.Duration // MaxAutoKXMediateIDRequests is the max number of autokx mediate ID // requests to make to a particular user id. // // If unspecified, a default value of 3 is used. MaxAutoKXMediateIDRequests int // AutoHandshakeInterval is the interval after which, for any ratchets // that haven't been communicated with, an automatic handshake attempt // is made. AutoHandshakeInterval time.Duration // AutoRemoveIdleUsersInterval is the interval after which any idle // users (i.e. users from which no message has been received) will be // automatically removed from GCs the local client admins and will be // automatically unsubscribed from posts. AutoRemoveIdleUsersInterval time.Duration // AutoRemoveIdleUsersIgnoreList is a list of users that should NOT be // forcibly unsubscribed even if they are idle. The values may be an // user's nick or the prefix of the string representatation of its nick // (i.e. anything acceptable as returned by UserByNick()). AutoRemoveIdleUsersIgnoreList []string // SendReceiveReceipts flags whether to send receive receipts for all // domains. SendReceiveReceipts bool // AutoSubscribeToPosts flags whether to automatically subscribe to // posts when kx'ing for the first time with an user. AutoSubscribeToPosts bool // PingInterval sets how often to send pings to the server to keep // the connection open. If unset, defaults to the RPC default ping // interval. If negative, pings are not sent. PingInterval time.Duration // Collator is used to compare nick and other strings to determine // equality and sorting order. Collator *collate.Collator // GCInviteExpiration is how long a GC invitation is valid for. Defaults // to 7 days. GCInviteExpiration time.Duration }
Config holds the necessary config for instantiating a CR client.
type DcrlnPaymentClient ¶
type DcrlnPaymentClient struct {
// contains filtered or unexported fields
}
DcrlnPaymentClient implements the PaymentClient interface for servers that offer the "dcrln" payment scheme.
func NewDcrlndPaymentClient ¶
func NewDcrlndPaymentClient(ctx context.Context, cfg DcrlnPaymentClientCfg) (*DcrlnPaymentClient, error)
NewDcrlndPaymentClient creates a new payment client that can send payments through dcrlnd.
func (*DcrlnPaymentClient) ChainParams ¶ added in v0.1.8
func (pc *DcrlnPaymentClient) ChainParams(ctx context.Context) (*chaincfg.Params, error)
func (*DcrlnPaymentClient) CreateInviteFunds ¶ added in v0.1.7
func (pc *DcrlnPaymentClient) CreateInviteFunds(ctx context.Context, amount dcrutil.Amount, account string) (*rpc.InviteFunds, error)
func (*DcrlnPaymentClient) DecodeInvoice ¶
func (pc *DcrlnPaymentClient) DecodeInvoice(ctx context.Context, invoice string) (clientintf.DecodedInvoice, error)
func (*DcrlnPaymentClient) GetInvoice ¶
func (*DcrlnPaymentClient) IsInvoicePaid ¶
func (*DcrlnPaymentClient) IsPaymentCompleted ¶ added in v0.1.4
func (*DcrlnPaymentClient) LNChain ¶ added in v0.2.0
func (pc *DcrlnPaymentClient) LNChain() chainrpc.ChainNotifierClient
func (*DcrlnPaymentClient) LNRPC ¶
func (pc *DcrlnPaymentClient) LNRPC() lnrpc.LightningClient
func (*DcrlnPaymentClient) LNRouter ¶ added in v0.2.2
func (pc *DcrlnPaymentClient) LNRouter() routerrpc.RouterClient
func (*DcrlnPaymentClient) LNWallet ¶ added in v0.1.7
func (pc *DcrlnPaymentClient) LNWallet() walletrpc.WalletKitClient
func (*DcrlnPaymentClient) NewReceiveAddress ¶ added in v0.1.8
func (pc *DcrlnPaymentClient) NewReceiveAddress(ctx context.Context, acct string) (stdaddr.Address, error)
NewReceiveAddress returns a new on-chain address from the underlying wallet.
func (*DcrlnPaymentClient) PayInvoice ¶
func (*DcrlnPaymentClient) PayInvoiceAmount ¶
func (*DcrlnPaymentClient) PayScheme ¶
func (pc *DcrlnPaymentClient) PayScheme() string
func (*DcrlnPaymentClient) PaymentTimingStats ¶ added in v0.1.2
func (pc *DcrlnPaymentClient) PaymentTimingStats() []timestats.Quantile
PaymentTimingStats returns timing information for payment stats.
func (*DcrlnPaymentClient) RedeemInviteFunds ¶ added in v0.1.7
func (pc *DcrlnPaymentClient) RedeemInviteFunds(ctx context.Context, funds *rpc.InviteFunds) (dcrutil.Amount, chainhash.Hash, error)
func (*DcrlnPaymentClient) TrackInvoice ¶ added in v0.1.8
func (*DcrlnPaymentClient) UnlockWallet ¶
func (pc *DcrlnPaymentClient) UnlockWallet(ctx context.Context, pass string) error
func (*DcrlnPaymentClient) WaitNextBlock ¶ added in v0.1.7
WaitNextBlock blocks until the next block is received.
func (*DcrlnPaymentClient) WaitTxConfirmed ¶ added in v0.1.7
WaitTxConfirmed blocks until the given transaction (which must be a wallet tx) is confirmed onchain.
func (*DcrlnPaymentClient) WatchTransactions ¶ added in v0.1.8
func (pc *DcrlnPaymentClient) WatchTransactions(ctx context.Context, handler func(tx *lnrpc.Transaction))
WatchTransactions watches transactions until the given context is closed.
type DcrlnPaymentClientCfg ¶
type ErrKXSearchNeeded ¶ added in v0.1.6
type ErrKXSearchNeeded struct {
Author UserID
}
ErrKXSearchNeeded is returned when an action cannot be completed and a KX search must be performed.
func (ErrKXSearchNeeded) Error ¶ added in v0.1.6
func (err ErrKXSearchNeeded) Error() string
func (ErrKXSearchNeeded) Is ¶ added in v0.1.6
func (err ErrKXSearchNeeded) Is(target error) bool
type GCID ¶
type GCID = zkidentity.ShortID
type LastUserReceivedTime ¶ added in v0.1.4
type LastUserReceivedTime struct { UID clientintf.UserID LastDecrypted time.Time }
LastUserReceivedTime is a record for user and their last decrypted message time.
type MsgContentFilteredEvent ¶ added in v0.1.8
type MsgContentFilteredEvent struct { UID UserID GC *zkidentity.ShortID PID *clientintf.PostID PostFrom *clientintf.UserID IsPostComment bool Msg string Rule clientdb.ContentFilter }
MsgContentFilteredEvent is the data for a message content filter event.
type NotificationHandler ¶ added in v0.1.4
type NotificationHandler interface {
// contains filtered or unexported methods
}
type NotificationManager ¶ added in v0.1.4
type NotificationManager struct {
// contains filtered or unexported fields
}
func NewNotificationManager ¶ added in v0.1.4
func NewNotificationManager() *NotificationManager
func (*NotificationManager) AnyRegistered ¶ added in v0.1.8
func (ngmr *NotificationManager) AnyRegistered(handler NotificationHandler) bool
AnyRegistered returns true if there are any handlers registered for the given handler type.
func (*NotificationManager) Register ¶ added in v0.1.4
func (nmgr *NotificationManager) Register(handler NotificationHandler) NotificationRegistration
Register registers a callback notification function that is called asynchronously to the event (i.e. in a separate goroutine).
func (*NotificationManager) RegisterSync ¶ added in v0.1.4
func (nmgr *NotificationManager) RegisterSync(handler NotificationHandler) NotificationRegistration
RegisterSync registers a callback notification function that is called synchronously to the event. This callback SHOULD return as soon as possible, otherwise the client might hang.
Synchronous callbacks are mostly intended for tests and when external callers need to ensure proper order of multiple sequential events. In general it is preferable to use callbacks registered with the Register call, to ensure the client will not deadlock or hang.
type NotificationRegistration ¶ added in v0.1.4
type NotificationRegistration struct {
// contains filtered or unexported fields
}
func (NotificationRegistration) Unregister ¶ added in v0.1.4
func (reg NotificationRegistration) Unregister() bool
type OnAddedGCMembersNtfn ¶ added in v0.1.6
type OnAddedGCMembersNtfn func(gc rpc.RMGroupList, uids []clientintf.UserID)
OnAddedGCMembersNtfn is a handler for new members added to a GC.
type OnBlockNtfn ¶ added in v0.1.7
type OnBlockNtfn func(user *RemoteUser)
OnBlockNtfn is called when we blocked the specified user due to their request. Note that the passed user cannot be used for messaging anymore.
type OnContentListReceived ¶ added in v0.1.10
type OnContentListReceived func(user *RemoteUser, files []clientdb.RemoteFile, listErr error)
ContentListReceived is called when the list of content of the user is received.
type OnFileDownloadCompleted ¶ added in v0.1.10
type OnFileDownloadCompleted func(user *RemoteUser, fm rpc.FileMetadata, diskPath string)
FileDownloadCompleted is called whenever a download of a file has completed.
type OnFileDownloadProgress ¶ added in v0.1.10
type OnFileDownloadProgress func(user *RemoteUser, fm rpc.FileMetadata, nbMissingChunks int)
FileDownloadProgress is called reporting the progress of a file download process.
type OnGCAdminsChangedNtfn ¶ added in v0.1.6
type OnGCAdminsChangedNtfn func(ru *RemoteUser, gc rpc.RMGroupList, added, removed []zkidentity.ShortID)
type OnGCInviteAcceptedNtfn ¶ added in v0.1.6
type OnGCInviteAcceptedNtfn func(user *RemoteUser, gc rpc.RMGroupList)
OnGCInviteAcceptedNtfn is a handler for invites accepted by remote users to join a GC we invited them to.
type OnGCKilledNtfn ¶ added in v0.1.6
OnGCKilledNtfn is a handler for a GC dissolved by its admin.
type OnGCMNtfn ¶ added in v0.1.4
type OnGCMNtfn func(*RemoteUser, rpc.RMGroupMessage, time.Time)
OnGCMNtfn is the handler for received gc messages.
type OnGCUpgradedNtfn ¶ added in v0.1.6
type OnGCUpgradedNtfn func(gc rpc.RMGroupList, oldVersion uint8)
OnGCUpgradedNtfn is a handler for a GC that had its version upgraded.
type OnGCUserPartedNtfn ¶ added in v0.1.6
OnGCUserPartedNtfn is a handler when a user parted from a GC or an admin kicked a user.
type OnGCVersionWarning ¶ added in v0.1.5
type OnGCVersionWarning func(user *RemoteUser, gc rpc.RMGroupList, minVersion, maxVersion uint8)
OnGCVersionWarning is a handler for warnings about a GC that has an unsupported version.
type OnGCWithUnkxdMemberNtfn ¶ added in v0.1.8
type OnGCWithUnkxdMemberNtfn func(gc zkidentity.ShortID, uid clientintf.UserID, hasKX, hasMI bool, miCount uint32, startedMIMediator *clientintf.UserID)
OnGCWithUnkxdMemberNtfn is called when attempting to send a message to a GC in which there are members that the local client hasn't KX'd with.
type OnHandshakeStageNtfn ¶ added in v0.1.8
type OnHandshakeStageNtfn func(ru *RemoteUser, msgtype string)
OnHandshakeStageNtfn is called during a 3-way handshake with a remote client. mstype may be SYN, SYNACK or ACK. The SYNACK and ACK types allow the respective clients to infer that the ratchet operations are working.
type OnInvitedToGCNtfn ¶ added in v0.1.6
type OnInvitedToGCNtfn func(user *RemoteUser, iid uint64, invite rpc.RMGroupInvite)
OnInvitedToGCNtfn is a handler for invites received to join GCs.
type OnInvoiceGenFailedNtfn ¶ added in v0.1.5
type OnInvoiceGenFailedNtfn func(user *RemoteUser, dcrAmount float64, err error)
type OnJoinedGCNtfn ¶ added in v0.1.6
type OnJoinedGCNtfn func(gc rpc.RMGroupList)
OnJoinedGCNtfn is a handler for when the local client joins a GC.
type OnKXCompleted ¶ added in v0.1.5
type OnKXCompleted func(*clientintf.RawRVID, *RemoteUser, bool)
OnKXCompleted is called after KX is completed with a remote user (either a new user or a reset KX).
type OnKXSearchCompleted ¶ added in v0.1.6
type OnKXSearchCompleted func(user *RemoteUser)
OnKXSearchCompleted is a handler for completed KX search procedures.
type OnKXSuggested ¶ added in v0.1.7
type OnKXSuggested func(*RemoteUser, zkidentity.PublicIdentity)
OnKXSuggested is called after a remote user suggests that this user should KX with another remote user.
type OnLocalClientOfflineTooLong ¶ added in v0.1.4
OnLocalClientOfflineTooLong is called after the local client connects to the server, if it determines it has been offline for too long given the server's message retention policy.
type OnMsgContentFilteredNtfn ¶ added in v0.1.8
type OnMsgContentFilteredNtfn func(MsgContentFilteredEvent)
OnMsgContentFilteredNtfn is called when a message was filtered due to its contents.
type OnOnboardStateChangedNtfn ¶ added in v0.1.7
type OnOnboardStateChangedNtfn func(state clientintf.OnboardState, err error)
type OnPMNtfn ¶ added in v0.1.4
type OnPMNtfn func(*RemoteUser, rpc.RMPrivateMessage, time.Time)
OnPMNtfn is the handler for received private messages.
type OnPostRcvdNtfn ¶ added in v0.1.4
type OnPostRcvdNtfn func(*RemoteUser, clientdb.PostSummary, rpc.PostMetadata)
OnPostRcvdNtfn is the handler for received posts.
type OnPostStatusRcvdNtfn ¶ added in v0.1.4
type OnPostStatusRcvdNtfn func(*RemoteUser, clientintf.PostID, UserID, rpc.PostMetadataStatus)
OnPostStatusRcvdNtfn is the handler for received post status updates.
type OnPostSubscriberUpdated ¶ added in v0.1.9
type OnPostSubscriberUpdated func(user *RemoteUser, subscribed bool)
OnPostSubscriberUpdated is called when a remote user changes its subscription status to the local client's posts (i.e. the remote user subscribed or unsubscribed to the local client's posts).
type OnPostsListReceived ¶ added in v0.1.9
type OnPostsListReceived func(user *RemoteUser, postList rpc.RMListPostsReply)
PostsListReceived is called when the local client receives the list of posts from a remote user.
type OnProfileUpdated ¶ added in v0.2.0
type OnProfileUpdated func(ru *RemoteUser, ab *clientdb.AddressBookEntry, fields []ProfileUpdateField)
OnProfileChanged is a notification sent whenever a remote client has updated its profile.
type OnRMReceived ¶ added in v0.1.10
type OnRMReceived func(ru *RemoteUser, h *rpc.RMHeader, p interface{}, ts time.Time)
OnRMReceived is a notification sent whenever a remote user receives an RM. Note: this is called _before_ the RM has been processed, therefore care must be taken when hooking and handling this notification.
type OnRMSent ¶ added in v0.2.0
type OnRMSent func(ru *RemoteUser, p interface{})
OnRMSent is a notification sent whenever a message has been delivered to the server directed to a remote user. Note: this is called _after_ the RM has been acknowledged by the server.
type OnReceiveReceipt ¶ added in v0.1.10
type OnReceiveReceipt func(user *RemoteUser, rr rpc.RMReceiveReceipt, serverTime time.Time)
OnReceiveReceipt is a notification sent when a remote client sends a receive receipt.
type OnRemoteSubscriptionChangedNtfn ¶ added in v0.1.4
type OnRemoteSubscriptionChangedNtfn func(*RemoteUser, bool)
OnRemoteSubscriptionChanged is the handler for a remote user subscription changed event.
type OnRemoteSubscriptionErrorNtfn ¶ added in v0.1.4
type OnRemoteSubscriptionErrorNtfn func(user *RemoteUser, wasSubscribing bool, errMsg string)
OnRemoteSubscriptionErrorNtfn is the handler for a remote user subscription change attempt that errored.
type OnRemovedGCMembersNtfn ¶ added in v0.1.6
type OnRemovedGCMembersNtfn func(gc rpc.RMGroupList, uids []clientintf.UserID)
OnRemovedGCMembersNtfn is a handler for members removed from a GC.
type OnRequestingMediateID ¶ added in v0.2.0
type OnRequestingMediateID func(mediator, target UserID)
OnRequestingMediateID is called whenever an autokx attempt is requesting a mediator to mediate id between the local client and a target.
type OnResourceFetchedNtfn ¶ added in v0.1.8
type OnResourceFetchedNtfn func(ru *RemoteUser, fr clientdb.FetchedResource, sess clientdb.PageSessionOverview)
OnResourceFetchedNtfn is called when a reply to a fetched resource is received.
Note that the user may be nil if the resource was fetched locally, such as through the FetchLocalResource call.
type OnServerSessionChangedNtfn ¶ added in v0.1.7
type OnServerSessionChangedNtfn func(connected bool, policy clientintf.ServerPolicy)
OnServerSessionChangedNtfn is called indicating that the connection to the server changed to the specified state (either connected or not).
The push and subscription rates are specified in milliatoms/byte.
type OnServerUnwelcomeError ¶ added in v0.1.10
type OnServerUnwelcomeError func(err error)
OnServerUnwelcomeError is a notification sent, when attempting to connect to a server, the client receives an error that hints that it should upgrade.
type OnTipAttemptProgressNtfn ¶ added in v0.1.7
type OnTipReceivedNtfn ¶ added in v0.1.8
type OnTipReceivedNtfn func(ru *RemoteUser, amountMAtoms int64)
OnTipReceivedNtfn is called when a tip is received from a remote user.
type OnTipUserInvoiceGeneratedNtfn ¶ added in v0.1.8
type OnTipUserInvoiceGeneratedNtfn func(ru *RemoteUser, tag uint32, invoice string)
OnTipUserInvoiceGeneratedNtfn is called when the local client generates an invoice to send to a remote user, for tipping purposes.
type OnTransitiveEvent ¶ added in v0.2.0
type OnTransitiveEvent func(src, dst UserID, event TransitiveEvent)
OnTransitiveEvent is called whenever a request is made by source for the local client to forward a message to dst.
type OnUnsubscribingIdleRemoteClient ¶ added in v0.1.9
type OnUnsubscribingIdleRemoteClient func(user *RemoteUser, lastDecTime time.Time)
OnUnsubscribingIdleRemoteClient is a notification sent when a remote client is detected as idle and being unsubscribed from GCs and posts.
type ProfileUpdateField ¶ added in v0.2.0
type ProfileUpdateField string
ProfileUpdateField tracks profile fields which may be updated.
const ( // ProfileUpdateAvatar is the profile field that corresponds to the // user's avatar. ProfileUpdateAvatar ProfileUpdateField = "avatar" )
type RatchetDebugInfo ¶ added in v0.1.4
type RatchetDebugInfo struct { SendRV ratchet.RVPoint `json:"send_rv"` SendRVPlain string `json:"send_rv_plain"` RecvRV ratchet.RVPoint `json:"recv_rv"` RecvRVPlain string `json:"recv_rv_plain"` DrainRV ratchet.RVPoint `json:"drain_rv"` DrainRVPlain string `json:"drain_rv_plain"` MyResetRV string `json:"my_reset_rv"` TheirResetRV string `json:"their_reset_rv"` NbSavedKeys int `json:"nb_saved_keys"` WillRatchet bool `json:"will_ratchet"` LastEncTime time.Time `json:"last_enc_time"` LastDecTime time.Time `json:"last_dec_time"` }
RatchetDebugInfo is debug information about a user's ratchet state.
type RemoteUser ¶
type RemoteUser struct {
// contains filtered or unexported fields
}
RemoteUser tracks the state of a fully formed ratchet (that is, after kx completes) and offers services that can be performed on this remote user.
func (*RemoteUser) ID ¶
func (ru *RemoteUser) ID() UserID
func (*RemoteUser) IsIgnored ¶
func (ru *RemoteUser) IsIgnored() bool
func (*RemoteUser) LastRatchetTimes ¶ added in v0.1.4
func (ru *RemoteUser) LastRatchetTimes() (time.Time, time.Time)
func (*RemoteUser) Nick ¶
func (ru *RemoteUser) Nick() string
func (*RemoteUser) RatchetDebugInfo ¶ added in v0.1.4
func (ru *RemoteUser) RatchetDebugInfo() RatchetDebugInfo
RatchetDebugInfo returns debug information about this user's ratchet.
func (*RemoteUser) SetIgnored ¶
func (ru *RemoteUser) SetIgnored(ignored bool)
func (*RemoteUser) String ¶
func (ru *RemoteUser) String() string
type RunningTipUserAttempt ¶ added in v0.1.8
type RunningTipUserAttempt struct { Tag int32 UID clientintf.UserID NextAction string NextActionTime time.Time }
RunningTipUserAttempt tracks information about a running attempt at tipping a user.
type SendProgress ¶
SendProgress is sent to track progress of messages that are sent to multiple remote users (for example, GC messages that are sent to all members).
type TransitiveEvent ¶
type TransitiveEvent string
type UserID ¶
type UserID = clientintf.UserID
func SortedUserPayStatsIDs ¶
func SortedUserPayStatsIDs(stats map[UserID]clientdb.UserPayStats) []UserID
SortedUserPayStatsIDs returns a sorted list of IDs from the passed stats map, ordered by largest total payments.
func UserIDFromStr ¶
RemoteIDFromStr converts the given string to a UserID. Returns an empty uid if the string is not a valid UserID.
type WalletUsableError ¶
type WalletUsableError struct {
// contains filtered or unexported fields
}
WalletUsableError is a complex error type that wraps both one the type of error and an underlying error (if it exists)
func (WalletUsableError) Error ¶
func (err WalletUsableError) Error() string
func (WalletUsableError) Unwrap ¶
func (err WalletUsableError) Unwrap() error
type WalletUsableErrorKind ¶
type WalletUsableErrorKind string
WalletUsableErrorKind holds the types of errors that may happen when checking if an LN wallet is usable for payments to the server.
func (WalletUsableErrorKind) Error ¶
func (err WalletUsableErrorKind) Error() string
Source Files ¶
- client.go
- client_autokx.go
- client_content.go
- client_filters.go
- client_groupchat.go
- client_kx.go
- client_kxsearch.go
- client_onboard.go
- client_onchain.go
- client_payments.go
- client_posts.go
- client_resources.go
- client_rm_handlers.go
- client_sendq.go
- client_transreset.go
- doc.go
- errors.go
- interface.go
- kx.go
- notifications.go
- payment.go
- remoteuser.go
- rmtypes.go
- tip_attempts.go
- unsafe.go
- util.go
Directories ¶
Path | Synopsis |
---|---|
Package clientintf holds client-global interfaces and helper functions.
|
Package clientintf holds client-global interfaces and helper functions. |
internal
|
|