WebSocket
Create Lightning Withdrawal
Creates a Lightning Network withdrawal via WebSocket.
Auth:API Key
Tags:
Lightning
Command Name
WithdrawLightningCommand Arguments
| Field | Type | Required | Description |
|---|---|---|---|
ClientId | string | Required | Custom client ID (max 36 characters) Example: "my-withdrawal-123" |
PaymentRequestHash | string | Required | Encoded Lightning payment request to pay Example: "lnbc1..." |
ClientIdRequired
Type:
string
Description:
Custom client ID (max 36 characters)
Example:
"my-withdrawal-123"PaymentRequestHashRequired
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
executionEventsSubject
execution.withdrawal.lightspark.createdResponse containing the Lightning withdrawal details
| Field | Type | Description |
|---|---|---|
httpStatusCode | number | HTTP status code of the withdrawal response |
paymentId | string | Payment ID for the Lightning withdrawal |
status | string | Status of the Lightning withdrawal |
amountBTC | number | Amount of BTC withdrawn |
destinationPublicKey | string | Destination public key for the withdrawal |
message | string | Response 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