Skip to content

Search #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 3 additions & 234 deletions bindings/lni_nodejs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,237 +3,6 @@

/* auto-generated by NAPI-RS */

export interface PhoenixdConfig {
url: string
password: string
socks5Proxy?: string
acceptInvalidCerts?: boolean
httpTimeout?: number
}
export interface PhoenixdNode {
config: PhoenixdConfig
}
export interface Bolt11Resp {
amountSat: number
paymentHash: string
serialized: string
}
export interface PhoenixPayInvoiceResp {
amountSat: number
routingFeeSat: number
paymentId: string
paymentHash: string
preimage: string
}
export interface ClnConfig {
url: string
rune: string
socks5Proxy?: string
acceptInvalidCerts?: boolean
httpTimeout?: number
}
export interface ClnNode {
config: ClnConfig
}
export interface LndConfig {
url: string
macaroon: string
socks5Proxy?: string
acceptInvalidCerts?: boolean
httpTimeout?: number
}
export interface LndNode {
config: LndConfig
}
export const enum InvoiceType {
Bolt11 = 'Bolt11',
Bolt12 = 'Bolt12'
}
export interface TlvRecord {
type: number
value: string
}
export interface NodeInfo {
alias: string
color: string
pubkey: string
network: string
blockHeight: number
blockHash: string
sendBalanceMsat: number
receiveBalanceMsat: number
feeCreditBalanceMsat: number
unsettledSendBalanceMsat: number
unsettledReceiveBalanceMsat: number
pendingOpenSendBalance: number
pendingOpenReceiveBalance: number
}
export interface Transaction {
type: string
invoice: string
description: string
descriptionHash: string
preimage: string
paymentHash: string
amountMsats: number
feesPaid: number
createdAt: number
expiresAt: number
settledAt: number
payerNote?: string
externalId?: string
}
export interface NodeConnectionInfo {
pubkey: string
address: string
port: number
}
export interface Channel {
localBalance: number
localSpendableBalance: number
remoteBalance: number
id: string
remotePubkey: string
fundingTxId: string
fundingTxVout: number
active: boolean
public: boolean
internalChannel: string
confirmations: number
confirmationsRequired: number
forwardingFeeBaseMsat: number
unspendablePunishmentReserve: number
counterpartyUnspendablePunishmentReserve: number
error: string
isOutbound: boolean
}
export interface NodeStatus {
isReady: boolean
internalNodeStatus: string
}
export interface ConnectPeerRequest {
pubkey: string
address: string
port: number
}
export interface OpenChannelRequest {
pubkey: string
amountMsats: number
public: boolean
}
export interface OpenChannelResponse {
fundingTxId: string
}
export interface CloseChannelRequest {
channelId: string
nodeId: string
force: boolean
}
export interface UpdateChannelRequest {
channelId: string
nodeId: string
forwardingFeeBaseMsat: number
maxDustHtlcExposureFromFeeRateMultiplier: number
}
export interface CloseChannelResponse {

}
export interface PendingBalanceDetails {
channelId: string
nodeId: string
amountMsats: number
fundingTxId: string
fundingTxVout: number
}
export interface OnchainBalanceResponse {
spendable: number
total: number
reserved: number
pendingBalancesFromChannelClosures: number
pendingBalancesDetails: Array<PendingBalanceDetails>
internalBalances: string
}
export interface PeerDetails {
nodeId: string
address: string
isPersisted: boolean
isConnected: boolean
}
export interface LightningBalanceResponse {
totalSpendable: number
totalReceivable: number
nextMaxSpendable: number
nextMaxReceivable: number
nextMaxSpendableMpp: number
nextMaxReceivableMpp: number
}
export interface PayInvoiceResponse {
paymentHash: string
preimage: string
feeMsats: number
}
export interface PayKeysendResponse {
fee: number
}
export interface BalancesResponse {
onchain: OnchainBalanceResponse
lightning: LightningBalanceResponse
}
export interface PaymentFailedEventProperties {
transaction: Transaction
reason: string
}
export interface ListTransactionsParams {
from: number
limit: number
paymentHash?: string
}
export interface CreateInvoiceParams {
invoiceType: InvoiceType
amountMsats?: number
offer?: string
description?: string
descriptionHash?: string
expiry?: number
rPreimage?: string
isBlinded?: boolean
isKeysend?: boolean
isAmp?: boolean
isPrivate?: boolean
}
export interface PayCode {
offerId: string
bolt12: string
label?: string
active?: boolean
singleUse?: boolean
used?: boolean
}
export interface PayInvoiceParams {
invoice: string
feeLimitMsat?: number
feeLimitPercentage?: number
timeoutSeconds?: number
amountMsats?: number
maxParts?: number
firstHopPubkey?: string
lastHopPubkey?: string
allowSelfPayment?: boolean
isAmp?: boolean
}
export interface OnInvoiceEventParams {
paymentHash: string
pollingDelaySec: number
maxPollingSec: number
}
export interface Payment {
paymentId: string
circId: string
round: number
relayFingerprint: string
updatedAt: number
amountMsats: number
}
export declare class PhoenixdNode {
constructor(config: PhoenixdConfig)
getUrl(): string
Expand All @@ -243,7 +12,7 @@ export declare class PhoenixdNode {
createInvoice(params: CreateInvoiceParams): Transaction
payInvoice(params: PayInvoiceParams): PayInvoiceResponse
getOffer(): PayCode
lookupInvoice(paymentHash: string): Transaction
lookupInvoice(params: LookupInvoiceParams): Transaction
payOffer(offer: string, amountMsats: number, payerNote?: string | undefined | null): PayInvoiceResponse
listTransactions(params: ListTransactionsParams): Array<Transaction>
onInvoiceEvents(params: OnInvoiceEventParams, callback: (arg0: string, arg1?: Transaction | undefined | null) => void): void
Expand All @@ -259,7 +28,7 @@ export declare class ClnNode {
getOffer(search?: string | undefined | null): PayCode
listOffers(search?: string | undefined | null): Array<PayCode>
payOffer(offer: string, amountMsats: number, payerNote?: string | undefined | null): PayInvoiceResponse
lookupInvoice(paymentHash: string): Transaction
lookupInvoice(params: LookupInvoiceParams): Transaction
listTransactions(params: ListTransactionsParams): Array<Transaction>
decode(str: string): string
onInvoiceEvents(params: OnInvoiceEventParams, callback: (arg0: string, arg1?: Transaction | undefined | null) => void): void
Expand All @@ -275,7 +44,7 @@ export declare class LndNode {
getOffer(search?: string | undefined | null): PayCode
listOffers(search?: string | undefined | null): Array<PayCode>
payOffer(offer: string, amountMsats: number, payerNote?: string | undefined | null): PayInvoiceResponse
lookupInvoice(paymentHash: string): Transaction
lookupInvoice(params: LookupInvoiceParams): Transaction
listTransactions(params: ListTransactionsParams): Array<Transaction>
decode(str: string): string
onInvoiceEvents(params: OnInvoiceEventParams, callback: (arg0: string, arg1?: Transaction | undefined | null) => void): void
Expand Down
3 changes: 1 addition & 2 deletions bindings/lni_nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,8 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

const { InvoiceType, PhoenixdNode, ClnNode, LndNode } = nativeBinding
const { PhoenixdNode, ClnNode, LndNode } = nativeBinding

module.exports.InvoiceType = InvoiceType
module.exports.PhoenixdNode = PhoenixdNode
module.exports.ClnNode = ClnNode
module.exports.LndNode = LndNode
14 changes: 8 additions & 6 deletions bindings/lni_nodejs/src/cln.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use lni::{cln::lib::ClnConfig, CreateInvoiceParams, PayInvoiceParams};
use lni::{cln::lib::ClnConfig, CreateInvoiceParams, LookupInvoiceParams, PayInvoiceParams};
use napi::bindgen_prelude::*;
use napi_derive::napi;
#[napi]
Expand Down Expand Up @@ -84,9 +84,10 @@ impl ClnNode {
}

#[napi]
pub fn lookup_invoice(&self, payment_hash: String) -> napi::Result<lni::Transaction> {
let txn = lni::cln::api::lookup_invoice(&self.inner, Some(payment_hash), None, None)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
pub fn lookup_invoice(&self, params: LookupInvoiceParams) -> napi::Result<lni::Transaction> {
let txn =
lni::cln::api::lookup_invoice(&self.inner, params.payment_hash, None, None, params.search)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
Ok(txn)
}

Expand All @@ -95,8 +96,9 @@ impl ClnNode {
&self,
params: lni::types::ListTransactionsParams,
) -> napi::Result<Vec<lni::Transaction>> {
let txns = lni::cln::api::list_transactions(&self.inner, params.from, params.limit)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
let txns =
lni::cln::api::list_transactions(&self.inner, params.from, params.limit, params.search)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
Ok(txns)
}

Expand Down
14 changes: 8 additions & 6 deletions bindings/lni_nodejs/src/lnd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use lni::{lnd::lib::LndConfig, CreateInvoiceParams, PayInvoiceParams};
use lni::{lnd::lib::LndConfig, CreateInvoiceParams, LookupInvoiceParams, PayInvoiceParams};
use napi::bindgen_prelude::*;
use napi_derive::napi;
#[napi]
Expand Down Expand Up @@ -82,9 +82,10 @@ impl LndNode {
}

#[napi]
pub fn lookup_invoice(&self, payment_hash: String) -> napi::Result<lni::Transaction> {
let txn = lni::lnd::api::lookup_invoice(&self.inner, Some(payment_hash))
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
pub fn lookup_invoice(&self, params: LookupInvoiceParams) -> napi::Result<lni::Transaction> {
let txn =
lni::lnd::api::lookup_invoice(&self.inner, params.payment_hash, None, None, params.search)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
Ok(txn)
}

Expand All @@ -93,8 +94,9 @@ impl LndNode {
&self,
params: lni::types::ListTransactionsParams,
) -> napi::Result<Vec<lni::Transaction>> {
let txns = lni::lnd::api::list_transactions(&self.inner, params.from, params.limit)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
let txns =
lni::lnd::api::list_transactions(&self.inner, params.from, params.limit, params.search)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
Ok(txns)
}

Expand Down
18 changes: 13 additions & 5 deletions bindings/lni_nodejs/src/phoenixd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use lni::{phoenixd::lib::PhoenixdConfig, CreateInvoiceParams, PayInvoiceParams};
use lni::{
phoenixd::lib::PhoenixdConfig, CreateInvoiceParams, LookupInvoiceParams, PayInvoiceParams,
};
use napi::bindgen_prelude::*;
use napi_derive::napi;

Expand Down Expand Up @@ -65,9 +67,15 @@ impl PhoenixdNode {
}

#[napi]
pub fn lookup_invoice(&self, payment_hash: String) -> napi::Result<lni::Transaction> {
let txn = lni::phoenixd::api::lookup_invoice(&self.inner, payment_hash)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
pub fn lookup_invoice(&self, params: LookupInvoiceParams) -> napi::Result<lni::Transaction> {
let txn = lni::phoenixd::api::lookup_invoice(
&self.inner,
params.payment_hash,
None,
None,
params.search,
)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
Ok(txn)
}

Expand All @@ -88,7 +96,7 @@ impl PhoenixdNode {
&self,
params: crate::ListTransactionsParams,
) -> napi::Result<Vec<lni::Transaction>> {
let txns = lni::phoenixd::api::list_transactions(&self.inner, params.from, params.limit, None)
let txns = lni::phoenixd::api::list_transactions(&self.inner, params)
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
Ok(txns)
}
Expand Down
Loading