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
- func CheckLNWalletUsable(ctx context.Context, lc lnrpc.LightningClient, svrNode string) error
- func PaymentFeeLimit(amountMAtoms uint64) *lnrpc.FeeLimit
- type AddressBookEntry
- type Client
- func (c *Client) AcceptGroupChatInvite(iid uint64) error
- func (c *Client) AcceptInvite(invite rpc.OOBPublicIdentityInvite) error
- func (c *Client) AddToGCBlockList(gcid zkidentity.ShortID, uid UserID) error
- func (c *Client) AddressBook() []*AddressBookEntry
- func (c *Client) AliasGC(gcID zkidentity.ShortID, newAlias string) error
- func (c *Client) Block(uid UserID) error
- func (c *Client) ClearPayStats(uid *UserID) error
- func (c *Client) CommentPost(postFrom clientintf.UserID, pid clientintf.PostID, comment string, ...) error
- func (c *Client) CreatePost(post, descr string) (clientdb.PostSummary, error)
- 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) GetGC(gcID zkidentity.ShortID) (clientdb.GCAddressBookEntry, 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) 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) ListDownloads() ([]clientdb.FileDownload, error)
- func (c *Client) ListGCInvitesFor(gcName string) ([]*clientdb.GCInvite, error)
- func (c *Client) ListGCs() ([]clientdb.GCAddressBookEntry, 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) 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) 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) NewGroupChat(name string) (zkidentity.ShortID, error)
- func (c *Client) NotificationManager() *NotificationManager
- func (c *Client) PM(uid UserID, msg string) error
- func (c *Client) PartFromGC(gcID zkidentity.ShortID, reason string) error
- 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) ReadInvite(r io.Reader) (rpc.OOBPublicIdentityInvite, 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) 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) Run(ctx context.Context) error
- func (c *Client) SendFile(uid UserID, filepath string) error
- func (c *Client) ServerLNNode() string
- func (c *Client) ShareFile(fname string, uid *UserID, cost uint64, isRef bool, descr string) (clientdb.SharedFile, rpc.FileMetadata, error)
- func (c *Client) SubscribeToPosts(uid UserID) 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) 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) UserByID(uid UserID) (*RemoteUser, error)
- func (c *Client) UserByNick(nick string) (*RemoteUser, error)
- func (c *Client) UserExists(id UserID) bool
- func (c *Client) UserNick(uid UserID) (string, error)
- func (c *Client) WriteNewInvite(w io.Writer) (rpc.OOBPublicIdentityInvite, error)
- type Config
- type DcrlnPaymentClient
- 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) error
- func (pc *DcrlnPaymentClient) LNRPC() lnrpc.LightningClient
- 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) UnlockWallet(ctx context.Context, pass string) error
- type DcrlnPaymentClientCfg
- type GCID
- type LastUserReceivedTime
- type NotificationHandler
- type NotificationManager
- type NotificationRegistration
- type OnGCMNtfn
- type OnGCVersionWarning
- type OnInvoiceGenFailedNtfn
- type OnKXCompleted
- type OnLocalClientOfflineTooLong
- type OnPMNtfn
- type OnPostRcvdNtfn
- type OnPostStatusRcvdNtfn
- type OnRemoteSubscriptionChangedNtfn
- type OnRemoteSubscriptionErrorNtfn
- type RatchetDebugInfo
- type RemoteUser
- func (ru *RemoteUser) AddressBookEntry() AddressBookEntry
- 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) PublicIdentity() zkidentity.PublicIdentity
- func (ru *RemoteUser) RatchetDebugInfo() RatchetDebugInfo
- func (ru *RemoteUser) SetIgnored(ignored bool)
- func (ru *RemoteUser) String() string
- 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 ¶
This section is empty.
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.
Types ¶
type AddressBookEntry ¶
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) 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() []*AddressBookEntry
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) 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) 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) 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) GetGC ¶
func (c *Client) GetGC(gcID zkidentity.ShortID) (clientdb.GCAddressBookEntry, 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) 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) ListDownloads ¶
func (c *Client) ListDownloads() ([]clientdb.FileDownload, error)
ListDownloads lists all outstanding downloads.
func (*Client) ListGCInvitesFor ¶
ListGCInvitesFor returns all GC invites received that were for the specified gc name.
func (*Client) ListGCs ¶
func (c *Client) ListGCs() ([]clientdb.GCAddressBookEntry, 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) 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) 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) NewGroupChat ¶
func (c *Client) NewGroupChat(name string) (zkidentity.ShortID, error)
NewGroupChat creates a new gc with the local user as admin.
func (*Client) NotificationManager ¶ added in v0.1.4
func (c *Client) NotificationManager() *NotificationManager
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) 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) ReadInvite ¶
ReadInvite decodes an invite from the given reader. Note the invite is not acted upon until AcceptInvite is called.
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) 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) 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) ShareFile ¶
func (c *Client) ShareFile(fname string, uid *UserID, cost uint64, isRef bool, 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) SubscribeToPosts ¶
SubscribeToPosts attempts to subscribe to the posts of the given user.
It returns when the remote user replies or the client exits.
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) 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) 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) WriteNewInvite ¶
WriteNewInvite creates a new invite and writes it to the given writer.
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 // CheckServerSession is called after a server session is established // but before ServerSessionChanged 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 *NotificationManager // ServerSessionChanged 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. ServerSessionChanged func(connected bool, pushRate, subRate, expirationDays uint64) // GCInviteHandler is called when the user received an invitation to // join a group chat from a remote user. GCInviteHandler func(user *RemoteUser, iid uint64, invite rpc.RMGroupInvite) // GCJoinHandler is called when a user has joined a GC we administer. GCJoinHandler func(user *RemoteUser, gc clientdb.GCAddressBookEntry) // GCListUpdated is called when we receive remote updates for a GC from // the GC admin. GCListUpdated func(gc clientdb.GCAddressBookEntry) // GCUserParted is called when a user was removed from a GC. Kicked // signals whether it was the user that left or whether the admin // kicked the user. GCUserParted func(gcid GCID, uid UserID, reason string, kicked bool) // GCKilled is called when the given GC is dissolved by its admin. GCKilled func(gcid GCID, reason string) // GCWithUnkxdMember is called when an attempt to send a GC message // failed due to a GC member being unkxd with the local client. GCWithUnkxdMember func(gcid GCID, uid UserID) // KXSuggestion is called when a remote user sends a suggestion to KX // with a new user. KXSuggestion func(user *RemoteUser, pii zkidentity.PublicIdentity) // PostsListReceived is called when we receive the list of posts from // a remote user. PostsListReceived func(user *RemoteUser, postList rpc.RMListPostsReply) TipReceived func(user *RemoteUser, amount float64) // SubscriptionChanged is called whenever the given user changes its // subscription status with the local client (either subscribed or // unsubscribed). SubscriptionChanged func(user *RemoteUser, subscribed bool) // ContentListReceived is called when the list of content of the user is // received. ContentListReceived func(user *RemoteUser, files []clientdb.RemoteFile, listErr error) // FileDownloadConfirmer is called to confirm the start of a file // download with the user. FileDownloadConfirmer func(user *RemoteUser, fm rpc.FileMetadata) bool // FileDownloadCompleted is called whenever a download of a file has // completed. FileDownloadCompleted func(user *RemoteUser, fm rpc.FileMetadata, diskPath string) // FileDownloadProgress is called reporting the progress of a file // download process. FileDownloadProgress func(user *RemoteUser, fm rpc.FileMetadata, nbMissingChunks int) // TransitiveEvent is called whenever a request is made by source for // the local client to forward a message to dst. TransitiveEvent func(src, dst UserID, event TransitiveEvent) // UserBlocked is called when we blocked the specified user due to their // request. Note that the passed user cannot be used for messaging // anymore. UserBlocked func(user *RemoteUser) // KXSearchCompleted is called when KX is completed with a user that // was the target of a KX search. KXSearchCompleted func(user *RemoteUser) }
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) 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 (pc *DcrlnPaymentClient) IsPaymentCompleted(ctx context.Context, invoice string) error
func (*DcrlnPaymentClient) LNRPC ¶
func (pc *DcrlnPaymentClient) LNRPC() lnrpc.LightningClient
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) UnlockWallet ¶
func (pc *DcrlnPaymentClient) UnlockWallet(ctx context.Context, pass string) error
type DcrlnPaymentClientCfg ¶
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 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) Register ¶ added in v0.1.4
func (nmgr *NotificationManager) Register(handler NotificationHandler) NotificationRegistration
func (*NotificationManager) RegisterSync ¶ added in v0.1.4
func (nmgr *NotificationManager) RegisterSync(handler NotificationHandler) NotificationRegistration
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 OnGCMNtfn ¶ added in v0.1.4
type OnGCMNtfn func(*RemoteUser, rpc.RMGroupMessage, time.Time)
OnGCMNtfn is the handler for received gc messages.
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 OnInvoiceGenFailedNtfn ¶ added in v0.1.5
type OnInvoiceGenFailedNtfn func(user *RemoteUser, dcrAmount float64, err error)
type OnKXCompleted ¶ added in v0.1.5
type OnKXCompleted func(*RemoteUser)
OnKXCompleted is called after KX is completed with a remote user (either a new user or a reset KX).
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 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.0
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 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) AddressBookEntry ¶
func (ru *RemoteUser) AddressBookEntry() AddressBookEntry
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) PublicIdentity ¶
func (ru *RemoteUser) PublicIdentity() zkidentity.PublicIdentity
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 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 ¶
Directories ¶
Path | Synopsis |
---|---|
Package clientintf holds client-global interfaces and helper functions.
|
Package clientintf holds client-global interfaces and helper functions. |
internal
|
|