Hercle
WebSocket

Create Lightning Withdrawal

Creates a Lightning Network withdrawal via WebSocket.

Auth:API Key
Tags:
Lightning
Command Name
WithdrawLightning

Command Arguments

ClientId
Required
Type:
string
Description:

Custom client ID (max 36 characters)

Example: "my-withdrawal-123"
PaymentRequestHash
Required
Type:
string
Description:

Encoded Lightning payment request to pay

Example: "lnbc1..."

Command Invocation

Command Arguments Example:
[
  "my-withdrawal-123",
  "lnbc1..."
]
Invocation Example:
connection.invoke('WithdrawLightning', ['my-withdrawal-123', 'lnbc1...'])

Response Event

Event Name
executionEvents
Subject
execution.withdrawal.lightspark.created
FieldTypeDescription
httpStatusCodenumberHTTP status code of the withdrawal response
paymentIdstringPayment ID for the Lightning withdrawal
statusstringStatus of the Lightning withdrawal
amountBTCnumberAmount of BTC withdrawn
destinationPublicKeystringDestination public key for the withdrawal
messagestringResponse message

Example Response

{
  "data": {
    "httpStatusCode": 200,
    "paymentId": "pay_abc123def456",
    "status": "PENDING",
    "amountBTC": 0.001,
    "destinationPublicKey": "02a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",
    "message": "Lightning withdrawal created successfully"
  }
}

Code Examples

const signalR = require('@microsoft/signalr');

const apiKey = 'YOUR_API_KEY_HERE';
const connection = new signalR.HubConnectionBuilder()
  .withUrl('https://publicapi.sandbox.hercle.financial/ExecutionLiveServer/v1', {
    accessTokenFactory: () => apiKey,
  })
  .build();

connection.start()
  .then(() => {
    console.log('Connected to WebSocket');
    
    // Invoke command
    connection.invoke('WithdrawLightning', "my-withdrawal-123", "lnbc1...")
      .then(() => {
        console.log('Command sent successfully');
      })
      .catch(err => {
        console.error('Command failed:', err);
      });
  })
  .catch(err => {
    console.error('Connection failed:', err);
  });

// Listen for events
connection.on('executionEvents', (data) => {
  console.log('Received event:', data);
});

SignalR API Tester

Test this command in the sandbox environment

Disconnected

Your API key is only used locally and never stored

Event Log

No events yet. Connect and invoke a command to see events.