Create and pay an invoice with CLN

LNROOM #1November 08, 2022

In this episode we startup 2 local nodes with bitcoind running on regtest, then we create an invoice and pay that invoice with lightning-cli.

Transcript with corrections and improvements

Hi guys, I'm Tony Aldon, welcome to the LN Room.

This is the first episode and today we are going to talk about CLN, we will use lightning-cli to create an invoice and to pay that invoice.

To do this, we will use the script contrib/startup_regtest.sh provided in the lightning repository.

It allows to start a Lightning Network running on the regtest chain.

This script provides the following commands: start_ln, connect, fund_nodes.

We will use some of them.

Today we will use the following sub commands of lightning-cli:

  • getinfo to receive information about a the Core Lightning node,

  • listchannels to query active lightning channels in the entire network,

  • bkpr-listbalances for listing current channel and wallet balances,

  • invoice for accepting payments,

  • listinvoices for querying invoice status,

  • pay for sending a payment to a BOLT11 invoice.

Start a Lightning Network on regtest with two connected nodes

Let's jump into the terminal.

We are in the lightning repository.

We source the file contrib/startup_regtest.sh.

This provides us with the following commands start_ln, connect, fund_nodes, stop_ln and destroy_ln. For, instance:

  • start_ln 3 starts 3 nodes on the chain regtest,

  • connect 1 2 connects the first node l1 and second node l2 nodes.

We will use some of them right now.

Since we just want to generate and pay one invoice, we don't need to build a network with 3 nodes or more.

So we run the following command to start a network with only 2 nodes:

$ start_ln 2

This creates a wallet called default.

And it provides the following aliases: l1-cli, l1-log, l2-cli, l2-log, bt-cli, stop_ln and fund_nodes.

We can look at those aliases by running this commands:

$ alias | grep -E 'l[12]|bt'
alias bt-cli='bitcoin-cli -regtest'
alias l1-cli='lightning-cli --lightning-dir=/tmp/l1-regtest'
alias l1-log='less /tmp/l1-regtest/log'
alias l2-cli='lightning-cli --lightning-dir=/tmp/l2-regtest'
alias l2-log='less /tmp/l2-regtest/log'

What we can do know is to get some information about regtest chain by running this command:

$ bt-cli -getinfo
Chain: regtest
Blocks: 1
Headers: 1
Verification progress: 100.0000%
Difficulty: 4.656542373906925e-10

Network: in 0, out 0, total 0
Version: 230000
Time offset (s): 0
Proxies: n/a
Min tx relay fee rate (BTC/kvB): 0.00001000

Wallet: default
Keypool size: 4000
Transaction fee rate (-paytxfee) (BTC/kvB): 0.00000000

Balance: 0.00000000

Warnings:

The chain has one block and the wallet default has no coin.

Before connecting the nodes, we look at the node l1 by running the following command:

$ l1-cli getinfo
{
   "id": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
   "alias": "HOPPINGFELONY",
   "color": "02a2e9",
   "num_peers": 0,
   "num_pending_channels": 0,
   "num_active_channels": 0,
   "num_inactive_channels": 0,
   "address": [],
   "binding": [
      {
         "type": "ipv4",
         "address": "127.0.0.1",
         "port": 7171
      }
   ],
   "version": "0.12.1",
   "blockheight": 1,
   "network": "regtest",
   "fees_collected_msat": 0,
   "lightning-dir": "/tmp/l1-regtest/regtest",
   "our_features": {
      "init": "08a000080269a2",
      "node": "88a000080269a2",
      "channel": "",
      "invoice": "02000000024100"
   }
}

Looking at the attribute num_peers we see that the node l1 is not connecting to any node and looking at the attribute num_active_channels we see that the node l1 has no active channels.

We can do the same for the node l2 and we get the same kind of information. We also see that the node l2 has no peers.

$ l2-cli getinfo
{
   "id": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
   "alias": "JUNIORYARD",
   "color": "03da44",
   "num_peers": 0,
   "num_pending_channels": 0,
   "num_active_channels": 0,
   "num_inactive_channels": 0,
   "address": [],
   "binding": [
      {
         "type": "ipv4",
         "address": "127.0.0.1",
         "port": 7171
      }
   ],
   "version": "0.12.1",
   "blockheight": 1,
   "network": "regtest",
   "fees_collected_msat": 0,
   "lightning-dir": "/tmp/l1-regtest/regtest",
   "our_features": {
      "init": "08a000080269a2",
      "node": "88a000080269a2",
      "channel": "",
      "invoice": "02000000024100"
   }
}

Using the command connect provided by the script contrib/startup_regtest.sh we connect the nodes l1 and l2.

$ connect 1 2
{
   "id": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
   "features": "08a000080269a2",
   "direction": "out",
   "address": {
      "type": "ipv4",
      "address": "127.0.0.1",
      "port": 7272
   }
}

Now, by running the command l2-cli getinfo and looking at the attribute num_peers we see that l2 is connected to another peer and that peer is the node l1.

Fund a channel from the node l1 to the node l2

We obtain a similar information for the node l1 by running the command:

$ l1-cli getinfo | jq .num_peers
1

The two nodes connected, we can verify that there is no active channels between the nodes l1 and l2:

$ l1-cli listchannels
{
   "channels": []
}
$ l2-cli listchannels
{
   "channels": []
}

Before openning a channel between the nodes l1 and l2 we can check that the wallets of the node l1 and the node l2 has no coins:

$ l1-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}
$ l2-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}

Now we fund a channel from the node l1 to the node l2 using the command fund_nodes provided by the script contrib/startup_regtest.sh:

$ fund_nodes
Mining into address bcrt1quy3250z0dsaulzv3vlxg6aqrhz6yhpmgnhq6zr... done.
bitcoind balance: 50.00000000
Waiting for lightning node funds... found.
Funding channel from node 1 to node 2. Waiting for confirmation... done.

Now if we look at the regtest chain, we can see that 108 blocks have been minned and that the wallet default now has 398.99999859 coins:

$ bt-cli -getinfo
Chain: regtest
Blocks: 108
Headers: 108
Verification progress: 100.0000%
Difficulty: 4.656542373906925e-10

Network: in 0, out 0, total 0
Version: 230000
Time offset (s): 0
Proxies: n/a
Min tx relay fee rate (BTC/kvB): 0.00001000

Wallet: default
Keypool size: 4000
Transaction fee rate (-paytxfee) (BTC/kvB): 0.00000000

Balance: 398.99999859

Warnings:

Using the listchannels sub command we can check that a channel has been funding from node l1 to l2 with an amount of 1000000000 msat:

$ l1-cli listchannels | jq
{
   "channels": [
      {
         "source": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
         "destination": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
         "short_channel_id": "103x1x0",
         "public": true,
         "amount_msat": 1000000000,
         "message_flags": 1,
         "channel_flags": 0,
         "active": true,
         "last_update": 1667932003,
         "base_fee_millisatoshi": 1,
         "fee_per_millionth": 10,
         "delay": 6,
         "htlc_minimum_msat": 0,
         "htlc_maximum_msat": 990000000,
         "features": ""
      },
      {
         "source": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
         "destination": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
         "short_channel_id": "103x1x0",
         "public": true,
         "amount_msat": 1000000000,
         "message_flags": 1,
         "channel_flags": 1,
         "active": true,
         "last_update": 1667932003,
         "base_fee_millisatoshi": 1,
         "fee_per_millionth": 10,
         "delay": 6,
         "htlc_minimum_msat": 0,
         "htlc_maximum_msat": 990000000,
         "features": ""
      }
   ]
}

With the sub command bkpr-listbalances we can check that:

  1. the wallet of the node l1 has some coins,

  2. the node l1 has a channel opened with the node l2 with an amount of 1000000000 msat on its side,

  3. the node l2 has channel opened with the node l1 with an amount of 0 msat on its side:

$ l1-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 98999846000,
               "coin_type": "bcrt"
            }
         ]
      },
      {
         "account": "09fa4182dcba4862180ec7ab093bb60226eb72e70660ec9c9f8a49f154dfd027",
         "peer_id": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
         "we_opened": true,
         "account_closed": false,
         "account_resolved": false,
         "balances": [
            {
               "balance_msat": 1000000000,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}
$ l2-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      },
      {
         "account": "09fa4182dcba4862180ec7ab093bb60226eb72e70660ec9c9f8a49f154dfd027",
         "peer_id": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
         "we_opened": true,
         "account_closed": false,
         "account_resolved": false,
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}

Question: for the node l1 there is a difference between the balances in the wallet and the channel, why is that? (I don't know)

Create an invoice with the node l2 and pay that invoice with the node l1

Since in our network of only one channel from l1 and l2 with funds only on the l1 side, the only node that can send coins is l1. Under these conditions, as we want to see how invoices work, it makes sens to generate an invoice by the node l2.

This is what we do by running the following command that generate a BOLT11 invoice:

  • in the amount of 20000 sat,

  • with the label inv-1 and

  • the description pizza:

$ l2-cli invoice 20000sat inv-1 "pizza"
{
   "payment_hash": "b41d3de79d96ad05a6cd62d7df7b18f7aeebb0290ca4cf393ca6b6fa9718722c",
   "expires_at": 1668537490,
   "bolt11": "lnbcrt200u1p3k4gsjsp5l3mswdg45glzgmlpfm6766r0j5xdkucju643ku63nkjacdp32rgspp5kswnmeuaj6kstfkdvtta77cc77hwhvpfpjjv7wfu56m049ccwgkqdqgwp5h57npxqyjw5qcqp29qyysgq486ln2hsl0dzw0tdqkj4kru95mjvmtrhksfx00vp64ljcgxs4cdzuw2ww9w0snscr5xtwzymzastggsdsy0sftlk5gn4fl9j8hm2hkgp8jnqgr",
   "payment_secret": "fc77073515a23e246fe14ef5ed686f950cdb7312e6ab1b73519da5dc343150d1",
   "warning_deadends": "Insufficient incoming capacity, once dead-end peers were excluded"
}

Using the value of the attribute bolt11 of the previous output, the node l1 will be able to pay that invoice. But before doing it, let's have a look at the invoices of the node l2 by running the following command:

$ l2-cli listinvoices
{
   "invoices": [
      {
         "label": "inv-1",
         "bolt11": "lnbcrt200u1p3k4gsjsp5l3mswdg45glzgmlpfm6766r0j5xdkucju643ku63nkjacdp32rgspp5kswnmeuaj6kstfkdvtta77cc77hwhvpfpjjv7wfu56m049ccwgkqdqgwp5h57npxqyjw5qcqp29qyysgq486ln2hsl0dzw0tdqkj4kru95mjvmtrhksfx00vp64ljcgxs4cdzuw2ww9w0snscr5xtwzymzastggsdsy0sftlk5gn4fl9j8hm2hkgp8jnqgr",
         "payment_hash": "b41d3de79d96ad05a6cd62d7df7b18f7aeebb0290ca4cf393ca6b6fa9718722c",
         "amount_msat": 20000000,
         "status": "unpaid",
         "description": "pizza",
         "expires_at": 1668537490
      }
   ]
}

By looking at the attribute status we can see that the invoice has not been paid yet.

Now let's pay that BOLT11 invoice by running the following command:

$ l1-cli pay lnbcrt200u1p3k4gsjsp5l3mswdg45glzgmlpfm6766r0j5xdkucju643ku63nkjacdp32rgspp5kswnmeuaj6kstfkdvtta77cc77hwhvpfpjjv7wfu56m049ccwgkqdqgwp5h57npxqyjw5qcqp29qyysgq486ln2hsl0dzw0tdqkj4kru95mjvmtrhksfx00vp64ljcgxs4cdzuw2ww9w0snscr5xtwzymzastggsdsy0sftlk5gn4fl9j8hm2hkgp8jnqgr
{
   "destination": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
   "payment_hash": "b41d3de79d96ad05a6cd62d7df7b18f7aeebb0290ca4cf393ca6b6fa9718722c",
   "created_at": 1667932848.462,
   "parts": 1,
   "amount_msat": 20000000,
   "amount_sent_msat": 20000000,
   "payment_preimage": "1d906245fe5bd60646bcd2c67c51df18a58b60989a266f57943d4f448a50388d",
   "status": "complete"
}

We've done what we wanted to do today:

  1. Setting up a lightning network on the chain regtest with 2 nodes l1 and l2 with an active channel funded from l1 to l2,

  2. Creating an BOLT11 invoice with the sub command invoice of lightning-cli,

  3. And paying that invoice using the the sub command pay of lightning-cli.

Bonus

There is still three informations that we can look at to complete our episode #1 of LN Room.

We can list the invoices of the node l2 and verify looking at the attribute paid_at that the invoice labeled inv-1 has been paid at epoch unix time 1667932849 (Tuesday, November 8, 2022 6:40:49pm UTC):

$ l2-cli listinvoices
{
   "invoices": [
      {
         "label": "inv-1",
         "bolt11": "lnbcrt200u1p3k4gsjsp5l3mswdg45glzgmlpfm6766r0j5xdkucju643ku63nkjacdp32rgspp5kswnmeuaj6kstfkdvtta77cc77hwhvpfpjjv7wfu56m049ccwgkqdqgwp5h57npxqyjw5qcqp29qyysgq486ln2hsl0dzw0tdqkj4kru95mjvmtrhksfx00vp64ljcgxs4cdzuw2ww9w0snscr5xtwzymzastggsdsy0sftlk5gn4fl9j8hm2hkgp8jnqgr",
         "payment_hash": "119e9fcec6b5578b84fdae09c1ac1c43be0f5a585d2c53787e462d7d31bbd7e7",
         "amount_msat": 20000000,
         "status": "paid",
         "pay_index": 1,
         "amount_received_msat": 20000000,
         "paid_at": 1667932849,
         "payment_preimage": "1d906245fe5bd60646bcd2c67c51df18a58b60989a266f57943d4f448a50388d",
         "description": "pizza",
         "expires_at": 1668537490
      }
   ]
}

We can check that the balances of the channel between the node l1 and l2 increased from 0 msat to 20000000 msat on the l2 side (corresponding to the amount of the previous invoice that has been paid) by running the following command:

$ l2-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      },
      {
         "account": "09fa4182dcba4862180ec7ab093bb60226eb72e70660ec9c9f8a49f154dfd027",
         "peer_id": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
         "we_opened": true,
         "account_closed": false,
         "account_resolved": false,
         "balances": [
            {
               "balance_msat": 200000000,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}

In the same vein, we can check that the balances of the channel between the node l1 and l2 decreased from 1000000000 msat to 980000000 msat on the l1 side by running the following command:

$ l1-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 98999846000,
               "coin_type": "bcrt"
            }
         ]
      },
      {
         "account": "09fa4182dcba4862180ec7ab093bb60226eb72e70660ec9c9f8a49f154dfd027",
         "peer_id": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
         "we_opened": true,
         "account_closed": false,
         "account_resolved": false,
         "balances": [
            {
               "balance_msat": 980000000,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}

This is what I wanted to do with you today, I hope enjoyed the video and this first LN Room.

See next you time.

Terminal session

We ran the following commands in this order:

$ git clone https://github.com/ElementsProject/lightning
$ cd lightning
$ ls
$ source contrib/startup_regtest.sh
$ start_ln
$ alias | grep -E 'l[12]|bt'
$ bt-cli -getinfo
$ l1-cli getinfo | jq
$ l2-cli getinfo | jq
$ connect 1 2
$ l2-cli getinfo | jq
$ l1-cli getinfo | jq .num_peers
$ l1-cli listchannels
$ l2-cli listchannels
$ l1-cli bkpr-listbalances
$ l2-cli bkpr-listbalances
$ fund_nodes
$ bt-cli -getinfo
$ l1-cli listchannels | jq
$ l1-cli bkpr-listbalances
$ l2-cli bkpr-listbalances
$ l2-cli help invoice
$ l2-cli invoice 20000sat inv-1 "pizza"
$ l2-cli listinvoices | jq
$ l1-cli help pay
$ l1-cli pay lnbcrt200u1p3k4gsjsp5l3mswdg45glzgmlpfm6766r0j5xdkucju643ku63nkjacdp32rgspp5kswnmeuaj6kstfkdvtta77cc77hwhvpfpjjv7wfu56m049ccwgkqdqgwp5h57npxqyjw5qcqp29qyysgq486ln2hsl0dzw0tdqkj4kru95mjvmtrhksfx00vp64ljcgxs4cdzuw2ww9w0snscr5xtwzymzastggsdsy0sftlk5gn4fl9j8hm2hkgp8jnqgr
$ l2-cli listinvoices
$ l2-cli bkpr-listbalances
$ l1-cli bkpr-listbalances

And below you can read the terminal session (command lines and outputs):

◉ tony@tony:~/lnroom/lightning:[git»master]
$ ls
action.yml     CHANGELOG.md  common     doc         lightningd   pyproject.toml
bitcoin        channeld      configure  Dockerfile  Makefile     README.md
Cargo.lock     cli           connectd   external    onchaind     tests
Cargo.toml     cln-grpc      contrib    gossipd     openingd     tools
ccan           cln-rpc       db         hsmd        plugins      wallet
◉ tony@tony:~/lnroom/lightning:[git»master]
$ source contrib/startup_regtest.sh
lightning-cli is /usr/bin/lightning-cli
lightningd is /usr/bin/lightningd
Useful commands:
  start_ln 3: start three nodes, l1, l2, l3
  connect 1 2: connect l1 and l2
  fund_nodes: connect all nodes with channels, in a row
  stop_ln: shutdown
  destroy_ln: remove ln directories
◉ tony@tony:~/lnroom/lightning:[git»master]
$ start_ln
Bitcoin Core starting
awaiting bitcoind...
Making "default" bitcoind wallet.
[1] 5511
[2] 5547
WARNING: eatmydata not found: instal it for faster testing
Commands:
        l1-cli, l1-log,
        l2-cli, l2-log,
        bt-cli, stop_ln, fund_nodes
◉ tony@tony:~/lnroom/lightning:[git»master]
$ alias | grep -E 'l[12]|bt'
alias bt-cli='bitcoin-cli -regtest'
alias l1-cli='lightning-cli --lightning-dir=/tmp/l1-regtest'
alias l1-log='less /tmp/l1-regtest/log'
alias l2-cli='lightning-cli --lightning-dir=/tmp/l2-regtest'
alias l2-log='less /tmp/l2-regtest/log'
◉ tony@tony:~/lnroom/lightning:[git»master]
$ bt-cli -getinfo
Chain: regtest
Blocks: 1
Headers: 1
Verification progress: 100.0000%
Difficulty: 4.656542373906925e-10

Network: in 0, out 0, total 0
Version: 230000
Time offset (s): 0
Proxies: n/a
Min tx relay fee rate (BTC/kvB): 0.00001000

Wallet: default
Keypool size: 4000
Transaction fee rate (-paytxfee) (BTC/kvB): 0.00000000

Balance: 0.00000000

Warnings:
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l1-cli getinfo | jq
{
   "id": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
   "alias": "HOPPINGFELONY",
   "color": "02a2e9",
   "num_peers": 0,
   "num_pending_channels": 0,
   "num_active_channels": 0,
   "num_inactive_channels": 0,
   "address": [],
   "binding": [
      {
         "type": "ipv4",
         "address": "127.0.0.1",
         "port": 7171
      }
   ],
   "version": "0.12.1",
   "blockheight": 1,
   "network": "regtest",
   "fees_collected_msat": 0,
   "lightning-dir": "/tmp/l1-regtest/regtest",
   "our_features": {
      "init": "08a000080269a2",
      "node": "88a000080269a2",
      "channel": "",
      "invoice": "02000000024100"
   }
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli getinfo | jq
{
   "id": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
   "alias": "JUNIORYARD",
   "color": "03da44",
   "num_peers": 0,
   "num_pending_channels": 0,
   "num_active_channels": 0,
   "num_inactive_channels": 0,
   "address": [],
   "binding": [
      {
         "type": "ipv4",
         "address": "127.0.0.1",
         "port": 7171
      }
   ],
   "version": "0.12.1",
   "blockheight": 1,
   "network": "regtest",
   "fees_collected_msat": 0,
   "lightning-dir": "/tmp/l1-regtest/regtest",
   "our_features": {
      "init": "08a000080269a2",
      "node": "88a000080269a2",
      "channel": "",
      "invoice": "02000000024100"
   }
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ connect 1 2
{
   "id": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
   "features": "08a000080269a2",
   "direction": "out",
   "address": {
      "type": "ipv4",
      "address": "127.0.0.1",
      "port": 7272
   }
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli getinfo | jq
{
   "id": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
   "alias": "JUNIORYARD",
   "color": "03da44",
   "num_peers": 1,
   "num_pending_channels": 0,
   "num_active_channels": 0,
   "num_inactive_channels": 0,
   "address": [],
   "binding": [
      {
         "type": "ipv4",
         "address": "127.0.0.1",
         "port": 7171
      }
   ],
   "version": "0.12.1",
   "blockheight": 1,
   "network": "regtest",
   "fees_collected_msat": 0,
   "lightning-dir": "/tmp/l1-regtest/regtest",
   "our_features": {
      "init": "08a000080269a2",
      "node": "88a000080269a2",
      "channel": "",
      "invoice": "02000000024100"
   }
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l1-cli getinfo | jq .num_peers
1
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l1-cli listchannels
{
   "channels": []
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli listchannels
{
   "channels": []
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l1-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ fund_nodes
Mining into address bcrt1quy3250z0dsaulzv3vlxg6aqrhz6yhpmgnhq6zr... done.
bitcoind balance: 50.00000000
Waiting for lightning node funds... found.
Funding channel from node 1 to node 2. Waiting for confirmation... done.
◉ tony@tony:~/lnroom/lightning:[git»master]
$ bt-cli -getinfo
Chain: regtest
Blocks: 108
Headers: 108
Verification progress: 100.0000%
Difficulty: 4.656542373906925e-10

Network: in 0, out 0, total 0
Version: 230000
Time offset (s): 0
Proxies: n/a
Min tx relay fee rate (BTC/kvB): 0.00001000

Wallet: default
Keypool size: 4000
Transaction fee rate (-paytxfee) (BTC/kvB): 0.00000000

Balance: 398.99999859

Warnings:
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l1-cli listchannels | jq
{
   "channels": [
      {
         "source": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
         "destination": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
         "short_channel_id": "103x1x0",
         "public": true,
         "amount_msat": 1000000000,
         "message_flags": 1,
         "channel_flags": 0,
         "active": true,
         "last_update": 1667932003,
         "base_fee_millisatoshi": 1,
         "fee_per_millionth": 10,
         "delay": 6,
         "htlc_minimum_msat": 0,
         "htlc_maximum_msat": 990000000,
         "features": ""
      },
      {
         "source": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
         "destination": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
         "short_channel_id": "103x1x0",
         "public": true,
         "amount_msat": 1000000000,
         "message_flags": 1,
         "channel_flags": 1,
         "active": true,
         "last_update": 1667932003,
         "base_fee_millisatoshi": 1,
         "fee_per_millionth": 10,
         "delay": 6,
         "htlc_minimum_msat": 0,
         "htlc_maximum_msat": 990000000,
         "features": ""
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l1-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 98999846000,
               "coin_type": "bcrt"
            }
         ]
      },
      {
         "account": "09fa4182dcba4862180ec7ab093bb60226eb72e70660ec9c9f8a49f154dfd027",
         "peer_id": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
         "we_opened": true,
         "account_closed": false,
         "account_resolved": false,
         "balances": [
            {
               "balance_msat": 1000000000,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      },
      {
         "account": "09fa4182dcba4862180ec7ab093bb60226eb72e70660ec9c9f8a49f154dfd027",
         "peer_id": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
         "we_opened": true,
         "account_closed": false,
         "account_resolved": false,
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli help invoice
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli invoice 20000sat inv-1 "pizza"
{
   "payment_hash": "b41d3de79d96ad05a6cd62d7df7b18f7aeebb0290ca4cf393ca6b6fa9718722c",
   "expires_at": 1668537490,
   "bolt11": "lnbcrt200u1p3k4gsjsp5l3mswdg45glzgmlpfm6766r0j5xdkucju643ku63nkjacdp32rgspp5kswnmeuaj6kstfkdvtta77cc77hwhvpfpjjv7wfu56m049ccwgkqdqgwp5h57npxqyjw5qcqp29qyysgq486ln2hsl0dzw0tdqkj4kru95mjvmtrhksfx00vp64ljcgxs4cdzuw2ww9w0snscr5xtwzymzastggsdsy0sftlk5gn4fl9j8hm2hkgp8jnqgr",
   "payment_secret": "fc77073515a23e246fe14ef5ed686f950cdb7312e6ab1b73519da5dc343150d1",
   "warning_deadends": "Insufficient incoming capacity, once dead-end peers were excluded"
}

◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli listinvoices | jq
{
   "invoices": [
      {
         "label": "inv-1",
         "bolt11": "lnbcrt200u1p3k4gsjsp5l3mswdg45glzgmlpfm6766r0j5xdkucju643ku63nkjacdp32rgspp5kswnmeuaj6kstfkdvtta77cc77hwhvpfpjjv7wfu56m049ccwgkqdqgwp5h57npxqyjw5qcqp29qyysgq486ln2hsl0dzw0tdqkj4kru95mjvmtrhksfx00vp64ljcgxs4cdzuw2ww9w0snscr5xtwzymzastggsdsy0sftlk5gn4fl9j8hm2hkgp8jnqgr",
         "payment_hash": "b41d3de79d96ad05a6cd62d7df7b18f7aeebb0290ca4cf393ca6b6fa9718722c",
         "amount_msat": 20000000,
         "status": "unpaid",
         "description": "pizza",
         "expires_at": 1668537490
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l1-cli help pay
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l1-cli pay lnbcrt200u1p3k4gsjsp5l3mswdg45glzgmlpfm6766r0j5xdkucju643ku63nkjacdp32rgspp5kswnmeuaj6kstfkdvtta77cc77hwhvpfpjjv7wfu56m049ccwgkqdqgwp5h57npxqyjw5qcqp29qyysgq486ln2hsl0dzw0tdqkj4kru95mjvmtrhksfx00vp64ljcgxs4cdzuw2ww9w0snscr5xtwzymzastggsdsy0sftlk5gn4fl9j8hm2hkgp8jnqgr
{
   "destination": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
   "payment_hash": "b41d3de79d96ad05a6cd62d7df7b18f7aeebb0290ca4cf393ca6b6fa9718722c",
   "created_at": 1667932848.462,
   "parts": 1,
   "amount_msat": 20000000,
   "amount_sent_msat": 20000000,
   "payment_preimage": "1d906245fe5bd60646bcd2c67c51df18a58b60989a266f57943d4f448a50388d",
   "status": "complete"
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli listinvoices
{
   "invoices": [
      {
         "label": "inv-1",
         "bolt11": "lnbcrt200u1p3k4gsjsp5l3mswdg45glzgmlpfm6766r0j5xdkucju643ku63nkjacdp32rgspp5kswnmeuaj6kstfkdvtta77cc77hwhvpfpjjv7wfu56m049ccwgkqdqgwp5h57npxqyjw5qcqp29qyysgq486ln2hsl0dzw0tdqkj4kru95mjvmtrhksfx00vp64ljcgxs4cdzuw2ww9w0snscr5xtwzymzastggsdsy0sftlk5gn4fl9j8hm2hkgp8jnqgr",
         "payment_hash": "119e9fcec6b5578b84fdae09c1ac1c43be0f5a585d2c53787e462d7d31bbd7e7",
         "amount_msat": 20000000,
         "status": "paid",
         "pay_index": 1,
         "amount_received_msat": 20000000,
         "paid_at": 1667932849,
         "payment_preimage": "1d906245fe5bd60646bcd2c67c51df18a58b60989a266f57943d4f448a50388d",
         "description": "pizza",
         "expires_at": 1668537490
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l2-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 0,
               "coin_type": "bcrt"
            }
         ]
      },
      {
         "account": "09fa4182dcba4862180ec7ab093bb60226eb72e70660ec9c9f8a49f154dfd027",
         "peer_id": "02a2e9326a8d90d13cc97d865c3d2b8f299d9b0a1a095e984c5d41664b6e61010e",
         "we_opened": true,
         "account_closed": false,
         "account_resolved": false,
         "balances": [
            {
               "balance_msat": 200000000,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»master]
$ l1-cli bkpr-listbalances
{
   "accounts": [
      {
         "account": "wallet",
         "balances": [
            {
               "balance_msat": 98999846000,
               "coin_type": "bcrt"
            }
         ]
      },
      {
         "account": "09fa4182dcba4862180ec7ab093bb60226eb72e70660ec9c9f8a49f154dfd027",
         "peer_id": "03da443e2532086c56231a04ef82ef9b34d2681ba2916b80b1069d0996fd49d950",
         "we_opened": true,
         "account_closed": false,
         "account_resolved": false,
         "balances": [
            {
               "balance_msat": 980000000,
               "coin_type": "bcrt"
            }
         ]
      }
   ]
}

Resources