nwc

package
v1.2.34 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Unlicense Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	PaymentSent     = by("payment_sent")
	PaymentReceived = by("payment_received")
)
View Source
var Errors = struct {
	// RateLimited - The client is sending commands too fast.It should retry in a few seconds.
	RateLimited,

	NotImplemented,

	InsufficientBalance,

	QuotaExceeded,

	Restricted,

	Unauthorized,

	Internal,

	Other by
}{
	by("RATE_LIMITED"),
	by("NOT_IMPLEMENTED"),
	by("INSUFFICIENT_BALANCE"),
	by("QUOTA_EXCEEDED"),
	by("RESTRICTED"),
	by("UNAUTHORIZED"),
	by("INTERNAL"),
	by("OTHER"),
}
View Source
var Keys = struct {
	Method,
	Params,
	ResultType,
	Error,
	Result,
	Invoice,
	Amount,
	Preimage,
	FeesPaid,
	Id,
	TLVRecords,
	Type,
	Value,
	Pubkey,
	Description,
	DescriptionHash,
	Expiry,
	CreatedAt,
	ExpiresAt,
	Metadata,
	SettledAt,
	From,
	Until,
	Offset,
	Unpaid,
	Balance,
	Notifications,
	NotificationType,
	Notification,
	PaymentHash by
}{
	by("method"),
	by("params"),
	by("result_type"),
	by("error"),
	by("result"),
	by("invoice"),
	by("amount"),
	by("preimage"),
	by("fees_paid"),
	by("id"),
	by("tlv_records"),
	by("type"),
	by("value"),
	by("pubkey"),
	by("description"),
	by("description_hash"),
	by("expiry"),
	by("created_at"),
	by("expires_at"),
	by("metadata"),
	by("settled_at"),
	by("from"),
	by("until"),
	by("offset"),
	by("unpaid"),
	by("balance"),
	by("notifications"),
	by("notification_type"),
	by("notification"),
	by("payment_hash"),
}

Keys are the proper JSON bytes for the JSON object keys of the structs of the same-named type used lower in the following. Anonymous struct syntax is used to make neater addressing of these fields as symbols.

View Source
var Methods = struct {
	PayInvoice,
	MultiPayInvoice,
	PayKeysend,
	MultiPayKeysend,
	MakeInvoice,
	LookupInvoice,
	ListTransactions,
	GetBalance,
	GetInfo by
}{
	by("pay_invoice"),
	by("multi_pay_invoice"),
	by("pay_keysend"),
	by("multi_pay_keysend"),
	by("make_invoice"),
	by("lookup_invoice"),
	by("list_transactions"),
	by("get_balance"),
	by("get_info"),
}

Methods are the text of the value of the Method field of Request.Method and Response.ResultType in a form that allows more convenient reference than using a map or package scoped variable. These appear in the API Request and Response types.

View Source
var Notifications = struct {
	PaymentReceived, PaymentSent by
}{
	by("payment_received"),
	by("payment_sent"),
}

Notifications are the proper strings for the Notification.NotificationType

Functions

This section is empty.

Types

type Client

type Client struct {
}

type Error

type Error struct {
	Code    by
	Message by
}

type GetBalanceRequest

type GetBalanceRequest struct {
	Request
}

func NewGetBalanceRequest

func NewGetBalanceRequest() *GetBalanceRequest

type GetBalanceResponse

type GetBalanceResponse struct {
	Response
	Balance Msat
}

func NewGetBalanceResponse

func NewGetBalanceResponse(balance Msat) *GetBalanceResponse

type GetInfo

type GetInfo struct {
	Alias       by
	Color       by // Hex string
	Pubkey      by
	Network     by // mainnet/testnet/signet/regtest
	BlockHeight uint64
	BlockHash   by
	Methods     by // pay_invoice, get_balance, make_invoice, lookup_invoice, list_transactions, get_info (list of methods)
}

type GetInfoRequest

type GetInfoRequest struct {
	Request
}

func NewGetInfoRequest

func NewGetInfoRequest() GetInfoRequest

type GetInfoResponse

type GetInfoResponse struct {
	Response
	GetInfo
}

func NewGetInfoResponse

func NewGetInfoResponse(gi GetInfo) GetInfoResponse

type Invoice

type Invoice struct {
	Id      by // nil for request, required for responses (omitted if nil)
	Invoice by
	Amount  Msat // optional, omitted if zero
}

type InvoiceResponse

type InvoiceResponse struct {
	Type            by // incoming or outgoing
	Invoice         by // optional
	Description     by // optional
	DescriptionHash by // optional
	Preimage        by // optional if unpaid
	PaymentHash     by
	Amount          Msat
	FeesPaid        Msat
	CreatedAt       int64
	ExpiresAt       int64 // optional if not applicable
	Metadata        []any // optional, probably like tags but retardation can be retarded so allow also numbers and floats

}

type ListTransactions

type ListTransactions struct {
	From   int64 // optional
	Until  int64 // optional
	Limit  no    // optional
	Offset no    // optional
	Unpaid bo    // optional default false
	Type   by    // incoming/outgoing/empty for "both"
}

type ListTransactionsRequest

type ListTransactionsRequest struct {
	Request
	ListTransactions
}

func NewListTransactionsRequest

func NewListTransactionsRequest(req ListTransactions) *ListTransactionsRequest

type ListTransactionsResponse

type ListTransactionsResponse struct {
	Response
	Transactions []LookupInvoice
}

func NewListTransactionsResponse

func NewListTransactionsResponse(txs []LookupInvoice) ListTransactionsResponse

type LookupInvoice

type LookupInvoice struct {
	Response
	InvoiceResponse
	SettledAt int64 // optional if unpaid
}

type LookupInvoiceRequest

type LookupInvoiceRequest struct {
	Request
	PaymentHash, Invoice by
}

func NewLookupInvoiceRequest

func NewLookupInvoiceRequest(paymentHash, invoice by) *LookupInvoiceRequest

type LookupInvoiceResponse

type LookupInvoiceResponse struct {
	Response
	LookupInvoice
}

func NewLookupInvoiceResponse

func NewLookupInvoiceResponse(resp LookupInvoice) LookupInvoiceResponse

type MakeInvoiceRequest

type MakeInvoiceRequest struct {
	Request
	Amount          Msat
	Description     by // optional
	DescriptionHash by // optional
	Expiry          no // optional
}

func NewMakeInvoiceRequest

func NewMakeInvoiceRequest(amount Msat, description, descriptionHash by,
	expiry no) MakeInvoiceRequest

type MakeInvoiceResponse

type MakeInvoiceResponse struct {
	Response
	InvoiceResponse
}

func NewMakeInvoiceResponse

func NewMakeInvoiceResponse(resp InvoiceResponse) MakeInvoiceResponse

type Msat

type Msat uint64

Msat is milli-sat, max possible value is 1000 x 21 x 100 000 000 (well, under 19 places of 64 bits in base 10)

func (Msat) Bytes

func (m Msat) Bytes(dst by) (b by)

type MultiPayInvoiceRequest

type MultiPayInvoiceRequest struct {
	Request
	Invoices []Invoice
}

func NewMultiPayInvoiceRequest

func NewMultiPayInvoiceRequest(invoices []Invoice) MultiPayInvoiceRequest

type MultiPayInvoiceResponse

type MultiPayInvoiceResponse = PayInvoiceResponse

func NewMultiPayInvoiceResponse

func NewMultiPayInvoiceResponse(preimage by, feesPaid Msat) MultiPayInvoiceResponse

type MultiPayKeysendRequest

type MultiPayKeysendRequest struct {
	Request
	Keysends []PayKeysendRequest
}

func NewMultiPayKeysendRequest

func NewMultiPayKeysendRequest(keysends []PayKeysendRequest) MultiPayKeysendRequest

type MultiPayKeysendResponse

type MultiPayKeysendResponse = PayKeysendResponse

func NewMultiPayKKeysendResponse

func NewMultiPayKKeysendResponse(preimage by, feesPaid Msat) MultiPayKeysendResponse

type Notification

type Notification struct {
	Type by
}

func (Notification) NotificationType

func (n Notification) NotificationType() by

type Notifier

type Notifier interface {
	NotificationType() by
}

type PayInvoiceRequest

type PayInvoiceRequest struct {
	Request
	Invoice
}

func NewPayInvoiceRequest

func NewPayInvoiceRequest[V st | by](invoice V, amount Msat) PayInvoiceRequest

func (PayInvoiceRequest) MarshalJSON

func (p PayInvoiceRequest) MarshalJSON(dst by) (b by, err er)
Example
ir := NewPayInvoiceRequest("lnbc50n1...", 0)
var b by
var err er
if b, err = ir.MarshalJSON(b); chk.E(err) {
	return
}
fmt.Printf("%s\n", b)
b = b[:0]
ir = NewPayInvoiceRequest("lnbc50n1...", 123)
if b, err = ir.MarshalJSON(b); chk.E(err) {
	return
}
fmt.Printf("%s\n", b)
Output:

{"method":"pay_invoice","params":{"invoice":"lnbc50n1..."}}
{"method":"pay_invoice","params":{"invoice":"lnbc50n1...","amount":123}}

func (PayInvoiceRequest) UnmarshalJSON

func (p PayInvoiceRequest) UnmarshalJSON(b by) (r by, err er)

type PayInvoiceResponse

type PayInvoiceResponse struct {
	Response
	Preimage by
	FeesPaid Msat // optional, omitted if zero
}

func NewPayInvoiceResponse

func NewPayInvoiceResponse(preimage by, feesPaid Msat) PayInvoiceResponse

func (PayInvoiceResponse) MarshalJSON

func (p PayInvoiceResponse) MarshalJSON(dst by) (b by, err er)

func (PayInvoiceResponse) UnmarshalJSON

func (p PayInvoiceResponse) UnmarshalJSON(b by) (r by, err er)

type PayKeysendRequest

type PayKeysendRequest struct {
	Request
	Amount     Msat
	Pubkey     by
	Preimage   by    // optional
	TLVRecords []TLV // optional
}

func NewPayKeysendRequest

func NewPayKeysendRequest(amount Msat, pubkey, preimage by,
	tlvRecords []TLV) PayKeysendRequest

type PayKeysendResponse

type PayKeysendResponse = PayInvoiceResponse

func NewPayKeysendResponse

func NewPayKeysendResponse(preimage by, feesPaid Msat) PayKeysendResponse

type PaymentReceivedNotification

type PaymentReceivedNotification struct {
	LookupInvoiceResponse
}

type PaymentSentNotification

type PaymentSentNotification struct {
	LookupInvoiceResponse
}

type Request

type Request struct {
	Method by
}

func (Request) RequestType

func (r Request) RequestType() by

type Requester

type Requester interface {
	RequestType() by
}

type Response

type Response struct {
	Type by
	Error
}

func (Response) ResultType

func (r Response) ResultType() by

type Resulter

type Resulter interface {
	ResultType() by
}

type Server

type Server struct {
}

type TLV

type TLV struct {
	Type  uint64
	Value by
}

Jump to

Keyboard shortcuts

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