A penalty transaction managed by Core Lightning

LNROOM #8December 23, 2022

In this episode 8 we see how Core Lightning manages penalty transactions. Specifically, a node l1 tries to cheat a node l2 by sending a revocated transaction that he signs with the developer command dev-sign-last-tx available because we've compiled CLN with --enable-developer option. While l1 tries to cheat l2 we observe the node l2 sending its penalty transaction automatically using the subdaemon lightning_ondchaind.

Transcript with corrections and improvements

Hi guys, welcome to the LN Room, I'm Tony Aldon and today in this episode 8 we are going to see how Core Lightning manages penalty transactions.

Specifically, we are going to set up a Lightning Network running on regtest with two nodes l1 and l2. The node l1 will try to cheat the node l2 by sending a revocated transaction that we are going to sign with the developer command dev-sign-last-tx available when CLN is compiled with --enable-developer option. Then we are going to see how the node l2 sends its penalty transaction automatically using the subdaemon lightning_ondchaind.

I'm really excited about this episode and I hope you will enjoy it.

Let's go.

Compile CLN with --enable-developer and set up a Lightning Network on regtest

To use the developer command dev-sign-last-tx we build CLN with the variable DEVELOPER set to 1 in the file config.var by using --enable-developer option of ./configure and compiling it with the make command:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ ./configure --enable-developer
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ make -j$(nproc)

As we did in all the previous videos, we use the script contrib/startup_regtest.sh to set up a Lightning Network running on regtest. This network has 2 nodes l1 and l2. The node l1 starts with 1btc and 1000000sat locked in a channel opened with the node l2:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ source contrib/startup_regtest.sh
lightning-cli is /home/tony/lnroom/lightning/cli/lightning-cli
lightningd is /home/tony/lnroom/lightning/lightningd/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»(HEAD detached at v22.11.1)]
$ start_ln 2
Bitcoin Core starting
awaiting bitcoind...
Making "default" bitcoind wallet.
[1] 31748
[2] 31789
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»(HEAD detached at v22.11.1)]
$ alias l1-cli
alias l1-cli='/home/tony/lnroom/lightning/cli/lightning-cli --lightning-dir=/tmp/l1-regtest'
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ fund_nodes
Mining into address bcrt1qfrs6yr4er4xvdvs2meugekmxdla5dpryv8tfkt... done.
bitcoind balance: 50.00000000
Waiting for lightning node funds... found.
Funding channel from node 1 to node 2. Waiting for confirmation... done.

The node l1 signs its last commitment transaction with dev-sign-last-tx developer command

As we've build CLN with --enable-developer option, we have access to the following developer commands:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli help | grep dev-
dev-queryrates id amount request_amt [commitment_feerate] [funding_feerate]
invoice amount_msat label description [expiry] [fallbacks] [preimage] [exposeprivatechannels] [cltv] [deschashonly] [dev-routes]
dev-rawrequest invreq nodeid [timeout]
dev-sendcustommsg node_id msg
dev-compact-gossip-store
dev-fail id
dev-feerate id feerate
dev-forget-channel id [short_channel_id] [channel_id] [force]
dev-gossip-set-time time
dev-ignore-htlcs id ignore
dev-listaddrs [bip32_max_index]
dev-memdump
dev-memleak
dev-reenable-commit id
dev-rescan-outputs
dev-set-max-scids-encode-size max
dev-sign-last-tx id
dev-suppress-gossip

Each time the node l1 send sats to the node l2 (or l2 to l1) the state of the channel is updated and this is reflected in two commitment transactions one for the node l1 and the other for the node l2.

With the command dev-sign-last-tx we can sign and show the last commitment transaction with a peer as we can see below:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli help dev-sign-last-tx
No manual entry for lightning-dev-sign-last-tx
man: /home/tony/lnroom/lightning/cli/../doc/lightning-dev-sign-last-tx.7: No such file or directory
command=dev-sign-last-tx id
category=developer
description=Sign and show the last commitment transaction with peer {id}
verbose=HELP! Please contribute a description for this json_command!

At any moment we (the node l1 or l2) can sign the last commitment transaction and go onchain and this is perfectly legit.

But, in this episode, what we're going to do is sign this last commitment transaction (which reflects the current state of the channel) keep it and send it later onchain after it's been revoked (and no longer reflect the state of the channel).

Before we sign the last commitment transaction of the node l1, let's list the funds of the two nodes:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli listfunds | jq
{
  "outputs": [
    {
      "txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "output": 1,
      "amount_msat": 98999846000,
      "scriptpubkey": "001462417c6a87d0b55efba61030bb3c328831344326",
      "address": "bcrt1qvfqhc6586z64a7axzqctk0pj3qcngsexntgfm0",
      "status": "confirmed",
      "blockheight": 103,
      "reserved": false
    }
  ],
  "channels": [
    {
      "peer_id": "029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421",
      "connected": true,
      "state": "CHANNELD_NORMAL",
      "short_channel_id": "103x1x0",
      "our_amount_msat": 1000000000,
      "amount_msat": 1000000000,
      "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "funding_output": 0
    }
  ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listfunds | jq
{
  "outputs": [],
  "channels": [
    {
      "peer_id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
      "connected": true,
      "state": "CHANNELD_NORMAL",
      "short_channel_id": "103x1x0",
      "our_amount_msat": 0,
      "amount_msat": 1000000000,
      "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "funding_output": 0
    }
  ]
}

The channel 103x1x0 between the node l1 and l2 has an amount of 1000000sat with all the funds on the l1 side.

That means that the last commitment transaction of l1 if it goes onchain would transfer 1000000sat (minus the fees) to him.

In the following snippet, the node l1 signs its last commitment transaction with its peer l2:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli getinfo | jq .id -r
029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli dev-sign-last-tx 029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421
{
   "tx": "02000000000101614ede01b596c97188865c296cebcba511b5317fa75eb64ccbb82acf7eb9a456000000000015b86980024a010000000000002200204760120cb1724e700f7e0553a55f28bb33392973b6e9465d984810d43394acf4903e0f0000000000220020e7e3c2fcb98c46ebadf430ea6e9bdcd6817fa7745db7685b54089ac64024fda90400473044022072bc63143cbf201748cc5b019690ce108ec3a59f8a3e416e4877facf6b64141d02206a5b402a88098053c897f4f1bee0d4dcae97c846d9192d4094983d37583409cd01473044022044cd292037347d9dda1ae928534a35a7bf7fdb9d8f69b6be911170287c6cfc3d0220533fce928a3f0932bd7ac97ec0b5e8064f9d1d0dc072a0aa3db914dbd3debd36014752210265a4484d62ab7de8749aef3a7dc61f001c120870a3cca3ecaddc6f0cb3385d872102b17f1c590309d887b0e5fd0a30834c6a5032f6c3d33e730a9eacc835b7ca2d8952aee249b020"
}

We keep that transaction.

The node l1 pays an invoice to the node l2

In this section, the node l2 creates an invoice for an amount of 20000sat and the node l1 pays that invoice as we can see below:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli invoice 20000sat inv "pizza"
{
   "payment_hash": "250ae0e01ebc4e024549dafe27b39e937d43eee9b7469a5960e82e54dfe2cecc",
   "expires_at": 1672392968,
   "bolt11": "lnbcrt200u1p362a5gsp535hjsnt5pm6m0k2l63v52cmtvs5lxfyycawm72f64s06wl7jrn4spp5y59wpcq7h38qy32fmtlz0vu7jd758mhfkarf5ktqaqh9fhlzemxqdqgwp5h57npxqyjw5qcqp29qx3qysgqdp9rkas3ek5w2d9qraaaax6rp32ysj3duy6s4z57ph4w2wwwztsp3hel3f46tsgnkpqf3rywsv9zygyffm0n069d9jplxj4hwkq50esq9w486j",
   "payment_secret": "8d2f284d740ef5b7d95fd45945636b6429f32484c75dbf293aac1fa77fd21ceb",
   "warning_deadends": "Insufficient incoming capacity, once dead-end peers were excluded"
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli pay lnbcrt200u1p362a5gsp535hjsnt5pm6m0k2l63v52cmtvs5lxfyycawm72f64s06wl7jrn4spp5y59wpcq7h38qy32fmtlz0vu7jd758mhfkarf5ktqaqh9fhlzemxqdqgwp5h57npxqyjw5qcqp29qx3qysgqdp9rkas3ek5w2d9qraaaax6rp32ysj3duy6s4z57ph4w2wwwztsp3hel3f46tsgnkpqf3rywsv9zygyffm0n069d9jplxj4hwkq50esq9w486j
{
   "destination": "029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421",
   "payment_hash": "250ae0e01ebc4e024549dafe27b39e937d43eee9b7469a5960e82e54dfe2cecc",
   "created_at": 1671788189.491,
   "parts": 1,
   "amount_msat": 20000000,
   "amount_sent_msat": 20000000,
   "payment_preimage": "6e8829be8b4428de2ca41769c46c208e399fec5d193cb3b0e8ee0027a585e0d9",
   "status": "complete"
}

This has the effect of advancing the state of the channel. Now, the node l2 has 20000sat it can spend in that channel as we can see using the sub-command listfunds like this:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli listfunds | jq
{
  "outputs": [
    {
      "txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "output": 1,
      "amount_msat": 98999846000,
      "scriptpubkey": "001462417c6a87d0b55efba61030bb3c328831344326",
      "address": "bcrt1qvfqhc6586z64a7axzqctk0pj3qcngsexntgfm0",
      "status": "confirmed",
      "blockheight": 103,
      "reserved": false
    }
  ],
  "channels": [
    {
      "peer_id": "029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421",
      "connected": true,
      "state": "CHANNELD_NORMAL",
      "short_channel_id": "103x1x0",
      "our_amount_msat": 980000000,
      "amount_msat": 1000000000,
      "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "funding_output": 0
    }
  ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listfunds | jq
{
  "outputs": [],
  "channels": [
    {
      "peer_id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
      "connected": true,
      "state": "CHANNELD_NORMAL",
      "short_channel_id": "103x1x0",
      "our_amount_msat": 20000000,
      "amount_msat": 1000000000,
      "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "funding_output": 0
    }
  ]
}

If the nodes l1 and l2 close the channel mutually (or unilateraly with one of the last commitment transactions) 980000sat (minus fees) would be transfered to the node l1 and 20000sat to the node l2.

But this is not what we are going to do.

The node l1 tries to cheat the node l2 by sending its signed revocated commitment transaction

Now the node l1 send its signed revocated commitment transaction (that we kept) onchain using the sub-command sendrawtransaction of bitcoin-cli like this:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest sendrawtransaction 02000000000101614ede01b596c97188865c296cebcba511b5317fa75eb64ccbb82acf7eb9a456000000000015b86980024a010000000000002200204760120cb1724e700f7e0553a55f28bb33392973b6e9465d984810d43394acf4903e0f0000000000220020e7e3c2fcb98c46ebadf430ea6e9bdcd6817fa7745db7685b54089ac64024fda90400473044022072bc63143cbf201748cc5b019690ce108ec3a59f8a3e416e4877facf6b64141d02206a5b402a88098053c897f4f1bee0d4dcae97c846d9192d4094983d37583409cd01473044022044cd292037347d9dda1ae928534a35a7bf7fdb9d8f69b6be911170287c6cfc3d0220533fce928a3f0932bd7ac97ec0b5e8064f9d1d0dc072a0aa3db914dbd3debd36014752210265a4484d62ab7de8749aef3a7dc61f001c120870a3cca3ecaddc6f0cb3385d872102b17f1c590309d887b0e5fd0a30834c6a5032f6c3d33e730a9eacc835b7ca2d8952aee249b020
6545a67a8b129e215323d9cd920ee71efb4faf4c5f6442d297a442d94a6dd272

The node l2 sends its penalty transaction automatically via lightning_onchaind subdaemon

In this episode we are interesting in seeing how CLN behaves when one of its peers try to cheat by going onchain with a revocated transaction.

In CLN this is the job of the subdaemon lightning_onchaind which is started by lightningd daemon whenever it observe something onchain.

So let's "monitor" lightning_onchaind process:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ ps -ax | grep onchaind
11997 pts/1    S+     0:00 grep --color=auto onchaind

No lightning_onchaind processes have been started so far.

This is normal because "nothing" happened onchain. As we are running the regtest chain ourselves, so far the revocated transaction has just been sent to the mempool as we can see here:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest getmempoolinfo
{
  "loaded": true,
  "size": 1,
  "bytes": 192,
  "usage": 1472,
  "total_fee": 0.00000614,
  "maxmempool": 300000000,
  "mempoolminfee": 0.00001000,
  "minrelaytxfee": 0.00001000,
  "incrementalrelayfee": 0.00001000,
  "unbroadcastcount": 1,
  "fullrbf": false
}

To trigger the lightning_onchaind subdaemon, we just need to mine one block with the revocated transaction been part of that block:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest -rpcwallet=default getnewaddress
bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest generatetoaddress 1 bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he
[
  "4cfd884117e11b94d419d1ee8c4672037ac5f00ecd530446fde375f55fe22c0a"
]

Now, we observe that two instances of lightning_onchaind has been started, one for the node l1 and one for the node l2:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ ps -ax | grep onchaind
13145 pts/1    S      0:00 /home/tony/lnroom/lightning/lightningd/lightning_onchaind
13146 pts/1    S      0:00 /home/tony/lnroom/lightning/lightningd/lightning_onchaind
13166 pts/1    S+     0:00 grep --color=auto onchaind

Using the sub-command listpeers of lightning-cli, we see that the node l1 is waiting for 99 more blocks to be mined to forget the channel:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli listpeers
{
   "peers": [
      {
         "id": "029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421",
         "connected": true,
         "netaddr": [
            "127.0.0.1:7272"
         ],
         "features": "08a0802a2269a2",
         "channels": [
            {
               "state": "ONCHAIN",
               "scratch_txid": "8ffafe1710fc5acd25687c283eee77981675084587e6cb8866c252fed2ad48cf",
               "last_tx_fee_msat": 284000,
               "feerate": {
                  "perkw": 253,
                  "perkb": 1012
               },
               "owner": "onchaind",
               "short_channel_id": "103x1x0",
               "direction": 1,
               "channel_id": "58ab59ac28fe9bae5eb63f7c695c304d901c1058b77dc0a1e3c97ca3274a8ac4",
               "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
               "funding_outnum": 0,
               "close_to_addr": "bcrt1q2z42n55mn2y3kl6h4xjws7cumvnqd96fwy7umk",
               "close_to": "001450aaa9d29b9a891b7f57a9a4e87b1cdb26069749",
               "private": false,
               "opener": "local",
               "closer": "remote",
               "alias": {
                  "local": "7083440x9106516x44986"
               },
               "features": [
                  "option_static_remotekey",
                  "option_anchor_outputs"
               ],
               "funding": {
                  "local_funds_msat": "1000000000msat",
                  "remote_funds_msat": "0msat",
                  "pushed_msat": 0
               },
               "to_us_msat": 980000000,
               "min_to_us_msat": 980000000,
               "max_to_us_msat": 1000000000,
               "total_msat": 1000000000,
               "fee_base_msat": 1,
               "fee_proportional_millionths": 10,
               "dust_limit_msat": 546000,
               "max_total_htlc_in_msat": 18446744073709551615,
               "their_reserve_msat": 10000000,
               "our_reserve_msat": 10000000,
               "spendable_msat": 968598000,
               "receivable_msat": 10000000,
               "minimum_htlc_in_msat": 0,
               "minimum_htlc_out_msat": 0,
               "maximum_htlc_out_msat": 990000000,
               "their_to_self_delay": 6,
               "our_to_self_delay": 6,
               "max_accepted_htlcs": 483,
               "state_changes": [
                  {
                     "timestamp": "2022-12-23T09:23:48.187Z",
                     "old_state": "DUALOPEND_OPEN_INIT",
                     "new_state": "DUALOPEND_AWAITING_LOCKIN",
                     "cause": "user",
                     "message": "Sigs exchanged, waiting for lock-in"
                  },
                  {
                     "timestamp": "2022-12-23T09:23:52.475Z",
                     "old_state": "DUALOPEND_AWAITING_LOCKIN",
                     "new_state": "CHANNELD_NORMAL",
                     "cause": "user",
                     "message": "Lockin complete"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.954Z",
                     "old_state": "CHANNELD_NORMAL",
                     "new_state": "AWAITING_UNILATERAL",
                     "cause": "onchain",
                     "message": "Funding transaction spent"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.955Z",
                     "old_state": "AWAITING_UNILATERAL",
                     "new_state": "FUNDING_SPEND_SEEN",
                     "cause": "onchain",
                     "message": "Onchain funding spend"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:55.053Z",
                     "old_state": "FUNDING_SPEND_SEEN",
                     "new_state": "ONCHAIN",
                     "cause": "onchain",
                     "message": "Onchain init reply"
                  }
               ],
               "status": [
                  "ONCHAIN:Tracking their illegal close: taking all funds",
                  "ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel"
               ],
               "in_payments_offered": 0,
               "in_offered_msat": 0,
               "in_payments_fulfilled": 0,
               "in_fulfilled_msat": 0,
               "out_payments_offered": 1,
               "out_offered_msat": 20000000,
               "out_payments_fulfilled": 1,
               "out_fulfilled_msat": 20000000,
               "htlcs": []
            }
         ]
      }
   ]
}

and that the node l2 is waiting for the penalty transaction (sent to the regtest chain) spending the output 1 of the revocated transaction 6545a67a8b129e215323d9cd920ee71efb4faf4c5f6442d297a442d94a6dd272 to himself taking all the remaining funds of the channel to be confirmed:

"status": [
   "ONCHAIN:Tracking their illegal close: taking all funds",
   "ONCHAIN:3 outputs unresolved: waiting confirmation that we spent DELAYED_CHEAT_OUTPUT_TO_THEM (6545a67a8b129e215323d9cd920ee71efb4faf4c5f6442d297a442d94a6dd272:1) using OUR_PENALTY_TX"
]

Here is the whole information:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listpeers
{
   "peers": [
      {
         "id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
         "connected": true,
         "netaddr": [
            "127.0.0.1:44562"
         ],
         "features": "08a0802a2269a2",
         "channels": [
            {
               "state": "ONCHAIN",
               "scratch_txid": "770a326618c0528566d5d58c765ffeab94b70cab92933ab1e9c4b8f2a074f2ad",
               "last_tx_fee_msat": 284000,
               "feerate": {
                  "perkw": 253,
                  "perkb": 1012
               },
               "owner": "onchaind",
               "short_channel_id": "103x1x0",
               "direction": 0,
               "channel_id": "58ab59ac28fe9bae5eb63f7c695c304d901c1058b77dc0a1e3c97ca3274a8ac4",
               "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
               "funding_outnum": 0,
               "close_to_addr": "bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t",
               "close_to": "0014d720082734843f27f93ca40c416873d57f190360",
               "private": false,
               "opener": "remote",
               "closer": "remote",
               "alias": {
                  "local": "16754152x10077133x31343"
               },
               "features": [
                  "option_static_remotekey",
                  "option_anchor_outputs"
               ],
               "funding": {
                  "local_funds_msat": "0msat",
                  "remote_funds_msat": "1000000000msat",
                  "pushed_msat": 0
               },
               "to_us_msat": 20000000,
               "min_to_us_msat": 0,
               "max_to_us_msat": 20000000,
               "total_msat": 1000000000,
               "fee_base_msat": 1,
               "fee_proportional_millionths": 10,
               "dust_limit_msat": 546000,
               "max_total_htlc_in_msat": 18446744073709551615,
               "their_reserve_msat": 10000000,
               "our_reserve_msat": 10000000,
               "spendable_msat": 10000000,
               "receivable_msat": 968598000,
               "minimum_htlc_in_msat": 0,
               "minimum_htlc_out_msat": 0,
               "maximum_htlc_out_msat": 990000000,
               "their_to_self_delay": 6,
               "our_to_self_delay": 6,
               "max_accepted_htlcs": 483,
               "state_changes": [
                  {
                     "timestamp": "2022-12-23T09:23:48.188Z",
                     "old_state": "DUALOPEND_OPEN_INIT",
                     "new_state": "DUALOPEND_AWAITING_LOCKIN",
                     "cause": "remote",
                     "message": "Sigs exchanged, waiting for lock-in"
                  },
                  {
                     "timestamp": "2022-12-23T09:23:52.564Z",
                     "old_state": "DUALOPEND_AWAITING_LOCKIN",
                     "new_state": "CHANNELD_NORMAL",
                     "cause": "remote",
                     "message": "Lockin complete"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.970Z",
                     "old_state": "CHANNELD_NORMAL",
                     "new_state": "AWAITING_UNILATERAL",
                     "cause": "onchain",
                     "message": "Funding transaction spent"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.971Z",
                     "old_state": "AWAITING_UNILATERAL",
                     "new_state": "FUNDING_SPEND_SEEN",
                     "cause": "onchain",
                     "message": "Onchain funding spend"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:55.095Z",
                     "old_state": "FUNDING_SPEND_SEEN",
                     "new_state": "ONCHAIN",
                     "cause": "onchain",
                     "message": "Onchain init reply"
                  }
               ],
               "status": [
                  "ONCHAIN:Tracking their illegal close: taking all funds",
                  "ONCHAIN:3 outputs unresolved: waiting confirmation that we spent DELAYED_CHEAT_OUTPUT_TO_THEM (6545a67a8b129e215323d9cd920ee71efb4faf4c5f6442d297a442d94a6dd272:1) using OUR_PENALTY_TX"
               ],
               "in_payments_offered": 1,
               "in_offered_msat": 20000000,
               "in_payments_fulfilled": 1,
               "in_fulfilled_msat": 20000000,
               "out_payments_offered": 0,
               "out_offered_msat": 0,
               "out_payments_fulfilled": 0,
               "out_fulfilled_msat": 0,
               "htlcs": []
            }
         ]
      }
   ]
}

As we run ourselves the regtest chain, no block has been mined yet and the penalty transaction is siting in the mempool as we can see below:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest getmempoolinfo
{
  "loaded": true,
  "size": 1,
  "bytes": 121,
  "usage": 1232,
  "total_fee": 0.00000121,
  "maxmempool": 300000000,
  "mempoolminfee": 0.00001000,
  "minrelaytxfee": 0.00001000,
  "incrementalrelayfee": 0.00001000,
  "unbroadcastcount": 1,
  "fullrbf": false
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest getrawmempool
[
  "96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc"
]
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest getrawtransaction 96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc
0200000000010172d26d4ad942a497d242645f4caf4ffb1ee70e92cdd92353219e128b7aa645650100000000fdffffff01173e0f0000000000160014d720082734843f27f93ca40c416873d57f1903600347304402204548de87a6bfa4dd1d26868b380b67b459f35fc5a1686d7fe0da562266d7f4ff02203da555c7b8e0fc778455a4323cad5f8de010434970e81779cf31b61b6ba236360101014b632103f0a9449e68f940055029ff400fd7c1bfb2d082552a7f5493f4013d4f7644f20f6756b2752103872d6a7f133c0b614c0b8aa8b08ea18e52be4f4c504750c8cde454d3af9759a968ac00000000
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest decoderawtransaction 0200000000010172d26d4ad942a497d242645f4caf4ffb1ee70e92cdd92353219e128b7aa645650100000000fdffffff01173e0f0000000000160014d720082734843f27f93ca40c416873d57f1903600347304402204548de87a6bfa4dd1d26868b380b67b459f35fc5a1686d7fe0da562266d7f4ff02203da555c7b8e0fc778455a4323cad5f8de010434970e81779cf31b61b6ba236360101014b632103f0a9449e68f940055029ff400fd7c1bfb2d082552a7f5493f4013d4f7644f20f6756b2752103872d6a7f133c0b614c0b8aa8b08ea18e52be4f4c504750c8cde454d3af9759a968ac00000000
{
  "txid": "96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc",
  "hash": "515eb047cae56dbec7b109331df4d43217c7cb274d2e98b992cc0bf5227d9c44",
  "version": 2,
  "size": 235,
  "vsize": 121,
  "weight": 481,
  "locktime": 0,
  "vin": [
    {
      "txid": "6545a67a8b129e215323d9cd920ee71efb4faf4c5f6442d297a442d94a6dd272",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402204548de87a6bfa4dd1d26868b380b67b459f35fc5a1686d7fe0da562266d7f4ff02203da555c7b8e0fc778455a4323cad5f8de010434970e81779cf31b61b6ba2363601",
        "01",
        "632103f0a9449e68f940055029ff400fd7c1bfb2d082552a7f5493f4013d4f7644f20f6756b2752103872d6a7f133c0b614c0b8aa8b08ea18e52be4f4c504750c8cde454d3af9759a968ac"
      ],
      "sequence": 4294967293
    }
  ],
  "vout": [
    {
      "value": 0.00998935,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 d720082734843f27f93ca40c416873d57f190360",
        "desc": "addr(bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t)#sdfqy426",
        "hex": "0014d720082734843f27f93ca40c416873d57f190360",
        "address": "bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t",
        "type": "witness_v0_keyhash"
      }
    }
  ]
}

In the last output object we see that the transaction 96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc has no time locks and so its input will be spent immediately (before the to_self_delay of the node l1 that is trying to cheat) and that the address receiving those funds is bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t which belongs to the node l2, specifically this is the address specified in the attribute close_to_addr of the channel object in the object returned by the subcommand listpeers.

Now we mine a block:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest generatetoaddress 1 bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he
[
  "70619d1e73eb7a1ef89751a2c91c3d618affa031f38f8ef13de57989b0f79e0f"
]

Since the penalty transaction has been mined in a block we can check that:

  1. the lightning wallet of the node l1 didn't get the funds of the channel (1000000sat minus the fees) he was trying to steal and

  2. the lightning wallet of the node l2 got all the funds of the channel (1000000sat minus the fees).

To check that we print out the outputs of the lightning wallets listed by the sub-command listfunds of lightning-cli:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli listfunds | jq .outputs -r
[
  {
    "txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
    "output": 1,
    "amount_msat": 98999846000,
    "scriptpubkey": "001462417c6a87d0b55efba61030bb3c328831344326",
    "address": "bcrt1qvfqhc6586z64a7axzqctk0pj3qcngsexntgfm0",
    "status": "confirmed",
    "blockheight": 103,
    "reserved": false
  }
]
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listfunds | jq .outputs -r
[
  {
    "txid": "96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc",
    "output": 0,
    "amount_msat": 998935000,
    "scriptpubkey": "0014d720082734843f27f93ca40c416873d57f190360",
    "address": "bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t",
    "status": "confirmed",
    "blockheight": 110,
    "reserved": false
  }
]

As we can read in the status attribute there is one thing left to do to forget that channel which is to mine 99 more blocks:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listpeers
{
   "peers": [
      {
         "id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
         "connected": true,
         "netaddr": [
            "127.0.0.1:44562"
         ],
         "features": "08a0802a2269a2",
         "channels": [
            {
               "state": "ONCHAIN",
               "scratch_txid": "770a326618c0528566d5d58c765ffeab94b70cab92933ab1e9c4b8f2a074f2ad",
               "last_tx_fee_msat": 284000,
               "feerate": {
                  "perkw": 253,
                  "perkb": 1012
               },
               "owner": "onchaind",
               "short_channel_id": "103x1x0",
               "direction": 0,
               "channel_id": "58ab59ac28fe9bae5eb63f7c695c304d901c1058b77dc0a1e3c97ca3274a8ac4",
               "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
               "funding_outnum": 0,
               "close_to_addr": "bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t",
               "close_to": "0014d720082734843f27f93ca40c416873d57f190360",
               "private": false,
               "opener": "remote",
               "closer": "remote",
               "alias": {
                  "local": "16754152x10077133x31343"
               },
               "features": [
                  "option_static_remotekey",
                  "option_anchor_outputs"
               ],
               "funding": {
                  "local_funds_msat": "0msat",
                  "remote_funds_msat": "1000000000msat",
                  "pushed_msat": 0
               },
               "to_us_msat": 20000000,
               "min_to_us_msat": 0,
               "max_to_us_msat": 20000000,
               "total_msat": 1000000000,
               "fee_base_msat": 1,
               "fee_proportional_millionths": 10,
               "dust_limit_msat": 546000,
               "max_total_htlc_in_msat": 18446744073709551615,
               "their_reserve_msat": 10000000,
               "our_reserve_msat": 10000000,
               "spendable_msat": 10000000,
               "receivable_msat": 968598000,
               "minimum_htlc_in_msat": 0,
               "minimum_htlc_out_msat": 0,
               "maximum_htlc_out_msat": 990000000,
               "their_to_self_delay": 6,
               "our_to_self_delay": 6,
               "max_accepted_htlcs": 483,
               "state_changes": [
                  {
                     "timestamp": "2022-12-23T09:23:48.188Z",
                     "old_state": "DUALOPEND_OPEN_INIT",
                     "new_state": "DUALOPEND_AWAITING_LOCKIN",
                     "cause": "remote",
                     "message": "Sigs exchanged, waiting for lock-in"
                  },
                  {
                     "timestamp": "2022-12-23T09:23:52.564Z",
                     "old_state": "DUALOPEND_AWAITING_LOCKIN",
                     "new_state": "CHANNELD_NORMAL",
                     "cause": "remote",
                     "message": "Lockin complete"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.970Z",
                     "old_state": "CHANNELD_NORMAL",
                     "new_state": "AWAITING_UNILATERAL",
                     "cause": "onchain",
                     "message": "Funding transaction spent"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.971Z",
                     "old_state": "AWAITING_UNILATERAL",
                     "new_state": "FUNDING_SPEND_SEEN",
                     "cause": "onchain",
                     "message": "Onchain funding spend"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:55.095Z",
                     "old_state": "FUNDING_SPEND_SEEN",
                     "new_state": "ONCHAIN",
                     "cause": "onchain",
                     "message": "Onchain init reply"
                  }
               ],
               "status": [
                  "ONCHAIN:Tracking their illegal close: taking all funds",
                  "ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel"
               ],
               "in_payments_offered": 1,
               "in_offered_msat": 20000000,
               "in_payments_fulfilled": 1,
               "in_fulfilled_msat": 20000000,
               "out_payments_offered": 0,
               "out_offered_msat": 0,
               "out_payments_fulfilled": 0,
               "out_fulfilled_msat": 0,
               "htlcs": []
            }
         ]
      }
   ]
}

Let's mine those blocks and run listpeers sub-command again:

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest generatetoaddress 100 bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he > /dev/null
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listpeers
{
   "peers": [
      {
         "id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
         "connected": true,
         "netaddr": [
            "127.0.0.1:44562"
         ],
         "features": "08a0802a2269a2",
         "channels": []
      }
   ]
}

We haven't done it in the video but if we had run again the command

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ ps -ax | grep onchaind

we would have observed that after forgetting the channel the subdaemonds lightningd_onchaind have been shut down.

json_sign_last_tx function definition

In one of the LN Room episode comming we are going to see how to add developer commands to CLN. But for now let's just show json_sign_last_tx function which implement dev_sign_last_tx function that we've been using during this episode.

static struct command_result *json_sign_last_tx(struct command *cmd,
                                                const char *buffer,
                                                const jsmntok_t *obj UNNEEDED,
                                                const jsmntok_t *params)
{
        struct node_id *peerid;
        struct peer *peer;
        struct json_stream *response;
        struct channel *channel;
        bool more_than_one;

        if (!param(cmd, buffer, params,
                   p_req("id", param_node_id, &peerid),
                   NULL))
                return command_param_failed();

        peer = peer_by_id(cmd->ld, peerid);
        if (!peer) {
                return command_fail(cmd, LIGHTNINGD,
                                    "Could not find peer with that id");
        }
        channel = peer_any_active_channel(peer, &more_than_one);
        if (!channel || more_than_one) {
                return command_fail(cmd, LIGHTNINGD,
                                    "Could not find single active channel");
        }

        response = json_stream_success(cmd);
        log_debug(channel->log, "dev-sign-last-tx: signing tx with %zu outputs",
                  channel->last_tx->wtx->num_outputs);

        sign_last_tx(channel, channel->last_tx, &channel->last_sig);
        json_add_tx(response, "tx", channel->last_tx);
        remove_sig(channel->last_tx);

        /* If we've got inflights, return them */
        if (!list_empty(&channel->inflights)) {
                struct channel_inflight *inflight;

                json_array_start(response, "inflights");
                list_for_each(&channel->inflights, inflight, list) {
                        sign_last_tx(channel, inflight->last_tx,
                                     &inflight->last_sig);
                        json_object_start(response, NULL);
                        json_add_txid(response, "funding_txid",
                                      &inflight->funding->outpoint.txid);
                        remove_sig(inflight->last_tx);
                        json_add_tx(response, "tx", channel->last_tx);
                        json_object_end(response);
                }
                json_array_end(response);
        }

        return command_success(cmd, response);
}

static const struct json_command dev_sign_last_tx = {
        "dev-sign-last-tx",
        "developer",
        json_sign_last_tx,
        "Sign and show the last commitment transaction with peer {id}"
};
AUTODATA(json_command, &dev_sign_last_tx);

We are done for today.

I hope you enjoyed the video.

See you in the next episode of LN Room.

Terminal sessions

We ran the following commands in this order:

$ ./configure --enable-developer
$ make -j$(nproc)
$ source contrib/startup_regtest.sh
$ start_ln 2
$ alias l1-cli
$ fund_nodes
$ l1-cli help | grep dev-
$ l1-cli help dev-sign-last-tx
$ l1-cli listfunds | jq
$ l2-cli listfunds | jq
$ l2-cli getinfo | jq .id -r
$ l1-cli dev-sign-last-tx 029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421
$ l2-cli invoice 20000sat inv "pizza"
$ l1-cli pay lnbcrt200u1p362a5gsp535hjsnt5pm6m0k2l63v52cmtvs5lxfyycawm72f64s06wl7jrn4spp5y59wpcq7h38qy32fmtlz0vu7jd758mhfkarf5ktqaqh9fhlzemxqdqgwp5h57npxqyjw5qcqp29qx3qysgqdp9rkas3ek5w2d9qraaaax6rp32ysj3duy6s4z57ph4w2wwwztsp3hel3f46tsgnkpqf3rywsv9zygyffm0n069d9jplxj4hwkq50esq9w486j
$ l1-cli listfunds | jq
$ l2-cli listfunds | jq
$ bitcoin-cli -regtest sendrawtransaction 02000000000101614ede01b596c97188865c296cebcba511b5317fa75eb64ccbb82acf7eb9a456000000000015b86980024a010000000000002200204760120cb1724e700f7e0553a55f28bb33392973b6e9465d984810d43394acf4903e0f0000000000220020e7e3c2fcb98c46ebadf430ea6e9bdcd6817fa7745db7685b54089ac64024fda90400473044022072bc63143cbf201748cc5b019690ce108ec3a59f8a3e416e4877facf6b64141d02206a5b402a88098053c897f4f1bee0d4dcae97c846d9192d4094983d37583409cd01473044022044cd292037347d9dda1ae928534a35a7bf7fdb9d8f69b6be911170287c6cfc3d0220533fce928a3f0932bd7ac97ec0b5e8064f9d1d0dc072a0aa3db914dbd3debd36014752210265a4484d62ab7de8749aef3a7dc61f001c120870a3cca3ecaddc6f0cb3385d872102b17f1c590309d887b0e5fd0a30834c6a5032f6c3d33e730a9eacc835b7ca2d8952aee249b020
$ ps -ax | grep onchaind
$ bitcoin-cli -regtest getmempoolinfo
$ bitcoin-cli -regtest -rpcwallet=default getnewaddress
$ bitcoin-cli -regtest generatetoaddress 1 bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he
$ ps -ax | grep onchaind
$ l1-cli listpeers
$ l2-cli listpeers
$ bitcoin-cli -regtest getmempoolinfo
$ bitcoin-cli -regtest getrawmempool
$ bitcoin-cli -regtest getrawtransaction 96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc
$ bitcoin-cli -regtest decoderawtransaction 0200000000010172d26d4ad942a497d242645f4caf4ffb1ee70e92cdd92353219e128b7aa645650100000000fdffffff01173e0f0000000000160014d720082734843f27f93ca40c416873d57f1903600347304402204548de87a6bfa4dd1d26868b380b67b459f35fc5a1686d7fe0da562266d7f4ff02203da555c7b8e0fc778455a4323cad5f8de010434970e81779cf31b61b6ba236360101014b632103f0a9449e68f940055029ff400fd7c1bfb2d082552a7f5493f4013d4f7644f20f6756b2752103872d6a7f133c0b614c0b8aa8b08ea18e52be4f4c504750c8cde454d3af9759a968ac00000000
$ bitcoin-cli -regtest generatetoaddress 1 bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he
$ l1-cli listfunds | jq .outputs -r
$ l2-cli listfunds | jq .outputs -r
$ l2-cli listpeers
$ bitcoin-cli -regtest generatetoaddress 100 bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he > /dev/null
$ l2-cli listpeers

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

◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ ./configure --enable-developer
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ make -j$(nproc)
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ source contrib/startup_regtest.sh
lightning-cli is /home/tony/lnroom/lightning/cli/lightning-cli
lightningd is /home/tony/lnroom/lightning/lightningd/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»(HEAD detached at v22.11.1)]
$ start_ln 2
Bitcoin Core starting
awaiting bitcoind...
Making "default" bitcoind wallet.
[1] 31748
[2] 31789
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»(HEAD detached at v22.11.1)]
$ alias l1-cli
alias l1-cli='/home/tony/lnroom/lightning/cli/lightning-cli --lightning-dir=/tmp/l1-regtest'
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ fund_nodes
Mining into address bcrt1qfrs6yr4er4xvdvs2meugekmxdla5dpryv8tfkt... 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»(HEAD detached at v22.11.1)]
$ l1-cli help | grep dev-
dev-queryrates id amount request_amt [commitment_feerate] [funding_feerate]
invoice amount_msat label description [expiry] [fallbacks] [preimage] [exposeprivatechannels] [cltv] [deschashonly] [dev-routes]
dev-rawrequest invreq nodeid [timeout]
dev-sendcustommsg node_id msg
dev-compact-gossip-store
dev-fail id
dev-feerate id feerate
dev-forget-channel id [short_channel_id] [channel_id] [force]
dev-gossip-set-time time
dev-ignore-htlcs id ignore
dev-listaddrs [bip32_max_index]
dev-memdump
dev-memleak
dev-reenable-commit id
dev-rescan-outputs
dev-set-max-scids-encode-size max
dev-sign-last-tx id
dev-suppress-gossip
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli help dev-sign-last-tx
No manual entry for lightning-dev-sign-last-tx
man: /home/tony/lnroom/lightning/cli/../doc/lightning-dev-sign-last-tx.7: No such file or directory
command=dev-sign-last-tx id
category=developer
description=Sign and show the last commitment transaction with peer {id}
verbose=HELP! Please contribute a description for this json_command!
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli listfunds | jq
{
  "outputs": [
    {
      "txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "output": 1,
      "amount_msat": 98999846000,
      "scriptpubkey": "001462417c6a87d0b55efba61030bb3c328831344326",
      "address": "bcrt1qvfqhc6586z64a7axzqctk0pj3qcngsexntgfm0",
      "status": "confirmed",
      "blockheight": 103,
      "reserved": false
    }
  ],
  "channels": [
    {
      "peer_id": "029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421",
      "connected": true,
      "state": "CHANNELD_NORMAL",
      "short_channel_id": "103x1x0",
      "our_amount_msat": 1000000000,
      "amount_msat": 1000000000,
      "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "funding_output": 0
    }
  ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listfunds | jq
{
  "outputs": [],
  "channels": [
    {
      "peer_id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
      "connected": true,
      "state": "CHANNELD_NORMAL",
      "short_channel_id": "103x1x0",
      "our_amount_msat": 0,
      "amount_msat": 1000000000,
      "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "funding_output": 0
    }
  ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli getinfo | jq .id -r
029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli dev-sign-last-tx 029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421
{
   "tx": "02000000000101614ede01b596c97188865c296cebcba511b5317fa75eb64ccbb82acf7eb9a456000000000015b86980024a010000000000002200204760120cb1724e700f7e0553a55f28bb33392973b6e9465d984810d43394acf4903e0f0000000000220020e7e3c2fcb98c46ebadf430ea6e9bdcd6817fa7745db7685b54089ac64024fda90400473044022072bc63143cbf201748cc5b019690ce108ec3a59f8a3e416e4877facf6b64141d02206a5b402a88098053c897f4f1bee0d4dcae97c846d9192d4094983d37583409cd01473044022044cd292037347d9dda1ae928534a35a7bf7fdb9d8f69b6be911170287c6cfc3d0220533fce928a3f0932bd7ac97ec0b5e8064f9d1d0dc072a0aa3db914dbd3debd36014752210265a4484d62ab7de8749aef3a7dc61f001c120870a3cca3ecaddc6f0cb3385d872102b17f1c590309d887b0e5fd0a30834c6a5032f6c3d33e730a9eacc835b7ca2d8952aee249b020"
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli invoice 20000sat inv "pizza"
{
   "payment_hash": "250ae0e01ebc4e024549dafe27b39e937d43eee9b7469a5960e82e54dfe2cecc",
   "expires_at": 1672392968,
   "bolt11": "lnbcrt200u1p362a5gsp535hjsnt5pm6m0k2l63v52cmtvs5lxfyycawm72f64s06wl7jrn4spp5y59wpcq7h38qy32fmtlz0vu7jd758mhfkarf5ktqaqh9fhlzemxqdqgwp5h57npxqyjw5qcqp29qx3qysgqdp9rkas3ek5w2d9qraaaax6rp32ysj3duy6s4z57ph4w2wwwztsp3hel3f46tsgnkpqf3rywsv9zygyffm0n069d9jplxj4hwkq50esq9w486j",
   "payment_secret": "8d2f284d740ef5b7d95fd45945636b6429f32484c75dbf293aac1fa77fd21ceb",
   "warning_deadends": "Insufficient incoming capacity, once dead-end peers were excluded"
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli pay lnbcrt200u1p362a5gsp535hjsnt5pm6m0k2l63v52cmtvs5lxfyycawm72f64s06wl7jrn4spp5y59wpcq7h38qy32fmtlz0vu7jd758mhfkarf5ktqaqh9fhlzemxqdqgwp5h57npxqyjw5qcqp29qx3qysgqdp9rkas3ek5w2d9qraaaax6rp32ysj3duy6s4z57ph4w2wwwztsp3hel3f46tsgnkpqf3rywsv9zygyffm0n069d9jplxj4hwkq50esq9w486j
{
   "destination": "029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421",
   "payment_hash": "250ae0e01ebc4e024549dafe27b39e937d43eee9b7469a5960e82e54dfe2cecc",
   "created_at": 1671788189.491,
   "parts": 1,
   "amount_msat": 20000000,
   "amount_sent_msat": 20000000,
   "payment_preimage": "6e8829be8b4428de2ca41769c46c208e399fec5d193cb3b0e8ee0027a585e0d9",
   "status": "complete"
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli listfunds | jq
{
  "outputs": [
    {
      "txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "output": 1,
      "amount_msat": 98999846000,
      "scriptpubkey": "001462417c6a87d0b55efba61030bb3c328831344326",
      "address": "bcrt1qvfqhc6586z64a7axzqctk0pj3qcngsexntgfm0",
      "status": "confirmed",
      "blockheight": 103,
      "reserved": false
    }
  ],
  "channels": [
    {
      "peer_id": "029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421",
      "connected": true,
      "state": "CHANNELD_NORMAL",
      "short_channel_id": "103x1x0",
      "our_amount_msat": 980000000,
      "amount_msat": 1000000000,
      "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "funding_output": 0
    }
  ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listfunds | jq
{
  "outputs": [],
  "channels": [
    {
      "peer_id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
      "connected": true,
      "state": "CHANNELD_NORMAL",
      "short_channel_id": "103x1x0",
      "our_amount_msat": 20000000,
      "amount_msat": 1000000000,
      "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
      "funding_output": 0
    }
  ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest sendrawtransaction 02000000000101614ede01b596c97188865c296cebcba511b5317fa75eb64ccbb82acf7eb9a456000000000015b86980024a010000000000002200204760120cb1724e700f7e0553a55f28bb33392973b6e9465d984810d43394acf4903e0f0000000000220020e7e3c2fcb98c46ebadf430ea6e9bdcd6817fa7745db7685b54089ac64024fda90400473044022072bc63143cbf201748cc5b019690ce108ec3a59f8a3e416e4877facf6b64141d02206a5b402a88098053c897f4f1bee0d4dcae97c846d9192d4094983d37583409cd01473044022044cd292037347d9dda1ae928534a35a7bf7fdb9d8f69b6be911170287c6cfc3d0220533fce928a3f0932bd7ac97ec0b5e8064f9d1d0dc072a0aa3db914dbd3debd36014752210265a4484d62ab7de8749aef3a7dc61f001c120870a3cca3ecaddc6f0cb3385d872102b17f1c590309d887b0e5fd0a30834c6a5032f6c3d33e730a9eacc835b7ca2d8952aee249b020
6545a67a8b129e215323d9cd920ee71efb4faf4c5f6442d297a442d94a6dd272
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ ps -ax | grep onchaind
11997 pts/1    S+     0:00 grep --color=auto onchaind
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest getmempoolinfo
{
  "loaded": true,
  "size": 1,
  "bytes": 192,
  "usage": 1472,
  "total_fee": 0.00000614,
  "maxmempool": 300000000,
  "mempoolminfee": 0.00001000,
  "minrelaytxfee": 0.00001000,
  "incrementalrelayfee": 0.00001000,
  "unbroadcastcount": 1,
  "fullrbf": false
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest -rpcwallet=default getnewaddress
bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest generatetoaddress 1 bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he
[
  "4cfd884117e11b94d419d1ee8c4672037ac5f00ecd530446fde375f55fe22c0a"
]
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ ps -ax | grep onchaind
13145 pts/1    S      0:00 /home/tony/lnroom/lightning/lightningd/lightning_onchaind
13146 pts/1    S      0:00 /home/tony/lnroom/lightning/lightningd/lightning_onchaind
13166 pts/1    S+     0:00 grep --color=auto onchaind
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli listpeers
{
   "peers": [
      {
         "id": "029e2d35d8965b3dd63093e5a455decd2a4ef10ccfb54549b650f9342848bd9421",
         "connected": true,
         "netaddr": [
            "127.0.0.1:7272"
         ],
         "features": "08a0802a2269a2",
         "channels": [
            {
               "state": "ONCHAIN",
               "scratch_txid": "8ffafe1710fc5acd25687c283eee77981675084587e6cb8866c252fed2ad48cf",
               "last_tx_fee_msat": 284000,
               "feerate": {
                  "perkw": 253,
                  "perkb": 1012
               },
               "owner": "onchaind",
               "short_channel_id": "103x1x0",
               "direction": 1,
               "channel_id": "58ab59ac28fe9bae5eb63f7c695c304d901c1058b77dc0a1e3c97ca3274a8ac4",
               "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
               "funding_outnum": 0,
               "close_to_addr": "bcrt1q2z42n55mn2y3kl6h4xjws7cumvnqd96fwy7umk",
               "close_to": "001450aaa9d29b9a891b7f57a9a4e87b1cdb26069749",
               "private": false,
               "opener": "local",
               "closer": "remote",
               "alias": {
                  "local": "7083440x9106516x44986"
               },
               "features": [
                  "option_static_remotekey",
                  "option_anchor_outputs"
               ],
               "funding": {
                  "local_funds_msat": "1000000000msat",
                  "remote_funds_msat": "0msat",
                  "pushed_msat": 0
               },
               "to_us_msat": 980000000,
               "min_to_us_msat": 980000000,
               "max_to_us_msat": 1000000000,
               "total_msat": 1000000000,
               "fee_base_msat": 1,
               "fee_proportional_millionths": 10,
               "dust_limit_msat": 546000,
               "max_total_htlc_in_msat": 18446744073709551615,
               "their_reserve_msat": 10000000,
               "our_reserve_msat": 10000000,
               "spendable_msat": 968598000,
               "receivable_msat": 10000000,
               "minimum_htlc_in_msat": 0,
               "minimum_htlc_out_msat": 0,
               "maximum_htlc_out_msat": 990000000,
               "their_to_self_delay": 6,
               "our_to_self_delay": 6,
               "max_accepted_htlcs": 483,
               "state_changes": [
                  {
                     "timestamp": "2022-12-23T09:23:48.187Z",
                     "old_state": "DUALOPEND_OPEN_INIT",
                     "new_state": "DUALOPEND_AWAITING_LOCKIN",
                     "cause": "user",
                     "message": "Sigs exchanged, waiting for lock-in"
                  },
                  {
                     "timestamp": "2022-12-23T09:23:52.475Z",
                     "old_state": "DUALOPEND_AWAITING_LOCKIN",
                     "new_state": "CHANNELD_NORMAL",
                     "cause": "user",
                     "message": "Lockin complete"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.954Z",
                     "old_state": "CHANNELD_NORMAL",
                     "new_state": "AWAITING_UNILATERAL",
                     "cause": "onchain",
                     "message": "Funding transaction spent"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.955Z",
                     "old_state": "AWAITING_UNILATERAL",
                     "new_state": "FUNDING_SPEND_SEEN",
                     "cause": "onchain",
                     "message": "Onchain funding spend"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:55.053Z",
                     "old_state": "FUNDING_SPEND_SEEN",
                     "new_state": "ONCHAIN",
                     "cause": "onchain",
                     "message": "Onchain init reply"
                  }
               ],
               "status": [
                  "ONCHAIN:Tracking their illegal close: taking all funds",
                  "ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel"
               ],
               "in_payments_offered": 0,
               "in_offered_msat": 0,
               "in_payments_fulfilled": 0,
               "in_fulfilled_msat": 0,
               "out_payments_offered": 1,
               "out_offered_msat": 20000000,
               "out_payments_fulfilled": 1,
               "out_fulfilled_msat": 20000000,
               "htlcs": []
            }
         ]
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listpeers
{
   "peers": [
      {
         "id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
         "connected": true,
         "netaddr": [
            "127.0.0.1:44562"
         ],
         "features": "08a0802a2269a2",
         "channels": [
            {
               "state": "ONCHAIN",
               "scratch_txid": "770a326618c0528566d5d58c765ffeab94b70cab92933ab1e9c4b8f2a074f2ad",
               "last_tx_fee_msat": 284000,
               "feerate": {
                  "perkw": 253,
                  "perkb": 1012
               },
               "owner": "onchaind",
               "short_channel_id": "103x1x0",
               "direction": 0,
               "channel_id": "58ab59ac28fe9bae5eb63f7c695c304d901c1058b77dc0a1e3c97ca3274a8ac4",
               "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
               "funding_outnum": 0,
               "close_to_addr": "bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t",
               "close_to": "0014d720082734843f27f93ca40c416873d57f190360",
               "private": false,
               "opener": "remote",
               "closer": "remote",
               "alias": {
                  "local": "16754152x10077133x31343"
               },
               "features": [
                  "option_static_remotekey",
                  "option_anchor_outputs"
               ],
               "funding": {
                  "local_funds_msat": "0msat",
                  "remote_funds_msat": "1000000000msat",
                  "pushed_msat": 0
               },
               "to_us_msat": 20000000,
               "min_to_us_msat": 0,
               "max_to_us_msat": 20000000,
               "total_msat": 1000000000,
               "fee_base_msat": 1,
               "fee_proportional_millionths": 10,
               "dust_limit_msat": 546000,
               "max_total_htlc_in_msat": 18446744073709551615,
               "their_reserve_msat": 10000000,
               "our_reserve_msat": 10000000,
               "spendable_msat": 10000000,
               "receivable_msat": 968598000,
               "minimum_htlc_in_msat": 0,
               "minimum_htlc_out_msat": 0,
               "maximum_htlc_out_msat": 990000000,
               "their_to_self_delay": 6,
               "our_to_self_delay": 6,
               "max_accepted_htlcs": 483,
               "state_changes": [
                  {
                     "timestamp": "2022-12-23T09:23:48.188Z",
                     "old_state": "DUALOPEND_OPEN_INIT",
                     "new_state": "DUALOPEND_AWAITING_LOCKIN",
                     "cause": "remote",
                     "message": "Sigs exchanged, waiting for lock-in"
                  },
                  {
                     "timestamp": "2022-12-23T09:23:52.564Z",
                     "old_state": "DUALOPEND_AWAITING_LOCKIN",
                     "new_state": "CHANNELD_NORMAL",
                     "cause": "remote",
                     "message": "Lockin complete"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.970Z",
                     "old_state": "CHANNELD_NORMAL",
                     "new_state": "AWAITING_UNILATERAL",
                     "cause": "onchain",
                     "message": "Funding transaction spent"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.971Z",
                     "old_state": "AWAITING_UNILATERAL",
                     "new_state": "FUNDING_SPEND_SEEN",
                     "cause": "onchain",
                     "message": "Onchain funding spend"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:55.095Z",
                     "old_state": "FUNDING_SPEND_SEEN",
                     "new_state": "ONCHAIN",
                     "cause": "onchain",
                     "message": "Onchain init reply"
                  }
               ],
               "status": [
                  "ONCHAIN:Tracking their illegal close: taking all funds",
                  "ONCHAIN:3 outputs unresolved: waiting confirmation that we spent DELAYED_CHEAT_OUTPUT_TO_THEM (6545a67a8b129e215323d9cd920ee71efb4faf4c5f6442d297a442d94a6dd272:1) using OUR_PENALTY_TX"
               ],
               "in_payments_offered": 1,
               "in_offered_msat": 20000000,
               "in_payments_fulfilled": 1,
               "in_fulfilled_msat": 20000000,
               "out_payments_offered": 0,
               "out_offered_msat": 0,
               "out_payments_fulfilled": 0,
               "out_fulfilled_msat": 0,
               "htlcs": []
            }
         ]
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest getmempoolinfo
{
  "loaded": true,
  "size": 1,
  "bytes": 121,
  "usage": 1232,
  "total_fee": 0.00000121,
  "maxmempool": 300000000,
  "mempoolminfee": 0.00001000,
  "minrelaytxfee": 0.00001000,
  "incrementalrelayfee": 0.00001000,
  "unbroadcastcount": 1,
  "fullrbf": false
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest getrawmempool
[
  "96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc"
]
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest getrawtransaction 96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc
0200000000010172d26d4ad942a497d242645f4caf4ffb1ee70e92cdd92353219e128b7aa645650100000000fdffffff01173e0f0000000000160014d720082734843f27f93ca40c416873d57f1903600347304402204548de87a6bfa4dd1d26868b380b67b459f35fc5a1686d7fe0da562266d7f4ff02203da555c7b8e0fc778455a4323cad5f8de010434970e81779cf31b61b6ba236360101014b632103f0a9449e68f940055029ff400fd7c1bfb2d082552a7f5493f4013d4f7644f20f6756b2752103872d6a7f133c0b614c0b8aa8b08ea18e52be4f4c504750c8cde454d3af9759a968ac00000000
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest decoderawtransaction 0200000000010172d26d4ad942a497d242645f4caf4ffb1ee70e92cdd92353219e128b7aa645650100000000fdffffff01173e0f0000000000160014d720082734843f27f93ca40c416873d57f1903600347304402204548de87a6bfa4dd1d26868b380b67b459f35fc5a1686d7fe0da562266d7f4ff02203da555c7b8e0fc778455a4323cad5f8de010434970e81779cf31b61b6ba236360101014b632103f0a9449e68f940055029ff400fd7c1bfb2d082552a7f5493f4013d4f7644f20f6756b2752103872d6a7f133c0b614c0b8aa8b08ea18e52be4f4c504750c8cde454d3af9759a968ac00000000
{
  "txid": "96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc",
  "hash": "515eb047cae56dbec7b109331df4d43217c7cb274d2e98b992cc0bf5227d9c44",
  "version": 2,
  "size": 235,
  "vsize": 121,
  "weight": 481,
  "locktime": 0,
  "vin": [
    {
      "txid": "6545a67a8b129e215323d9cd920ee71efb4faf4c5f6442d297a442d94a6dd272",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402204548de87a6bfa4dd1d26868b380b67b459f35fc5a1686d7fe0da562266d7f4ff02203da555c7b8e0fc778455a4323cad5f8de010434970e81779cf31b61b6ba2363601",
        "01",
        "632103f0a9449e68f940055029ff400fd7c1bfb2d082552a7f5493f4013d4f7644f20f6756b2752103872d6a7f133c0b614c0b8aa8b08ea18e52be4f4c504750c8cde454d3af9759a968ac"
      ],
      "sequence": 4294967293
    }
  ],
  "vout": [
    {
      "value": 0.00998935,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 d720082734843f27f93ca40c416873d57f190360",
        "desc": "addr(bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t)#sdfqy426",
        "hex": "0014d720082734843f27f93ca40c416873d57f190360",
        "address": "bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t",
        "type": "witness_v0_keyhash"
      }
    }
  ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest generatetoaddress 1 bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he
[
  "70619d1e73eb7a1ef89751a2c91c3d618affa031f38f8ef13de57989b0f79e0f"
]
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l1-cli listfunds | jq .outputs -r
[
  {
    "txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
    "output": 1,
    "amount_msat": 98999846000,
    "scriptpubkey": "001462417c6a87d0b55efba61030bb3c328831344326",
    "address": "bcrt1qvfqhc6586z64a7axzqctk0pj3qcngsexntgfm0",
    "status": "confirmed",
    "blockheight": 103,
    "reserved": false
  }
]
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listfunds | jq .outputs -r
[
  {
    "txid": "96dad64d1babac29b02c38cacc2fbe2f471ed2b2001e6cc98ae1ac4f930686cc",
    "output": 0,
    "amount_msat": 998935000,
    "scriptpubkey": "0014d720082734843f27f93ca40c416873d57f190360",
    "address": "bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t",
    "status": "confirmed",
    "blockheight": 110,
    "reserved": false
  }
]
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listpeers
{
   "peers": [
      {
         "id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
         "connected": true,
         "netaddr": [
            "127.0.0.1:44562"
         ],
         "features": "08a0802a2269a2",
         "channels": [
            {
               "state": "ONCHAIN",
               "scratch_txid": "770a326618c0528566d5d58c765ffeab94b70cab92933ab1e9c4b8f2a074f2ad",
               "last_tx_fee_msat": 284000,
               "feerate": {
                  "perkw": 253,
                  "perkb": 1012
               },
               "owner": "onchaind",
               "short_channel_id": "103x1x0",
               "direction": 0,
               "channel_id": "58ab59ac28fe9bae5eb63f7c695c304d901c1058b77dc0a1e3c97ca3274a8ac4",
               "funding_txid": "56a4b97ecf2ab8cb4cb65ea77f31b511a5cbeb6c295c868871c996b501de4e61",
               "funding_outnum": 0,
               "close_to_addr": "bcrt1q6usqsfe5sslj07fu5sxyz6rn64l3jqmqejsz8t",
               "close_to": "0014d720082734843f27f93ca40c416873d57f190360",
               "private": false,
               "opener": "remote",
               "closer": "remote",
               "alias": {
                  "local": "16754152x10077133x31343"
               },
               "features": [
                  "option_static_remotekey",
                  "option_anchor_outputs"
               ],
               "funding": {
                  "local_funds_msat": "0msat",
                  "remote_funds_msat": "1000000000msat",
                  "pushed_msat": 0
               },
               "to_us_msat": 20000000,
               "min_to_us_msat": 0,
               "max_to_us_msat": 20000000,
               "total_msat": 1000000000,
               "fee_base_msat": 1,
               "fee_proportional_millionths": 10,
               "dust_limit_msat": 546000,
               "max_total_htlc_in_msat": 18446744073709551615,
               "their_reserve_msat": 10000000,
               "our_reserve_msat": 10000000,
               "spendable_msat": 10000000,
               "receivable_msat": 968598000,
               "minimum_htlc_in_msat": 0,
               "minimum_htlc_out_msat": 0,
               "maximum_htlc_out_msat": 990000000,
               "their_to_self_delay": 6,
               "our_to_self_delay": 6,
               "max_accepted_htlcs": 483,
               "state_changes": [
                  {
                     "timestamp": "2022-12-23T09:23:48.188Z",
                     "old_state": "DUALOPEND_OPEN_INIT",
                     "new_state": "DUALOPEND_AWAITING_LOCKIN",
                     "cause": "remote",
                     "message": "Sigs exchanged, waiting for lock-in"
                  },
                  {
                     "timestamp": "2022-12-23T09:23:52.564Z",
                     "old_state": "DUALOPEND_AWAITING_LOCKIN",
                     "new_state": "CHANNELD_NORMAL",
                     "cause": "remote",
                     "message": "Lockin complete"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.970Z",
                     "old_state": "CHANNELD_NORMAL",
                     "new_state": "AWAITING_UNILATERAL",
                     "cause": "onchain",
                     "message": "Funding transaction spent"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:54.971Z",
                     "old_state": "AWAITING_UNILATERAL",
                     "new_state": "FUNDING_SPEND_SEEN",
                     "cause": "onchain",
                     "message": "Onchain funding spend"
                  },
                  {
                     "timestamp": "2022-12-23T09:40:55.095Z",
                     "old_state": "FUNDING_SPEND_SEEN",
                     "new_state": "ONCHAIN",
                     "cause": "onchain",
                     "message": "Onchain init reply"
                  }
               ],
               "status": [
                  "ONCHAIN:Tracking their illegal close: taking all funds",
                  "ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel"
               ],
               "in_payments_offered": 1,
               "in_offered_msat": 20000000,
               "in_payments_fulfilled": 1,
               "in_fulfilled_msat": 20000000,
               "out_payments_offered": 0,
               "out_offered_msat": 0,
               "out_payments_fulfilled": 0,
               "out_fulfilled_msat": 0,
               "htlcs": []
            }
         ]
      }
   ]
}
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ bitcoin-cli -regtest generatetoaddress 100 bcrt1qutl5spu7e66r79pmq5ehg53jgtau67zf7q73he > /dev/null
◉ tony@tony:~/lnroom/lightning:[git»(HEAD detached at v22.11.1)]
$ l2-cli listpeers
{
   "peers": [
      {
         "id": "02a03ee3b7a66cacfa19c99b2fda36a9e8003f4f85806cd93c31637a10a0679cf6",
         "connected": true,
         "netaddr": [
            "127.0.0.1:44562"
         ],
         "features": "08a0802a2269a2",
         "channels": []
      }
   ]
}

Resources