@l2-technology/sensei-client
Advanced tools
Comparing version 0.1.23 to 0.1.24
{ | ||
"name": "@l2-technology/sensei-client", | ||
"version": "0.1.23", | ||
"version": "0.1.24", | ||
"description": "A javascript client for the Sensei HTTP API", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -45,2 +45,4 @@ export interface SenseiClientConfig { | ||
listenPort: number; | ||
entropy: string; | ||
crossNodeEntropy: string; | ||
} | ||
@@ -98,3 +100,6 @@ | ||
start: boolean; | ||
entropy?: string; | ||
crossNodeEntropy?: string; | ||
} | ||
export interface Node { | ||
@@ -162,2 +167,5 @@ id: string; | ||
id: string; | ||
nodeId: string; | ||
createdByNodeId: string; | ||
receivedByNodeId?: string; | ||
paymentHash: string; | ||
@@ -290,2 +298,3 @@ preimage?: string; | ||
getPayments({ filter, pagination }: GetPaymentsParams): Promise<GetPaymentsResponse>; | ||
getPhantomPayments({ filter, pagination }: GetPaymentsParams): Promise<GetPaymentsResponse>; | ||
getPeers(): Promise<GetPeersResponse>; | ||
@@ -298,2 +307,4 @@ getUnusedAddress(): Promise<AddressInfo>; | ||
createInvoice(amountMillisats: number, description: string): Promise<Invoice>; | ||
getPhantomRouteHints(): Promise<string>; | ||
createPhantomInvoice(amountMillisats: number, description: string, phantomRouteHintsHex: string[]): Promise<Invoice>; | ||
decodeInvoice(invoice: string): Promise<DecodedInvoice>; | ||
@@ -300,0 +311,0 @@ labelPayment(label: string, paymentHash: string): Promise<void>; |
@@ -172,3 +172,3 @@ class SenseiClient { | ||
async createNode({ username, alias, passphrase, start }) { | ||
async createNode({ username, alias, passphrase, start, entropy, crossNodeEntropy }) { | ||
let response = await this.post(`${this.basePath}/api/v1/nodes`, { | ||
@@ -179,2 +179,4 @@ username, | ||
start, | ||
entropy, | ||
cross_node_entropy: crossNodeEntropy, | ||
}); | ||
@@ -188,2 +190,4 @@ | ||
listenPort: response.listen_port, | ||
entropy: response.entropy, | ||
crossNodeEntropy: response.cross_node_entropy, | ||
}; | ||
@@ -321,2 +325,5 @@ } | ||
invoice: payment.invoice, | ||
nodeId: payment.node_id, | ||
createdByNodeId: payment.created_by_node_id, | ||
receivedByNodeId: payment.received_by_node_id, | ||
}; | ||
@@ -327,2 +334,35 @@ }), | ||
async getPhantomPayments({ filter = {}, pagination }) { | ||
const { page, take, searchTerm } = pagination; | ||
const origin = filter.origin || ''; | ||
const status = filter.status || ''; | ||
const response = await this.get( | ||
`${this.basePath}/api/v1/node/phantom-payments?page=${page}&take=${take}&query=${searchTerm}&origin=${origin}&status=${status}`, | ||
); | ||
return { | ||
pagination: response.pagination, | ||
payments: response.payments.map((payment) => { | ||
return { | ||
id: payment.id, | ||
paymentHash: payment.payment_hash, | ||
preimage: payment.preimage, | ||
secret: payment.secret, | ||
status: payment.status, | ||
origin: payment.origin, | ||
amtMsat: payment.amt_msat, | ||
feePaidMsat: payment.fee_paid_msat, | ||
createdAt: payment.created_at, | ||
updatedAt: payment.updated_at, | ||
label: payment.label, | ||
invoice: payment.invoice, | ||
nodeId: payment.node_id, | ||
createdByNodeId: payment.created_by_node_id, | ||
receivedByNodeId: payment.received_by_node_id, | ||
}; | ||
}), | ||
}; | ||
} | ||
async getPeers() { | ||
@@ -391,2 +431,19 @@ const { peers } = await this.get(`${this.basePath}/api/v1/node/peers`); | ||
async createPhantomInvoice(amountMillisats, description, phantomRouteHintsHex) { | ||
const response = await this.post(`${this.basePath}/api/v1/node/invoices/phantom`, { | ||
amt_msat: amountMillisats, | ||
description, | ||
phantom_route_hints_hex: phantomRouteHintsHex, | ||
}); | ||
return { | ||
invoice: response.invoice, | ||
}; | ||
} | ||
async getPhantomRouteHints() { | ||
const { phantom_route_hints_hex } = await this.get(`${this.basePath}/api/v1/node/ldk/phantom-route-hints`); | ||
return phantom_route_hints_hex; | ||
} | ||
async labelPayment(label, paymentHash) { | ||
@@ -393,0 +450,0 @@ return this.post(`${this.basePath}/api/v1/node/payments/label`, { |
29399
840