All Blog Posts

How Nodana Accepts Bitcoin Payments

Nodana Image
Last Updated: Oct 1

Introduction

Accepting Bitcoin payments on your app or website is a fantastic way to stack sats and boost the Bitcoin circular economy. Let me tell you how Nodana accepts payments on the website so you can try something similar for your project.

Lightning Node

Nodana uses a Phoenixd node to accept payments over the Lightning network. The node is "Nodana hosted" which the API connects to and this setup has proven to be very reliable over the last few months.

Phoenxid nodes take care of inbound liquidity and channel management automatically (for a small fee) so you don't have to. You can host your own Phoenixd node or host it on Nodana for $10 per month.

Top tip! You can test your node connection and credentials by using this terminal command.

If you see information about your node then you know it's accepting connections.

Payment Flow

Nodana has a SSR App and an API. When the API first starts it establishes a websocket connection to the node in order to listen for payments and there's some simple logic to handle reconnecting if the connection is dropped (but this doesn't happen very often).

A user can create an invoice using the App and then the API calls the node to create an invoice. The response from the node is passed back to the App and used for the QR code value.

I wrote a simple npm client for phoenixd here. It's written using Typescript and makes requests to your node easier from Javascript based applications.

As the invoice is a standard BOLT 11 it can be paid using any Lightning wallet or webln provider such as the Alby browser extension.

If you're interested, here's an example of how to create an invoice using the npm client mentioned above:

If successful, you will get a JSON response that looks a bit like this:

When the user makes the payment then the node will send a websocket event back to the API which in turn informs the App and a "Payment Success" message can be shown to the user. The balance will also be updated and this all happens without any refreshing of the page.

Withdrawing Sats

Nodana has an automated process that transfers the sats in the node's wallet to a private wallet. There's a convenient paylnaddress endpoint provided by Phoenixd which you can use to transfer sats to any wallet that supports Lightning Addresses.

That's about it. Of course there's quite a bit going on behind the scenes but this should give you an idea of how Nodana does it and give you a basis for your own approach. Feel free to DM on Nostr or Twitter with any questions or comments and I'll do my best to help.

If you want to learn more about Phoenixd then the website is https://phoenix.acinq.co/server