From 5281bef4f1d6a371349e06547e28403c5aa73686 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Fri, 10 Jul 2020 15:58:31 +0200 Subject: [PATCH 001/126] Create 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 13_0_Understanding_Your_Lightning_Setup.md diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md new file mode 100644 index 0000000..fdd8a91 --- /dev/null +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -0,0 +1,30 @@ +# Chapter Thirteen: Understanding Your Lighting Setup + +You're now ready to begin working with the `lightning-cli` command-line interface. But that first requires that you understand your c-lightning setup and its features, which is what will be explained in this chapter. + +For this and future chapters, we presume that you have a VPS with c-lightning installed, running `lightningd`. We also presume that you are connected to testnet, allowing for access to bitcoins without using real funds. You can either do this by hand, per [§2.1: Setting up a Bitcoin-Core VPS by Hand](02_1_Setting_Up_a_Bitcoin-Core_VPS_by_Hand.md), with Bitcoin Standup at Linode.com, per [§2.2: Setting up a Bitcoin-Core VPS with Bitcoin Standup](02_2_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md), or via other means, per [§2.3: Setting up a Bitcoin-Core Machine via Other Means](02_3_Setting_Up_Bitcoin_Core_Other.md). + +## Objectives for This Chapter + +After working through this chapter, a developer will be able to: + + * Demonstrate that Their c-lightning Node is Installed and Up-to-date + * Use Basic Wallet Commands + * Setting up a channel. + * Pay an invoice + * Generate a payment request. + +Supporting objectives include the ability to: + + * Use Basic Informational Commands + * Understand What a lightning channel Is + * Understand What a invoice Is + * Understand How to pay an invoice + +## Table of Contents + +* [Section One: Verifying Your Lightning Setup](13_1_Verifying_Your_Lightning_Setup.md) +* [Section Two: Knowing Your Lightning Setup](13_2_Knowing_Your_lightning_Setup.md) +* [Section Three: Setting Up a chhanel](13_3_Setting_Up_a_Channel.md) +* [Section Four: Paying an invoice](13_4_Paying_a_Invoice.md) +* [Section Five: Generate a payment request](01_5_Generate_a_Payment_Request.md) From ba90a6914f0d73b09b71123d4b1e17090ad1130e Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Fri, 10 Jul 2020 19:28:20 +0200 Subject: [PATCH 002/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index fdd8a91..7dbe38e 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -8,18 +8,18 @@ For this and future chapters, we presume that you have a VPS with c-lightning in After working through this chapter, a developer will be able to: - * Demonstrate that Their c-lightning Node is Installed and Up-to-date - * Use Basic Wallet Commands + * Demonstrate that their c-lightning Node is Installed and Up-to-date + * Use basic wallet Commands * Setting up a channel. * Pay an invoice * Generate a payment request. Supporting objectives include the ability to: - * Use Basic Informational Commands - * Understand What a lightning channel Is - * Understand What a invoice Is - * Understand How to pay an invoice + * Use Basic Informational Commands. + * Understand what a lightning channel is. + * Understand what a invoice is. + * Understand how to pay an invoice. ## Table of Contents From 174e01dd7447e7a0beaaece8767637492970d74a Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sun, 12 Jul 2020 10:08:17 +0200 Subject: [PATCH 003/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index 7dbe38e..f5995af 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -2,7 +2,8 @@ You're now ready to begin working with the `lightning-cli` command-line interface. But that first requires that you understand your c-lightning setup and its features, which is what will be explained in this chapter. -For this and future chapters, we presume that you have a VPS with c-lightning installed, running `lightningd`. We also presume that you are connected to testnet, allowing for access to bitcoins without using real funds. You can either do this by hand, per [§2.1: Setting up a Bitcoin-Core VPS by Hand](02_1_Setting_Up_a_Bitcoin-Core_VPS_by_Hand.md), with Bitcoin Standup at Linode.com, per [§2.2: Setting up a Bitcoin-Core VPS with Bitcoin Standup](02_2_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md), or via other means, per [§2.3: Setting up a Bitcoin-Core Machine via Other Means](02_3_Setting_Up_Bitcoin_Core_Other.md). +For this and future chapters, we presume that you have a VPS with c-lightning installed, running `lightningd` courtersy of [Bitcoin Standup Script](https://github.com/BlockchainCommons/Bitcoin-Standup-Scripts). +We also presume that you are connected to testnet, allowing for access to bitcoins without using real funds. You can either do this by hand, per [§2.1: Setting up a Bitcoin-Core VPS by Hand](02_1_Setting_Up_a_Bitcoin-Core_VPS_by_Hand.md), with Bitcoin Standup at Linode.com, per [§2.2: Setting up a Bitcoin-Core VPS with Bitcoin Standup](02_2_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md), or via other means, per [§2.3: Setting up a Bitcoin-Core Machine via Other Means](02_3_Setting_Up_Bitcoin_Core_Other.md). ## Objectives for This Chapter From f18fd40cd5109b7772bebeb9a5e19e422a2e66fb Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sun, 12 Jul 2020 10:08:53 +0200 Subject: [PATCH 004/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index f5995af..41fb135 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -2,7 +2,7 @@ You're now ready to begin working with the `lightning-cli` command-line interface. But that first requires that you understand your c-lightning setup and its features, which is what will be explained in this chapter. -For this and future chapters, we presume that you have a VPS with c-lightning installed, running `lightningd` courtersy of [Bitcoin Standup Script](https://github.com/BlockchainCommons/Bitcoin-Standup-Scripts). +For this and future chapters, we presume that you have a VPS with c-lightning installed, running `lightningd` courtersy of [Bitcoin Standup Scripts](https://github.com/BlockchainCommons/Bitcoin-Standup-Scripts). We also presume that you are connected to testnet, allowing for access to bitcoins without using real funds. You can either do this by hand, per [§2.1: Setting up a Bitcoin-Core VPS by Hand](02_1_Setting_Up_a_Bitcoin-Core_VPS_by_Hand.md), with Bitcoin Standup at Linode.com, per [§2.2: Setting up a Bitcoin-Core VPS with Bitcoin Standup](02_2_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md), or via other means, per [§2.3: Setting up a Bitcoin-Core Machine via Other Means](02_3_Setting_Up_Bitcoin_Core_Other.md). ## Objectives for This Chapter From 6f1c6cb7684619ef7fbcccc85a733aa00dc1bf66 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sun, 12 Jul 2020 14:08:06 +0200 Subject: [PATCH 005/126] Create 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 13_1_Verifying_Your_Lightning_Setup.md diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -0,0 +1 @@ + From f27d32166141a3d64508330abd1eff09f43432b8 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sun, 12 Jul 2020 14:20:32 +0200 Subject: [PATCH 006/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 76 ++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index 8b13789..83e7a98 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -1 +1,77 @@ +# 13.1: Verifying Your Lightning Setup + +> :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. + +Before you start playing with c-lightning, you should ensure that everything is setup correctly. + +## Create Your Aliases + +We suggest creating some aliases to make it easier to use c-lightning. + +You can do so by putting them in your `.bash_profile`. +``` +cat >> ~/.bash_profile < Date: Sun, 12 Jul 2020 14:21:30 +0200 Subject: [PATCH 007/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index 83e7a98..f431f48 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -15,7 +15,7 @@ cat >> ~/.bash_profile < Date: Sun, 12 Jul 2020 14:22:14 +0200 Subject: [PATCH 008/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index f431f48..e0a85ef 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -12,7 +12,7 @@ We suggest creating some aliases to make it easier to use c-lightning. You can do so by putting them in your `.bash_profile`. ``` cat >> ~/.bash_profile < Date: Sun, 12 Jul 2020 14:24:40 +0200 Subject: [PATCH 009/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index e0a85ef..579581d 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -35,7 +35,7 @@ If it's not running, you'll want to run `lightningd --network=testnet` by hand. ## Verify your node -You should have the whole blockchain downloaded before you start playing. Just run the `bitcoin-cli getblockcount` alias to see if it's all loaded. +You should have an output like this indicating your node is ready. ``` $ lightning-cli --network=testnet getinfo { @@ -68,9 +68,15 @@ $ lightning-cli --network=testnet getinfo } ``` +If node is still sycing with bitcoin network you should see a message like this. + +``` +"warning_bitcoind_sync": "Bitcoind is not up-to-date with network." +``` + ## Summary: Verifying your Lightning setup -Before you start playing with lightning, you should make sure that your aliases are set up, your lightinnd is running, and your node is synced. You may also want to set up some access to alternative lightning setups, if you're an advanced user. +Before you start playing with lightning, you should make sure that your aliases are set up, your lightningd is running, and your node is synced. You may also want to set up some access to alternative lightning setups, if you're an advanced user. ## What's Next? From 0f26a3ef92857b701f3fb734bc31eb63ef313f43 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sun, 12 Jul 2020 22:00:33 +0200 Subject: [PATCH 010/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index 579581d..8fc4071 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -35,7 +35,8 @@ If it's not running, you'll want to run `lightningd --network=testnet` by hand. ## Verify your node -You should have an output like this indicating your node is ready. +You should have an output like this indicating your node is ready if blockheight shows a height value that match with your most recent number getblockcount `bitcoin-cli getblockcount` command output. + ``` $ lightning-cli --network=testnet getinfo { @@ -73,6 +74,26 @@ If node is still sycing with bitcoin network you should see a message like this. ``` "warning_bitcoind_sync": "Bitcoind is not up-to-date with network." ``` +If you're not up-to-date, you'll get a message to you `getinfo command` like this: +``` +"warning_lightningd_sync": "Still loading latest blocks from bitcoind." +``` + +## Optional: Know Your Server Types + +> **TESTNET vs MAINNET:** When you set up your node, you choose to create it as either a Mainnet, Testnet, or Regtest node. Though this document presumes a testnet setup, it's worth understanding how you might access and use the other setup types — even all on the same machine! But, if you're a first-time user, skip on past this, as it's not necessary for a basic setup. + +When lightningd starts up it usually reads a general configuration file located depending on the network you are using (default: $HOME/.lightning/testnet/config). This can be changed: see –conf and –lightning-dir. + +The type of setup is mainly controlled through the ~/.lightning/config file. If you're running testnet, it probably will be located in ~/.lightning/testnet/config. In next section we will explain how to manage your lightning daemon options or general options. + +``` +~/.lightning/testnet$ ls -la config +-rw-rw-r-- 1 user user 267 jul 12 17:08 config +:~/.lightning/testnet$ + +``` +If you want to run several different sorts of nodes simultaneously, you must leave the testnet (or regtest) flag out of your configuration file. You should then choose whether you're using the mainnet, the testnet, or your regtest every time you run lightningd or lightning-cli. ## Summary: Verifying your Lightning setup From 678a180380f1f9efe785d3c87e2333a3ca0f182f Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sun, 12 Jul 2020 22:21:00 +0200 Subject: [PATCH 011/126] Create 13_2_Knowing_Your_lightning_Setup.md --- 13_2_Knowing_Your_lightning_Setup.md | 228 +++++++++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 13_2_Knowing_Your_lightning_Setup.md diff --git a/13_2_Knowing_Your_lightning_Setup.md b/13_2_Knowing_Your_lightning_Setup.md new file mode 100644 index 0000000..5028bd9 --- /dev/null +++ b/13_2_Knowing_Your_lightning_Setup.md @@ -0,0 +1,228 @@ +# 13.2: Knowing Your Lightning Setup + +> :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. + +Before you start playing with Lightning Network, you may always want to come to a better understanding of your setup. + +## Know Your c-lightning Directory + +To start with, you should understand where everything is kept: the `~/.lightning` directory. + +The main directory just contains as many networks as configured, in this case we have testnet directory. + +``` +$ ls ~/.lightning +testnet +``` + +In your ~/.lightning/testnet directory, you'll find that contains all of the guts: +``` +$ ls ~/.lightning/testnet3 +config gossip_store hsm_secret lightningd.sqlite3 lightningd.sqlite3-journal lightning-rpc +``` + +> :link: **TESTNET vs MAINNET:** If you're using mainnet, then _everything_ will instead be placed in the main `~/.lightning/bitcoin` directory. These various setups _do_ elegantly stack, so if you are using mainnet, testnet, and regtest, you'll find that `~/.lightning/bitcoin` contains your config file and your mainnet data, the `~/.lightning/testnet` directory contains your testnet data, and the `~/.lightning/regtest` directory contains your regtest data. + +## Know Your lightning-cli Commands + +Most of your early work will be done with the `lightning-cli` command, which offers an easy interface to `lightningd`. +``` +$ lightning-cli help +lightning-cli: WARNING: default network changing in 2020: please set network=testnet in config! +=== bitcoin === + +feerates style + Return feerate estimates, either satoshi-per-kw ({style} perkw) or satoshi-per-kb ({style} perkb). + +newaddr [addresstype] + Get a new {bech32, p2sh-segwit} (or all) address to fund a channel (default is bech32) + +reserveinputs outputs [feerate] [minconf] [utxos] + Reserve inputs and pass back the resulting psbt + +sendpsbt psbt + Finalize, extract and send a PSBT. + +signpsbt psbt + Sign this wallet's inputs on a provided PSBT. + +txdiscard txid + Abandon a transaction created by txprepare + +txprepare outputs [feerate] [minconf] [utxos] + Create a transaction, with option to spend in future (either txsend and txdiscard) + +txsend txid + Sign and broadcast a transaction created by txprepare + +unreserveinputs psbt + Unreserve inputs, freeing them up to be reused + +withdraw destination satoshi [feerate] [minconf] [utxos] + Send to {destination} address {satoshi} (or 'all') amount via Bitcoin transaction, at optional {feerate} + +=== channels === + +close id [unilateraltimeout] [destination] [fee_negotiation_step] + Close the channel with {id} (either peer ID, channel ID, or short channel ID). Force a unilateral close after {unilateraltimeout} seconds (default 48h). If {destination} address is provided, will be used as output address. + +fundchannel_cancel id + Cancel inflight channel establishment with peer {id}. + +fundchannel_complete id txid txout + Complete channel establishment with peer {id} for funding transactionwith {txid}. Returns true on success, false otherwise. + +fundchannel_start id amount [feerate] [announce] [close_to] [push_msat] + Start fund channel with {id} using {amount} satoshis. Returns a bech32 address to use as an output for a funding transaction. + +getroute id msatoshi riskfactor [cltv] [fromid] [fuzzpercent] [exclude] [maxhops] + Show route to {id} for {msatoshi}, using {riskfactor} and optional {cltv} (default 9). If specified search from {fromid} otherwise use this node as source. Randomize the route with up to {fuzzpercent} (default 5.0). {exclude} an array of short-channel-id/direction (e.g. [ '564334x877x1/0', '564195x1292x0/1' ]) or node-id from consideration. Set the {maxhops} the route can take (default 20). + +listchannels [short_channel_id] [source] + Show channel {short_channel_id} or {source} (or all known channels, if not specified) + +listforwards + List all forwarded payments and their information + +setchannelfee id [base] [ppm] + Sets specific routing fees for channel with {id} (either peer ID, channel ID, short channel ID or 'all'). Routing fees are defined by a fixed {base} (msat) and a {ppm} (proportional per millionth) value. If values for {base} or {ppm} are left out, defaults will be used. {base} can also be defined in other units, for example '1sat'. If {id} is 'all', the fees will be applied for all channels. + +=== network === + +connect id [host] [port] + Connect to {id} at {host} (which can end in ':port' if not default). {id} can also be of the form id@host + +disconnect id [force] + Disconnect from {id} that has previously been connected to using connect; with {force} set, even if it has a current channel + +listnodes [id] + Show node {id} (or all, if no {id}), in our local network view + +listpeers [id] [level] + Show current peers, if {level} is set, include logs for {id} + +ping id [len] [pongbytes] + Send peer {id} a ping of length {len} (default 128) asking for {pongbytes} (default 128) + +=== payment === + +createonion hops assocdata [session_key] + Create an onion going through the provided nodes, each with its own payload + +decodepay bolt11 [description] + Decode {bolt11}, using {description} if necessary + +delexpiredinvoice [maxexpirytime] + Delete all expired invoices that expired as of given {maxexpirytime} (a UNIX epoch time), or all expired invoices if not specified + +delinvoice label status + Delete unpaid invoice {label} with {status} + +invoice msatoshi label description [expiry] [fallbacks] [preimage] [exposeprivatechannels] + Create an invoice for {msatoshi} with {label} and {description} with optional {expiry} seconds (default 1 week), optional {fallbacks} address list(default empty list) and optional {preimage} (default autogenerated) + +listinvoices [label] + Show invoice {label} (or all, if no {label}) + +listsendpays [bolt11] [payment_hash] + Show sendpay, old and current, optionally limiting to {bolt11} or {payment_hash}. + +listtransactions + List transactions that we stored in the wallet + +sendonion onion first_hop payment_hash [label] [shared_secrets] [partid] + Send a payment with a pre-computed onion. + +sendpay route payment_hash [label] [msatoshi] [bolt11] [payment_secret] [partid] + Send along {route} in return for preimage of {payment_hash} + +waitanyinvoice [lastpay_index] [timeout] + Wait for the next invoice to be paid, after {lastpay_index} (if supplied). If {timeout} seconds is reached while waiting, fail with an error. + +waitinvoice label + Wait for an incoming payment matching the invoice with {label}, or if the invoice expires + +waitsendpay payment_hash [timeout] [partid] + Wait for payment attempt on {payment_hash} to succeed or fail, but only up to {timeout} seconds. + +=== plugin === + +autocleaninvoice [cycle_seconds] [expired_by] + Set up autoclean of expired invoices. + +estimatefees + Get the urgent, normal and slow Bitcoin feerates as sat/kVB. + +fundchannel id amount [feerate] [announce] [minconf] [utxos] [push_msat] + Fund channel with {id} using {amount} (or 'all'), at optional {feerate}. Only use outputs that have {minconf} confirmations. + +getchaininfo + Get the chain id, the header count, the block count, and whether this is IBD. + +getrawblockbyheight height + Get the bitcoin block at a given height + +getutxout txid vout + Get informations about an output, identified by a {txid} an a {vout} + +listpays [bolt11] + List result of payment {bolt11}, or all + +pay bolt11 [msatoshi] [label] [riskfactor] [maxfeepercent] [retry_for] [maxdelay] [exemptfee] + Send payment specified by {bolt11} with {amount} + +paystatus [bolt11] + Detail status of attempts to pay {bolt11}, or all + +plugin subcommand=start|stop|startdir|rescan|list + Control plugins (start, stop, startdir, rescan, list) + +sendrawtransaction tx + Send a raw transaction to the Bitcoin network. + +=== utility === + +check command_to_check + Don't run {command_to_check}, just verify parameters. + +checkmessage message zbase [pubkey] + Verify a digital signature {zbase} of {message} signed with {pubkey} + +getinfo + Show information about this node + +getlog [level] + Show logs, with optional log {level} (info|unusual|debug|io) + +getsharedsecret point + Compute the hash of the Elliptic Curve Diffie Hellman shared secret point from this node private key and an input {point}. + +help [command] + List available commands, or give verbose help on one {command}. + +listconfigs [config] + List all configuration options, or with [config], just that one. + +listfunds + Show available funds from the internal wallet + +signmessage message + Create a digital signature of {message} + +stop + Shut down the lightningd process + +waitblockheight blockheight [timeout] + Wait for the blockchain to reach {blockheight}, up to {timeout} seconds. + +=== developer === + +dev-listaddrs [bip32_max_index] + Show addresses list up to derivation {index} (default is the last bip32 index) + +dev-rescan-outputs + Synchronize the state of our funds with bitcoind + +--- +run `lightning-cli help ` for more information on a specific command +``` From 71352b37157ad896eac0951ca36c8db49d653892 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 13 Jul 2020 10:30:46 +0200 Subject: [PATCH 012/126] Update 13_2_Knowing_Your_lightning_Setup.md --- 13_2_Knowing_Your_lightning_Setup.md | 94 ++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/13_2_Knowing_Your_lightning_Setup.md b/13_2_Knowing_Your_lightning_Setup.md index 5028bd9..a7b35ee 100644 --- a/13_2_Knowing_Your_lightning_Setup.md +++ b/13_2_Knowing_Your_lightning_Setup.md @@ -226,3 +226,97 @@ dev-rescan-outputs --- run `lightning-cli help ` for more information on a specific command ``` + +## Optional: Know your lightning lnfo + +A variety of lightning-cli commands can give you additional information on your lightning node. The most general ones are: +``` +$ lightning-cli listconfigs +$ lightning-cli listfunds +$ lightning-cli listtransactions +$ lightning-cli listinvoices +$ lightning-cli listnodes +``` +For example `lightning-cli getnetworkinfo` gives you a variety of information on your setup and its access to various networks: +``` +lightning-cli --network=testnet listconfigs +{ + "# version": "v0.8.2-398-g869fa08", + "lightning-dir": "/home/user/.lightning", + "network": "testnet", + "allow-deprecated-apis": true, + "rpc-file": "lightning-rpc", + "plugin": "/usr/local/bin/../libexec/c-lightning/plugins/fundchannel", + "plugin": "/usr/local/bin/../libexec/c-lightning/plugins/autoclean", + "plugin": "/usr/local/bin/../libexec/c-lightning/plugins/bcli", + "plugin": "/usr/local/bin/../libexec/c-lightning/plugins/pay", + "plugin": "/usr/local/bin/../libexec/c-lightning/plugins/keysend", + "plugins": [ + { + "path": "/usr/local/bin/../libexec/c-lightning/plugins/fundchannel", + "name": "fundchannel" + }, + { + "path": "/usr/local/bin/../libexec/c-lightning/plugins/autoclean", + "name": "autoclean", + "options": { + "autocleaninvoice-cycle": null, + "autocleaninvoice-expired-by": null + } + }, + { + "path": "/usr/local/bin/../libexec/c-lightning/plugins/bcli", + "name": "bcli", + "options": { + "bitcoin-datadir": null, + "bitcoin-cli": null, + "bitcoin-rpcuser": null, + "bitcoin-rpcpassword": null, + "bitcoin-rpcconnect": null, + "bitcoin-rpcport": null, + "bitcoin-retry-timeout": null, + "commit-fee": "500" + } + }, + { + "path": "/usr/local/bin/../libexec/c-lightning/plugins/pay", + "name": "pay" + }, + { + "path": "/usr/local/bin/../libexec/c-lightning/plugins/keysend", + "name": "keysend" + } + ], + "disable-plugin": [], + "always-use-proxy": false, + "daemon": "false", + "wallet": "sqlite3:///home/user/.lightning/testnet/lightningd.sqlite3", + "wumbo": false, + "wumbo": false, + "rgb": "03fce2", + "alias": "learningBitcoin", + "pid-file": "/home/user/.lightning/lightningd-testnet.pid", + "ignore-fee-limits": false, + "watchtime-blocks": 144, + "max-locktime-blocks": 720, + "funding-confirms": 3, + "commit-fee-min": 200, + "commit-fee-max": 2000, + "cltv-delta": 6, + "cltv-final": 10, + "commit-time": 10, + "fee-base": 1, + "rescan": 15, + "fee-per-satoshi": 10, + "max-concurrent-htlcs": 483, + "min-capacity-sat": 10000, + "offline": "false", + "autolisten": true, + "disable-dns": "false", + "enable-autotor-v2-mode": "false", + "encrypted-hsm": false, + "rpc-file-mode": "0600", + "log-level": "DEBUG", + "log-prefix": "lightningd" +} +``` From c3944aa4e75cc0e06d09cd4c06d9fd743b31b24a Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 13 Jul 2020 10:31:47 +0200 Subject: [PATCH 013/126] Update 13_2_Knowing_Your_lightning_Setup.md --- 13_2_Knowing_Your_lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_2_Knowing_Your_lightning_Setup.md b/13_2_Knowing_Your_lightning_Setup.md index a7b35ee..ac14e9b 100644 --- a/13_2_Knowing_Your_lightning_Setup.md +++ b/13_2_Knowing_Your_lightning_Setup.md @@ -237,7 +237,7 @@ $ lightning-cli listtransactions $ lightning-cli listinvoices $ lightning-cli listnodes ``` -For example `lightning-cli getnetworkinfo` gives you a variety of information on your setup and its access to various networks: +For example `lightning-cli listconfigs` gives you a variety of information on your setup: ``` lightning-cli --network=testnet listconfigs { From 17ab36071500da83e8b4335decb4f756e00f8bea Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 13 Jul 2020 10:35:25 +0200 Subject: [PATCH 014/126] Update 13_2_Knowing_Your_lightning_Setup.md --- 13_2_Knowing_Your_lightning_Setup.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/13_2_Knowing_Your_lightning_Setup.md b/13_2_Knowing_Your_lightning_Setup.md index ac14e9b..2030e59 100644 --- a/13_2_Knowing_Your_lightning_Setup.md +++ b/13_2_Knowing_Your_lightning_Setup.md @@ -320,3 +320,11 @@ lightning-cli --network=testnet listconfigs "log-prefix": "lightningd" } ``` + +## Summary: Knowing Your lightning Setup + +The `~/.lightning` directory contains all of your files, while `lightning-cli help` and a variety of info commands can be used to get more information on how your setup and Lightning Network work. + +## What's Next? + +Continue "Understanding Your Lightning Setup" with [§13.3: Setting Up_a_Channel](13_3_Setting_Up_a_Channel.md). From 92d244cb32430aa5d4138222f203b900a7b1dcbb Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 13 Jul 2020 13:25:10 +0200 Subject: [PATCH 015/126] Create 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 13_3_Setting_Up_a_Channel.md diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/13_3_Setting_Up_a_Channel.md @@ -0,0 +1 @@ + From b351f79b423d8150144cc809a0218988d008be30 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 14 Jul 2020 16:38:55 +0200 Subject: [PATCH 016/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 8b13789..9f9000c 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -1 +1,71 @@ +# 13.3: Setting Up a Channel +> :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. + +You're now ready to your first lightning network channel. To begin with, you'll need to understand what is and how it's created an c-lightning channel. + +## What is a channel + +In simple terms a lightning channel is a money tube that allows fast, cheap and private transfers of money without sending transactions to the blockchain. +More technically a channel is a 2-of-2 multisignature bitcoin onchain transaction that establishes a financial relationship between two agents without trust. +As we seen in [§6.1:Sending a transaction to a multisig](06_1_Sending_a_Transaction_to_a_Multisig.md) chapter multisignatures are generally described as being "m of n". That means that the transaction is locked with a group of "n" keys, but only "m" of them are required to unlock the transaction. + +Channels on the Lightning Network always are created between two nodes. The channel mantains a local database with bitcoin balance for both parts keeping track of how much money they each have. + +In this chapter we will use testnet network and will use c-lightning as primary node to show all processes related but we will use a lnd node too to create a channel with it. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. + +### Steps to create a channel + +* Fund your c-lightning wallet with some satoshis. +* Connect to remote node as a peer. +* Open channel. + +#### Fund you c-lightning wallet. + +The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using this command an send it money. This is done with the `lightning-cli newaddr` command. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bench32. + +``` +$ lightning-cli --network=testnet newaddr +{ + "address": "tb1qefule33u7ukfuzkmxpz02kwejl8j8dt5jpgtu6", + "bech32": "tb1qefule33u7ukfuzkmxpz02kwejl8j8dt5jpgtu6" +} +``` + +To check you local balance you should use `lightning-cli listfunds` command: + +``` +lightning-cli --network=testnet listfunds +{ + "outputs": [], + "channels": [] +} +``` + +Since we still do not have the confirmed transaction we do not have a balance, after 6 confirmations we should see balance available: + +``` +lightning-cli --network=testnet listfunds +{ + "outputs": [], + "channels": [] +} +``` + + +Later we send some sats to this address in this transaction [11094bb9ac29ce5af9f1e5a0e4aac2066ae132f25b72bff90fcddf64bf2feb02](https://blockstream.info/testnet/tx/11094bb9ac29ce5af9f1e5a0e4aac2066ae132f25b72bff90fcddf64bf2feb02) + + +#### Connect to remote node + +The first thing you need to do is connect your node to a peer. This is done with the `lightning-cli connect` command. Remember that if you want more information on this command, you should type `lightning-cli help connect`. + +#### Open channel + + +In this example we will use two lightning nodes running c-lightning and LND implmentations. + +``` +$ lightning-cli getinfo +moKVV6XEhfrBCE3QCYq6ppT7AaMF8KsZ1B +``` From 51a18472dd471e7e24ca739910ac7e1545e00eb8 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 14 Jul 2020 16:41:26 +0200 Subject: [PATCH 017/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index 41fb135..9f56c5e 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -26,6 +26,6 @@ Supporting objectives include the ability to: * [Section One: Verifying Your Lightning Setup](13_1_Verifying_Your_Lightning_Setup.md) * [Section Two: Knowing Your Lightning Setup](13_2_Knowing_Your_lightning_Setup.md) -* [Section Three: Setting Up a chhanel](13_3_Setting_Up_a_Channel.md) +* [Section Three: Setting Up a channel](13_3_Setting_Up_a_Channel.md) * [Section Four: Paying an invoice](13_4_Paying_a_Invoice.md) * [Section Five: Generate a payment request](01_5_Generate_a_Payment_Request.md) From 3397b78b76cd021331cb9a61272290f5daef5487 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 14 Jul 2020 20:28:16 +0200 Subject: [PATCH 018/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 118 +++++++++++++++++++++++++++++++++-- 1 file changed, 113 insertions(+), 5 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 9f9000c..4dc4421 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -35,7 +35,7 @@ $ lightning-cli --network=testnet newaddr To check you local balance you should use `lightning-cli listfunds` command: ``` -lightning-cli --network=testnet listfunds +$ lightning-cli --network=testnet listfunds { "outputs": [], "channels": [] @@ -45,20 +45,128 @@ lightning-cli --network=testnet listfunds Since we still do not have the confirmed transaction we do not have a balance, after 6 confirmations we should see balance available: ``` -lightning-cli --network=testnet listfunds +$ lightning-cli --network=testnet listfunds { "outputs": [], "channels": [] } ``` - Later we send some sats to this address in this transaction [11094bb9ac29ce5af9f1e5a0e4aac2066ae132f25b72bff90fcddf64bf2feb02](https://blockstream.info/testnet/tx/11094bb9ac29ce5af9f1e5a0e4aac2066ae132f25b72bff90fcddf64bf2feb02) +Now that we have funded our c-lightning wallet we will get information about remote node to start creating channel process. On LND nodes you can get information about your node using `lncli -n testnet getinfo`: + +``` +lncli -n testnet getinfo +{ + "version": "0.10.99-beta commit=clock/v1.0.0-171-g8cb1276dbf0bfd9fcbf599df87a43238e599eaac", + "commit_hash": "8cb1276dbf0bfd9fcbf599df87a43238e599eaac", + "identity_pubkey": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "alias": "0302d48972ba7eef8b40", + "color": "#3399ff", + "num_pending_channels": 0, + "num_active_channels": 0, + "num_inactive_channels": 0, + "num_peers": 0, + "block_height": 1780686, + "block_hash": "000000000000000beb29fa5d3afb713a253f949b12f5f5be25935bb26764e321", + "best_header_timestamp": "1594737322", + "synced_to_chain": true, + "synced_to_graph": true, + "testnet": true, + "chains": [ + { + "chain": "bitcoin", + "network": "testnet" + } + ], + "uris": [ + ], + "features": { + "0": { + "name": "data-loss-protect", + "is_required": true, + "is_known": true + }, + "5": { + "name": "upfront-shutdown-script", + "is_required": false, + "is_known": true + }, + "7": { + "name": "gossip-queries", + "is_required": false, + "is_known": true + }, + "9": { + "name": "tlv-onion", + "is_required": false, + "is_known": true + }, + "13": { + "name": "static-remote-key", + "is_required": false, + "is_known": true + }, + "15": { + "name": "payment-addr", + "is_required": false, + "is_known": true + }, + "17": { + "name": "multi-path-payments", + "is_required": false, + "is_known": true + } + } +} +``` #### Connect to remote node -The first thing you need to do is connect your node to a peer. This is done with the `lightning-cli connect` command. Remember that if you want more information on this command, you should type `lightning-cli help connect`. +The first thing you need to do is connect your node to a peer. This is done with the `lightning-cli connect` command. Remember that if you want more information on this command, you should type `lightning-cli help connect`. The connect RPC command establishes a new connection with another node in the Lightning Network. + +To connect your node to a remote peer you need it's id that represents the target node’s public key. As a convenience, id may be of the form id@host or id@host:port. In this case, the port parameter must be changed due we're running two nodes on the same machine, c-lightning node it's running on 9735 default port and we've started LND node on 9736 port with this parameter. + +``` +$ lnd --listen=0.0.0.0:9736 +``` +We can check it's listening on 9736 port using this command: + +``` +$ netstat -aon | grep 9736 +tcp6 0 0 :::9736 :::* LISTEN off (0.00/0/0) +$ +``` +Now we can use `lightning-cli connect` command to reach node as a peer: + +``` +$ lightning-cli --network=testnet connect 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84@127.0.0.1:9736 +{ + "id": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "features": "02a2a1" +} +``` + +To check out: + +``` +$ lightning-cli --network=testnet listpeers +{ + "peers": [ + { + "id": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "connected": true, + "netaddr": [ + "127.0.0.1:9736" + ], + "features": "02a2a1", + "channels": [] + } + ] +} +``` +On success, an object with a “peers” key is returned containing a list distinct objects. Object features are bit flags showing supported features (BOLT #9). #### Open channel @@ -67,5 +175,5 @@ In this example we will use two lightning nodes running c-lightning and LND impl ``` $ lightning-cli getinfo -moKVV6XEhfrBCE3QCYq6ppT7AaMF8KsZ1B + ``` From 3d2214f6bf1846fdc7cdaf44d3d7a87561df9c4c Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 14 Jul 2020 20:36:28 +0200 Subject: [PATCH 019/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 4dc4421..85dc181 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -22,7 +22,7 @@ In this chapter we will use testnet network and will use c-lightning as primary #### Fund you c-lightning wallet. -The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using this command an send it money. This is done with the `lightning-cli newaddr` command. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bench32. +The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using `lightning-cli newaddr` command to use it later. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bench32. ``` $ lightning-cli --network=testnet newaddr @@ -31,6 +31,7 @@ $ lightning-cli --network=testnet newaddr "bech32": "tb1qefule33u7ukfuzkmxpz02kwejl8j8dt5jpgtu6" } ``` +We send some sats to this address in this transaction [11094bb9ac29ce5af9f1e5a0e4aac2066ae132f25b72bff90fcddf64bf2feb02](https://blockstream.info/testnet/tx/11094bb9ac29ce5af9f1e5a0e4aac2066ae132f25b72bff90fcddf64bf2feb02) To check you local balance you should use `lightning-cli listfunds` command: @@ -42,7 +43,7 @@ $ lightning-cli --network=testnet listfunds } ``` -Since we still do not have the confirmed transaction we do not have a balance, after 6 confirmations we should see balance available: +Since we still do not have 6 confirmations we do not have a balance, after 6 confirmations we should see balance available: ``` $ lightning-cli --network=testnet listfunds @@ -52,8 +53,6 @@ $ lightning-cli --network=testnet listfunds } ``` -Later we send some sats to this address in this transaction [11094bb9ac29ce5af9f1e5a0e4aac2066ae132f25b72bff90fcddf64bf2feb02](https://blockstream.info/testnet/tx/11094bb9ac29ce5af9f1e5a0e4aac2066ae132f25b72bff90fcddf64bf2feb02) - Now that we have funded our c-lightning wallet we will get information about remote node to start creating channel process. On LND nodes you can get information about your node using `lncli -n testnet getinfo`: ``` @@ -166,11 +165,10 @@ $ lightning-cli --network=testnet listpeers ] } ``` -On success, an object with a “peers” key is returned containing a list distinct objects. Object features are bit flags showing supported features (BOLT #9). +On success, an object with a “peers” key is returned containing a list distinct objects. Object features are bit flags showing supported features. #### Open channel - In this example we will use two lightning nodes running c-lightning and LND implmentations. ``` From 82d953965aaf510641618ec29eab5c7dc465f85c Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 15 Jul 2020 13:23:25 +0200 Subject: [PATCH 020/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 85dc181..37b943c 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -48,15 +48,28 @@ Since we still do not have 6 confirmations we do not have a balance, after 6 co ``` $ lightning-cli --network=testnet listfunds { - "outputs": [], + "outputs": [ + { + "txid": "11094bb9ac29ce5af9f1e5a0e4aac2066ae132f25b72bff90fcddf64bf2feb02", + "output": 0, + "value": 300000, + "amount_msat": "300000000msat", + "scriptpubkey": "0014ca79fcc63cf72c9e0adb3044f559d997cf23b574", + "address": "tb1qefule33u7ukfuzkmxpz02kwejl8j8dt5jpgtu6", + "status": "confirmed", + "blockheight": 1780680, + "reserved": false + } + ], "channels": [] } + ``` Now that we have funded our c-lightning wallet we will get information about remote node to start creating channel process. On LND nodes you can get information about your node using `lncli -n testnet getinfo`: ``` -lncli -n testnet getinfo +$ lncli -n testnet getinfo { "version": "0.10.99-beta commit=clock/v1.0.0-171-g8cb1276dbf0bfd9fcbf599df87a43238e599eaac", "commit_hash": "8cb1276dbf0bfd9fcbf599df87a43238e599eaac", From befab0645a4820d520e8e6ed3505cd53603865a2 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 15 Jul 2020 15:43:44 +0200 Subject: [PATCH 021/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 58 ++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 37b943c..4c6b528 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -182,9 +182,63 @@ On success, an object with a “peers” key is returned containing a list disti #### Open channel -In this example we will use two lightning nodes running c-lightning and LND implmentations. +The fundchannel RPC command opens a payment channel with a peer by committing a funding transaction to the blockchain. You should use `lightning-cli fundchannel` command that receives this parameters: + +* **id** is the peer id obtained from connect. + +* **amount** is the amount in satoshis taken from the internal wallet to fund the channel. The value cannot be less than the dust limit, currently set to 546, nor more than 16777215 satoshi (unless large channels were negotiated with the peer). + +* **feerate** is an optional feerate used for the opening transaction and as initial feerate for commitment and HTLC transactions. + +* **announce** is an optional flag that triggers whether to announce this channel or not. Defaults to true. If you want to create an unannounced private channel put to false. + +* **minconf** specifies the minimum number of confirmations that used outputs should have. Default is 1. + +* **utxos** specifies the utxos to be used to fund the channel, as an array of “txid:vout”. + +Now we open the channel like this: ``` -$ lightning-cli getinfo +$ lightning-cli --network=testnet fundchannel 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 280000 urgent true 1 +{ + "tx": "0200000000010102eb2fbf64dfcd0ff9bf725bf232e16a06c2aae4a0e5f1f95ace29acb94b09110000000000feffffff02264b000000000000160014aa572371f29310cd677d039cdcd054156c1a9545c045040000000000220020c1ebc407d32cd1fdcd7c0deb6817243b2b982cdaf3c70413f9d3ead29c36f11f024730440220676592b102ee659dfe5ac3acddbe35885140a8476ae7dbbb2f53a939cc815ac0022057a66de1ea16644008791d5cd510439bac00def02cbaa46d04febfe1d5e7e1e001210284368eca82346929a1c3ee2625077571b434b4c8111b81a715dfce5ea86dce1f1f2c1b00", + "txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "channel_id": "a67ad9b15cb10b74a584a284f059866dd2114e45f2a997b260464af537c04399" +} +``` +To confirm channel status use `lightning-cli listfunds` command: ``` +lightning-cli --network=testnet listfunds +{ + "outputs": [ + { + "txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "output": 0, + "value": 19238, + "amount_msat": "19238000msat", + "scriptpubkey": "0014aa572371f29310cd677d039cdcd054156c1a9545", + "address": "tb1q4ftjxu0jjvgv6emaqwwde5z5z4kp49299gmdpd", + "status": "confirmed", + "blockheight": 1780768, + "reserved": false + } + ], + "channels": [ + { + "peer_id": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "connected": true, + "state": "CHANNELD_AWAITING_LOCKIN", + "channel_sat": 280000, + "our_amount_msat": "280000000msat", + "channel_total_sat": 280000, + "amount_msat": "280000000msat", + "funding_txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "funding_output": 1 + } + ] +} +``` +While the channel with 280.000 satoshis is confirmed its state will be CHANNELD_AWAITING_LOCKIN and we got an change output with 19238 sats. +As we're using testnet network these values are used as an example to show the different states that a channel can have. In a channel with real funds, the actual mining circumstances of the mainnet network must be taken into account. + From a63b9cd88d11f3c7619fbdec80484f36a3a5e45a Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 15 Jul 2020 16:08:49 +0200 Subject: [PATCH 022/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 4c6b528..fcdb9b6 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -180,7 +180,7 @@ $ lightning-cli --network=testnet listpeers ``` On success, an object with a “peers” key is returned containing a list distinct objects. Object features are bit flags showing supported features. -#### Open channel +#### Open a channel The fundchannel RPC command opens a payment channel with a peer by committing a funding transaction to the blockchain. You should use `lightning-cli fundchannel` command that receives this parameters: @@ -239,6 +239,22 @@ lightning-cli --network=testnet listfunds ] } ``` -While the channel with 280.000 satoshis is confirmed its state will be CHANNELD_AWAITING_LOCKIN and we got an change output with 19238 sats. +While the channel with 280.000 satoshis (Channel capacity) is confirmed its state will be CHANNELD_AWAITING_LOCKIN and we got an change output with 19238 sats. As we're using testnet network these values are used as an example to show the different states that a channel can have. In a channel with real funds, the actual mining circumstances of the mainnet network must be taken into account. +The funding_txid onchain is [9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6](https://blockstream.info/testnet/tx/9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6) + +#### Channel capacity + +As we said before both sides of the channel own a portion of its capacity. The amount on your side of the channel is called *local balance* and the amount on your peer’s side is called *remote balance*. Both balances can be updated many times without closing the channel (sending final balance to the blockchain), but the channel capacity cannot change without closing or splicing it. Next chapter we will deep creating and paying invoices. + + +## Summary: Setting up a channel + +You need to create a channel with remote nodes to be able to receive and send money over the lightning network. Further a maintenance task is required to the channels to keep them balanced. + +## What's Next? + +Continue "Understanding Your Lightning Setup" with [§13.4: Paying_a_Invoice](13_4_Paying_a_Invoice.md). + + From 9f2b385ffc046ca4ab4bbb740606c0c03b1dcd94 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 15 Jul 2020 16:10:26 +0200 Subject: [PATCH 023/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index 9f56c5e..3cce815 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -1,6 +1,6 @@ # Chapter Thirteen: Understanding Your Lighting Setup -You're now ready to begin working with the `lightning-cli` command-line interface. But that first requires that you understand your c-lightning setup and its features, which is what will be explained in this chapter. +In this chapter you'll be ready to begin working with the `lightning-cli` command-line interface. But that first requires that you understand your c-lightning setup and its features, which is what will be explained. For this and future chapters, we presume that you have a VPS with c-lightning installed, running `lightningd` courtersy of [Bitcoin Standup Scripts](https://github.com/BlockchainCommons/Bitcoin-Standup-Scripts). We also presume that you are connected to testnet, allowing for access to bitcoins without using real funds. You can either do this by hand, per [§2.1: Setting up a Bitcoin-Core VPS by Hand](02_1_Setting_Up_a_Bitcoin-Core_VPS_by_Hand.md), with Bitcoin Standup at Linode.com, per [§2.2: Setting up a Bitcoin-Core VPS with Bitcoin Standup](02_2_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md), or via other means, per [§2.3: Setting up a Bitcoin-Core Machine via Other Means](02_3_Setting_Up_Bitcoin_Core_Other.md). From 4f00e6c8132ba5ae559e9ceb8aabbe819b3f7bc8 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 15 Jul 2020 16:11:27 +0200 Subject: [PATCH 024/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index 3cce815..18712c9 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -1,6 +1,6 @@ # Chapter Thirteen: Understanding Your Lighting Setup -In this chapter you'll be ready to begin working with the `lightning-cli` command-line interface. But that first requires that you understand your c-lightning setup and its features, which is what will be explained. +In this chapter you'll be ready to begin working with the `lightning-cli` command-line interface. But that first requires that you understand your c-lightning setup and its features, which is what will be explained with some examples and basic configuration. For this and future chapters, we presume that you have a VPS with c-lightning installed, running `lightningd` courtersy of [Bitcoin Standup Scripts](https://github.com/BlockchainCommons/Bitcoin-Standup-Scripts). We also presume that you are connected to testnet, allowing for access to bitcoins without using real funds. You can either do this by hand, per [§2.1: Setting up a Bitcoin-Core VPS by Hand](02_1_Setting_Up_a_Bitcoin-Core_VPS_by_Hand.md), with Bitcoin Standup at Linode.com, per [§2.2: Setting up a Bitcoin-Core VPS with Bitcoin Standup](02_2_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md), or via other means, per [§2.3: Setting up a Bitcoin-Core Machine via Other Means](02_3_Setting_Up_Bitcoin_Core_Other.md). From 6023ee54801eb39882bc7e57477ae7bcbf0186b7 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 15 Jul 2020 16:23:56 +0200 Subject: [PATCH 025/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index fcdb9b6..8e0cef3 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -22,7 +22,7 @@ In this chapter we will use testnet network and will use c-lightning as primary #### Fund you c-lightning wallet. -The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using `lightning-cli newaddr` command to use it later. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bench32. +The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using `lightning-cli newaddr` command to use it later. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This last transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bench32. ``` $ lightning-cli --network=testnet newaddr From aa0c4323c11629bfa07ad03067d80a09b002e303 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 15 Jul 2020 16:25:00 +0200 Subject: [PATCH 026/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 8e0cef3..5896fdc 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -43,7 +43,7 @@ $ lightning-cli --network=testnet listfunds } ``` -Since we still do not have 6 confirmations we do not have a balance, after 6 confirmations we should see balance available: +Since we still do not have 6 confirmations we do not have balance available, after 6 confirmations we should see balance: ``` $ lightning-cli --network=testnet listfunds From bb78907c99b5454dccb421773a363706c69313eb Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 15 Jul 2020 16:31:34 +0200 Subject: [PATCH 027/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index 18712c9..8943bdd 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -1,5 +1,7 @@ # Chapter Thirteen: Understanding Your Lighting Setup +> :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. + In this chapter you'll be ready to begin working with the `lightning-cli` command-line interface. But that first requires that you understand your c-lightning setup and its features, which is what will be explained with some examples and basic configuration. For this and future chapters, we presume that you have a VPS with c-lightning installed, running `lightningd` courtersy of [Bitcoin Standup Scripts](https://github.com/BlockchainCommons/Bitcoin-Standup-Scripts). From 7288918b4b0fd12bdc1c6d8548c1cc656d32ba53 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 11:30:35 +0200 Subject: [PATCH 028/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index 8fc4071..71aa385 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -74,7 +74,7 @@ If node is still sycing with bitcoin network you should see a message like this. ``` "warning_bitcoind_sync": "Bitcoind is not up-to-date with network." ``` -If you're not up-to-date, you'll get a message to you `getinfo command` like this: +If your lightning daemon is not up-to-date, you'll get a message to you `getinfo command` like this: ``` "warning_lightningd_sync": "Still loading latest blocks from bitcoind." ``` From ffbf2586abd2196b486984b6ac77c70fd7555060 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 12:51:48 +0200 Subject: [PATCH 029/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index 71aa385..19dae75 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -3,6 +3,10 @@ > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. +> :book: ***What is Lightning Network?*** + +Lightning Network is a decentralized network using smart contract functionality in the bitcoin blockchain to enable instant payments across a network of participants. Lightning is build like a layer-2 protocol that interacts with Bitcoin to allow users to exchange their bitcoins "off-chain". + Before you start playing with c-lightning, you should ensure that everything is setup correctly. ## Create Your Aliases From ca0c23fc6d80c413820b1e98897b288331254f3b Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 13:04:08 +0200 Subject: [PATCH 030/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index 19dae75..cff4170 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -5,9 +5,9 @@ > :book: ***What is Lightning Network?*** -Lightning Network is a decentralized network using smart contract functionality in the bitcoin blockchain to enable instant payments across a network of participants. Lightning is build like a layer-2 protocol that interacts with Bitcoin to allow users to exchange their bitcoins "off-chain". +Lightning Network is a decentralized network using smart contract functionality in the bitcoin blockchain to enable instant payments across a network of participants. Lightning is builded like a layer-2 protocol that interacts with Bitcoin to allow users to exchange their bitcoins "off-chain". -Before you start playing with c-lightning, you should ensure that everything is setup correctly. +This tutorial uses the standard-compliant c-lightning implementation as its trusted Lightning server. Before you start playing with c-lightning, you should ensure that everything is setup correctly. ## Create Your Aliases From 169bc6f2a92685e6c539446d47fa29e3a32f5a43 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 14:14:14 +0200 Subject: [PATCH 031/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 5896fdc..f7f5af1 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -8,11 +8,9 @@ You're now ready to your first lightning network channel. To begin with, you'll In simple terms a lightning channel is a money tube that allows fast, cheap and private transfers of money without sending transactions to the blockchain. More technically a channel is a 2-of-2 multisignature bitcoin onchain transaction that establishes a financial relationship between two agents without trust. -As we seen in [§6.1:Sending a transaction to a multisig](06_1_Sending_a_Transaction_to_a_Multisig.md) chapter multisignatures are generally described as being "m of n". That means that the transaction is locked with a group of "n" keys, but only "m" of them are required to unlock the transaction. +Channels on the Lightning Network always are created between two nodes. The channel mantains a local database with bitcoin balance for both parts keeping track of how much money they each have. The two users can then exchange bitcoins through their Lightning channel without ever writing to the Bitcoin blockchain. Only when they want to close out their channel do they settle their bitcoins, based on the final division of coins. -Channels on the Lightning Network always are created between two nodes. The channel mantains a local database with bitcoin balance for both parts keeping track of how much money they each have. - -In this chapter we will use testnet network and will use c-lightning as primary node to show all processes related but we will use a lnd node too to create a channel with it. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. +> :warning: **WARNING:** In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related but we will use a second lnd node too to create a channel with it. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. ### Steps to create a channel From f6b7b9f4df395a264694dc59a21ea0d0abd09532 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 14:15:16 +0200 Subject: [PATCH 032/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index f7f5af1..d9d493b 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -10,7 +10,7 @@ In simple terms a lightning channel is a money tube that allows fast, cheap and More technically a channel is a 2-of-2 multisignature bitcoin onchain transaction that establishes a financial relationship between two agents without trust. Channels on the Lightning Network always are created between two nodes. The channel mantains a local database with bitcoin balance for both parts keeping track of how much money they each have. The two users can then exchange bitcoins through their Lightning channel without ever writing to the Bitcoin blockchain. Only when they want to close out their channel do they settle their bitcoins, based on the final division of coins. -> :warning: **WARNING:** In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related but we will use a second lnd node too to create a channel with it. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. +> :warning: **WARNING:** In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related but we will use a second lnd node too to create a channel with it. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. All c-lightning commands will use prompt shell c$ and LND commans will use prompt shell lnd$. ### Steps to create a channel From 182d94000525581ddde44d62fee15d87156ca984 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 14:16:11 +0200 Subject: [PATCH 033/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index d9d493b..a577497 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -10,7 +10,7 @@ In simple terms a lightning channel is a money tube that allows fast, cheap and More technically a channel is a 2-of-2 multisignature bitcoin onchain transaction that establishes a financial relationship between two agents without trust. Channels on the Lightning Network always are created between two nodes. The channel mantains a local database with bitcoin balance for both parts keeping track of how much money they each have. The two users can then exchange bitcoins through their Lightning channel without ever writing to the Bitcoin blockchain. Only when they want to close out their channel do they settle their bitcoins, based on the final division of coins. -> :warning: **WARNING:** In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related but we will use a second lnd node too to create a channel with it. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. All c-lightning commands will use prompt shell c$ and LND commans will use prompt shell lnd$. +> :warning: **WARNING:** In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related but we will use a second lnd node too to create a channel with it. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. All c-lightning commands will use prompt shell c$ and LND commands will use prompt shell lnd$. ### Steps to create a channel From 9b5014fad4af808b96ce1da1f98587887ca9e74b Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 14:20:14 +0200 Subject: [PATCH 034/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index a577497..4d38741 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -10,7 +10,7 @@ In simple terms a lightning channel is a money tube that allows fast, cheap and More technically a channel is a 2-of-2 multisignature bitcoin onchain transaction that establishes a financial relationship between two agents without trust. Channels on the Lightning Network always are created between two nodes. The channel mantains a local database with bitcoin balance for both parts keeping track of how much money they each have. The two users can then exchange bitcoins through their Lightning channel without ever writing to the Bitcoin blockchain. Only when they want to close out their channel do they settle their bitcoins, based on the final division of coins. -> :warning: **WARNING:** In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related but we will use a second lnd node too to create a channel with it. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. All c-lightning commands will use prompt shell c$ and LND commands will use prompt shell lnd$. +> :warning: **WARNING:** In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related but we will use a second lnd node too to create a channel with it. All c-lightning commands will use prompt shell c$ and LND commands will use prompt shell lnd$. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. ### Steps to create a channel From 956e34cc9657544525e58dd429dd516fa746124c Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 14:52:24 +0200 Subject: [PATCH 035/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 4d38741..da4253d 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -4,7 +4,7 @@ You're now ready to your first lightning network channel. To begin with, you'll need to understand what is and how it's created an c-lightning channel. -## What is a channel +> :book: ***What is a channel In simple terms a lightning channel is a money tube that allows fast, cheap and private transfers of money without sending transactions to the blockchain. More technically a channel is a 2-of-2 multisignature bitcoin onchain transaction that establishes a financial relationship between two agents without trust. From 376e4804030834225a9b7ac4a1f98bf6996a55e1 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 14:53:44 +0200 Subject: [PATCH 036/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index da4253d..6c3f735 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -23,7 +23,7 @@ Channels on the Lightning Network always are created between two nodes. The chan The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using `lightning-cli newaddr` command to use it later. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This last transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bench32. ``` -$ lightning-cli --network=testnet newaddr +c$ lightning-cli --network=testnet newaddr { "address": "tb1qefule33u7ukfuzkmxpz02kwejl8j8dt5jpgtu6", "bech32": "tb1qefule33u7ukfuzkmxpz02kwejl8j8dt5jpgtu6" @@ -34,7 +34,7 @@ We send some sats to this address in this transaction [11094bb9ac29ce5af9f1e5a0e To check you local balance you should use `lightning-cli listfunds` command: ``` -$ lightning-cli --network=testnet listfunds +c$ lightning-cli --network=testnet listfunds { "outputs": [], "channels": [] @@ -44,7 +44,7 @@ $ lightning-cli --network=testnet listfunds Since we still do not have 6 confirmations we do not have balance available, after 6 confirmations we should see balance: ``` -$ lightning-cli --network=testnet listfunds +c$ lightning-cli --network=testnet listfunds { "outputs": [ { @@ -67,7 +67,7 @@ $ lightning-cli --network=testnet listfunds Now that we have funded our c-lightning wallet we will get information about remote node to start creating channel process. On LND nodes you can get information about your node using `lncli -n testnet getinfo`: ``` -$ lncli -n testnet getinfo +lnd$ lncli -n testnet getinfo { "version": "0.10.99-beta commit=clock/v1.0.0-171-g8cb1276dbf0bfd9fcbf599df87a43238e599eaac", "commit_hash": "8cb1276dbf0bfd9fcbf599df87a43238e599eaac", @@ -139,19 +139,19 @@ The first thing you need to do is connect your node to a peer. This is done with To connect your node to a remote peer you need it's id that represents the target node’s public key. As a convenience, id may be of the form id@host or id@host:port. In this case, the port parameter must be changed due we're running two nodes on the same machine, c-lightning node it's running on 9735 default port and we've started LND node on 9736 port with this parameter. ``` -$ lnd --listen=0.0.0.0:9736 +lnd$ lnd --listen=0.0.0.0:9736 ``` We can check it's listening on 9736 port using this command: ``` -$ netstat -aon | grep 9736 +c$ netstat -aon | grep 9736 tcp6 0 0 :::9736 :::* LISTEN off (0.00/0/0) -$ +c$ ``` Now we can use `lightning-cli connect` command to reach node as a peer: ``` -$ lightning-cli --network=testnet connect 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84@127.0.0.1:9736 +c$ lightning-cli --network=testnet connect 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84@127.0.0.1:9736 { "id": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", "features": "02a2a1" @@ -161,7 +161,7 @@ $ lightning-cli --network=testnet connect 0302d48972ba7eef8b40696102ad114090fd4c To check out: ``` -$ lightning-cli --network=testnet listpeers +c$ lightning-cli --network=testnet listpeers { "peers": [ { @@ -197,7 +197,7 @@ The fundchannel RPC command opens a payment channel with a peer by committing a Now we open the channel like this: ``` -$ lightning-cli --network=testnet fundchannel 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 280000 urgent true 1 +c$ lightning-cli --network=testnet fundchannel 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 280000 urgent true 1 { "tx": "0200000000010102eb2fbf64dfcd0ff9bf725bf232e16a06c2aae4a0e5f1f95ace29acb94b09110000000000feffffff02264b000000000000160014aa572371f29310cd677d039cdcd054156c1a9545c045040000000000220020c1ebc407d32cd1fdcd7c0deb6817243b2b982cdaf3c70413f9d3ead29c36f11f024730440220676592b102ee659dfe5ac3acddbe35885140a8476ae7dbbb2f53a939cc815ac0022057a66de1ea16644008791d5cd510439bac00def02cbaa46d04febfe1d5e7e1e001210284368eca82346929a1c3ee2625077571b434b4c8111b81a715dfce5ea86dce1f1f2c1b00", "txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", @@ -207,7 +207,7 @@ $ lightning-cli --network=testnet fundchannel 0302d48972ba7eef8b40696102ad114090 To confirm channel status use `lightning-cli listfunds` command: ``` -lightning-cli --network=testnet listfunds +c$ lightning-cli --network=testnet listfunds { "outputs": [ { From db882eb6dd46d8adf6ce1c514a9ec27ed17aaf4f Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 16:31:58 +0200 Subject: [PATCH 037/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 6c3f735..7bb634b 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -8,7 +8,7 @@ You're now ready to your first lightning network channel. To begin with, you'll In simple terms a lightning channel is a money tube that allows fast, cheap and private transfers of money without sending transactions to the blockchain. More technically a channel is a 2-of-2 multisignature bitcoin onchain transaction that establishes a financial relationship between two agents without trust. -Channels on the Lightning Network always are created between two nodes. The channel mantains a local database with bitcoin balance for both parts keeping track of how much money they each have. The two users can then exchange bitcoins through their Lightning channel without ever writing to the Bitcoin blockchain. Only when they want to close out their channel do they settle their bitcoins, based on the final division of coins. +Channels on the Lightning Network always are created between two nodes. Although a Lightning channel only allows payment between two users, channels can be connected together to form a network that allows payments between members that doesn't have a direct channel between them. The channel mantains a local database with bitcoin balance for both parts keeping track of how much money they each have. The two users can then exchange bitcoins through their Lightning channel without ever writing to the Bitcoin blockchain. Only when they want to close out their channel do they settle their bitcoins, based on the final division of coins. > :warning: **WARNING:** In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related but we will use a second lnd node too to create a channel with it. All c-lightning commands will use prompt shell c$ and LND commands will use prompt shell lnd$. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. From 5dd75dcc4627f2eb2b652e3c1b02031284f3489d Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 16:32:57 +0200 Subject: [PATCH 038/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 7bb634b..ef8cef0 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -20,7 +20,7 @@ Channels on the Lightning Network always are created between two nodes. Although #### Fund you c-lightning wallet. -The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using `lightning-cli newaddr` command to use it later. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This last transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bench32. +The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using `lightning-cli newaddr` command to use it later. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This last transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bech32. ``` c$ lightning-cli --network=testnet newaddr From c73cb37efdaccf5339467c9726eb6a141e223848 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 17:21:53 +0200 Subject: [PATCH 039/126] Update 13_2_Knowing_Your_lightning_Setup.md --- 13_2_Knowing_Your_lightning_Setup.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/13_2_Knowing_Your_lightning_Setup.md b/13_2_Knowing_Your_lightning_Setup.md index 2030e59..a1861b9 100644 --- a/13_2_Knowing_Your_lightning_Setup.md +++ b/13_2_Knowing_Your_lightning_Setup.md @@ -11,13 +11,13 @@ To start with, you should understand where everything is kept: the `~/.lightning The main directory just contains as many networks as configured, in this case we have testnet directory. ``` -$ ls ~/.lightning +c$ ls ~/.lightning testnet ``` In your ~/.lightning/testnet directory, you'll find that contains all of the guts: ``` -$ ls ~/.lightning/testnet3 +c$ ls ~/.lightning/testnet3 config gossip_store hsm_secret lightningd.sqlite3 lightningd.sqlite3-journal lightning-rpc ``` @@ -27,7 +27,7 @@ config gossip_store hsm_secret lightningd.sqlite3 lightningd.sqlite3-journal Most of your early work will be done with the `lightning-cli` command, which offers an easy interface to `lightningd`. ``` -$ lightning-cli help +c$ lightning-cli help lightning-cli: WARNING: default network changing in 2020: please set network=testnet in config! === bitcoin === @@ -231,15 +231,15 @@ run `lightning-cli help ` for more information on a specific command A variety of lightning-cli commands can give you additional information on your lightning node. The most general ones are: ``` -$ lightning-cli listconfigs -$ lightning-cli listfunds -$ lightning-cli listtransactions -$ lightning-cli listinvoices -$ lightning-cli listnodes +c$ lightning-cli listconfigs +c$ lightning-cli listfunds +c$ lightning-cli listtransactions +c$ lightning-cli listinvoices +c$ lightning-cli listnodes ``` For example `lightning-cli listconfigs` gives you a variety of information on your setup: ``` -lightning-cli --network=testnet listconfigs +c$ lightning-cli --network=testnet listconfigs { "# version": "v0.8.2-398-g869fa08", "lightning-dir": "/home/user/.lightning", From 2ecb3ca1458904904de304145fdc3ec6e51aa31a Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 22:57:02 +0200 Subject: [PATCH 040/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 154 +++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 72 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index ef8cef0..c2360e3 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -64,91 +64,101 @@ c$ lightning-cli --network=testnet listfunds ``` -Now that we have funded our c-lightning wallet we will get information about remote node to start creating channel process. On LND nodes you can get information about your node using `lncli -n testnet getinfo`: +Now that we have funded our c-lightning wallet we will get information about remote node to start creating channel process. Using `lightning-cli --network testnet listchannels` command you can list all active channels and select one remote node and it's public key: ``` -lnd$ lncli -n testnet getinfo -{ - "version": "0.10.99-beta commit=clock/v1.0.0-171-g8cb1276dbf0bfd9fcbf599df87a43238e599eaac", - "commit_hash": "8cb1276dbf0bfd9fcbf599df87a43238e599eaac", - "identity_pubkey": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", - "alias": "0302d48972ba7eef8b40", - "color": "#3399ff", - "num_pending_channels": 0, - "num_active_channels": 0, - "num_inactive_channels": 0, - "num_peers": 0, - "block_height": 1780686, - "block_hash": "000000000000000beb29fa5d3afb713a253f949b12f5f5be25935bb26764e321", - "best_header_timestamp": "1594737322", - "synced_to_chain": true, - "synced_to_graph": true, - "testnet": true, - "chains": [ - { - "chain": "bitcoin", - "network": "testnet" - } - ], - "uris": [ - ], - "features": { - "0": { - "name": "data-loss-protect", - "is_required": true, - "is_known": true - }, - "5": { - "name": "upfront-shutdown-script", - "is_required": false, - "is_known": true - }, - "7": { - "name": "gossip-queries", - "is_required": false, - "is_known": true - }, - "9": { - "name": "tlv-onion", - "is_required": false, - "is_known": true - }, - "13": { - "name": "static-remote-key", - "is_required": false, - "is_known": true - }, - "15": { - "name": "payment-addr", - "is_required": false, - "is_known": true - }, - "17": { - "name": "multi-path-payments", - "is_required": false, - "is_known": true - } - } -} +c$ lightning-cli --network listchannels + { + "source": "03eef6610d26489b897d81eb142f28ad5cd48a6b3e5c4e42a697cd00d5eb059313", + "destination": "020b1052c80eb9b2af1126e377640ff9534d8e27556ed78af9329c13c3d932c45f", + "short_channel_id": "1780579x3x1", + "public": true, + "satoshis": 120000, + "amount_msat": "120000000msat", + "message_flags": 1, + "channel_flags": 3, + "active": false, + "last_update": 1594650095, + "base_fee_millisatoshi": 1000, + "fee_per_millionth": 1, + "delay": 40, + "htlc_minimum_msat": "1000msat", + "htlc_maximum_msat": "118800000msat", + "features": "" + }, + { + "source": "038863cf8ab91046230f561cd5b386cbff8309fa02e3f0c3ed161a3aeb64a643b9", + "destination": "03f60f7369dd4dcff6a13d401b159e0bfc6aca34f05a93a8a897b75c7940a55bb9", + "short_channel_id": "1780610x42x1", + "public": true, + "satoshis": 50000, + "amount_msat": "50000000msat", + "message_flags": 1, + "channel_flags": 0, + "active": true, + "last_update": 1594658630, + "base_fee_millisatoshi": 1000, + "fee_per_millionth": 1, + "delay": 40, + "htlc_minimum_msat": "1000msat", + "htlc_maximum_msat": "49500000msat", + "features": "" + }, ``` #### Connect to remote node The first thing you need to do is connect your node to a peer. This is done with the `lightning-cli connect` command. Remember that if you want more information on this command, you should type `lightning-cli help connect`. The connect RPC command establishes a new connection with another node in the Lightning Network. -To connect your node to a remote peer you need it's id that represents the target node’s public key. As a convenience, id may be of the form id@host or id@host:port. In this case, the port parameter must be changed due we're running two nodes on the same machine, c-lightning node it's running on 9735 default port and we've started LND node on 9736 port with this parameter. +To connect your node to a remote peer you need it's id that represents the target node’s public key. As a convenience, id may be of the form id@host or id@host:port. Using `lightning-cli help listnodes` command you obtain all nodes available on the network and choose one. ``` -lnd$ lnd --listen=0.0.0.0:9736 +c$ lightning-cli help listnodes ``` -We can check it's listening on 9736 port using this command: - +Output ``` -c$ netstat -aon | grep 9736 -tcp6 0 0 :::9736 :::* LISTEN off (0.00/0/0) -c$ + { + "nodeid": "033c2c5eb5cc514b54264a838048b4e7194281e2dcd4ad03bab0198259df2dcbc7", + "alias": "shangoa0c8225d-d86b-4", + "color": "e20f00", + "last_timestamp": 1533416062, + "features": "", + "addresses": [ + { + "type": "ipv4", + "address": "54.158.207.111", + "port": 9735 + } + ] + }, + { + "nodeid": "03dc1ad7b657c4d7a042f1847ffcb953cd353bcfe818bce008c35abdcdc25a5257" + }, + { + "nodeid": "030b3a8efb847f1c267172d7afbfe93bf501c44a76c6ac6294a8b6b59335d5cdcd", + "alias": "030b3a8efb847f1c2671", + "color": "3399ff", + "last_timestamp": 1558873572, + "features": "", + "addresses": [ + { + "type": "ipv4", + "address": "167.99.231.18", + "port": 9735 + } + ] + }, + { + **"nodeid": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84",** + "alias": "0302d48972ba7eef8b40", + "color": "3399ff", + "last_timestamp": 1594828492, + "features": "02a2a1", + "addresses": [] + }, + ``` -Now we can use `lightning-cli connect` command to reach node as a peer: +We've selected node with public key 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 and we'll connect as a peer with `lightning-cli connect` command: ``` c$ lightning-cli --network=testnet connect 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84@127.0.0.1:9736 From ff0bd995c77d568fca4d9b1ef1290da1806fd3fd Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 22:58:15 +0200 Subject: [PATCH 041/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index c2360e3..4019c80 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -10,7 +10,7 @@ In simple terms a lightning channel is a money tube that allows fast, cheap and More technically a channel is a 2-of-2 multisignature bitcoin onchain transaction that establishes a financial relationship between two agents without trust. Channels on the Lightning Network always are created between two nodes. Although a Lightning channel only allows payment between two users, channels can be connected together to form a network that allows payments between members that doesn't have a direct channel between them. The channel mantains a local database with bitcoin balance for both parts keeping track of how much money they each have. The two users can then exchange bitcoins through their Lightning channel without ever writing to the Bitcoin blockchain. Only when they want to close out their channel do they settle their bitcoins, based on the final division of coins. -> :warning: **WARNING:** In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related but we will use a second lnd node too to create a channel with it. All c-lightning commands will use prompt shell c$ and LND commands will use prompt shell lnd$. If you're running our BitcoinStandup setup you could choose either of the two implementations at the time of installing. +In this chapter we will use testnet network and will use c-lightning as **primary node** to show all processes related. ### Steps to create a channel From e2f5006d904a9f320cf1c3aca084d43ff8ef7b1d Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 22:59:43 +0200 Subject: [PATCH 042/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 4019c80..09ad743 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -110,10 +110,10 @@ c$ lightning-cli --network listchannels The first thing you need to do is connect your node to a peer. This is done with the `lightning-cli connect` command. Remember that if you want more information on this command, you should type `lightning-cli help connect`. The connect RPC command establishes a new connection with another node in the Lightning Network. -To connect your node to a remote peer you need it's id that represents the target node’s public key. As a convenience, id may be of the form id@host or id@host:port. Using `lightning-cli help listnodes` command you obtain all nodes available on the network and choose one. +To connect your node to a remote peer you need it's id that represents the target node’s public key. As a convenience, id may be of the form id@host or id@host:port. Using `lightning-cli listnodes` command you obtain all nodes available on the network and choose one. ``` -c$ lightning-cli help listnodes +c$ lightning-cli listnodes ``` Output ``` From c2d2d9cd1337345e2948d691d675f7d87cebb69b Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 23:00:28 +0200 Subject: [PATCH 043/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 09ad743..97e694c 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -113,7 +113,7 @@ The first thing you need to do is connect your node to a peer. This is done with To connect your node to a remote peer you need it's id that represents the target node’s public key. As a convenience, id may be of the form id@host or id@host:port. Using `lightning-cli listnodes` command you obtain all nodes available on the network and choose one. ``` -c$ lightning-cli listnodes +c$ lightning-cli --network testnet listnodes ``` Output ``` From 2d39192d96a2cfd381ee4250f25c4ffad04bed39 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 16 Jul 2020 23:03:25 +0200 Subject: [PATCH 044/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 44 ++---------------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 97e694c..c211738 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -64,47 +64,7 @@ c$ lightning-cli --network=testnet listfunds ``` -Now that we have funded our c-lightning wallet we will get information about remote node to start creating channel process. Using `lightning-cli --network testnet listchannels` command you can list all active channels and select one remote node and it's public key: - -``` -c$ lightning-cli --network listchannels - { - "source": "03eef6610d26489b897d81eb142f28ad5cd48a6b3e5c4e42a697cd00d5eb059313", - "destination": "020b1052c80eb9b2af1126e377640ff9534d8e27556ed78af9329c13c3d932c45f", - "short_channel_id": "1780579x3x1", - "public": true, - "satoshis": 120000, - "amount_msat": "120000000msat", - "message_flags": 1, - "channel_flags": 3, - "active": false, - "last_update": 1594650095, - "base_fee_millisatoshi": 1000, - "fee_per_millionth": 1, - "delay": 40, - "htlc_minimum_msat": "1000msat", - "htlc_maximum_msat": "118800000msat", - "features": "" - }, - { - "source": "038863cf8ab91046230f561cd5b386cbff8309fa02e3f0c3ed161a3aeb64a643b9", - "destination": "03f60f7369dd4dcff6a13d401b159e0bfc6aca34f05a93a8a897b75c7940a55bb9", - "short_channel_id": "1780610x42x1", - "public": true, - "satoshis": 50000, - "amount_msat": "50000000msat", - "message_flags": 1, - "channel_flags": 0, - "active": true, - "last_update": 1594658630, - "base_fee_millisatoshi": 1000, - "fee_per_millionth": 1, - "delay": 40, - "htlc_minimum_msat": "1000msat", - "htlc_maximum_msat": "49500000msat", - "features": "" - }, -``` +Now that we have funded our c-lightning wallet we will get information about remote node to start creating channel process. #### Connect to remote node @@ -158,7 +118,7 @@ Output }, ``` -We've selected node with public key 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 and we'll connect as a peer with `lightning-cli connect` command: +We've selected node with public key 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 and we'll connect it with `lightning-cli connect` command: ``` c$ lightning-cli --network=testnet connect 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84@127.0.0.1:9736 From 8b81d4b5c8277d975dbf85720fb8d1a036c35539 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Fri, 17 Jul 2020 22:43:09 +0200 Subject: [PATCH 045/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index c211738..c6327b5 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -20,6 +20,9 @@ In this chapter we will use testnet network and will use c-lightning as **primar #### Fund you c-lightning wallet. +> :book: ***What is c-lightning wallet?*** + +C-lightning standard implementation comes with a integrated bitcoin wallet that allows you send and receive bitcoin onchain transactions. This wallet will be used to create new channels. The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using `lightning-cli newaddr` command to use it later. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This last transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bech32. ``` From ec77eaa719a25d1eff79fe675c9c00d696c8e8d0 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Fri, 17 Jul 2020 22:56:51 +0200 Subject: [PATCH 046/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index c6327b5..66b08ec 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -20,10 +20,9 @@ In this chapter we will use testnet network and will use c-lightning as **primar #### Fund you c-lightning wallet. -> :book: ***What is c-lightning wallet?*** +> :book: ***What is a c-lightning wallet?*** -C-lightning standard implementation comes with a integrated bitcoin wallet that allows you send and receive bitcoin onchain transactions. This wallet will be used to create new channels. -The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using `lightning-cli newaddr` command to use it later. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This last transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bech32. +C-lightning standard implementation comes with a integrated bitcoin wallet that allows you send and receive bitcoin onchain transactions. This wallet will be used to create new channels. The first thing you need to do is send some satoshis to your c-lightning wallet. You can create a new address using `lightning-cli newaddr` command to use it later. The newaddr RPC command generates a new address which can subsequently be used to fund channels managed by the c-lightning node. This last transaction is called the [funding transaction](https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#funding-transaction-output) and it needs to be confirmed before funds can be used. You can specify the type of address wanted, if not specified the address generated will be a bech32. ``` c$ lightning-cli --network=testnet newaddr From c98ee700f572d9caf554495f5ed73e690fa7ebe5 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Fri, 17 Jul 2020 23:31:21 +0200 Subject: [PATCH 047/126] Create 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 13_4_Paying_a_Invoice.md diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md new file mode 100644 index 0000000..4625533 --- /dev/null +++ b/13_4_Paying_a_Invoice.md @@ -0,0 +1,3 @@ +# 13.4: Paying a Invoice + +> :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. From be989ad499a61698971ae60fcc6cbbfad6baac8c Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sun, 19 Jul 2020 22:49:35 +0200 Subject: [PATCH 048/126] Update 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index 4625533..bbd904d 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -1,3 +1,77 @@ # 13.4: Paying a Invoice > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. + +### Understanding your invoice + +``` +lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj +{ + "currency": "tb", + "created_at": 1595191263, + "expiry": 3600, + "payee": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "msatoshi": 100000000, + "amount_msat": "100000000msat", + "description": "", + "min_final_cltv_expiry": 40, + "payment_secret": "ad3a5486ed3ee9d207f8e1f743d6981d76f16264335ae6551116e2a204764b6a", + "features": "028200", + "payment_hash": "133356c10e434d9b0000895974626cd213d5215658085fa5fd0df4f6be2739b6", + "signature": "30450221008c2a4d636465de07141b7c1277ffe621244299c39361ef86c0b898aafa50de8102204de4eb2e7495839beeb5540a9caf543641e44d52fdfdcb7261aec29c951b215f" +} +``` +### Paying your invoice + +``` +c$lightning-cli --network=testnet pay +lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj +{ + "id": 1, + "payment_hash": "133356c10e434d9b0000895974626cd213d5215658085fa5fd0df4f6be2739b6", + "destination": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "msatoshi": 100000000, + "amount_msat": "100000000msat", + "msatoshi_sent": 100000000, + "amount_sent_msat": "100000000msat", + "created_at": 1595191379, + "status": "complete", + "payment_preimage": "8b7549ffd4e648374669d47992c1ab44086501d5dd85d7e3d15766d70e9196e3", + "bolt11": "lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj" +} +``` + +### Check your balance + +``` +c$ lightning-cli --network=testnet listfunds +{ + "outputs": [ + { + "txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "output": 0, + "value": 19238, + "amount_msat": "19238000msat", + "scriptpubkey": "0014aa572371f29310cd677d039cdcd054156c1a9545", + "address": "tb1q4ftjxu0jjvgv6emaqwwde5z5z4kp49299gmdpd", + "status": "confirmed", + "blockheight": 1780768, + "reserved": false + } + ], + "channels": [ + { + "peer_id": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "connected": true, + "state": "CHANNELD_NORMAL", + "short_channel_id": "1780768x12x1", + "channel_sat": 180000, + "our_amount_msat": "180000000msat", + "channel_total_sat": 280000, + "amount_msat": "280000000msat", + "funding_txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "funding_output": 1 + } + ] +} +``` From 497d7de94b69be05486f0756277f4b32f2c9abc4 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sun, 19 Jul 2020 22:50:31 +0200 Subject: [PATCH 049/126] Update 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index bbd904d..634d200 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -5,7 +5,7 @@ ### Understanding your invoice ``` -lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj +c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj { "currency": "tb", "created_at": 1595191263, From 353c31288001e15880d8e6ba91d77684a60e926b Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sun, 19 Jul 2020 22:54:30 +0200 Subject: [PATCH 050/126] Update 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index 634d200..8dc6890 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -2,6 +2,10 @@ > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. +> :book: ***What is an invoice + + + ### Understanding your invoice ``` @@ -13,7 +17,7 @@ c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39v "payee": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", "msatoshi": 100000000, "amount_msat": "100000000msat", - "description": "", + "description": "First LN Payment - Learning Bitcoin and Lightning from the Command line.", "min_final_cltv_expiry": 40, "payment_secret": "ad3a5486ed3ee9d207f8e1f743d6981d76f16264335ae6551116e2a204764b6a", "features": "028200", From ab79d3af83ef2f88b24b3b239967a014db76d087 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 20 Jul 2020 12:41:47 +0200 Subject: [PATCH 051/126] Update 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index 8dc6890..4809119 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -4,7 +4,16 @@ > :book: ***What is an invoice +Almost all payments made on the Lightning Network require an invoice, which is nothing more than a request for payment made by the recipient of the money and sent by different means to the user who will pay. The format for a Lightning invoice uses bech32 encoding, which is already used for Bitcoin Segregated Witness and all payment requests are single use. +Invoices have two parts: + +- Human readable part: `ln` + (`lnbc` for Bitcoin mainnet, `lntb` for Bitcoin testnet, and `lnbcrt` for Bitcoin regtest) + data amount + +- Data part : UNIX Timestamp + tagged parts include a payment hash, the pubkey of the payee node, an optional description of the payment, an expiration time, and some extra routing information. + +Conside this ln invoice `lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj +` Starts with Prefix ln+tb+1m that indicates milli, so you should multi by 0.001. ### Understanding your invoice @@ -25,6 +34,41 @@ c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39v "signature": "30450221008c2a4d636465de07141b7c1277ffe621244299c39361ef86c0b898aafa50de8102204de4eb2e7495839beeb5540a9caf543641e44d52fdfdcb7261aec29c951b215f" } ``` +### Check your balance + +``` +c$ lightning-cli --network=testnet listfunds +{ + "outputs": [ + { + "txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "output": 0, + "value": 19238, + "amount_msat": "19238000msat", + "scriptpubkey": "0014aa572371f29310cd677d039cdcd054156c1a9545", + "address": "tb1q4ftjxu0jjvgv6emaqwwde5z5z4kp49299gmdpd", + "status": "confirmed", + "blockheight": 1780768, + "reserved": false + } + ], + "channels": [ + { + "peer_id": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "connected": true, + "state": "CHANNELD_AWAITING_LOCKIN", + "channel_sat": 280000, + "our_amount_msat": "280000000msat", + "channel_total_sat": 280000, + "amount_msat": "280000000msat", + "funding_txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "funding_output": 1 + } + ] +} +``` + + ### Paying your invoice ``` From 77e27e59c36a833d575c0fe106cdc6ca3cde8f83 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 20 Jul 2020 13:52:07 +0200 Subject: [PATCH 052/126] Update 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index 4809119..bf58880 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -13,7 +13,8 @@ Invoices have two parts: - Data part : UNIX Timestamp + tagged parts include a payment hash, the pubkey of the payee node, an optional description of the payment, an expiration time, and some extra routing information. Conside this ln invoice `lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj -` Starts with Prefix ln+tb+1m that indicates milli, so you should multi by 0.001. +` +This invoice starts with prefix ln+tb+1m that indicates milli, so you should multi by 0.001. That means we'll pay an invoice by 100000 satoshis. ### Understanding your invoice From d7ff317592cb7a6efc07982641f356b51f8ab25e Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 20 Jul 2020 14:48:50 +0200 Subject: [PATCH 053/126] Update 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index bf58880..17c5f1c 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -12,12 +12,17 @@ Invoices have two parts: - Data part : UNIX Timestamp + tagged parts include a payment hash, the pubkey of the payee node, an optional description of the payment, an expiration time, and some extra routing information. -Conside this ln invoice `lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj +Conside this ln invoice + +`lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj ` + This invoice starts with prefix ln+tb+1m that indicates milli, so you should multi by 0.001. That means we'll pay an invoice by 100000 satoshis. ### Understanding your invoice +If you want to decode your lightning invoice you should use `lightning-cli decodepay ` command that receives a string and checks and parses as specified by the [BOLT 11 specification](https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md). + ``` c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj { @@ -37,6 +42,8 @@ c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39v ``` ### Check your balance +As we did in previous chapter we have established an channel with a total capacity of 280.000 sats. + ``` c$ lightning-cli --network=testnet listfunds { @@ -60,7 +67,7 @@ c$ lightning-cli --network=testnet listfunds "state": "CHANNELD_AWAITING_LOCKIN", "channel_sat": 280000, "our_amount_msat": "280000000msat", - "channel_total_sat": 280000, + "channel_total_sat": **280000**, "amount_msat": "280000000msat", "funding_txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", "funding_output": 1 @@ -69,9 +76,10 @@ c$ lightning-cli --network=testnet listfunds } ``` - ### Paying your invoice +You should use `lightning-cli pay ` command to pay the invoice. The pay RPC command attempts to find a route to the given destination, and send the funds asked in amount value. + ``` c$lightning-cli --network=testnet pay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj @@ -92,6 +100,8 @@ lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp5 ### Check your balance +We've performed payment successfully + ``` c$ lightning-cli --network=testnet listfunds { From 971eb28bc82d96ff855748b9c5c2745c559cf191 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 20 Jul 2020 17:14:31 +0200 Subject: [PATCH 054/126] Update 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index 17c5f1c..e4d398c 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -23,6 +23,16 @@ This invoice starts with prefix ln+tb+1m that indicates milli, so you should mul If you want to decode your lightning invoice you should use `lightning-cli decodepay ` command that receives a string and checks and parses as specified by the [BOLT 11 specification](https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md). +On success it returns an object with the following fields: + +* currency: Currency. +* timestamp: the UNIX-style timestamp of the invoice. +* expiry: the number of seconds this is valid after timestamp. +* payee: the public key of the recipient. +* payment_hash: the payment hash of the request. +* signature: the DER-encoded signature. +* description: Description. + ``` c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj { @@ -42,7 +52,7 @@ c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39v ``` ### Check your balance -As we did in previous chapter we have established an channel with a total capacity of 280.000 sats. +As we did in previous chapter we have established an channel with a total capacity of 280.000 sats. This will be channel used to pay the invoice. ``` c$ lightning-cli --network=testnet listfunds @@ -100,7 +110,7 @@ lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp5 ### Check your balance -We've performed payment successfully +We've performed payment successfully and gets decreased channel balance on our side. Now it has 180000 as available balance. ``` c$ lightning-cli --network=testnet listfunds From eaed136c67c732996c3b2c7a78bbbe54301f40df Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 20 Jul 2020 22:02:15 +0200 Subject: [PATCH 055/126] Update 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index e4d398c..8312793 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -6,7 +6,7 @@ Almost all payments made on the Lightning Network require an invoice, which is nothing more than a request for payment made by the recipient of the money and sent by different means to the user who will pay. The format for a Lightning invoice uses bech32 encoding, which is already used for Bitcoin Segregated Witness and all payment requests are single use. -Invoices have two parts: +An invoice is made up of two parts, one is human readable and other is - Human readable part: `ln` + (`lnbc` for Bitcoin mainnet, `lntb` for Bitcoin testnet, and `lnbcrt` for Bitcoin regtest) + data amount From 21f5c1eafc978e5f6c630c58298c27072d410a68 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 20 Jul 2020 22:20:44 +0200 Subject: [PATCH 056/126] Update 13_4_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index 8312793..04c1df8 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -12,7 +12,7 @@ An invoice is made up of two parts, one is human readable and other is - Data part : UNIX Timestamp + tagged parts include a payment hash, the pubkey of the payee node, an optional description of the payment, an expiration time, and some extra routing information. -Conside this ln invoice +Consider this ln invoice: `lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj ` From 653b9077cccb4375790d37f6906a15ed616206de Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 22 Jul 2020 16:56:25 +0200 Subject: [PATCH 057/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 265 +++++++++++++++++++++++++ 1 file changed, 265 insertions(+) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index cff4170..7a4bca2 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -9,6 +9,271 @@ Lightning Network is a decentralized network using smart contract functionality This tutorial uses the standard-compliant c-lightning implementation as its trusted Lightning server. Before you start playing with c-lightning, you should ensure that everything is setup correctly. +## C-lightning installation + +As we said previous chapter you should have c-lightning installed courtesy BitcoinStandupScript, if not we describe here options and steps to install it. + +### Ubuntu ppa + +The first and fastest option is to use [Ubuntu ppa](https://launchpad.net/~lightningnetwork/+archive/ubuntu/ppa). + +``` +sudo apt-get install -y software-properties-common +sudo add-apt-repository -u ppa:lightningnetwork/ppa +sudo apt-get install lightningd +``` +### Install pre-compiled binaries + +Download and install binaries from [c-lightning](https://github.com/ElementsProject/lightning/releases) github repository. + +### Compiling the source code + +In this section we'll show you steps to compile c-lightning source code and running it. + +* Get dependencies +``` +c$ sudo apt-get install -y \ +> autoconf automake build-essential git libtool libgmp-dev \ +> libsqlite3-dev python3 python3-mako net-tools zlib1g-dev libsodium-dev \ +> gettext +``` +Output: +``` +Reading package lists... Done +Building dependency tree +Reading state information... Done +build-essential is already the newest version (12.1ubuntu2). +net-tools is already the newest version (1.60-26ubuntu1). +python3 is already the newest version (3.5.1-3). +python3-mako is already the newest version (1.0.3+ds1-1ubuntu1). +gettext is already the newest version (0.19.7-2ubuntu3.1). +The following packages were automatically installed and are no longer required: + glade2script glade2script-python3 pastebinit snapd-login-service +Use 'sudo apt autoremove' to remove them. +The following additional packages will be installed: + autotools-dev git-man liberror-perl libgmpxx4ldbl libltdl-dev m4 + ....... +``` +* Clone repository + +``` +c$ git clone https://github.com/ElementsProject/lightning.git +cd lightning +``` + +* Get additional dependencies for development or testing. + +``` +c$ sudo apt-get install -y valgrind python3-pip libpq-dev +``` + +Output: +``` +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following packages were automatically installed and are no longer required: + glade2script glade2script-python3 pastebinit snapd-login-service +Use 'sudo apt autoremove' to remove them. +The following additional packages will be installed: + comerr-dev krb5-multidev libexpat1-dev libgssrpc4 libkadm5clnt-mit9 libkadm5srv-mit9 libkdb5-8 libpq5 libpython3-dev libpython3.5-dev libssl-dev libssl-doc + python-pip-whl python3-dev python3-setuptools python3-wheel python3.5-dev +Suggested packages: + krb5-doc krb5-user postgresql-doc-9.5 python-setuptools-doc valgrind-dbg kcachegrind alleyoop valkyrie +The following NEW packages will be installed: + comerr-dev krb5-multidev libexpat1-dev libgssrpc4 libkadm5clnt-mit9 libkadm5srv-mit9 libkdb5-8 libpq-dev libpq5 libpython3-dev libpython3.5-dev libssl-dev libssl-doc + python-pip-whl python3-dev python3-pip python3-setuptools python3-wheel python3.5-dev valgrind +0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded. +Need to get 53,4 MB of archives. +After this operation, 137 MB of additional disk space will be used. +Get:1 http://es.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgssrpc4 amd64 1.13.2+dfsg-5ubuntu2.1 [54,5 kB] +Get:2 http://es.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkdb5-8 amd64 1.13.2+dfsg-5ubuntu2.1 [37,0 kB] +Get:3 http://es.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkadm5srv-mit9 amd64 1.13.2+dfsg-5ubuntu2.1 [51,3 kB] +....... +``` +* Install requirements + +``` +c$ pip3 install -r requirements.txt +``` +Output + +``` +Collecting Flask==1.1.1 (from -r requirements.txt (line 1)) + Downloading https://files.pythonhosted.org/packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl (94kB) + 100% |████████████████████████████████| 102kB 1.8MB/s +Collecting Sphinx==1.8.4 (from -r requirements.txt (line 2)) + Downloading https://files.pythonhosted.org/packages/75/25/905f901fb749e45cb201f1d946e82f59d84730c430287ea7980b0bcbd2dc/Sphinx-1.8.4-py2.py3-none-any.whl (3.1MB) + 100% |████████████████████████████████| 3.1MB 372kB/s +...... + Running setup.py install for mako ... done + Running setup.py install for mistune-contrib ... done + Running setup.py install for py-cpuinfo ... done +Successfully installed Flask-1.1.1 Jinja2-2.11.2 Pygments-2.6.1 Sphinx-1.8.4 Werkzeug-1.0.1 alabaster-0.7.12 apipkg-1.5 attrs-19.3.0 babel-2.8.0 cheroot-8.2.1 click-7.1.2 commonmark-0.8.1 docutils-0.16 entrypoints-0.3 ephemeral-port-reserve-1.1.1 execnet-1.7.1 flake8-3.7.8 flaky-3.6.1 future-0.18.2 imagesize-1.2.0 importlib-metadata-1.7.0 itsdangerous-1.1.0 jaraco.functools-3.0.1 m2r-0.2.1 mako-1.0.14 mccabe-0.6.1 mistune-0.8.4 mistune-contrib-0.1 more-itertools-8.4.0 mrkd-0.1.6 packaging-20.4 pathlib2-2.3.5 plac-1.2.0 pluggy-0.13.1 psycopg2-binary-2.8.4 py-1.9.0 py-cpuinfo-7.0.0 pycodestyle-2.5.0 pyflakes-2.1.1 pytest-5.3.1 pytest-benchmark-3.2.2 pytest-forked-1.0.2 pytest-timeout-1.3.3 pytest-xdist-1.29.0 python-bitcoinlib-0.10.2 pytz-2020.1 recommonmark-0.5.0 snowballstemmer-2.0.0 sphinx-rtd-theme-0.4.2 sphinxcontrib-websupport-1.1.0 tqdm-4.32.2 wcwidth-0.2.5 zipp-3.1.0 +You are using pip version 8.1.1, however version 20.1.1 is available. +``` + +* Build lightning +``` +c$ ./configure +``` + +Output: +``` +Compiling ccan/tools/configurator/configurator...done +checking for python3-mako... found +Making autoconf users comfortable... yes +checking for off_t is 32 bits... no +checking for __alignof__ support... yes +checking for asprintf() declaration... yes +checking for __attribute__((cold)) support... yes +checking for __attribute__((const)) support... yes +checking for __attribute__((deprecated)) support... no +checking for __attribute__((nonnull)) support... yes +checking for __attribute__((sentinel)) support... yes +checking for __attribute__((pure)) support... yes +checking for __attribute__((may_alias)) support... yes +checking for __attribute__((noreturn)) support... yes +checking for __attribute__ format printf support... yes +....... +Setting COMPAT... 1 +Setting PYTEST... pytest +Setting STATIC... 0 +Setting ASAN... 0 +Setting TEST_NETWORK... regtest +c$ +``` +* Make + +It will take some time depending your machine. + +``` +c$ make +``` +Output: + +``` +CC: cc -DBINTOPKGLIBEXECDIR="../libexec/c-lightning" -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -Wno-maybe-uninitialized -std=gnu11 -g -fstack-protector -Og -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/libbacktrace/ -I external/x86_64-linux-gnu/libbacktrace-build -I external/libsodium/src/libsodium/include -I external/libsodium/src/libsodium/include/sodium -I external/x86_64-linux-gnu/libsodium-build/src/libsodium/include -I . -I/usr/local/include -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -DBUILD_ELEMENTS=1 -c -o +LD: cc -Og -Lexternal/x86_64-linux-gnu -lwallycore -lsecp256k1 -ljsmn -lbacktrace -lsodium -L/usr/local/lib -lm -lgmp -lsqlite3 -lz -lpq -o +cc ccan/ccan/cdump/tools/cdump-enumstr.c +cc ccan/ccan/cdump/cdump.c +cc ccan/ccan/strmap/strmap.c +cc ccan/ccan/asort/asort.c +cc ccan/ccan/autodata/autodata.c +cc ccan/ccan/bitmap/bitmap.c +cc ccan/ccan/bitops/bitops.c +cc ccan/ccan/breakpoint/breakpoint.c +cc ccan/ccan/crc32c/crc32c.c +cc ccan/ccan/crypto/hmac_sha256/hmac_sha256.c +cc ccan/ccan/crypto/hkdf_sha256/hkdf_sha256.c +...... +cc common/channel_id.c +cc common/daemon.c +cc common/daemon_conn.c +cc common/derive_basepoints.c +cc common/funding_tx.c +tools/generate-wire.py --page impl common/gen_status_wire.h status < common/status_wire.csv > common/gen_status_wire.c +cc common/gen_status_wire.c +cc common/hash_u5.c +cc common/key_derive.c +cc common/memleak.c +cc common/msg_queue.c +cc common/node_id.c +cc common/permute_tx.c +cc common/setup.c +cc common/status.c +cc common/status_wire.c +cc common/subdaemon.c +cc common/type_to_string.c +cc common/utils.c +cc common/utxo.c +cc common/version.c +cc common/withdraw_tx.c +cc bitcoin/base58.c +cc bitcoin/block.c +cc bitcoin/chainparams.c +cc bitcoin/feerate.c +cc bitcoin/locktime.c +cc bitcoin/preimage.c +cc bitcoin/privkey.c +cc bitcoin/psbt.c +cc bitcoin/pubkey.c +cc bitcoin/script.c +cc bitcoin/shadouble.c +cc bitcoin/short_channel_id.c +cc bitcoin/signature.c +cc bitcoin/tx.c +cc bitcoin/tx_parts.c +cc bitcoin/varint.c +cc wire/wire_sync.c +....... +cc lightningd/test/run-invoice-select-inchan.c +ld lightningd/test/run-invoice-select-inchan +cc lightningd/test/run-jsonrpc.c +ld lightningd/test/run-jsonrpc +cc cli/test/run-remove-hint.c +ld cli/test/run-remove-hint +cc cli/test/run-large-input.c +ld cli/test/run-large-input +if [ x"`git log doc/lightningd-config.5 | head -n1`" != x"`git log doc/lightningd-config.5.md | head -n1`" -o x"`git diff doc/lightningd-config.5.md`" != x"" ]; then mrkd doc/lightningd-config.5.md doc/lightningd-config.5; else touch doc/lightningd-config.5; fi +if [ x"`git log doc/lightning-hsmtool.8 | head -n1`" != x"`git log doc/lightning-hsmtool.8.md | head -n1`" -o x"`git diff doc/lightning-hsmtool.8.md`" != x"" ]; then mrkd doc/lightning-hsmtool.8.md doc/lightning-hsmtool.8; else touch doc/lightning-hsmtool.8; fi +(grep -v '^ lightning.*\.[0-9]\.md>$' doc/index.rst; for m in $(cd doc && ls lightningd*.[0-9].md lightning-*.[0-9].md); do echo " ${m%.[0-9].md} <$m>"; done |LC_ALL=C sort) > doc/index.rst.tmp.$$ && mv doc/index.rst.tmp.$$ doc/index.rst +rm external/x86_64-linux-gnu/libwally-core-build/src/secp256k1/libsecp256k1.la +c$ +``` +* Make Install + +``` +$ sudo make install +``` + +Output: + +``` +mkdir -p /usr/local/bin +mkdir -p /usr/local/libexec/c-lightning +mkdir -p /usr/local/libexec/c-lightning/plugins +mkdir -p /usr/local/share/man/man1 +mkdir -p /usr/local/share/man/man5 +mkdir -p /usr/local/share/man/man7 +mkdir -p /usr/local/share/man/man8 +mkdir -p /usr/local/share/doc/c-lightning +cp tools/hsmtool tools/lightning-hsmtool +install cli/lightning-cli lightningd/lightningd tools/lightning-hsmtool /usr/local/bin +install lightningd/lightning_channeld lightningd/lightning_closingd lightningd/lightning_connectd lightningd/lightning_gossipd lightningd/lightning_hsmd lightningd/lightning_onchaind lightningd/lightning_openingd /usr/local/libexec/c-lightning +[ -z "plugins/autoclean plugins/bcli plugins/fundchannel plugins/keysend plugins/pay" ] || install plugins/autoclean plugins/bcli plugins/fundchannel plugins/keysend plugins/pay /usr/local/libexec/c-lightning/plugins +install -m 644 doc/lightning-cli.1 /usr/local/share/man/man1 +install -m 644 doc/lightningd-config.5 /usr/local/share/man/man5 +install -m 644 doc/lightning-autocleaninvoice.7 doc/lightning-check.7 doc/lightning-checkmessage.7 doc/lightning-close.7 doc/lightning-connect.7 doc/lightning-createonion.7 doc/lightning-decodepay.7 doc/lightning-delexpiredinvoice.7 doc/lightning-delinvoice.7 doc/lightning-dev-sendcustommsg.7 doc/lightning-disconnect.7 doc/lightning-fundchannel.7 doc/lightning-fundchannel_start.7 doc/lightning-fundchannel_complete.7 doc/lightning-fundchannel_cancel.7 doc/lightning-getroute.7 doc/lightning-getsharedsecret.7 doc/lightning-invoice.7 doc/lightning-listchannels.7 doc/lightning-listforwards.7 doc/lightning-listfunds.7 doc/lightning-listinvoices.7 doc/lightning-listpays.7 doc/lightning-listpeers.7 doc/lightning-listsendpays.7 doc/lightning-newaddr.7 doc/lightning-pay.7 doc/lightning-plugin.7 doc/lightning-reserveinputs.7 doc/lightning-sendonion.7 doc/lightning-sendpay.7 doc/lightning-setchannelfee.7 doc/lightning-signmessage.7 doc/lightning-txprepare.7 doc/lightning-txdiscard.7 doc/lightning-txsend.7 doc/lightning-unreserveinputs.7 doc/lightning-waitinvoice.7 doc/lightning-waitanyinvoice.7 doc/lightning-waitblockheight.7 doc/lightning-waitsendpay.7 doc/lightning-withdraw.7 /usr/local/share/man/man7 +install -m 644 doc/lightningd.8 doc/lightning-hsmtool.8 /usr/local/share/man/man8 +install -m 644 README.md doc/INSTALL.md doc/HACKING.md LICENSE /usr/local/share/doc/c-lightning +``` + +You can check your installation using + +``` +c$ lightningd --help +``` +Output: + +``` +lightningd: WARNING: default network changing in 2020: please set network=testnet in config! +Usage: lightningd +A bitcoin lightning daemon (default values shown for network: testnet). +--conf= Specify configuration file +--lightning-dir= Set base directory: network-specific + subdirectory is under here + (default: "/home/javier/.lightning") +--network Select the network parameters (bitcoin, + testnet, regtest, litecoin or + litecoin-testnet) (default: testnet) +--testnet Alias for --network=testnet +--signet Alias for --network=signet +--mainnet Alias for --network=bitcoin + +``` + + ## Create Your Aliases We suggest creating some aliases to make it easier to use c-lightning. From 0b5baf2d24f4291e54264c3a968a3d52b2382438 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 22 Jul 2020 17:03:51 +0200 Subject: [PATCH 058/126] Update 13_1_Verifying_Your_Lightning_Setup.md --- 13_1_Verifying_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/13_1_Verifying_Your_Lightning_Setup.md index 7a4bca2..c68b611 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/13_1_Verifying_Your_Lightning_Setup.md @@ -58,7 +58,7 @@ The following additional packages will be installed: ``` c$ git clone https://github.com/ElementsProject/lightning.git -cd lightning +c$ cd lightning ``` * Get additional dependencies for development or testing. From 4cbc60203d80dedf69c76cab07be3828b9910ad1 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 13:36:43 +0200 Subject: [PATCH 059/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 66b08ec..e2ad745 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -72,7 +72,9 @@ Now that we have funded our c-lightning wallet we will get information about rem The first thing you need to do is connect your node to a peer. This is done with the `lightning-cli connect` command. Remember that if you want more information on this command, you should type `lightning-cli help connect`. The connect RPC command establishes a new connection with another node in the Lightning Network. -To connect your node to a remote peer you need it's id that represents the target node’s public key. As a convenience, id may be of the form id@host or id@host:port. Using `lightning-cli listnodes` command you obtain all nodes available on the network and choose one. +You have two options here, you could set up a Lightning node on a second machine using the Standup script and choose LND implementation or search a node to connect to. + +To connect your node to a remote peer you need it's id that represents the target node’s public key. As a convenience, id may be of the form id@host or id@host:port. Using `lightning-cli listnodes` command you obtain all nodes available on the network and choose one. ``` c$ lightning-cli --network testnet listnodes From 56426b04ebc8cbd5a5a35c425a75726f067b88eb Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 13:39:04 +0200 Subject: [PATCH 060/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index 8943bdd..ddf8163 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -29,5 +29,5 @@ Supporting objectives include the ability to: * [Section One: Verifying Your Lightning Setup](13_1_Verifying_Your_Lightning_Setup.md) * [Section Two: Knowing Your Lightning Setup](13_2_Knowing_Your_lightning_Setup.md) * [Section Three: Setting Up a channel](13_3_Setting_Up_a_Channel.md) -* [Section Four: Paying an invoice](13_4_Paying_a_Invoice.md) -* [Section Five: Generate a payment request](01_5_Generate_a_Payment_Request.md) +* [Section Four: Generate a payment request](13_4_Generate_a_Payment_Request.md) +* [Section Five: Paying an invoice](13_5_Paying_a_Invoice.md) From 2ac60a8f0a8dd3168b1cec50e0468a9581e694c5 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 13:40:31 +0200 Subject: [PATCH 061/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index e2ad745..89fa505 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -227,6 +227,6 @@ You need to create a channel with remote nodes to be able to receive and send mo ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.4: Paying_a_Invoice](13_4_Paying_a_Invoice.md). +Continue "Understanding Your Lightning Setup" with [§13.4: Generate a Payment request](13_4_Generate_a_Payment_Request.md). From 662c46942180a927a1cc243af491527e11957345 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 13:55:11 +0200 Subject: [PATCH 062/126] Update and rename 13_4_Paying_a_Invoice.md to 13_5_Paying_a_Invoice.md --- 13_4_Paying_a_Invoice.md => 13_5_Paying_a_Invoice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename 13_4_Paying_a_Invoice.md => 13_5_Paying_a_Invoice.md (99%) diff --git a/13_4_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md similarity index 99% rename from 13_4_Paying_a_Invoice.md rename to 13_5_Paying_a_Invoice.md index 04c1df8..b587918 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -1,4 +1,4 @@ -# 13.4: Paying a Invoice +# 13.5: Paying a Invoice > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. From d7b0859ce4c9334f4f6496368de49097a8cd90f3 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 13:56:30 +0200 Subject: [PATCH 063/126] Create 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 13_4_Generate_a_Payment_Request.md diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/13_4_Generate_a_Payment_Request.md @@ -0,0 +1 @@ + From 7a2a00ef6170bd7b134cc5a6a6c2469e5ba944ea Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 14:48:03 +0200 Subject: [PATCH 064/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index b587918..da338c3 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -2,21 +2,12 @@ > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. -> :book: ***What is an invoice +As we did in previous chapter we have an invoice to pay. -Almost all payments made on the Lightning Network require an invoice, which is nothing more than a request for payment made by the recipient of the money and sent by different means to the user who will pay. The format for a Lightning invoice uses bech32 encoding, which is already used for Bitcoin Segregated Witness and all payment requests are single use. - -An invoice is made up of two parts, one is human readable and other is - -- Human readable part: `ln` + (`lnbc` for Bitcoin mainnet, `lntb` for Bitcoin testnet, and `lnbcrt` for Bitcoin regtest) + data amount - -- Data part : UNIX Timestamp + tagged parts include a payment hash, the pubkey of the payee node, an optional description of the payment, an expiration time, and some extra routing information. - -Consider this ln invoice: +Consider this ln invoice, created before: `lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj ` - This invoice starts with prefix ln+tb+1m that indicates milli, so you should multi by 0.001. That means we'll pay an invoice by 100000 satoshis. ### Understanding your invoice From a4c047706989f2190b7b6a2f9039c67804437ec6 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 14:58:56 +0200 Subject: [PATCH 065/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index 8b13789..26416b4 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -1 +1,19 @@ +# 13.4: Generate a Payment request. + +> :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. + +> :book: ***What is an invoice + +Almost all payments made on the Lightning Network require an invoice, which is nothing more than a request for payment made by the recipient of the money and sent by different means to the user who will pay. The format for a Lightning invoice uses bech32 encoding, which is already used for Bitcoin Segregated Witness and all payment requests are single use. + +An invoice is made up of two parts, one is human readable and other is + +- Human readable part: `ln` + (`lnbc` for Bitcoin mainnet, `lntb` for Bitcoin testnet, and `lnbcrt` for Bitcoin regtest) + data amount + +- Data part : UNIX Timestamp + tagged parts include a payment hash, the pubkey of the payee node, an optional description of the payment, an expiration time, and some extra routing information. + +For this example we've created a second lightning node using LND implementation. We will refer to this instance using `lnd$ ` prompt shell to indicate place where we'll generate LND commands. If you want to reproduce this steps you should use Bitcoin Standup to create a second machine and install LND. + + + From d08fbe1b83a8d5da73a6c6f0a6771799f9237417 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 15:27:33 +0200 Subject: [PATCH 066/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 88 +++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 2 deletions(-) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index 26416b4..0c9c15c 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -3,9 +3,11 @@ > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. +This chapter shows what is and how to create a payment request. For this example we've created a second lightning node using LND implementation to create an invoice to pay using our main c-lighting installation in next chapter. We will refer to this instance using `lnd$ ` prompt shell to indicate place where we'll generate LND commands. If you want to reproduce this steps you should use Bitcoin Standup to create a second machine and install LND. + > :book: ***What is an invoice -Almost all payments made on the Lightning Network require an invoice, which is nothing more than a request for payment made by the recipient of the money and sent by different means to the user who will pay. The format for a Lightning invoice uses bech32 encoding, which is already used for Bitcoin Segregated Witness and all payment requests are single use. +Almost all payments made on the Lightning Network require an invoice, which is nothing more than a **request for payment** made by the recipient of the money and sent by different means to the user who will pay. The format for a Lightning invoice uses bech32 encoding, which is already used for Bitcoin Segregated Witness and all payment requests are single use. An invoice is made up of two parts, one is human readable and other is @@ -13,7 +15,89 @@ An invoice is made up of two parts, one is human readable and other is - Data part : UNIX Timestamp + tagged parts include a payment hash, the pubkey of the payee node, an optional description of the payment, an expiration time, and some extra routing information. -For this example we've created a second lightning node using LND implementation. We will refer to this instance using `lnd$ ` prompt shell to indicate place where we'll generate LND commands. If you want to reproduce this steps you should use Bitcoin Standup to create a second machine and install LND. + +### Node information + +In this second instance we refer before you may get information about it using `lnd$lncli -n testnet getinfo` command. + +`lnd$ lncli -n testnet getinfo +{ + "version": "0.10.99-beta commit=clock/v1.0.0-171-g8cb1276dbf0bfd9fcbf599df87a43238e599eaac", + "commit_hash": "8cb1276dbf0bfd9fcbf599df87a43238e599eaac", + "identity_pubkey": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "alias": "0302d48972ba7eef8b40", + "color": "#3399ff", + "num_pending_channels": 0, + "num_active_channels": 1, + "num_inactive_channels": 0, + "num_peers": 3, + "block_height": 1781444, + "block_hash": "0000000018655b27a1801e976c800be99c6f42c9bfcf122695a7ef5c0fa12e73", + "best_header_timestamp": "1595509101", + "synced_to_chain": true, + "synced_to_graph": true, + "testnet": true, + "chains": [ + { + "chain": "bitcoin", + "network": "testnet" + } + ], + "uris": [ + "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84@47.62.163.70:9735" + ], + "features": { + "0": { + "name": "data-loss-protect", + "is_required": true, + "is_known": true + }, + "5": { + "name": "upfront-shutdown-script", + "is_required": false, + "is_known": true + }, + "7": { + "name": "gossip-queries", + "is_required": false, + "is_known": true + }, + "9": { + "name": "tlv-onion", + "is_required": false, + "is_known": true + }, + "13": { + "name": "static-remote-key", + "is_required": false, + "is_known": true + }, + "15": { + "name": "payment-addr", + "is_required": false, + "is_known": true + }, + "17": { + "name": "multi-path-payments", + "is_required": false, + "is_known": true + } + } +} +` + +### Generate a Payment request. + +Now you can create a payment request using using `lnd$lncli -n testnet addinvoice` command. You can use --amt argument to indicate amount to be payed and add a description using --memo argument. + +` +lnd$ lncli -n testnet addinvoice --amt 100000 --memo "First LN Payment - Learning Bitcoin and Lightning from the Command line." +{ + "r_hash": "72fbf5c2baadc780b17a27d983bd685f7d6ddf682b028c6dc13a50976e9e6e6c", + "payment_request": "lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj", + "add_index": "1" +} +` From 5124620875ef9dcc726af6c50e38a3d5326b0e6c Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 15:28:29 +0200 Subject: [PATCH 067/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index 0c9c15c..ef9d471 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -20,7 +20,8 @@ An invoice is made up of two parts, one is human readable and other is In this second instance we refer before you may get information about it using `lnd$lncli -n testnet getinfo` command. -`lnd$ lncli -n testnet getinfo +``` +lnd$ lncli -n testnet getinfo { "version": "0.10.99-beta commit=clock/v1.0.0-171-g8cb1276dbf0bfd9fcbf599df87a43238e599eaac", "commit_hash": "8cb1276dbf0bfd9fcbf599df87a43238e599eaac", @@ -84,20 +85,20 @@ In this second instance we refer before you may get information about it using ` } } } -` +``` ### Generate a Payment request. Now you can create a payment request using using `lnd$lncli -n testnet addinvoice` command. You can use --amt argument to indicate amount to be payed and add a description using --memo argument. -` +``` lnd$ lncli -n testnet addinvoice --amt 100000 --memo "First LN Payment - Learning Bitcoin and Lightning from the Command line." { "r_hash": "72fbf5c2baadc780b17a27d983bd685f7d6ddf682b028c6dc13a50976e9e6e6c", "payment_request": "lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj", "add_index": "1" } -` +``` From 2624e7df396af2e8f1302ac3f747f205f9e8d54e Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 15:29:32 +0200 Subject: [PATCH 068/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index ef9d471..e796556 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -45,7 +45,7 @@ lnd$ lncli -n testnet getinfo } ], "uris": [ - "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84@47.62.163.70:9735" + "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84@192.168.0.22:9736" ], "features": { "0": { From 9ad04525bd9069445263ad90f761b36f0aecb19c Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 15:35:32 +0200 Subject: [PATCH 069/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index e796556..0e6c254 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -100,5 +100,14 @@ lnd$ lncli -n testnet addinvoice --amt 100000 --memo "First LN Payment - Learnin } ``` +## Summary: Generating a Payment request. + +In most cases you need to receive an invoice to use Lightning Network payments. In this example we've created on manually but in real cases you can buy products and services that will generate a respective invoice for it. + +## What's Next? + +Continue "Understanding Your Lightning Setup" with [§13.5: Paying_a_Invoice](13_5_Paying_a_Invoice.md). + + From f8f9de36a3f3991bf64c353f46c98a980462d5a6 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 22:17:01 +0200 Subject: [PATCH 070/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index 0e6c254..8c51ffe 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -3,7 +3,7 @@ > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. -This chapter shows what is and how to create a payment request. For this example we've created a second lightning node using LND implementation to create an invoice to pay using our main c-lighting installation in next chapter. We will refer to this instance using `lnd$ ` prompt shell to indicate place where we'll generate LND commands. If you want to reproduce this steps you should use Bitcoin Standup to create a second machine and install LND. +This chapter shows what is and how to create a payment request. For this example we've created a second lightning node using LND implementation to create an invoice to be payed later using our main c-lighting installation in next chapter. We will refer to this instance using `lnd$ ` prompt shell to indicate place where we'll generate LND commands. If you want to reproduce this steps you should use Bitcoin Standup to create a second machine and install LND. > :book: ***What is an invoice From a0534755d384d08b1fedbd2307134efb92003aab Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 23 Jul 2020 22:20:51 +0200 Subject: [PATCH 071/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index 8c51ffe..732144f 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -18,7 +18,7 @@ An invoice is made up of two parts, one is human readable and other is ### Node information -In this second instance we refer before you may get information about it using `lnd$lncli -n testnet getinfo` command. +In this second instance that we refer before you may get information about it using `lnd$lncli -n testnet getinfo` command. ``` lnd$ lncli -n testnet getinfo @@ -89,7 +89,7 @@ lnd$ lncli -n testnet getinfo ### Generate a Payment request. -Now you can create a payment request using using `lnd$lncli -n testnet addinvoice` command. You can use --amt argument to indicate amount to be payed and add a description using --memo argument. +Now you can create a payment request using `lnd$lncli -n testnet addinvoice` command. You can use --amt argument to indicate amount to be payed and add a description using --memo argument. ``` lnd$ lncli -n testnet addinvoice --amt 100000 --memo "First LN Payment - Learning Bitcoin and Lightning from the Command line." From fff9f6562c1b5791a031a499e9bbf046ed9d60d9 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 27 Jul 2020 12:16:33 +0200 Subject: [PATCH 072/126] Create 13_6_Close_Channel.md --- 13_6_Close_Channel.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 13_6_Close_Channel.md diff --git a/13_6_Close_Channel.md b/13_6_Close_Channel.md new file mode 100644 index 0000000..6e3f31f --- /dev/null +++ b/13_6_Close_Channel.md @@ -0,0 +1,4 @@ +# 13.6: Close channel + +> :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. + From 06a0eacb1cdb8a7abc953a60257574d36a174584 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 27 Jul 2020 17:43:53 +0200 Subject: [PATCH 073/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 1 + 1 file changed, 1 insertion(+) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index ddf8163..7962bf2 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -31,3 +31,4 @@ Supporting objectives include the ability to: * [Section Three: Setting Up a channel](13_3_Setting_Up_a_Channel.md) * [Section Four: Generate a payment request](13_4_Generate_a_Payment_Request.md) * [Section Five: Paying an invoice](13_5_Paying_a_Invoice.md) +* [Section Five: Close a Channel](13_6_Close_channel.md) From 24a93f9c08844e8ef580569ee09733a775e102ab Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 27 Jul 2020 18:06:27 +0200 Subject: [PATCH 074/126] Update 13_0_Understanding_Your_Lightning_Setup.md From 53f9f79a9d67771e729765a0f07ed6f901d5ee8b Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 27 Jul 2020 18:15:05 +0200 Subject: [PATCH 075/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index da338c3..c242dc2 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -135,3 +135,11 @@ c$ lightning-cli --network=testnet listfunds ] } ``` + +## Summary: Paying a Invoice + +We've created an invoice by 100.000 satoshis using a second machine and we've payed it using our main Lightning network node c-lightning. The channel was created with an initial amount of 280000 satoshis. This is called Total capacity channel. Later we've payed invoice we proved local balance was reduced remaining at 180.000 satoshis. + +## What's Next? + +Continue "Understanding Your Lightning Setup" with [§13.6: Close a Channel](13_6_Close_channel.md). From 5299811a9ae665ba5fda3c7bfa36ebd0eb570082 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 27 Jul 2020 20:28:13 +0200 Subject: [PATCH 076/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index 732144f..ede2301 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -3,7 +3,8 @@ > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. -This chapter shows what is and how to create a payment request. For this example we've created a second lightning node using LND implementation to create an invoice to be payed later using our main c-lighting installation in next chapter. We will refer to this instance using `lnd$ ` prompt shell to indicate place where we'll generate LND commands. If you want to reproduce this steps you should use Bitcoin Standup to create a second machine and install LND. +This chapter shows what is and how to create a payment request. We will explain briefly how works payments on the Lightning Network. +For this example we've created a second lightning node using LND implementation to create an invoice to be payed later using our main c-lighting installation in next chapter. We will refer to this instance using `lnd$ ` prompt shell to indicate place where we'll generate LND commands. If you want to reproduce this steps you should use Bitcoin Standup to create a second machine and install LND. > :book: ***What is an invoice @@ -15,6 +16,17 @@ An invoice is made up of two parts, one is human readable and other is - Data part : UNIX Timestamp + tagged parts include a payment hash, the pubkey of the payee node, an optional description of the payment, an expiration time, and some extra routing information. +> :book: ***Conditional payments. + +As we said in Setting a channel chapter and although the channels are created between two participants, the channels can be connected to each other forming a payment network to allow payments between all the network participants without having a direct channel between them using an smart contract called **Hashed Time Locked Contract**. + +> :book: ***Hashed Time Locked Contract. + +A Hashed Time Locked Contract is a conditional payment that use hashlocks and timelocks to ensure payment security. This means that receiver must presents a payment preimage or generate a cryptographic proof of payment before a given time otherwise the payer can cancel the contract by spending it. This contracts are created as outputs from the Commitment transaction. + +> :book: ***Commitment transaction. + +Commitment transactions is a transaction that spends the funding transaction. Each peer holds the other peer's signature meaning that either one can spent his commitment transaction whatever he wants. After each new commitment transaction is created the old one is revoked. ### Node information From eabf768fc4f2001de86de2431e5f4f79b87d0d84 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Mon, 27 Jul 2020 22:55:40 +0200 Subject: [PATCH 077/126] Update 13_6_Close_Channel.md --- 13_6_Close_Channel.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/13_6_Close_Channel.md b/13_6_Close_Channel.md index 6e3f31f..9c1f4d5 100644 --- a/13_6_Close_Channel.md +++ b/13_6_Close_Channel.md @@ -2,3 +2,10 @@ > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. +In this chapter you'll be able to close a channel and learn what it means and how to do it using `lightning-cli close` command-line interface. The close RPC command attempts to close the channel cooperatively with the peer, or unilaterally after unilateraltimeout argument expires measured in seconds and the output will be sent to the address controlled by your c-lightning wallet if you don't specify one. + +### Channel close + +Close a channel means you and your counterparty will send their agreed-upon channel balance to the blockchain whereby you must pay transaction fees and must wait for the transaction to be mined. + + From bbd08b332752ede6e7b4b33081b8b74d73f73a06 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 11:48:48 +0200 Subject: [PATCH 078/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index ede2301..7cf8581 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -32,6 +32,8 @@ Commitment transactions is a transaction that spends the funding transaction. Ea In this second instance that we refer before you may get information about it using `lnd$lncli -n testnet getinfo` command. +> :warning: **WARNING:** Notice this example is using an LND instance, if you want to reproduce this steps you should use Bitcoin Standup Script and install a new LND instance. + ``` lnd$ lncli -n testnet getinfo { From 7cfc6faac2c260c0e5af370a2f396c463dbb5540 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 11:51:19 +0200 Subject: [PATCH 079/126] Update 13_4_Generate_a_Payment_Request.md --- 13_4_Generate_a_Payment_Request.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/13_4_Generate_a_Payment_Request.md b/13_4_Generate_a_Payment_Request.md index 7cf8581..4d9c822 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/13_4_Generate_a_Payment_Request.md @@ -30,7 +30,9 @@ Commitment transactions is a transaction that spends the funding transaction. Ea ### Node information -In this second instance that we refer before you may get information about it using `lnd$lncli -n testnet getinfo` command. +In this second instance that we refer before you may get information about it using `lnd$lncli -n testnet getinfo` command. Remember identity_pubkey field, due it will be the same value when you pay the invoice. + +**"identity_pubkey": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84"** > :warning: **WARNING:** Notice this example is using an LND instance, if you want to reproduce this steps you should use Bitcoin Standup Script and install a new LND instance. From 4dd4866d1b21cef6c6cc47e30b2f928e5bb783a6 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 11:52:57 +0200 Subject: [PATCH 080/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index c242dc2..71ad127 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -41,6 +41,10 @@ c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39v "signature": "30450221008c2a4d636465de07141b7c1277ffe621244299c39361ef86c0b898aafa50de8102204de4eb2e7495839beeb5540a9caf543641e44d52fdfdcb7261aec29c951b215f" } ``` +Check payee value is the same as identity_pubkey value seen previous chapter. + +"identity_pubkey": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + ### Check your balance As we did in previous chapter we have established an channel with a total capacity of 280.000 sats. This will be channel used to pay the invoice. From 971fc5ad08abab2c02aa48df7a1de6f5743d7cd9 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 11:53:25 +0200 Subject: [PATCH 081/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index 71ad127..eeb24e8 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -43,7 +43,7 @@ c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39v ``` Check payee value is the same as identity_pubkey value seen previous chapter. -"identity_pubkey": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", +**"identity_pubkey": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84",** ### Check your balance From 951e90358b00a5e3cfc5d712cbb7e900a60888ca Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 11:55:16 +0200 Subject: [PATCH 082/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 1 + 1 file changed, 1 insertion(+) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index eeb24e8..3b7b216 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -84,6 +84,7 @@ c$ lightning-cli --network=testnet listfunds ### Paying your invoice You should use `lightning-cli pay ` command to pay the invoice. The pay RPC command attempts to find a route to the given destination, and send the funds asked in amount value. +Notice amount is expressed in milli-satoshi. ``` c$lightning-cli --network=testnet pay From 8236cc219d8c0b73ee1b17f0edf5ec42463706c4 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 11:55:40 +0200 Subject: [PATCH 083/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 1 + 1 file changed, 1 insertion(+) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index 3b7b216..745c037 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -8,6 +8,7 @@ Consider this ln invoice, created before: `lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj ` + This invoice starts with prefix ln+tb+1m that indicates milli, so you should multi by 0.001. That means we'll pay an invoice by 100000 satoshis. ### Understanding your invoice From f4eaf990f1134861a6944ce5a20d199c9ebd2d77 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 12:01:56 +0200 Subject: [PATCH 084/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index 745c037..995381b 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -2,9 +2,9 @@ > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. -As we did in previous chapter we have an invoice to pay. +In this chapter you will learn how to pay an invoice using `lightning-cli pay ` command. As we did in previous chapter we already have an invoice to pay. -Consider this ln invoice, created before: +Check ln invoice: `lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj ` From 2703b55a9ea1fe24039196c8e653288c036dd5e4 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 12:05:19 +0200 Subject: [PATCH 085/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index 995381b..4f04779 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -148,4 +148,4 @@ We've created an invoice by 100.000 satoshis using a second machine and we've pa ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.6: Close a Channel](13_6_Close_channel.md). +Continue "Understanding Your Lightning Setup" with [§13.6: Close a Channel](13_6_Close_Channel.md). From 81ecdbc6954567051d6cbd73f28ed3c032b39836 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 12:34:09 +0200 Subject: [PATCH 086/126] Update and rename 13_6_Close_Channel.md to 13_6_Closing_a_Channel.md --- 13_6_Close_Channel.md | 11 --------- 13_6_Closing_a_Channel.md | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 11 deletions(-) delete mode 100644 13_6_Close_Channel.md create mode 100644 13_6_Closing_a_Channel.md diff --git a/13_6_Close_Channel.md b/13_6_Close_Channel.md deleted file mode 100644 index 9c1f4d5..0000000 --- a/13_6_Close_Channel.md +++ /dev/null @@ -1,11 +0,0 @@ -# 13.6: Close channel - -> :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. - -In this chapter you'll be able to close a channel and learn what it means and how to do it using `lightning-cli close` command-line interface. The close RPC command attempts to close the channel cooperatively with the peer, or unilaterally after unilateraltimeout argument expires measured in seconds and the output will be sent to the address controlled by your c-lightning wallet if you don't specify one. - -### Channel close - -Close a channel means you and your counterparty will send their agreed-upon channel balance to the blockchain whereby you must pay transaction fees and must wait for the transaction to be mined. - - diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md new file mode 100644 index 0000000..b345c5c --- /dev/null +++ b/13_6_Closing_a_Channel.md @@ -0,0 +1,48 @@ +# 13.6: Closing a Channel + +> :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. + +In this chapter you'll be able to close a channel and learn what it means and how to do it using `lightning-cli close` command-line interface. The close RPC command attempts to close the channel cooperatively with the peer, or unilaterally after unilateraltimeout argument expires measured in seconds and the output will be sent to the address controlled by your c-lightning wallet if you don't specify one. + +Close a channel means you and your counterparty will send their agreed-upon channel balance to the blockchain whereby you must pay transaction fees and must wait for the transaction to be mined. + +### Listing your channels. + +You can use the `lightning-cli listfunds` command to see your channels. This RPC command displays all funds available, either in unspent outputs (UTXOs) in the internal wallet or funds locked in currently open channels. + +``` +c$ lightning-cli --network=testnet listfunds +{ + "outputs": [ + { + "txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "output": 0, + "value": 19238, + "amount_msat": "19238000msat", + "scriptpubkey": "0014aa572371f29310cd677d039cdcd054156c1a9545", + "address": "tb1q4ftjxu0jjvgv6emaqwwde5z5z4kp49299gmdpd", + "status": "confirmed", + "blockheight": 1780768, + "reserved": false + } + ], + "channels": [ + { + "peer_id": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "connected": false, + "state": "CHANNELD_NORMAL", + "short_channel_id": "1780768x12x1", + "channel_sat": 180000, + "our_amount_msat": "180000000msat", + "channel_total_sat": 280000, + "amount_msat": "280000000msat", + "funding_txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "funding_output": 1 + } + ] +} +``` + +### Closing a channel + +You should use `lightning-cli close` command to close the channel. This RPC command attempts to close the channel cooperatively with the peer, or unilaterally after unilateraltimeout expires, and the to-local output will be sent to the address specified in destination. From f2f19f5b6af0573427f85bc60acb260ce0270be0 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 12:47:18 +0200 Subject: [PATCH 087/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index 4f04779..7493d0b 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -148,4 +148,4 @@ We've created an invoice by 100.000 satoshis using a second machine and we've pa ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.6: Close a Channel](13_6_Close_Channel.md). +Continue "Understanding Your Lightning Setup" with [§13.6: Close a Channel](13_6_Closing_a_Channel.md). From c817933acbffc1738424c50677045cbdf75456d1 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 12:47:44 +0200 Subject: [PATCH 088/126] Update 13_5_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_5_Paying_a_Invoice.md b/13_5_Paying_a_Invoice.md index 7493d0b..e13e00d 100644 --- a/13_5_Paying_a_Invoice.md +++ b/13_5_Paying_a_Invoice.md @@ -148,4 +148,4 @@ We've created an invoice by 100.000 satoshis using a second machine and we've pa ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.6: Close a Channel](13_6_Closing_a_Channel.md). +Continue "Understanding Your Lightning Setup" with [§13.6: Closing a Channel](13_6_Closing_a_Channel.md). From b6a6895ce296ee274e185ecf2b4eb3dcb6f45593 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 12:50:48 +0200 Subject: [PATCH 089/126] Update 13_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/13_3_Setting_Up_a_Channel.md b/13_3_Setting_Up_a_Channel.md index 89fa505..0408bfc 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/13_3_Setting_Up_a_Channel.md @@ -218,7 +218,8 @@ The funding_txid onchain is [9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740 #### Channel capacity -As we said before both sides of the channel own a portion of its capacity. The amount on your side of the channel is called *local balance* and the amount on your peer’s side is called *remote balance*. Both balances can be updated many times without closing the channel (sending final balance to the blockchain), but the channel capacity cannot change without closing or splicing it. Next chapter we will deep creating and paying invoices. +As we said before both sides of the channel own a portion of its capacity. The amount on your side of the channel is called *local balance* and the amount on your peer’s side is called *remote balance*. Both balances can be updated many times without closing the channel (sending final balance to the blockchain), but the channel capacity cannot change without closing or splicing it. The total capacity of a channel is the sum of the balance held by each participant in the channel. +Next chapter we will deep creating and paying invoices. ## Summary: Setting up a channel From cf7560ac109d462762b29a560bd8fba14fde52eb Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 13:55:20 +0200 Subject: [PATCH 090/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index b345c5c..c54b7e4 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -46,3 +46,17 @@ c$ lightning-cli --network=testnet listfunds ### Closing a channel You should use `lightning-cli close` command to close the channel. This RPC command attempts to close the channel cooperatively with the peer, or unilaterally after unilateraltimeout expires, and the to-local output will be sent to the address specified in destination. + +### Types of Closing Channels. + +Each participant of the channel is able to create as many Lightning payments to their counterparty as their funds they have. Most of the time there will be no disagreements between the participants, so there will only be two onchain transactions, one opening and the other closing the channel. + +#### Cooperative Close + +In this case both channel participants agree to close the channel and settle the final state to the blockchain. Both participants must be online and it's performed by broadcasting an unconditional spend of the funding transaction with an output to each peer. + +#### Foce Close + +In this case when only one participant is online or if the participants disagree on the last state of the channel, so one peer can perform an unilateral close of the channel without the cooperation of the other node. It's performed by broadcasting a commitment transaction that commits to a previous channel state which both parts have agreed upon. + + From b4f5784931b868f6e003e56c2cbf1d9b6dd0687d Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 14:45:46 +0200 Subject: [PATCH 091/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index c54b7e4..b677721 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -43,7 +43,7 @@ c$ lightning-cli --network=testnet listfunds } ``` -### Closing a channel +## Closing a channel You should use `lightning-cli close` command to close the channel. This RPC command attempts to close the channel cooperatively with the peer, or unilaterally after unilateraltimeout expires, and the to-local output will be sent to the address specified in destination. From b6182c380363b00176a0c807bf6007dda706ee59 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 15:50:02 +0200 Subject: [PATCH 092/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index b677721..31535a6 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -49,14 +49,15 @@ You should use `lightning-cli close` command to close the channel. This RPC co ### Types of Closing Channels. -Each participant of the channel is able to create as many Lightning payments to their counterparty as their funds they have. Most of the time there will be no disagreements between the participants, so there will only be two onchain transactions, one opening and the other closing the channel. +Each participant of the channel is able to create as many Lightning payments to their counterparty as their funds they have. Most of the time there will be no disagreements between the participants, so there will only be two onchain transactions, one opening and the other closing the channel. However, there may be other scenarios in which you are not online, you do not agree with the last state of the channel or someone tries to steal funds from the other party. #### Cooperative Close In this case both channel participants agree to close the channel and settle the final state to the blockchain. Both participants must be online and it's performed by broadcasting an unconditional spend of the funding transaction with an output to each peer. -#### Foce Close +#### Force Close In this case when only one participant is online or if the participants disagree on the last state of the channel, so one peer can perform an unilateral close of the channel without the cooperation of the other node. It's performed by broadcasting a commitment transaction that commits to a previous channel state which both parts have agreed upon. +This commitment transaction contains the channel state divided in two parts: the balance of each participant and all the pending payments (HTLCs). From 0f4ad8c316ac6d144ced6fd0fbc3e8a478707fd9 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 17:09:54 +0200 Subject: [PATCH 093/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index 31535a6..25947db 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -60,4 +60,22 @@ In this case both channel participants agree to close the channel and settle the In this case when only one participant is online or if the participants disagree on the last state of the channel, so one peer can perform an unilateral close of the channel without the cooperation of the other node. It's performed by broadcasting a commitment transaction that commits to a previous channel state which both parts have agreed upon. This commitment transaction contains the channel state divided in two parts: the balance of each participant and all the pending payments (HTLCs). +### Node Information + +Now we'll show you how to get information about your channel using `lightning-cli listchannels` command. The listchannels RPC command returns data on channels that are known to the node. Because channels may be bidirectional, up to 2 objects will be returned for each channel (one for each direction). To query information about own channels we'll use jq tool showed in previous chapters. + +First we'll get our own node id public_key in NODEID variable. + +``` +c$ NODEID=$(lightning-cli --network=testnet getinfo | jq .id) +c$ echo $NODEID +"03fce2a20393a65b9d6cab5425f4cd33ddc621ade458efd69d652917e2b5eaf59c" +c$ +``` +Later we'll use select to show only data containing public_key id as source or destination. + +``` +$ lightning-cli listchannels | jq '.channels[] | select(.source == '$NODEID' or .destination == '$NODEID')' +``` + From 04c5ef68175e52178307cef2009626869a16cefd Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 20:10:33 +0200 Subject: [PATCH 094/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index 25947db..06d587a 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -76,6 +76,25 @@ Later we'll use select to show only data containing public_key id as source or d ``` $ lightning-cli listchannels | jq '.channels[] | select(.source == '$NODEID' or .destination == '$NODEID')' +{ + "source": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "destination": "03fce2a20393a65b9d6cab5425f4cd33ddc621ade458efd69d652917e2b5eaf59c", + "short_channel_id": "1780768x12x1", + "public": true, + "satoshis": 280000, + "amount_msat": "280000000msat", + "message_flags": 1, + "channel_flags": 2, + "active": false, + "last_update": 1595508075, + "base_fee_millisatoshi": 1000, + "fee_per_millionth": 1, + "delay": 40, + "htlc_minimum_msat": "1000msat", + "htlc_maximum_msat": "280000000msat", + "features": "" +} + ``` From ec9a0e098c9a115134d86d5729c6c21e52997445 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 20:11:45 +0200 Subject: [PATCH 095/126] Update 13_6_Closing_a_Channel.md From f3c79e480965c3695a67a012385edfff99b0b747 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 20:32:14 +0200 Subject: [PATCH 096/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index 06d587a..c6fd4d7 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -77,15 +77,15 @@ Later we'll use select to show only data containing public_key id as source or d ``` $ lightning-cli listchannels | jq '.channels[] | select(.source == '$NODEID' or .destination == '$NODEID')' { - "source": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", - "destination": "03fce2a20393a65b9d6cab5425f4cd33ddc621ade458efd69d652917e2b5eaf59c", + "source": "03fce2a20393a65b9d6cab5425f4cd33ddc621ade458efd69d652917e2b5eaf59c", + "destination": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", "short_channel_id": "1780768x12x1", "public": true, "satoshis": 280000, "amount_msat": "280000000msat", "message_flags": 1, "channel_flags": 2, - "active": false, + "active": true, "last_update": 1595508075, "base_fee_millisatoshi": 1000, "fee_per_millionth": 1, @@ -94,7 +94,6 @@ $ lightning-cli listchannels | jq '.channels[] | select(.source == '$NODEID' or "htlc_maximum_msat": "280000000msat", "features": "" } - ``` From 18756e2f12b30bf8f15f94bbc1d9a07ac5a62c24 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 23:20:06 +0200 Subject: [PATCH 097/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index 7962bf2..d89828a 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -31,4 +31,4 @@ Supporting objectives include the ability to: * [Section Three: Setting Up a channel](13_3_Setting_Up_a_Channel.md) * [Section Four: Generate a payment request](13_4_Generate_a_Payment_Request.md) * [Section Five: Paying an invoice](13_5_Paying_a_Invoice.md) -* [Section Five: Close a Channel](13_6_Close_channel.md) +* [Section Five: Close a Channel](13_6_Closing_a_Channel.md) From f2e9d4f02f811c7f8599dc342155c976437cc52c Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 23:20:29 +0200 Subject: [PATCH 098/126] Update 13_0_Understanding_Your_Lightning_Setup.md --- 13_0_Understanding_Your_Lightning_Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/13_0_Understanding_Your_Lightning_Setup.md index d89828a..31e8d22 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/13_0_Understanding_Your_Lightning_Setup.md @@ -31,4 +31,4 @@ Supporting objectives include the ability to: * [Section Three: Setting Up a channel](13_3_Setting_Up_a_Channel.md) * [Section Four: Generate a payment request](13_4_Generate_a_Payment_Request.md) * [Section Five: Paying an invoice](13_5_Paying_a_Invoice.md) -* [Section Five: Close a Channel](13_6_Closing_a_Channel.md) +* [Section Five: Closing a Channel](13_6_Closing_a_Channel.md) From 7481a2a303d64b5c890c6af3a16cb21786f176a8 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Tue, 28 Jul 2020 23:58:58 +0200 Subject: [PATCH 099/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 111 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index c6fd4d7..a655b1d 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -95,5 +95,116 @@ $ lightning-cli listchannels | jq '.channels[] | select(.source == '$NODEID' or "features": "" } ``` +### Closing a channel +Finally you should use `lightning-cli close` command to close the channel. The close RPC command attempts to close the channel cooperatively with the peer, if you want to close it unilaterally set unilateraltimeout argument with number of seconds command will wait. If you set to 0 and the peer is online command can negotiate a mutual close. For this example we use an mutual close. +``` +lightning-cli --network=testnet close 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 0 +{ + "tx": "0200000001a67ad9b15cb10b74a584a284f059866dd2114e45f2a997b260464af537c043980100000000ffffffff02a08601000000000016001404e34b25e1310c9b90c7a53a6eba88f4eefe8efb69be020000000000160014865353eaccaa94aa4f90d3a0acdf3903c06c12c400000000", + "txid": "b4c0a1993dd113081eff5369a22d6afe1af9f0d07b29a590e8772ac7f712736a", + "type": "mutual" +} +``` +The closing transaction onchain is [b4c0a1993dd113081eff5369a22d6afe1af9f0d07b29a590e8772ac7f712736a](https://blockstream.info/testnet/tx/b4c0a1993dd113081eff5369a22d6afe1af9f0d07b29a590e8772ac7f712736a). + +This transaction has two outputs, one for remote node and other for local c-lightning wallet. Output on index 0 corresponds to remote node with a value of 100000. Output on index 1 correspond to local node with a value of 179817. + +``` +c$ bitcoin-cli -testnet getrawtransaction b4c0a1993dd113081eff5369a22d6afe1af9f0d07b29a590e8772ac7f712736a 1 +{ + "txid": "b4c0a1993dd113081eff5369a22d6afe1af9f0d07b29a590e8772ac7f712736a", + "hash": "9433409227ca3d7a6999cdcc2856272314aef96f0e869a04711eda4969bbd21f", + "version": 2, + "size": 334, + "vsize": 169, + "weight": 673, + "locktime": 0, + "vin": [ + { + "txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "vout": 1, + "scriptSig": { + "asm": "", + "hex": "" + }, + "txinwitness": [ + "", + "3045022100ef40a71fc4d4d0e197cd3d503961da90b71cedab25f6f30740b3640664efb617022061f68aaffccf739824668d07519c8cb59ec30117d87beff2ef217e31cb5e628801", + "304402201a28274f64ec78fecba74ebc2b13582564ab155f83593c65ca1667bb92c42de10220489e7c3adc5be8bac2c5771482e5571abd3f602cb40ece2cfea3b768eb5341ea01", + "52210364d9b2e600d837aad224702c5f30c0ab73ac499cb67f43899cbf83f6358d422c21036695eadb796fe140434aad02c7da76395a44f62747770bf381fa4a3c52ff279452ae" + ], + "sequence": 4294967295 + } + ], + "vout": [ + { + "value": 0.00100000, + "n": 0, + "scriptPubKey": { + "asm": "0 04e34b25e1310c9b90c7a53a6eba88f4eefe8efb", + "hex": "001404e34b25e1310c9b90c7a53a6eba88f4eefe8efb", + "reqSigs": 1, + "type": "witness_v0_keyhash", + "addresses": [ + "tb1qqn35kf0pxyxfhyx855axaw5g7nh0arhmxyv3zk" + ] + } + }, + { + "value": 0.00179817, + "n": 1, + "scriptPubKey": { + "asm": "0 865353eaccaa94aa4f90d3a0acdf3903c06c12c4", + "hex": "0014865353eaccaa94aa4f90d3a0acdf3903c06c12c4", + "reqSigs": 1, + "type": "witness_v0_keyhash", + "addresses": [ + "tb1qsef486kv42225nus6ws2eheeq0qxcykycqsymn" + ] + } + } + ], + "hex": "02000000000101a67ad9b15cb10b74a584a284f059866dd2114e45f2a997b260464af537c043980100000000ffffffff02a08601000000000016001404e34b25e1310c9b90c7a53a6eba88f4eefe8efb69be020000000000160014865353eaccaa94aa4f90d3a0acdf3903c06c12c40400483045022100ef40a71fc4d4d0e197cd3d503961da90b71cedab25f6f30740b3640664efb617022061f68aaffccf739824668d07519c8cb59ec30117d87beff2ef217e31cb5e62880147304402201a28274f64ec78fecba74ebc2b13582564ab155f83593c65ca1667bb92c42de10220489e7c3adc5be8bac2c5771482e5571abd3f602cb40ece2cfea3b768eb5341ea014752210364d9b2e600d837aad224702c5f30c0ab73ac499cb67f43899cbf83f6358d422c21036695eadb796fe140434aad02c7da76395a44f62747770bf381fa4a3c52ff279452ae00000000" +} +``` + +Listing funds onchain or offchain we get an output with a value of 179817 that results of 280000 minus 183 per fee in 279817. We have to substract 100000 paid on the invoice of the previous chapter to finally receives 179817 satoshis. + +``` +lightning-cli --network=testnet listfunds +{ + "outputs": [ + { + "txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "output": 0, + "value": 19238, + "amount_msat": "19238000msat", + "scriptpubkey": "0014aa572371f29310cd677d039cdcd054156c1a9545", + "address": "tb1q4ftjxu0jjvgv6emaqwwde5z5z4kp49299gmdpd", + "status": "confirmed", + "blockheight": 1780768, + "reserved": false + }, + { + "txid": "b4c0a1993dd113081eff5369a22d6afe1af9f0d07b29a590e8772ac7f712736a", + "output": 1, + "value": 179817, + "amount_msat": "179817000msat", + "scriptpubkey": "0014865353eaccaa94aa4f90d3a0acdf3903c06c12c4", + "address": "tb1qsef486kv42225nus6ws2eheeq0qxcykycqsymn", + "status": "confirmed", + "blockheight": 1781830, + "reserved": false + } +} +``` + +## Summary: Closing a channel + +When you close a channel you perform an onchain transaction ending your financial relationship with remote node. To close a channel you must take into account its status and the type of closure you want to execute and decide some arguments to do it. + +## What's Next? + +Continue "Understanding Your Lightning Setup" with [§13.7: Lightning Network Implementations](13_7_Lightning_Network_Implementations.md). From 624cd21d8789fc8c26605c53b9550083d931eece Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 30 Jul 2020 22:43:13 +0200 Subject: [PATCH 100/126] Create Lightning_Network_Implementations.md --- Lightning_Network_Implementations.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Lightning_Network_Implementations.md diff --git a/Lightning_Network_Implementations.md b/Lightning_Network_Implementations.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Lightning_Network_Implementations.md @@ -0,0 +1 @@ + From 87f64a1f77685453a1e407ac19307d43a63ff4b5 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 30 Jul 2020 22:43:42 +0200 Subject: [PATCH 101/126] Delete Lightning_Network_Implementations.md --- Lightning_Network_Implementations.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Lightning_Network_Implementations.md diff --git a/Lightning_Network_Implementations.md b/Lightning_Network_Implementations.md deleted file mode 100644 index 8b13789..0000000 --- a/Lightning_Network_Implementations.md +++ /dev/null @@ -1 +0,0 @@ - From c1854ab27ceaf812377a94190c42c80f79be2355 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 30 Jul 2020 22:44:19 +0200 Subject: [PATCH 102/126] Create 13_7_Lightning_Network_Implementations.md --- 13_7_Lightning_Network_Implementations.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 13_7_Lightning_Network_Implementations.md diff --git a/13_7_Lightning_Network_Implementations.md b/13_7_Lightning_Network_Implementations.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/13_7_Lightning_Network_Implementations.md @@ -0,0 +1 @@ + From 69ab776ddee829c54286758ff547575e3afc1965 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 30 Jul 2020 22:49:47 +0200 Subject: [PATCH 103/126] Update 13_7_Lightning_Network_Implementations.md --- 13_7_Lightning_Network_Implementations.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/13_7_Lightning_Network_Implementations.md b/13_7_Lightning_Network_Implementations.md index 8b13789..04db5ea 100644 --- a/13_7_Lightning_Network_Implementations.md +++ b/13_7_Lightning_Network_Implementations.md @@ -1 +1,4 @@ - +| Name | Description | +| ------------- | ------------- | +| C-lighting | Blockstream | +| LND | Lightning Labs | From a4cdea0ef3e7317a1520d7db598a0a01c527052b Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 30 Jul 2020 22:57:58 +0200 Subject: [PATCH 104/126] Update 13_7_Lightning_Network_Implementations.md --- 13_7_Lightning_Network_Implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13_7_Lightning_Network_Implementations.md b/13_7_Lightning_Network_Implementations.md index 04db5ea..d2f58df 100644 --- a/13_7_Lightning_Network_Implementations.md +++ b/13_7_Lightning_Network_Implementations.md @@ -1,4 +1,4 @@ -| Name | Description | +| Name | Description | | ------------- | ------------- | | C-lighting | Blockstream | | LND | Lightning Labs | From fb91f7529c488ac4895c928424f3d45ef414b28f Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 30 Jul 2020 23:04:25 +0200 Subject: [PATCH 105/126] Update 13_7_Lightning_Network_Implementations.md --- 13_7_Lightning_Network_Implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/13_7_Lightning_Network_Implementations.md b/13_7_Lightning_Network_Implementations.md index d2f58df..d937bf5 100644 --- a/13_7_Lightning_Network_Implementations.md +++ b/13_7_Lightning_Network_Implementations.md @@ -2,3 +2,4 @@ | ------------- | ------------- | | C-lighting | Blockstream | | LND | Lightning Labs | +| Eclair | ACINQ | From 63a5b4f4a42b013ffe814a7b5369e54a50f6dab2 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 13:53:43 +0200 Subject: [PATCH 106/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index a655b1d..8121630 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -60,6 +60,12 @@ In this case both channel participants agree to close the channel and settle the In this case when only one participant is online or if the participants disagree on the last state of the channel, so one peer can perform an unilateral close of the channel without the cooperation of the other node. It's performed by broadcasting a commitment transaction that commits to a previous channel state which both parts have agreed upon. This commitment transaction contains the channel state divided in two parts: the balance of each participant and all the pending payments (HTLCs). +To perform this kind of close you need to specify an argument called unilateraltimeout. If this value is not zero, the close command will unilaterally close the channel when that number of seconds is reached like this: + +``` + +``` + ### Node Information Now we'll show you how to get information about your channel using `lightning-cli listchannels` command. The listchannels RPC command returns data on channels that are known to the node. Because channels may be bidirectional, up to 2 objects will be returned for each channel (one for each direction). To query information about own channels we'll use jq tool showed in previous chapters. From ea00e42e254a4df8614725ae1d83f999602d8959 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 14:28:56 +0200 Subject: [PATCH 107/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index 8121630..6c771a5 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -42,6 +42,13 @@ c$ lightning-cli --network=testnet listfunds ] } ``` +Each channel has an identifier expressed in the short_channel_id field. Each value in short_channel_id means + +"1780768x12x1" + +* Created on 1780768 block. +* transaction index (12). +* output index (1). ## Closing a channel @@ -81,7 +88,7 @@ c$ Later we'll use select to show only data containing public_key id as source or destination. ``` -$ lightning-cli listchannels | jq '.channels[] | select(.source == '$NODEID' or .destination == '$NODEID')' +c$ lightning-cli listchannels | jq '.channels[] | select(.source == '$NODEID' or .destination == '$NODEID')' { "source": "03fce2a20393a65b9d6cab5425f4cd33ddc621ade458efd69d652917e2b5eaf59c", "destination": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", @@ -105,8 +112,18 @@ $ lightning-cli listchannels | jq '.channels[] | select(.source == '$NODEID' or Finally you should use `lightning-cli close` command to close the channel. The close RPC command attempts to close the channel cooperatively with the peer, if you want to close it unilaterally set unilateraltimeout argument with number of seconds command will wait. If you set to 0 and the peer is online command can negotiate a mutual close. For this example we use an mutual close. +Now we'll get remote node id public key in a variable: + ``` -lightning-cli --network=testnet close 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 0 +c$ $NODEIDREMOTE=lightning-cli listchannels | jq '.channels[] | select(.source == '$NODEID')' | jq .destination +c$ echo $NODEIDREMOTE +0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 +c$ +``` +Now we use NODEIDREMOTE to close channel: + +``` +c$lightning-cli --network=testnet close $NODEIDREMOTE 0 { "tx": "0200000001a67ad9b15cb10b74a584a284f059866dd2114e45f2a997b260464af537c043980100000000ffffffff02a08601000000000016001404e34b25e1310c9b90c7a53a6eba88f4eefe8efb69be020000000000160014865353eaccaa94aa4f90d3a0acdf3903c06c12c400000000", "txid": "b4c0a1993dd113081eff5369a22d6afe1af9f0d07b29a590e8772ac7f712736a", @@ -179,7 +196,7 @@ c$ bitcoin-cli -testnet getrawtransaction b4c0a1993dd113081eff5369a22d6afe1af9f0 Listing funds onchain or offchain we get an output with a value of 179817 that results of 280000 minus 183 per fee in 279817. We have to substract 100000 paid on the invoice of the previous chapter to finally receives 179817 satoshis. ``` -lightning-cli --network=testnet listfunds +c$lightning-cli --network=testnet listfunds { "outputs": [ { From 2fe9709986b3d04089a290710e315777a6cdbc2d Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 15:13:12 +0200 Subject: [PATCH 108/126] Update 13_6_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/13_6_Closing_a_Channel.md b/13_6_Closing_a_Channel.md index 6c771a5..b13a15e 100644 --- a/13_6_Closing_a_Channel.md +++ b/13_6_Closing_a_Channel.md @@ -70,6 +70,12 @@ This commitment transaction contains the channel state divided in two parts: the To perform this kind of close you need to specify an argument called unilateraltimeout. If this value is not zero, the close command will unilaterally close the channel when that number of seconds is reached like this: ``` +c$ lightning-cli --network=testnet close $NODEIDREMOTE 60 +{ + "tx": "0200000001a1091f727e6041cc93fead2ea46b8402133f53e6ab89ab106b49638c11f27cba00000000006a40aa8001df85010000000000160014d22818913daf3b4f86e0bcb302a5a812d1ef6b91c6772d20", + "txid": "02cc4c647eb3e06f37fcbde39871ebae4333b7581954ea86b27b85ced6a5c4f7", + "type": "unilateral" +} ``` From f59a945446f6df32929bc40642c610f707ac994b Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 16:06:50 +0200 Subject: [PATCH 109/126] Update and rename 13_0_Understanding_Your_Lightning_Setup.md to 18_0_Understanding_Your_Lightning_Setup.md --- ...d => 18_0_Understanding_Your_Lightning_Setup.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename 13_0_Understanding_Your_Lightning_Setup.md => 18_0_Understanding_Your_Lightning_Setup.md (79%) diff --git a/13_0_Understanding_Your_Lightning_Setup.md b/18_0_Understanding_Your_Lightning_Setup.md similarity index 79% rename from 13_0_Understanding_Your_Lightning_Setup.md rename to 18_0_Understanding_Your_Lightning_Setup.md index 31e8d22..98c090f 100644 --- a/13_0_Understanding_Your_Lightning_Setup.md +++ b/18_0_Understanding_Your_Lightning_Setup.md @@ -1,4 +1,4 @@ -# Chapter Thirteen: Understanding Your Lighting Setup +# Chapter Eighteen: Understanding Your Lighting Setup > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. @@ -26,9 +26,9 @@ Supporting objectives include the ability to: ## Table of Contents -* [Section One: Verifying Your Lightning Setup](13_1_Verifying_Your_Lightning_Setup.md) -* [Section Two: Knowing Your Lightning Setup](13_2_Knowing_Your_lightning_Setup.md) -* [Section Three: Setting Up a channel](13_3_Setting_Up_a_Channel.md) -* [Section Four: Generate a payment request](13_4_Generate_a_Payment_Request.md) -* [Section Five: Paying an invoice](13_5_Paying_a_Invoice.md) -* [Section Five: Closing a Channel](13_6_Closing_a_Channel.md) +* [Section One: Verifying Your Lightning Setup](18_1_Verifying_Your_Lightning_Setup.md) +* [Section Two: Knowing Your Lightning Setup](18_2_Knowing_Your_lightning_Setup.md) +* [Section Three: Setting Up a channel](18_3_Setting_Up_a_Channel.md) +* [Section Four: Generate a payment request](18_4_Generate_a_Payment_Request.md) +* [Section Five: Paying an invoice](18_5_Paying_a_Invoice.md) +* [Section Five: Closing a Channel](18_6_Closing_a_Channel.md) From 31f40f73ef7ff65571e45346d39a93dae6d7bf97 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 16:08:42 +0200 Subject: [PATCH 110/126] Update 18_0_Understanding_Your_Lightning_Setup.md --- 18_0_Understanding_Your_Lightning_Setup.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/18_0_Understanding_Your_Lightning_Setup.md b/18_0_Understanding_Your_Lightning_Setup.md index 98c090f..5080c66 100644 --- a/18_0_Understanding_Your_Lightning_Setup.md +++ b/18_0_Understanding_Your_Lightning_Setup.md @@ -29,6 +29,6 @@ Supporting objectives include the ability to: * [Section One: Verifying Your Lightning Setup](18_1_Verifying_Your_Lightning_Setup.md) * [Section Two: Knowing Your Lightning Setup](18_2_Knowing_Your_lightning_Setup.md) * [Section Three: Setting Up a channel](18_3_Setting_Up_a_Channel.md) -* [Section Four: Generate a payment request](18_4_Generate_a_Payment_Request.md) -* [Section Five: Paying an invoice](18_5_Paying_a_Invoice.md) -* [Section Five: Closing a Channel](18_6_Closing_a_Channel.md) +* [Section Four: Generate a payment request](19_1_Generate_a_Payment_Request.md) +* [Section Five: Paying an invoice](19_2_Paying_a_Invoice.md) +* [Section Five: Closing a Channel](19_3_Closing_a_Channel.md) From 41f6c8689f6e8241d362ef1f485c47dfba04c0cb Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 16:10:05 +0200 Subject: [PATCH 111/126] Update and rename 13_1_Verifying_Your_Lightning_Setup.md to 18_1_Verifying_Your_Lightning_Setup.md --- ...ghtning_Setup.md => 18_1_Verifying_Your_Lightning_Setup.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename 13_1_Verifying_Your_Lightning_Setup.md => 18_1_Verifying_Your_Lightning_Setup.md (99%) diff --git a/13_1_Verifying_Your_Lightning_Setup.md b/18_1_Verifying_Your_Lightning_Setup.md similarity index 99% rename from 13_1_Verifying_Your_Lightning_Setup.md rename to 18_1_Verifying_Your_Lightning_Setup.md index c68b611..2fdf476 100644 --- a/13_1_Verifying_Your_Lightning_Setup.md +++ b/18_1_Verifying_Your_Lightning_Setup.md @@ -1,5 +1,5 @@ -# 13.1: Verifying Your Lightning Setup +# 18.1: Verifying Your Lightning Setup > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. @@ -370,4 +370,4 @@ Before you start playing with lightning, you should make sure that your aliases ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.2: Knowing Your Lightning Setup](13_2_Knowing_Your_lightning_Setup.md). +Continue "Understanding Your Lightning Setup" with [§18.2: Knowing Your Lightning Setup](18_2_Knowing_Your_lightning_Setup.md). From 92ec671b9f4a0b01f23037eed5ca71d62280a49d Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 16:11:02 +0200 Subject: [PATCH 112/126] Update and rename 13_2_Knowing_Your_lightning_Setup.md to 18_2_Knowing_Your_lightning_Setup.md --- ...lightning_Setup.md => 18_2_Knowing_Your_lightning_Setup.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename 13_2_Knowing_Your_lightning_Setup.md => 18_2_Knowing_Your_lightning_Setup.md (98%) diff --git a/13_2_Knowing_Your_lightning_Setup.md b/18_2_Knowing_Your_lightning_Setup.md similarity index 98% rename from 13_2_Knowing_Your_lightning_Setup.md rename to 18_2_Knowing_Your_lightning_Setup.md index a1861b9..e0c7f4a 100644 --- a/13_2_Knowing_Your_lightning_Setup.md +++ b/18_2_Knowing_Your_lightning_Setup.md @@ -1,4 +1,4 @@ -# 13.2: Knowing Your Lightning Setup +# 18.2: Knowing Your Lightning Setup > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. @@ -327,4 +327,4 @@ The `~/.lightning` directory contains all of your files, while `lightning-cli he ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.3: Setting Up_a_Channel](13_3_Setting_Up_a_Channel.md). +Continue "Understanding Your Lightning Setup" with [§18.3: Setting Up_a_Channel](18_3_Setting_Up_a_Channel.md). From a09babfdab3da3f064e615ad36b0209fcdb85155 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 16:13:43 +0200 Subject: [PATCH 113/126] Update and rename 13_3_Setting_Up_a_Channel.md to 18_3_Setting_Up_a_Channel.md --- 13_3_Setting_Up_a_Channel.md => 18_3_Setting_Up_a_Channel.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename 13_3_Setting_Up_a_Channel.md => 18_3_Setting_Up_a_Channel.md (98%) diff --git a/13_3_Setting_Up_a_Channel.md b/18_3_Setting_Up_a_Channel.md similarity index 98% rename from 13_3_Setting_Up_a_Channel.md rename to 18_3_Setting_Up_a_Channel.md index 0408bfc..0565937 100644 --- a/13_3_Setting_Up_a_Channel.md +++ b/18_3_Setting_Up_a_Channel.md @@ -1,4 +1,4 @@ -# 13.3: Setting Up a Channel +# 18.3: Setting Up a Channel > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. @@ -228,6 +228,6 @@ You need to create a channel with remote nodes to be able to receive and send mo ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.4: Generate a Payment request](13_4_Generate_a_Payment_Request.md). +Continue "Understanding Your Lightning Setup" with [§19.1: Generate a Payment request](19_1_Generate_a_Payment_Request.md). From 69dd54d0c14c9e75d30b16ebbd1f0095d3362bfc Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 16:16:26 +0200 Subject: [PATCH 114/126] Update and rename 13_4_Generate_a_Payment_Request.md to 19_1_Generate_a_Payment_Request.md --- ...Payment_Request.md => 19_1_Generate_a_Payment_Request.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename 13_4_Generate_a_Payment_Request.md => 19_1_Generate_a_Payment_Request.md (93%) diff --git a/13_4_Generate_a_Payment_Request.md b/19_1_Generate_a_Payment_Request.md similarity index 93% rename from 13_4_Generate_a_Payment_Request.md rename to 19_1_Generate_a_Payment_Request.md index 4d9c822..230170b 100644 --- a/13_4_Generate_a_Payment_Request.md +++ b/19_1_Generate_a_Payment_Request.md @@ -1,5 +1,5 @@ -# 13.4: Generate a Payment request. +# 19.1: Generate a Payment request. > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. @@ -26,7 +26,7 @@ A Hashed Time Locked Contract is a conditional payment that use hashlocks and ti > :book: ***Commitment transaction. -Commitment transactions is a transaction that spends the funding transaction. Each peer holds the other peer's signature meaning that either one can spent his commitment transaction whatever he wants. After each new commitment transaction is created the old one is revoked. +Commitment transaction is a transaction that spends the funding transaction. Each peer holds the other peer's signature meaning that either one can spent his commitment transaction whatever he wants. After each new commitment transaction is created the old one is revoked. ### Node information @@ -122,7 +122,7 @@ In most cases you need to receive an invoice to use Lightning Network payments. ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.5: Paying_a_Invoice](13_5_Paying_a_Invoice.md). +Continue "Understanding Your Lightning Setup" with [§19.2: Paying_a_Invoice](19_2_Paying_a_Invoice.md). From f42234a575185453ca0c3aa7e14d53ee8d0a8ddb Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 16:18:13 +0200 Subject: [PATCH 115/126] Update and rename 13_5_Paying_a_Invoice.md to 19_2_Paying_a_Invoice.md --- 13_5_Paying_a_Invoice.md => 19_2_Paying_a_Invoice.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename 13_5_Paying_a_Invoice.md => 19_2_Paying_a_Invoice.md (98%) diff --git a/13_5_Paying_a_Invoice.md b/19_2_Paying_a_Invoice.md similarity index 98% rename from 13_5_Paying_a_Invoice.md rename to 19_2_Paying_a_Invoice.md index e13e00d..f9146a9 100644 --- a/13_5_Paying_a_Invoice.md +++ b/19_2_Paying_a_Invoice.md @@ -1,4 +1,4 @@ -# 13.5: Paying a Invoice +# 19.2: Paying a Invoice > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. @@ -148,4 +148,4 @@ We've created an invoice by 100.000 satoshis using a second machine and we've pa ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.6: Closing a Channel](13_6_Closing_a_Channel.md). +Continue "Understanding Your Lightning Setup" with [§19.3: Closing a Channel](19_3_Closing_a_Channel.md). From 0e186876cb2082de0af03b3c94afa8710bdad724 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 16:21:09 +0200 Subject: [PATCH 116/126] Update and rename 13_6_Closing_a_Channel.md to 19_3_Closing_a_Channel.md --- 13_6_Closing_a_Channel.md => 19_3_Closing_a_Channel.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename 13_6_Closing_a_Channel.md => 19_3_Closing_a_Channel.md (98%) diff --git a/13_6_Closing_a_Channel.md b/19_3_Closing_a_Channel.md similarity index 98% rename from 13_6_Closing_a_Channel.md rename to 19_3_Closing_a_Channel.md index b13a15e..849fed0 100644 --- a/13_6_Closing_a_Channel.md +++ b/19_3_Closing_a_Channel.md @@ -1,4 +1,4 @@ -# 13.6: Closing a Channel +# 19.3: Closing a Channel > :information_source: **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning. @@ -126,7 +126,7 @@ c$ echo $NODEIDREMOTE 0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84 c$ ``` -Now we use NODEIDREMOTE to close channel: +Now we use NODEIDREMOTE variable to close channel: ``` c$lightning-cli --network=testnet close $NODEIDREMOTE 0 @@ -236,4 +236,4 @@ When you close a channel you perform an onchain transaction ending your financia ## What's Next? -Continue "Understanding Your Lightning Setup" with [§13.7: Lightning Network Implementations](13_7_Lightning_Network_Implementations.md). +Continue "Understanding Your Lightning Setup" with [§19.4: Lightning Network Implementations](19_4_Lightning_Network_Implementations.md). From 56f145f2b696618d1d92b54acf5dbbb88a291ad3 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 17:02:20 +0200 Subject: [PATCH 117/126] Update 13_7_Lightning_Network_Implementations.md --- 13_7_Lightning_Network_Implementations.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/13_7_Lightning_Network_Implementations.md b/13_7_Lightning_Network_Implementations.md index d937bf5..eee9ba2 100644 --- a/13_7_Lightning_Network_Implementations.md +++ b/13_7_Lightning_Network_Implementations.md @@ -1,5 +1,9 @@ -| Name | Description | -| ------------- | ------------- | -| C-lighting | Blockstream | -| LND | Lightning Labs | -| Eclair | ACINQ | +### Lightning Network implementations + + +| Name | Description | BitcoinStandup | Language | Repository | +| ------------- | ------------- | :---: | ------------- | ------------- | +| C-lighting | Blockstream | X | C | [Download](https://github.com/ElementsProject/lightning) | +| LND | Lightning Labs | X | Go | [Download](https://github.com/lightningnetwork/lnd) | +| Eclair | ACINQ | - | Scala | [Download](https://github.com/ACINQ/eclair) | + From 8010d7707a62502bcc015fab3d5c7a0dc4d67ed4 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 17:02:44 +0200 Subject: [PATCH 118/126] Rename 13_7_Lightning_Network_Implementations.md to 19_4_Lightning_Network_Implementations.md --- ...mplementations.md => 19_4_Lightning_Network_Implementations.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 13_7_Lightning_Network_Implementations.md => 19_4_Lightning_Network_Implementations.md (100%) diff --git a/13_7_Lightning_Network_Implementations.md b/19_4_Lightning_Network_Implementations.md similarity index 100% rename from 13_7_Lightning_Network_Implementations.md rename to 19_4_Lightning_Network_Implementations.md From eb31ef9e28ed0564a28d73b58027b77b1a471e24 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 18:00:54 +0200 Subject: [PATCH 119/126] Update 19_4_Lightning_Network_Implementations.md --- 19_4_Lightning_Network_Implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/19_4_Lightning_Network_Implementations.md b/19_4_Lightning_Network_Implementations.md index eee9ba2..518a9aa 100644 --- a/19_4_Lightning_Network_Implementations.md +++ b/19_4_Lightning_Network_Implementations.md @@ -1,5 +1,6 @@ ### Lightning Network implementations +In this brief review we list the most widely used implementations in the lightning network Today, although there are more. Basis of Lightning Technology (BOLT) documents describe a layer-2 protocol for off-chain bitcoin transfers. The specifications are currently a work-in-progress and currently being drafted. | Name | Description | BitcoinStandup | Language | Repository | | ------------- | ------------- | :---: | ------------- | ------------- | @@ -7,3 +8,4 @@ | LND | Lightning Labs | X | Go | [Download](https://github.com/lightningnetwork/lnd) | | Eclair | ACINQ | - | Scala | [Download](https://github.com/ACINQ/eclair) | + From cceec6d00be15ff715e050865c1a3d51af4032e9 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 18:34:32 +0200 Subject: [PATCH 120/126] Update and rename 19_4_Lightning_Network_Implementations.md to 19_4_Lightning_Network_Review.md --- 19_4_Lightning_Network_Implementations.md | 11 ----------- 19_4_Lightning_Network_Review.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 19_4_Lightning_Network_Implementations.md create mode 100644 19_4_Lightning_Network_Review.md diff --git a/19_4_Lightning_Network_Implementations.md b/19_4_Lightning_Network_Implementations.md deleted file mode 100644 index 518a9aa..0000000 --- a/19_4_Lightning_Network_Implementations.md +++ /dev/null @@ -1,11 +0,0 @@ -### Lightning Network implementations - -In this brief review we list the most widely used implementations in the lightning network Today, although there are more. Basis of Lightning Technology (BOLT) documents describe a layer-2 protocol for off-chain bitcoin transfers. The specifications are currently a work-in-progress and currently being drafted. - -| Name | Description | BitcoinStandup | Language | Repository | -| ------------- | ------------- | :---: | ------------- | ------------- | -| C-lighting | Blockstream | X | C | [Download](https://github.com/ElementsProject/lightning) | -| LND | Lightning Labs | X | Go | [Download](https://github.com/lightningnetwork/lnd) | -| Eclair | ACINQ | - | Scala | [Download](https://github.com/ACINQ/eclair) | - - diff --git a/19_4_Lightning_Network_Review.md b/19_4_Lightning_Network_Review.md new file mode 100644 index 0000000..22b2ea0 --- /dev/null +++ b/19_4_Lightning_Network_Review.md @@ -0,0 +1,11 @@ +### Lightning Network Review + +In this brief review we add some important features of C-lightning and we list the most widely used implementations in the lightning network Today, although there are more. All implementations follow the Basis of Lightning Technology (BOLT) documents describe a layer-2 protocol for off-chain bitcoin transfers. The specifications are currently a work-in-progress and currently being drafted. + +| Name | Description | BitcoinStandup | Language | Repository | +| ------------- | ------------- | :---: | ------------- | ------------- | +| C-lighting | Blockstream | X | C | [Download](https://github.com/ElementsProject/lightning) | +| LND | Lightning Labs | X | Go | [Download](https://github.com/lightningnetwork/lnd) | +| Eclair | ACINQ | - | Scala | [Download](https://github.com/ACINQ/eclair) | + + From 9bc3a7d76a4bd5bc235e058e708acaeaa3054e3e Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 22:43:28 +0200 Subject: [PATCH 121/126] Update 19_4_Lightning_Network_Review.md --- 19_4_Lightning_Network_Review.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/19_4_Lightning_Network_Review.md b/19_4_Lightning_Network_Review.md index 22b2ea0..5a9fd43 100644 --- a/19_4_Lightning_Network_Review.md +++ b/19_4_Lightning_Network_Review.md @@ -1,4 +1,4 @@ -### Lightning Network Review +## Lightning Network Review In this brief review we add some important features of C-lightning and we list the most widely used implementations in the lightning network Today, although there are more. All implementations follow the Basis of Lightning Technology (BOLT) documents describe a layer-2 protocol for off-chain bitcoin transfers. The specifications are currently a work-in-progress and currently being drafted. @@ -8,4 +8,14 @@ In this brief review we add some important features of C-lightning and we list t | LND | Lightning Labs | X | Go | [Download](https://github.com/lightningnetwork/lnd) | | Eclair | ACINQ | - | Scala | [Download](https://github.com/ACINQ/eclair) | - + +### Plugins + +c-lightning is a lightweight, highly customizable and standard compliant implementation of the Lightning Network protocol. The way c-lightning extend the functionality is using Plugins, that are a powerful and easy way to do it. Mainly they are subprocesses that are initiated by lightningd daemon and can interact with lightningd in a different ways: + +* Command line option that allows plugins to register their own command line options that are exposed through lightningd. +* JSON-RPC command passthrough allows plugins to add their own commands to the JSON-RPC interface. +* Event stream subscriptions provide plugins with a push-based notification mechanism about events from the lightningd. +* Hooks are a primitive option that allows plugins to be notified about events in lightningd daemon and modify its behavior or pass custom behaviors. + +A plugin may be written in any language, and communicates with lightningd through the plugin’s stdin and stdout. JSON-RPCv2 is used as protocol on top of the two streams, with the plugin acting as server and lightningd acting as client. From 5820662e2d8aa1180d710f96e772c3eb94d7a111 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 23:25:04 +0200 Subject: [PATCH 122/126] Update 19_4_Lightning_Network_Review.md --- 19_4_Lightning_Network_Review.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/19_4_Lightning_Network_Review.md b/19_4_Lightning_Network_Review.md index 5a9fd43..1ff92f4 100644 --- a/19_4_Lightning_Network_Review.md +++ b/19_4_Lightning_Network_Review.md @@ -19,3 +19,5 @@ c-lightning is a lightweight, highly customizable and standard compliant impleme * Hooks are a primitive option that allows plugins to be notified about events in lightningd daemon and modify its behavior or pass custom behaviors. A plugin may be written in any language, and communicates with lightningd through the plugin’s stdin and stdout. JSON-RPCv2 is used as protocol on top of the two streams, with the plugin acting as server and lightningd acting as client. + +Here is a updated list of [plugins](https://github.com/lightningd/plugins) available. From 515869b6c3ffb50faf799d2db1996560736eba27 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Wed, 5 Aug 2020 23:59:18 +0200 Subject: [PATCH 123/126] Update 19_3_Closing_a_Channel.md --- 19_3_Closing_a_Channel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/19_3_Closing_a_Channel.md b/19_3_Closing_a_Channel.md index 849fed0..a10fc71 100644 --- a/19_3_Closing_a_Channel.md +++ b/19_3_Closing_a_Channel.md @@ -236,4 +236,4 @@ When you close a channel you perform an onchain transaction ending your financia ## What's Next? -Continue "Understanding Your Lightning Setup" with [§19.4: Lightning Network Implementations](19_4_Lightning_Network_Implementations.md). +Continue "Understanding Your Lightning Setup" with [§19.4: Lightning Network Review](19_4_Lightning_Network_Review.md). From 36c72b71c74883acbb5915d38224c66ba4d22e4f Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Thu, 6 Aug 2020 00:15:59 +0200 Subject: [PATCH 124/126] Update 19_4_Lightning_Network_Review.md --- 19_4_Lightning_Network_Review.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/19_4_Lightning_Network_Review.md b/19_4_Lightning_Network_Review.md index 1ff92f4..f4c6361 100644 --- a/19_4_Lightning_Network_Review.md +++ b/19_4_Lightning_Network_Review.md @@ -21,3 +21,7 @@ c-lightning is a lightweight, highly customizable and standard compliant impleme A plugin may be written in any language, and communicates with lightningd through the plugin’s stdin and stdout. JSON-RPCv2 is used as protocol on top of the two streams, with the plugin acting as server and lightningd acting as client. Here is a updated list of [plugins](https://github.com/lightningd/plugins) available. + +### Backup + +As we mentioned on Closing a channel chapter your node needs to be online all the time otherwise your counterparty could send a previous channel status and steals your funds. However, there is another scenario in which funds can be lost, and that is when a hardware failure occurs that prevents the node from establishing a cooperative closure with the counterparty. This will probably imply that if you do not have an exact copy of the state of the channel before the failure, you will have an invalid state that could cause the other node to assume it as an attempted fraud and use the penalty transaction. In this case all funds will be lost. To avoid this undesirable situation there is a developed a solution based on the high availability of postgresQL database From c338dc13e66388fb0cfafb3f83deecf74ee8cb67 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sat, 8 Aug 2020 21:05:43 +0200 Subject: [PATCH 125/126] Update 19_4_Lightning_Network_Review.md --- 19_4_Lightning_Network_Review.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/19_4_Lightning_Network_Review.md b/19_4_Lightning_Network_Review.md index f4c6361..cfcfdf9 100644 --- a/19_4_Lightning_Network_Review.md +++ b/19_4_Lightning_Network_Review.md @@ -24,4 +24,13 @@ Here is a updated list of [plugins](https://github.com/lightningd/plugins) avail ### Backup -As we mentioned on Closing a channel chapter your node needs to be online all the time otherwise your counterparty could send a previous channel status and steals your funds. However, there is another scenario in which funds can be lost, and that is when a hardware failure occurs that prevents the node from establishing a cooperative closure with the counterparty. This will probably imply that if you do not have an exact copy of the state of the channel before the failure, you will have an invalid state that could cause the other node to assume it as an attempted fraud and use the penalty transaction. In this case all funds will be lost. To avoid this undesirable situation there is a developed a solution based on the high availability of postgresQL database +As we mentioned on Closing a channel chapter your node needs to be online all the time otherwise your counterparty could send a previous channel status and steals your funds. However, there is another scenario in which funds can be lost, and that is when a hardware failure occurs that prevents the node from establishing a cooperative closure with the counterparty. This will probably imply that if you do not have an exact copy of the state of the channel before the failure, you will have an invalid state that could cause the other node to assume it as an attempted fraud and use the penalty transaction. In this case all funds will be lost. To avoid this undesirable situation exists a solution based on the high availability of postgresQL database [here](https://github.com/gabridome/docs/blob/master/c-lightning_with_postgresql_reliability.md). We haven't tested this solution. + +### Mobile wallets. + +Today we know about two mobile lightning wallets that support c-lightning implementation. For iOS devices FullyNoded which is an open source iOS Bitcoin wallet that connects via Tor V3 authenticated service to your own full node and SparkWallet that is a minimalistic wallet GUI for c-lightning, accessible over the web or through mobile and desktop apps (for Android, Linux, macOS and Windows). + +* [FullyNoded](https://github.com/Fonta1n3/FullyNoded/blob/master/Docs/Lightning.md) in TestFlight +* [SparkWallet](https://github.com/shesek/spark-wallet) + + From f2b08277bfeafedced2d9e69d07970cd9944d3c4 Mon Sep 17 00:00:00 2001 From: Javier Vargas Date: Sat, 8 Aug 2020 21:08:31 +0200 Subject: [PATCH 126/126] Update 19_4_Lightning_Network_Review.md --- 19_4_Lightning_Network_Review.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/19_4_Lightning_Network_Review.md b/19_4_Lightning_Network_Review.md index cfcfdf9..ca29b20 100644 --- a/19_4_Lightning_Network_Review.md +++ b/19_4_Lightning_Network_Review.md @@ -28,7 +28,9 @@ As we mentioned on Closing a channel chapter your node needs to be online all th ### Mobile wallets. -Today we know about two mobile lightning wallets that support c-lightning implementation. For iOS devices FullyNoded which is an open source iOS Bitcoin wallet that connects via Tor V3 authenticated service to your own full node and SparkWallet that is a minimalistic wallet GUI for c-lightning, accessible over the web or through mobile and desktop apps (for Android, Linux, macOS and Windows). +Today we know about two mobile lightning wallets that support c-lightning implementation. For iOS devices FullyNoded which is an open source iOS Bitcoin wallet that connects via Tor V3 authenticated service to your own full node. FullyNoded functionality is currently under active development and in early beta testing phase. + +SparkWallet is a minimalistic wallet GUI for c-lightning, accessible over the web or through mobile and desktop apps for Android. * [FullyNoded](https://github.com/Fonta1n3/FullyNoded/blob/master/Docs/Lightning.md) in TestFlight * [SparkWallet](https://github.com/shesek/spark-wallet)