Hack A Lapp/Introduction to Bitcoins Lightning Network App Development/C-Lightning with python/Ask your customer to pay with bitcoins lightning network by creating a lightning invoice

From Wikiversity
Jump to navigation Jump to search

Ask your customer to pay with bitcoins lightning network by creating a lightning invoice

Learning goals

  1. install pylightning module
  2. invoke an Remote Procedure Call to your c-lightning node in a python code base
  3. create an invoice for your customer



exercise: invoice = rpc_interface.invoice() was executed. Find out which meta data besides the bolt11 string is provided. What is the meaning of this meta data?


1 What is the correct syntax to create an invoice in python?

rpc_interface.invoice(2000, "label", "description")
rpc_interface.create_invoice(2000, "label", "description")

2 looking at the pylightning api client we find the declaration of the invoice function: def invoice(self, msatoshi, label, description, expiry=None, fallbacks=None, preimage=None ): What does that tell us?

The invoice needs to have 6 arguments
The invoice can have up to 6 arguments
The invoice must have at least 3 arguments

3 If you don't provide the expire argument, how long will the invoice be valid?

Forever, since it does not expire
144 Block times
1 Hour

4 you have successfully invoked the .invoice() RPC-function and stored the object to the variable called invoice. How do you print the bolt11 string?

< code> invoice.bolt11()

5 initiating the rpc interface with rpc_interface = LightningRpc() we need to pass a string as an argument. Which value should the string be given?

the local path the the lightning-rpc file
publickey of your lightning node followed by its IP address and port
some unique identifier for your pythong programm to be able to access the interface