Voltage
Search…
Webhooks
The Voltage Platform supports webhooks to notify users about events in their node. This document will explain how to use the Voltage webhooks as well as example payloads.

Adding a Webhook Endpoint

You can add a webhook endpoint to your node by editing the node's settings. First navigate to your node and click Expand Settings. Once your settings are expanded, there is field named Webhook URL. Fill in this field with the endpoint that you'd like Voltage to make a request to. While you're in the settings you should also note down the field labeled Webhook Secret as this will be used to validate the request.

How It Works

When an event is triggered, Voltage will make a POST request to your webhook endpoint. This request will include a JSON payload with details about the event. This request will also include a header named VOLTAGE_SECRET which will contain your webhook secret. When receiving the webhook event, you should parse the fields and take appropriate action.
You should always validate both the VOLTAGE_SECRET header and the "api" field in the JSON payload. This will help you ensure that the request was made from Voltage and you are sending requests to a node or endpoint that you trust.

Payload Schema

There are 3 root fields to the JSON payload; type, details, and api.

type

The type field is used to specify what type of event it was. The current options are status , update, or error.

details

The details field will include specific details about the event based on the what Type the event is.

api

This is the API endpoint for the node the event was sent for. This can be used to respond to the event and also validate what node the event was for.

Webhook Events

Status

Waiting for Unlock

This means the node is waiting to be unlocked.
1
{
2
"type": "status",
3
"details": {
4
"status": "waiting_unlock"
5
},
6
"api": "yournode.m.voltageapp.io"
7
}
Copied!

Waiting for Initialization

This means the node is waiting to be initialized.
1
{
2
"type": "status",
3
"details": {
4
"status": "waiting_init"
5
},
6
"api": "yournode.m.voltageapp.io"
7
}
Copied!

Stopped

This means the node just entered the Stopped state.
1
{
2
"type": "status",
3
"details": {
4
"status": "stopped"
5
},
6
"api": "yournode.m.voltageapp.io"
7
}
Copied!

Update

Update Available

This means the node has a new update available for it.
1
{
2
"type": "update",
3
"details": {
4
"update_available": "true",
5
"lnd_version": "0.13.1",
6
"volt_version": "v0.3.1"
7
},
8
"api": "yournode.m.voltageapp.io"
9
}
Copied!

Error

Out of Order Block Error

This event is sent when we find an important error in your log messages about the order of Bitcoin blocks being out of order. If you receive this, you should restart your node as soon as you can.
1
{
2
"type": "error",
3
"details": {
4
"type": "out_of_order_block",
5
"log": "CRTR: out of order block: expecting height=660646, got height=660648"
6
},
7
"api": "yournode.m.voltageapp.io"
8
}
Copied!

Example - Automatic Unlock

As an example, we'll demonstrate how to automatically unlock your node whenever it's restarted. First, you must set your Webhook endpoint in your node's settings. Go to your node on the Voltage Dashboard and click Expand Settings. Then find the Webhook URL field and paste in your webhook endpoint. Also take note of your Webhook Secret. Save your settings.
Once you have your webhook endpoint set, now you need to handle the waiting_unlock status event. When a request comes in, you should first check the VOLTAGE_SECRET header to ensure it matches what you expect. Second, you should validate the api field in the JSON payload to ensure it's what you expect. If their of these are not what you're expecting you should stop processing the event.
Once you've confirmed the secret and API fields are what you're expecting, you will check the type field. If the type is status then you can proceed to check the details.status field. If the details.status field equals waiting_unlock then you can continue processing the event and unlock your node.
Unlocking the node requires making API directly to your node's endpoint. Following the LND API Documentation, we'll be making a call to the /v1/unlockwallet API. This takes a POST request with a JSON payload containing 2 fields. wallet_password and stateless_init. You're password must be base64 encoded and stateless_init must be true. Here's an example of what it would look like with curl:
1
curl -X POST https://yournode.m.voltageapp.io:8080/v1/unlockwallet \
2
-d '{ "wallet_password":"cGFzc3dvcmQK","stateless_init":true}'
Copied!
Now, everytime you restart your node your webhook will automatically unlock the node for you!
You should always use some sort of password manager or environment variables for the Voltage Webhook Secret and your node's password.
Last modified 1mo ago