@webbtc/webln-types
Advanced tools
Comparing version 1.0.14 to 2.0.0
{ | ||
"name": "@webbtc/webln-types", | ||
"description": "Type definitions for WebLN", | ||
"version": "1.0.14", | ||
"version": "2.0.0", | ||
"types": "types/index.d.ts", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -5,27 +5,29 @@ // Workaround for code completion to account for values this library doesn't know about yet. | ||
type RequestMethod = | ||
| "getinfo" | ||
| "listchannels" | ||
| "listinvoices" | ||
| "channelbalance" | ||
| "walletbalance" | ||
| "openchannel" | ||
| "connectpeer" | ||
| "disconnectpeer" | ||
| "estimatefee" | ||
| "getchaninfo" | ||
| "getnetworkinfo" | ||
| "getnodeinfo" | ||
| "gettransactions" | ||
| "listpayments" | ||
| "listpeers" | ||
| "lookupinvoice" | ||
| "queryroutes" | ||
| "verifymessage" | ||
| "sendtoroute" | ||
| "decodepayreq" | ||
| "routermc" | ||
| "addinvoice" | ||
type WebLNRequestMethod = | ||
| "request.getinfo" | ||
| "request.listchannels" | ||
| "request.listinvoices" | ||
| "request.channelbalance" | ||
| "request.walletbalance" | ||
| "request.openchannel" | ||
| "request.connectpeer" | ||
| "request.disconnectpeer" | ||
| "request.estimatefee" | ||
| "request.getchaninfo" | ||
| "request.getnetworkinfo" | ||
| "request.getnodeinfo" | ||
| "request.gettransactions" | ||
| "request.listpayments" | ||
| "request.listpeers" | ||
| "request.lookupinvoice" | ||
| "request.queryroutes" | ||
| "request.verifymessage" | ||
| "request.sendtoroute" | ||
| "request.decodepayreq" | ||
| "request.routermc" | ||
| "request.addinvoice" | ||
| AdditionalString; | ||
type WebLNMethod = keyof WebLNProvider | AdditionalString; | ||
interface WebLNNode { | ||
@@ -40,3 +42,3 @@ alias: string; | ||
supports: ("lightning" | AdditionalString)[]; | ||
methods: RequestMethod[]; | ||
methods: (WebLNRequestMethod | WebLNMethod)[]; | ||
} | ||
@@ -58,3 +60,3 @@ interface SendPaymentResponse { | ||
} | ||
interface RequestInvoiceResponse { | ||
interface MakeInvoiceResponse { | ||
paymentRequest: string; | ||
@@ -67,3 +69,25 @@ } | ||
type ListPeersResponse = { | ||
type LNURLResponse = | ||
| { | ||
status: "OK"; | ||
} | ||
| { status: "ERROR"; reason: string }; | ||
interface GetBalanceResponse { | ||
balance: number; | ||
max_amount?: number; | ||
budget_renewal?: string; | ||
} | ||
interface LookupInvoiceArgs { | ||
invoice?: string; | ||
payment_hash?: string; | ||
} | ||
interface LookupInvoiceResponse { | ||
paymentRequest: string; | ||
paid: boolean; | ||
} | ||
type WebLNRequestListPeersResponse = { | ||
peers: { | ||
@@ -87,5 +111,7 @@ pub_key: string; | ||
type ListPeersRequestFunc = (method: "listpeers") => ListPeersResponse; | ||
type WebLNRequestListPeersRequestFunc = ( | ||
method: "request.listpeers" | ||
) => WebLNRequestListPeersResponse; | ||
type ListChannelsResponse = { | ||
type WebLNRequestListChannelsResponse = { | ||
channels: { | ||
@@ -143,5 +169,7 @@ active: boolean; | ||
type ListChannelsRequestFunc = (method: "listchannels") => ListPeersResponse; | ||
type WebLNRequestListChannelsRequestFunc = ( | ||
method: "request.listchannels" | ||
) => WebLNRequestListChannelsResponse; | ||
type ListInvoicesResponse = { | ||
type WebLNRequestListInvoicesResponse = { | ||
invoices: { | ||
@@ -192,4 +220,4 @@ memo: string; | ||
type ListInvoicesRequestFunc = ( | ||
method: "listinvoices", | ||
type WebLNRequestListInvoicesRequestFunc = ( | ||
method: "request.listinvoices", | ||
args?: { | ||
@@ -203,5 +231,5 @@ reversed?: boolean; | ||
} | ||
) => ListInvoicesResponse; | ||
) => WebLNRequestListInvoicesResponse; | ||
type ListPaymentsResponse = { | ||
type WebLNRequestListPaymentsResponse = { | ||
payments: { | ||
@@ -229,4 +257,4 @@ payment_hash: string; | ||
type ListPaymentsRequestFunc = ( | ||
method: "listpayments", | ||
type WebLNRequestListPaymentsFunc = ( | ||
method: "request.listpayments", | ||
args?: { | ||
@@ -240,11 +268,5 @@ reversed?: boolean; | ||
} | ||
) => ListInvoicesResponse; | ||
) => WebLNRequestListPaymentsResponse; | ||
type LNURLResponse = | ||
| { | ||
status: "OK"; | ||
} | ||
| { status: "ERROR"; reason: string }; | ||
type WalletBalanceResponse = { | ||
type WebLNRequestWalletBalanceResponse = { | ||
total_balance: string; | ||
@@ -263,5 +285,5 @@ confirmed_balance: string; | ||
type WalletBalanceRequestFunc = ( | ||
method: "walletbalance" | ||
) => WalletBalanceResponse; | ||
type WebLNRequestWalletBalanceRequestFunc = ( | ||
method: "request.walletbalance" | ||
) => WebLNRequestWalletBalanceResponse; | ||
@@ -271,16 +293,16 @@ interface WebLNProvider { | ||
getInfo(): Promise<GetInfoResponse>; | ||
keysend(args: KeysendArgs): Promise<SendPaymentResponse>; | ||
lnurl(lnurl: string): Promise<LNURLResponse>; | ||
makeInvoice( | ||
args: string | number | RequestInvoiceArgs | ||
): Promise<RequestInvoiceResponse>; | ||
request: ListPeersRequestFunc & | ||
ListChannelsRequestFunc & | ||
ListInvoicesRequestFunc & | ||
ListPaymentsRequestFunc & | ||
WalletBalanceRequestFunc & | ||
((method: RequestMethod, args?: unknown) => Promise<unknown>); | ||
): Promise<MakeInvoiceResponse>; | ||
sendPayment(paymentRequest: string): Promise<SendPaymentResponse>; | ||
signMessage(message: string): Promise<SignMessageResponse>; | ||
verifyMessage(signature: string, message: string): Promise<void>; | ||
// optional methods | ||
isEnabled?(): boolean; | ||
getBalance?(): Promise<GetBalanceResponse>; | ||
keysend?(args: KeysendArgs): Promise<SendPaymentResponse>; | ||
lnurl?(lnurl: string): Promise<LNURLResponse>; | ||
lookupInvoice?(args: LookupInvoiceArgs): Promise<LookupInvoiceResponse>; | ||
request?: (method: WebLNRequestMethod, args?: unknown) => Promise<unknown>; | ||
signMessage?(message: string): Promise<SignMessageResponse>; | ||
verifyMessage?(signature: string, message: string): Promise<void>; | ||
on?(eventName: string, listener: () => void): void; | ||
@@ -298,3 +320,3 @@ off?(eventName: string, listener: () => void): void; | ||
WebLNProvider, | ||
RequestMethod, | ||
WebLNMethod, | ||
WebLNNode, | ||
@@ -305,9 +327,16 @@ GetInfoResponse, | ||
KeysendArgs, | ||
RequestInvoiceResponse, | ||
MakeInvoiceResponse, | ||
SignMessageResponse, | ||
ListPeersResponse, | ||
ListChannelsResponse, | ||
WalletBalanceResponse, | ||
ListInvoicesResponse, | ||
ListPaymentsResponse, | ||
GetBalanceResponse, | ||
LookupInvoiceArgs, | ||
LookupInvoiceResponse, | ||
// webln.request methods | ||
WebLNRequestMethod, | ||
// (webln.request as WebLNRequestWalletBalanceRequestFunc)("request.walletbalance") | ||
WebLNRequestWalletBalanceRequestFunc, | ||
WebLNRequestListChannelsRequestFunc, | ||
WebLNRequestListInvoicesRequestFunc, | ||
WebLNRequestListPaymentsFunc, | ||
WebLNRequestListPeersRequestFunc, | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11402
306