Documentation ¶
Index ¶
- Constants
- Variables
- func BuildInfo() (commitDesc string, hash string)
- func Version() string
- func WithDefaultFeeLimitMsat(defaultLimitMsat int64) func(*App) error
- type App
- func (app *App) AddContact(_ context.Context, contact *model.Contact) (*model.Contact, error)
- func (app *App) AddDiscussion(_ context.Context, discussion *model.Discussion) (*model.Discussion, error)
- func (app *App) Cleanup() (err error)
- func (app *App) ConnectNode(ctx context.Context, address string, hostport string) error
- func (app *App) CreateInvoice(ctx context.Context, memo string, amtMsat int64, expiry int64, private bool) (*model.Invoice, error)
- func (app *App) EstimatePayment(ctx context.Context, payload string, amtMsat int64, discID uint64, ...) (*model.Message, error)
- func (app *App) GetContacts(_ context.Context) ([]model.Contact, error)
- func (app *App) GetDiscussionHistory(ctx context.Context, discID uint64, pageOpts model.PageOptions) ([]model.Message, error)
- func (app *App) GetDiscussionStatistics(_ context.Context, id uint64) (*model.DiscussionStatistics, error)
- func (app *App) GetDiscussions(_ context.Context) ([]model.Discussion, error)
- func (app *App) GetNodes(ctx context.Context) ([]model.Node, error)
- func (app *App) GetNodesByAddress(ctx context.Context, address string) ([]model.Node, error)
- func (app *App) GetNodesByAlias(ctx context.Context, aliasSubstr string) ([]model.Node, error)
- func (app *App) GetSelfBalance(ctx context.Context) (*model.SelfBalance, error)
- func (app *App) GetSelfInfo(ctx context.Context) (*model.SelfInfo, error)
- func (app *App) Init(ctx context.Context, infoTimeoutSecs uint) error
- func (app *App) LookupInvoice(ctx context.Context, payReq string) (*model.Invoice, error)
- func (app *App) OpenChannel(ctx context.Context, address string, amtMsat, pushAmtMsat uint64, ...) (*model.ChannelPoint, error)
- func (app *App) RemoveContactByAddress(_ context.Context, address string) error
- func (app *App) RemoveContactByID(_ context.Context, id uint64) error
- func (app *App) RemoveDiscussion(_ context.Context, id uint64) error
- func (app *App) SendPayment(ctx context.Context, payload string, amtMsat int64, discID uint64, ...) (*model.Message, error)
- func (app *App) SubscribeMessages(ctx context.Context) (<-chan *message.Message, error)
- func (app *App) UpdateDiscussionLastRead(_ context.Context, discID, readMsgID uint64) error
- type ErrKind
- type Error
Constants ¶
const ( // PayloadTypeKey is the key of the payload. PayloadTypeKey = 0x117C17A7 + 2*iota // SenderTypeKey is the key of the sender address. SenderTypeKey // SignatureTypeKey is the key of the sender signature. SignatureTypeKey )
Definition of the payload TLV types. These are used as keys for payloads embedded in payment HTLCs over Lightning, and are required to be in the custom TLV range (>=65536). Additionally, odd types are optional, while even fields are mandatory. If an HTLC containing an unknown even type is received, the HTLC is rejected.
const (
// ReceiveTopic is the pubsub topic for received messages.
ReceiveTopic = "message.receive"
)
Variables ¶
var DefaultOptions = model.MessageOptions{ FeeLimitMsat: 3000, Anonymous: false, }
DefaultOptions defines the default message options to be used when no overrides have been set.
var ErrDiscAnonymousMessage = fmt.Errorf("anonymous message in group discussion is disallowed")
ErrDiscAnonymousMessage indicates that an anonymous send was requested to a group discussion.
Functions ¶
func BuildInfo ¶
BuildInfo returns the commit descriptor as well as the commit hash used in the current c13n build.
func Version ¶
func Version() string
Version returns the application version as a properly formed string, as per the semantic versioning specification 2.0.0.
func WithDefaultFeeLimitMsat ¶
WithDefaultFeeLimitMsat sets the FeeLimitMsat default value for the app instance. The FeeLimitMsat default value is the default maximum fee used for sending a message.
Types ¶
type App ¶
type App struct { Log *slog.Logger Self lnchat.SelfInfo LNManager lnchat.LightManager Database store.Database PubSubBus *gochannel.GoChannel Tomb *tomb.Tomb }
App defines the c13n application logic.
func New ¶
func New(lnChat lnchat.LightManager, database store.Database, options ...func(*App) error) (*App, error)
New creates a new app instance.
func (*App) AddContact ¶
AddContact adds a contact to the database if it doesn't exist.
func (*App) AddDiscussion ¶
func (app *App) AddDiscussion(_ context.Context, discussion *model.Discussion) (*model.Discussion, error)
AddDiscussion adds a discussion to database.
func (*App) ConnectNode ¶
ConnectNode connects a node as a peer.
func (*App) CreateInvoice ¶
func (app *App) CreateInvoice(ctx context.Context, memo string, amtMsat int64, expiry int64, private bool) (*model.Invoice, error)
CreateInvoice creates an invoice and returns it.
func (*App) EstimatePayment ¶
func (app *App) EstimatePayment(ctx context.Context, payload string, amtMsat int64, discID uint64, opts model.MessageOptions) (*model.Message, error)
EstimatePayment attempts to calculate the details for sending a payment (or message) to a discussion. If the discussion contains multiple participants, one route for each participant is calculated and the fees are cumulative.
func (*App) GetContacts ¶
GetContacts returns all contacts stored in database.
func (*App) GetDiscussionHistory ¶
func (app *App) GetDiscussionHistory(ctx context.Context, discID uint64, pageOpts model.PageOptions) ([]model.Message, error)
GetDiscussionHistory returns the requested range of messages for a specific discussion.
func (*App) GetDiscussionStatistics ¶
func (app *App) GetDiscussionStatistics(_ context.Context, id uint64) ( *model.DiscussionStatistics, error)
GetDiscussionStatistics retrieves the discussion messages and calculates statistics.
func (*App) GetDiscussions ¶
GetDiscussions returns all messages stored in database.
func (*App) GetNodesByAddress ¶
GetNodesByAddress returns the visible nodes, filtered based on address.
func (*App) GetNodesByAlias ¶
GetNodesByAlias returns the visible nodes, filtered based on the provided alias substring.
func (*App) GetSelfBalance ¶
GetSelfBalance returns the current node's balance.
func (*App) GetSelfInfo ¶
GetSelfInfo returns the current node's information.
func (*App) Init ¶
Init performs any initializations needed at the logic layer, and also opens a persistent publisher listening for received messages from the Lightning daemon.
func (*App) LookupInvoice ¶
LookupInvoice retrieves an invoice and returns it.
func (*App) OpenChannel ¶
func (app *App) OpenChannel(ctx context.Context, address string, amtMsat, pushAmtMsat uint64, minInputConfs int32, txOptions model.TxFeeOptions) (*model.ChannelPoint, error)
OpenChannel creates a channel with the node identified by the provided Lightning address. The function returns when the funding transaction is published, meaning the channel is pending and not yet considered open.
func (*App) RemoveContactByAddress ¶
RemoveContactByAddress removes the contact matching the passed address from database.
func (*App) RemoveContactByID ¶
RemoveContactByID removes the contact matching the passed id from database.
func (*App) RemoveDiscussion ¶
RemoveDiscussion removes the discussion matching the passed id from database.
func (*App) SendPayment ¶
func (app *App) SendPayment(ctx context.Context, payload string, amtMsat int64, discID uint64, payReq string, opts model.MessageOptions) (*model.Message, error)
SendPayment attempts to send a payment. A payment fulfils the payment request, if one is provided, otherwise it is addressed to the discussion participants. If payload is present, it is sent along with the payment (respecting the provided and discussion options, if applicable).
func (*App) SubscribeMessages ¶
SubscribeMessages returns a channel over which received messages are sent.