Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelPoint ¶
type ChannelPoint struct {
lnchat.ChannelPoint
}
ChannelPoint describes a channel by specifying its funding transaction output.
type Discussion ¶
type Discussion struct { ID uint64 `json:"id" badgerhold:"key"` Participants []string `json:"participants"` LastReadID uint64 `json:"last_read_message_id"` LastMessageID uint64 `json:"last_message_id"` Options MessageOptions `json:"options"` }
Discussion is the discussion model for c13n.
func (*Discussion) Indexes ¶
func (d *Discussion) Indexes() map[string]badgerhold.Index
Indexes satisfies badgerhold.Storer interface.
func (*Discussion) Type ¶
func (d *Discussion) Type() string
Type satisfies badgerhold.Storer interface.
type DiscussionStatistics ¶
type DiscussionStatistics struct { // Total amount sent in discussion (in millisatoshi). AmtMsatSent uint64 // Total amount of fees in discussion (in millisatoshi). AmtMsatFees uint64 // Total amount received in discussion (in millisatoshi). AmtMsatReceived uint64 // Number of sent messages in discussion. MessagesSent uint64 // Number of received messages in discussion. MessagesReceived uint64 }
DiscussionStatistics represents statistics about a discussion.
type Hop ¶
type Hop struct { // The channel id. ChanID uint64 `json:"chan_id"` // The address (public key) of the hop. HopAddress string `json:"hop_address"` // The amount to be forwarded through the hop (in millisatoshi). AmtToForwardMsat int64 `json:"amt_to_forward_msat"` // The fee to be paid to the hop (in millisatoshi). FeeMsat int64 `json:"fee_msat"` // The custom records for the hop. CustomRecords map[uint64][]byte `json:"custom_records"` }
Hop represents a hop in a payment route.
type Invoice ¶
type Invoice struct { // Since only the invoice creator has access to the Invoice, // the CreatorAddress is the Lightning address of the underlying node. CreatorAddress string // The embedded invoice. lnchat.Invoice }
Invoice embeds lnchat.Invoice, implementing the badgerhold.Storer interface.
type Message ¶
type Message struct { // The id of the message. ID uint64 `json:"id" badgerhold:"key"` // The id of the discussion the message is part of. DiscussionID uint64 `json:"discussion_id"` // The message payload. Payload string `json:"payload"` // The total amount sent with this message across all routes (in millisatoshi). AmtMsat int64 `json:"amt_msat"` // The address of the sender, if present. Sender string `json:"sender"` // The address of the recipient. Receiver string `json:"receiver"` // Whether the sender was verified via signature. SenderVerified bool `json:"sender_verified"` // The time the message was sent (in nanoseconds since Unix Epoch). SentTimeNs int64 `json:"sent_time_ns"` // The time the message was received (in nanoseconds since Unix Epoch). ReceivedTimeNs int64 `json:"received_time_ns"` // The message index (settle_index for received messages, // payment_index for sent messages), as it relates to lnd. Index uint64 // The total fees used to send this message across all routes (in millisatoshi). TotalFeesMsat int64 `json:"total_fees_msat"` // The routes used to send this message. Routes []Route `json:"routes"` // Preimage hash. PreimageHash []byte // The payment preimage. Preimage lnchat.PreImage `json:"preimage"` // The payment request (invoice) to be paid. If empty, corresponds to a spontaneous payment. PayReq string `json:"pay_req"` // Arrival success probability. SuccessProb float64 }
Message represents a message.
func NewIncomingMessage ¶
func NewIncomingMessage(rawMsg *RawMessage, inv *Invoice, discussionRetriever func([]string) (*Discussion, error)) (*Message, error)
NewIncomingMessage constructs a Message from a RawMessage and Invoice.
func NewOutgoingMessage ¶
func NewOutgoingMessage(rawMsg *RawMessage, onlySuccessfulPayments bool, payments ...*Payment) (*Message, error)
NewOutgoingMessage constructs a Message from a RawMessage and a list of Payments.
type MessageAggregate ¶
type MessageAggregate struct { // The raw message. RawMessage *RawMessage // The invoice carrying the message (valid only for incoming messages). Invoice *Invoice // The payments fulfilling the message (valid only for outgoing messages). Payments []*Payment }
MessageAggregate represents a raw discussion message along with the invoice or payments it references.
type MessageOptions ¶
type MessageOptions struct { // The maximum fee allowed for sending a message (in millisatoshi). FeeLimitMsat int64 `json:"fee_limit_msat"` // Whether to include the sender address in the message. Anonymous bool `json:"anonymous"` }
MessageOptions represents options for a message.
func (MessageOptions) GetPaymentOptions ¶
func (o MessageOptions) GetPaymentOptions() lnchat.PaymentOptions
GetPaymentOptions returns the corresponding lnchat.PaymentOptions.
func (MessageOptions) WithFeeLimit ¶
func (o MessageOptions) WithFeeLimit(feeLimitMsat int64) MessageOptions
WithFeeLimit sets the fee limit option.
type PageOptions ¶
type PageOptions struct { // LastID represents the id of the element to return. // 0 represents the first element (or last if reverse is specified). LastID uint64 // PageSize represents the number // of requested elements (inclusive of the first element). // 0 represents no limit. PageSize uint64 // Reverse represents that the requested range // retrieve elements from LastID going backwards. Reverse bool }
PageOptions represents pagination options.
type Payment ¶
type Payment struct { // The Lightningaddress of the payer. PayerAddress string // The Lightning address of the payee. PayeeAddress string // The embedded payment. lnchat.Payment }
Payment embeds lnchat.Payment, implementing the badgerhold.Storer interface.
type RawMessage ¶
type RawMessage struct { // The message id (store index). ID uint64 `badgerhold:"key"` // The id of the discussion the message belongs to. DiscussionID uint64 `badgerholdIndex:"DiscIdx"` // The raw message payload. RawPayload []byte // The Lightning address of the sender. // TODO: Replace Sender field type with lnchat.NodeID. Sender string // The message signature. Signature []byte // Whether the sender was the one that signed the payload. SignatureVerified bool // The SettleIndex of the invoice associated // with the message (incoming). InvoiceSettleIndex uint64 // The PaymentIndexes of the payments // used to transport the message (outgoing). PaymentIndexes []uint64 // The timestamp of the message. // It is an internal field and does not correspond // to the sent or received time of the message. Timestamp time.Time }
RawMessage represents a raw message over the Lightning network, associated with a payment or an invoice - depending on whether it was incoming or outgoing. Exactly one of InvoiceSettleIndex or PaymentIndex must be populated.
func NewRawMessage ¶
func NewRawMessage(discussion *Discussion, payload string) (*RawMessage, error)
NewRawMessage constructs a raw message from a discussion and payload.
func (*RawMessage) UnmarshalPayload ¶
func (raw *RawMessage) UnmarshalPayload() (string, []string, error)
UnmarshalPayload returns the message participants.
func (*RawMessage) WithPaymentIndexes ¶
func (raw *RawMessage) WithPaymentIndexes(paymentIdxs ...uint64)
WithPaymentIndexes associates the provided payment indexes with the message.
func (*RawMessage) WithSignature ¶
func (raw *RawMessage) WithSignature(sender string, signature []byte) error
WithSignature adds the provided sender and signature to the raw message.
func (*RawMessage) WithTimestamp ¶
func (raw *RawMessage) WithTimestamp(ts time.Time)
WithTimestamp adds the provided timestamp to the raw message.
type Route ¶
type Route struct { // The total timelock across the entire route. TotalTimeLock uint32 `json:"total_timelock"` // The amount sent via this route, disregarding the route fees (in millisatoshi). RouteAmtMsat int64 `json:"route_amt_msat"` // The total route fees (in millisatoshi). RouteFeesMsat int64 `json:"route_fees_msat"` // The list of hops for the route. RouteHops []Hop `json:"route_hops"` }
Route represents a payment route.
type SelfBalance ¶
type SelfBalance struct {
lnchat.SelfBalance
}
SelfBalance represents the model for the current node's balance.
type TxFeeOptions ¶
TxFeeOptions specifies options used for fee calculation of an on-chain transaction.