The OpenNode Developer Hub

Welcome to the OpenNode developer hub. You'll find comprehensive guides and documentation to help you start working with OpenNode as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    API Reference

Paying through the Lightning Network

You need to have an BOLT 11 compatible invoice to do payments through Lightning Network.


Payment stuck

Due to the nature of Lightning Network, sometimes payments do not go through instantly. For instance, if a node included the payment route suddenly goes offline the payment will be stuck until the HTLC expires.

Since a Lightning Network payment can be stuck, or take longer than an HTTP request timeout, you should subscribe to withdrawal events. You can subscribe to withdrawal events by passing url endpoint on the callback_url parameter.


Paying 0 sat invoices

If the invoice you're paying has a 0 sat payment associated, you'll need to pass an amount to pay.

const opennode = require('opennode');
opennode.setCredentials('MY_API_KEY', 'live');

const withdrawal = {
  type: 'ln',
  address: 'lntb100n1pw0fl34pp5p8u6alsp6vr7ngevp82lu6kz7j4ryla0dgpg9es0jq70shs39xzsdqqcqzpgxqyz5vqm5egyvdadnnvrecqdzamwl6guhhvkpja0s9e0vu6g0ay75kegzfnhjykdveagfj8rt9nay0yvu8j94shsvj3ghxu306y2pac02nq85qq7m8tsc',
  //amount: 120, - Required if the invoice has no amount set (amount = 0)
  callback_url: ''

 .then(withdrawal => {
 .catch(error => {
  console.error(`${error.status} | ${error.message}`);

If the request was correctly sent, the API will reply with a 201 status code a withdrawal object. The endpoint provided on callback_url parameter will be notified when the withdrawal either succeeds or fails.

    "data": {
        "id": "3f50999e-f21f-4981-b67c-ea9c075be7d6",
        "type": "ln",
        "amount": 10,
        "reference": "lntb100n1pw0fl34pp5p8u6alsp6vr7ngevp82lu6kz7j4ryla0dgpg9es0jq70shs39xzsdqqcqzpgxqyz5vqm5egyvdadnnvrecqdzamwl6guhhvkpja0s9e0vu6g0ay75kegzfnhjykdveagfj8rt9nay0yvu8j94shsvj3ghxu306y2pac02nq85qq7m8tsc",
        "fee": 0,
        "status": "pending",
        "processed_at": 1559559748

Paying through the Lightning Network

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.