If you have followed the first part of the chapter you will recognise these commands and be able to "decipher" their meaning. It looks quite complex, but we will walk through it step-by-step and you'll quickly get the hang of it.
If you have followed the first part of the chapter you will recognise these commands and be able to "decipher" their meaning. It looks quite complex, but we will walk through it step-by-step and you'll quickly get the hang of it.
@ -1106,22 +1106,22 @@ We do the same with the other nodes, setting up connections and channels. Each n
To Bob's node (c-lightning) we send these commands:
To Bob's node (c-lightning) we send these commands:
[source,bash]
[source,bash]
----
----
docker-compose exec -T Bob lightning-cli connect ${wei_address//\"}@Chan
docker-compose exec -T Bob lightning-cli connect ${chan_address//\"}@Chan
docker-compose exec -T Bob lightning-cli fundchannel ${wei_address//\"} 1000000
docker-compose exec -T Bob lightning-cli fundchannel ${chan_address//\"} 1000000
The +addinvoice+ command creates an invoice for the specified amount in satoshis and produces a JSON object with the invoice details. From that JSON object we only need the actual bech32-encoded payment request, which we extract with +jq+.
The +addinvoice+ command creates an invoice for the specified amount in satoshis and produces a JSON object with the invoice details. From that JSON object we only need the actual bech32-encoded payment request, which we extract with +jq+.
@ -1132,7 +1132,7 @@ The final command is the actual invoice payment. We connect to Alice's node and
We ask Alice's node to pay the invoice, but also ask for +inflight_updates+ in +json+ format. That will give us detailed output about the invoice, the route, the HTLCs, and the final payment result. We can study this additional output and learn from it!
We ask Alice's node to pay the invoice, but also ask for +inflight_updates+ in +json+ format. That will give us detailed output about the invoice, the route, the HTLCs, and the final payment result. We can study this additional output and learn from it!
@ -25,9 +25,9 @@ The innovation of routed payment channels allows Dina to receive tips without ma
As long as there exists a path of well-funded channels from that viewer to Glori, she will be able to receive payment from that fan.
As long as there exists a path of well-funded channels from that viewer to Glori, she will be able to receive payment from that fan.
The nodes along the path from the fan to Dina are intermediaries and called "routing nodes" in the context of routing a payment.
The nodes along the path from the fan to Dina are intermediaries and called "routing nodes" in the context of routing a payment.
[[gloria-routing-diagram]]
[[dina-routing-diagram]]
.Any one of Dina's fans in the diagram can pay her by routing via the nodes in between them and Dina
.Any one of Dina's fans in the diagram can pay her by routing via the nodes in between them and Dina
image:images/gloria-routing-diagram.PNG["Any one of Dina's fans in the diagram can pay her by routing via the nodes in between them and Dina"]
image:images/dina-routing-diagram.PNG["Any one of Dina's fans in the diagram can pay her by routing via the nodes in between them and Dina"]
Importantly, the routing nodes are unable to steal the funds while routing a payment from a fan to Dina.
Importantly, the routing nodes are unable to steal the funds while routing a payment from a fan to Dina.
Furthermore, routing nodes cannot lose money while participating in the routing process.
Furthermore, routing nodes cannot lose money while participating in the routing process.
@ -81,7 +81,7 @@ In the physical world contracts could be used for safely carrying out a series o
Alice could negotiate a contract with Bob which reads:
Alice could negotiate a contract with Bob which reads:
[alice-gloria-routing-1]
[alice-dina-routing-1]
====
====
_I (Alice) will give you (Bob) 10 gold coins if you pass them on to Chan_
_I (Alice) will give you (Bob) 10 gold coins if you pass them on to Chan_
====
====
@ -92,7 +92,7 @@ Assuming these issues are magically solved, it's still unclear how to leverage s
We thus improve our contract:
We thus improve our contract:
[alice-gloria-routing-2]
[alice-dina-routing-2]
====
====
_I (Alice) will reimburse you (Bob) with 10 gold coins if you can prove to me (for example via a receipt) that you already have delivered 10 gold coins to Chan_
_I (Alice) will reimburse you (Bob) with 10 gold coins if you can prove to me (for example via a receipt) that you already have delivered 10 gold coins to Chan_
====
====
@ -106,7 +106,7 @@ Thus Bob and Chan face both risk and opportunity cost for agreeing to this contr
Alice can this make this attractive to both Bob and Chan, by offering them fees of 1 gold coin each, if they transmit her payment to Dina.
Alice can this make this attractive to both Bob and Chan, by offering them fees of 1 gold coin each, if they transmit her payment to Dina.
The final contract would instead read:
The final contract would instead read:
[alice-gloria-routing-3]
[alice-dina-routing-3]
====
====
_I (Alice) will reimburse you (Bob) with 12 gold coins if you can prove to me (for example via a receipt) that you already have delivered 11 golden coins to Chan_
_I (Alice) will reimburse you (Bob) with 12 gold coins if you can prove to me (for example via a receipt) that you already have delivered 11 golden coins to Chan_
====
====
@ -134,7 +134,7 @@ footnote:[You can verify this by typing `echo -n "Dinas secret" | sha256sum` to
To facilitate Alice's payment, Dina will create the secret and the payment hash and send the payment hash to Alice. Alice doesn't know the secret but she can rewrite her contract to use the hash of the secret as a proof of payment:
To facilitate Alice's payment, Dina will create the secret and the payment hash and send the payment hash to Alice. Alice doesn't know the secret but she can rewrite her contract to use the hash of the secret as a proof of payment:
[alice-gloria-routing-4]
[alice-dina-routing-4]
====
====
_I (Alice) will reimburse you (Bob) with 12 gold coins if you can show me a valid message that hashes to:`+f23c83...+`.
_I (Alice) will reimburse you (Bob) with 12 gold coins if you can show me a valid message that hashes to:`+f23c83...+`.
You can acquire this message by setting up a similar Contract with Chan who has to set up a similar contract with Dina.
You can acquire this message by setting up a similar Contract with Chan who has to set up a similar contract with Dina.
@ -151,7 +151,7 @@ Similarly, Chan will also demand a fee and will expect to receive 11 gold coins
Bob's contract with Chan will read:
Bob's contract with Chan will read:
[alice-gloria-routing-5]
[alice-dina-routing-5]
====
====
_I (Bob) will reimburse you (Chan) with 11 gold coins if you can show me a valid message that hashes to:`+f23c83...+`.
_I (Bob) will reimburse you (Chan) with 11 gold coins if you can show me a valid message that hashes to:`+f23c83...+`.
You can acquire this message by setting up a similar contract with Dina.
You can acquire this message by setting up a similar contract with Dina.
@ -160,7 +160,7 @@ In order to assure you that you will get reimbursed I will provide the 11 gold c
Once Chan gets the message from the escrow that Bob has deposited the 11 gold coins, Chan sets up a similar contract with Dina:
Once Chan gets the message from the escrow that Bob has deposited the 11 gold coins, Chan sets up a similar contract with Dina:
[alice-gloria-routing-6]
[alice-dina-routing-6]
====
====
_I (Chan) will reimburse you (Dina) with 10 golden coins if you can show me a valid message that hashes to:`+f23c83...+`.
_I (Chan) will reimburse you (Dina) with 10 golden coins if you can show me a valid message that hashes to:`+f23c83...+`.
In order to assure you that you will get reimbursed after revealing the secret I will provide the 10 gold coins to an trusted escrow._
In order to assure you that you will get reimbursed after revealing the secret I will provide the 10 gold coins to an trusted escrow._
@ -199,7 +199,7 @@ The deposit is locked with the escrow service for a certain amount of time, and
In order to factor this in, the contract between Alice and Bob is once again amended with a new clause:
In order to factor this in, the contract between Alice and Bob is once again amended with a new clause:
[alice-gloria-routing-7]
[alice-dina-routing-7]
====
====
_Bob has 24 hours to show the secret after the contract was signed.
_Bob has 24 hours to show the secret after the contract was signed.
If Bob does not provide the secret by this time, Alice's deposit will be refunded by the escrow service and the contract becomes invalid._
If Bob does not provide the secret by this time, Alice's deposit will be refunded by the escrow service and the contract becomes invalid._
@ -210,7 +210,7 @@ Even if he successfully pays Chan, if he receives the proof of payment later tha
In turn, Bob will alter his contract with Chan in the following way:
In turn, Bob will alter his contract with Chan in the following way:
[alice-gloria-routing-8]
[alice-dina-routing-8]
====
====
_Chan has 22 hours to show the secret after the contract was signed.
_Chan has 22 hours to show the secret after the contract was signed.
If he does not provide the secret by this time, Bob's deposit will be refunded by the escrow service and the contract becomes invalid._
If he does not provide the secret by this time, Bob's deposit will be refunded by the escrow service and the contract becomes invalid._
@ -218,7 +218,7 @@ If he does not provide the secret by this time, Bob's deposit will be refunded b
As you might have guessed, Chan is now incentivized to also alter his contract with Dina:
As you might have guessed, Chan is now incentivized to also alter his contract with Dina:
[alice-gloria-routing-9]
[alice-dina-routing-9]
====
====
_Dina has 20 hours to show the secret after the contract was signed.
_Dina has 20 hours to show the secret after the contract was signed.
If he does not provide the secret by this time, Bob's deposit will be refunded by the escrow service and the contract becomes invalid._
If he does not provide the secret by this time, Bob's deposit will be refunded by the escrow service and the contract becomes invalid._