# LightningApi

All URIs are relative to *http://localhost*

| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**cancelReceive**](LightningApi.md#cancelreceive) | **DELETE** /api/v1/lightning/receives/{identifier} | Cancel a pending receive |
| [**generateInvoice**](LightningApi.md#generateinvoice) | **POST** /api/v1/lightning/receives/invoice | Create a BOLT11 invoice |
| [**generateInvoiceForAddress**](LightningApi.md#generateinvoiceforaddress) | **POST** /api/v1/lightning/receives/invoice/for-address | Create a BOLT11 invoice for an Ark address |
| [**getReceiveStatus**](LightningApi.md#getreceivestatus) | **GET** /api/v1/lightning/receives/{identifier} | Get receive status |
| [**listReceiveStatuses**](LightningApi.md#listreceivestatuses) | **GET** /api/v1/lightning/receives | List all pending receive statuses |
| [**pay**](LightningApi.md#pay) | **POST** /api/v1/lightning/pay | Send a Lightning payment |



## cancelReceive

> cancelReceive(identifier)

Cancel a pending receive

Cancels a pending Lightning receive identified by its payment hash or invoice string. The server will refuse cancellation if HTLC-recv VTXOs have already been granted. Bark also prevents cancellation when the preimage has been revealed.

### Example

```ts
import {
  Configuration,
  LightningApi,
} from '@secondts/barkd';
import type { CancelReceiveRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new LightningApi(config);

  const body = {
    // string | Payment hash or invoice string
    identifier: identifier_example,
  } satisfies CancelReceiveRequest;

  try {
    const data = await api.cancelReceive(body);
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters


| Name | Type | Description  | Notes |
|------------- | ------------- | ------------- | -------------|
| **identifier** | `string` | Payment hash or invoice string | [Defaults to `undefined`] |

### Return type

`void` (Empty response body)

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: `application/json`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Receive canceled successfully |  -  |
| **400** | Bad request |  -  |
| **404** | Not found |  -  |
| **500** | Internal server error |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)


## generateInvoice

> InvoiceInfo generateInvoice(lightningInvoiceRequest)

Create a BOLT11 invoice

Generates a new BOLT11 invoice for the specified amount via the Ark server, creating a pending Lightning receive.

### Example

```ts
import {
  Configuration,
  LightningApi,
} from '@secondts/barkd';
import type { GenerateInvoiceRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new LightningApi(config);

  const body = {
    // LightningInvoiceRequest
    lightningInvoiceRequest: ...,
  } satisfies GenerateInvoiceRequest;

  try {
    const data = await api.generateInvoice(body);
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters


| Name | Type | Description  | Notes |
|------------- | ------------- | ------------- | -------------|
| **lightningInvoiceRequest** | [LightningInvoiceRequest](LightningInvoiceRequest.md) |  | |

### Return type

[**InvoiceInfo**](InvoiceInfo.md)

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: `application/json`
- **Accept**: `application/json`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Returns the created invoice |  -  |
| **500** | Internal server error |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)


## generateInvoiceForAddress

> InvoiceInfo generateInvoiceForAddress(lightningInvoiceForAddressRequest)

Create a BOLT11 invoice for an Ark address

Generates a new BOLT11 invoice. When paid, the wallet claims the Lightning receive and forwards the resulting Ark VTXO to the supplied Ark address mailbox.

### Example

```ts
import {
  Configuration,
  LightningApi,
} from '@secondts/barkd';
import type { GenerateInvoiceForAddressRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new LightningApi(config);

  const body = {
    // LightningInvoiceForAddressRequest
    lightningInvoiceForAddressRequest: ...,
  } satisfies GenerateInvoiceForAddressRequest;

  try {
    const data = await api.generateInvoiceForAddress(body);
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters


| Name | Type | Description  | Notes |
|------------- | ------------- | ------------- | -------------|
| **lightningInvoiceForAddressRequest** | [LightningInvoiceForAddressRequest](LightningInvoiceForAddressRequest.md) |  | |

### Return type

[**InvoiceInfo**](InvoiceInfo.md)

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: `application/json`
- **Accept**: `application/json`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Returns the created invoice |  -  |
| **400** | Bad request |  -  |
| **500** | Internal server error |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)


## getReceiveStatus

> LightningReceiveInfo getReceiveStatus(identifier)

Get receive status

Returns the status of a specified Lightning receive, identified by its payment hash, invoice string, or preimage. The response tracks progress through timestamps: &#x60;htlc_vtxos&#x60; is populated once HTLCs are created by the Ark server, &#x60;preimage_revealed_at&#x60; records when the preimage was sent, and &#x60;finished_at&#x60; indicates the receive has settled or been canceled.

### Example

```ts
import {
  Configuration,
  LightningApi,
} from '@secondts/barkd';
import type { GetReceiveStatusRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new LightningApi(config);

  const body = {
    // string | Payment hash, invoice string or preimage to search for
    identifier: identifier_example,
  } satisfies GetReceiveStatusRequest;

  try {
    const data = await api.getReceiveStatus(body);
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters


| Name | Type | Description  | Notes |
|------------- | ------------- | ------------- | -------------|
| **identifier** | `string` | Payment hash, invoice string or preimage to search for | [Defaults to `undefined`] |

### Return type

[**LightningReceiveInfo**](LightningReceiveInfo.md)

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: `application/json`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Returns the Lightning receive status |  -  |
| **400** | Bad request |  -  |
| **404** | Not found |  -  |
| **500** | Internal server error |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)


## listReceiveStatuses

> Array&lt;LightningReceiveInfo&gt; listReceiveStatuses()

List all pending receive statuses

Returns the statuses of all pending Lightning receives, ordered from oldest to newest. A receive is pending until its &#x60;finished_at&#x60; timestamp is set, indicating it has settled or been canceled.

### Example

```ts
import {
  Configuration,
  LightningApi,
} from '@secondts/barkd';
import type { ListReceiveStatusesRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new LightningApi(config);

  try {
    const data = await api.listReceiveStatuses();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters

This endpoint does not need any parameter.

### Return type

[**Array&lt;LightningReceiveInfo&gt;**](LightningReceiveInfo.md)

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: `application/json`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Returns all pending receive statuses |  -  |
| **500** | Internal server error |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)


## pay

> LightningPayResponse pay(lightningPayRequest)

Send a Lightning payment

Sends a payment to a Lightning destination. Accepts a BOLT11 invoice, BOLT12 offer, or Lightning address. The &#x60;amount_sat&#x60; field is required for Lightning addresses but optional for invoices and offers. Comments are only supported for Lightning addresses.

### Example

```ts
import {
  Configuration,
  LightningApi,
} from '@secondts/barkd';
import type { PayRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new LightningApi(config);

  const body = {
    // LightningPayRequest
    lightningPayRequest: ...,
  } satisfies PayRequest;

  try {
    const data = await api.pay(body);
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters


| Name | Type | Description  | Notes |
|------------- | ------------- | ------------- | -------------|
| **lightningPayRequest** | [LightningPayRequest](LightningPayRequest.md) |  | |

### Return type

[**LightningPayResponse**](LightningPayResponse.md)

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: `application/json`
- **Accept**: `application/json`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Returns success message, optionally with preimage if payment was immediately settled |  -  |
| **400** | The provided destination is not a valid BOLT11 invoice, BOLT12 offer, or Lightning address |  -  |
| **500** | Internal server error |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)

