|
1 |
| -The examples in this folder contain sample code to demonstrate WebRTC and Bitcoin Lightning interoperating. |
| 1 | +# WebRTC Lightning Payment Video Stream Demo |
| 2 | + |
| 3 | +This demo project showcases a real-time WebRTC video stream whose source is controlled by Bitcoin Lightning payments. Viewers can trigger changes in the video stream by making micropayments over the Lightning Network. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This project integrates two cutting-edge technologies: |
| 8 | +- **WebRTC Video Streaming:** Enabling low-latency, real-time video communications. |
| 9 | +- **Bitcoin Lightning Payments:** Allowing instant, low-cost micropayments that trigger changes in the video source. |
| 10 | + |
| 11 | +When a viewer makes a payment, the system processes and verifies the Lightning payment. Once confirmed, the video source is updated accordingly—demonstrating a pay-per-view or dynamic content control model. |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- **Real-Time Video Streaming:** Built using WebRTC for low-latency video delivery. |
| 16 | +- **Micropayment Control:** Use Bitcoin Lightning payments to trigger video content updates. |
| 17 | +- **Dynamic Integration:** Seamless integration between payment events and WebRTC streaming. |
| 18 | +- **Demo-Ready:** Easy-to-run demo for testing and showcasing the technology. |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +Before running the demo, ensure you have: |
| 23 | +- **Docker** and **Docker Compose** installed on your system. |
| 24 | +- A modern web browser with WebRTC support (Chrome, Firefox, etc.). |
| 25 | + |
| 26 | +## Running the Demo |
| 27 | + |
| 28 | +### 1. Clone the Repository |
| 29 | + |
| 30 | +Clone the repository and navigate to the project directory: |
| 31 | + |
| 32 | +```bash |
| 33 | +git clone [email protected]:sipsorcery-org/sipsorcery.git |
| 34 | +cd sipsorcery/examples/WebRTCLightningExamples/WebRTCLightningGetStarted |
| 35 | +``` |
| 36 | + |
| 37 | +### 2. Set Up the Docker Environment |
| 38 | + |
| 39 | +This demo uses a `docker-compose` file to set up a Bitcoin Signet node, an LND Lightning node, and the RTL (Ride the Lightning) web interface. |
| 40 | + |
| 41 | +1. **Start the Docker Containers** |
| 42 | + |
| 43 | + Run the following command to start the Bitcoin Signet node, LND, and RTL: |
| 44 | + |
| 45 | + ```bash |
| 46 | + docker-compose up -d |
| 47 | + ``` |
| 48 | + |
| 49 | + This will spin up three services: |
| 50 | + |
| 51 | + - bitcoind: A Bitcoin Signet node. |
| 52 | + - lnd: A Lightning Network node connected to the Bitcoin Signet network. |
| 53 | + - rtl: A web interface for managing your LND node. |
| 54 | + |
| 55 | +2. **Wait for Initialization** |
| 56 | + |
| 57 | + The LND node will take a few minutes to sync with the Bitcoin Signet network. You can monitor the progress by checking the logs: |
| 58 | + |
| 59 | + ```bash |
| 60 | + docker logs -f lnd |
| 61 | + ``` |
| 62 | + |
| 63 | +3. **Access RTL (Optional)** |
| 64 | + |
| 65 | + Once the LND node is synced, you can access the RTL web interface at [http://localhost:3000](http://localhost:3000) to manage your Lightning node. |
| 66 | + |
| 67 | +### 3. Configure the Demo Application |
| 68 | + |
| 69 | +1. **Update appSettings.json:** |
| 70 | + |
| 71 | + Ensure the LND connection settings in your appSettings.Development.json file match the credentials and ports used in the docker-compose setup. For example: |
| 72 | + |
| 73 | + ```json |
| 74 | + { |
| 75 | + "LndSettings": { |
| 76 | + "Url": "localhost:10009", |
| 77 | + "MacaroonPath": "../lnd-data/data/chain/bitcoin/signet/admin.macaroon", |
| 78 | + "CertificatePath": "../lnd-data/tls.cert" |
| 79 | + } |
| 80 | + } |
| 81 | + ``` |
| 82 | + |
| 83 | + If you're using the default `docker-compose` setup, the paths and ports should already be preconfigured. |
| 84 | +
|
| 85 | +2. **Run the Demo Application** |
| 86 | +
|
| 87 | + Start the demo application using the following command: |
| 88 | +
|
| 89 | + ```bash |
| 90 | + dotnet run |
| 91 | + ``` |
| 92 | +
|
| 93 | +### 4. Make Payments |
| 94 | +
|
| 95 | +1. **Scan the QR Code** |
| 96 | +
|
| 97 | + The video stream will display a payment request QR code when it transitions to certain states. Use a mobile Lightning Network client (e.g. Zeus) to scan the QR code and make a payment. |
| 98 | +
|
| 99 | +2. **Trigger Video Updates** |
| 100 | +
|
| 101 | + Once the payment is detected, the video source will update dynamically, demonstrating the pay-per-view or dynamic content control model. |
| 102 | +
|
| 103 | +### 5. Stopping the Demo |
| 104 | +
|
| 105 | +To stop the Docker containers, run: |
| 106 | +
|
| 107 | +```bash |
| 108 | +docker-compose down |
| 109 | +``` |
| 110 | +
|
| 111 | +This will gracefully shut down the Bitcoin Signet node, LND, and RTL services. |
| 112 | +
|
| 113 | +### Docker Compose Configuration |
| 114 | +
|
| 115 | +The `docker-compose.yml` file provided sets up the following services: |
| 116 | +
|
| 117 | +- **Bitcoin Signet Node (bitcoind):** |
| 118 | +
|
| 119 | + - Runs a Bitcoin Signet node for testing purposes. |
| 120 | + - Exposes RPC and ZMQ ports for communication with LND. |
| 121 | +
|
| 122 | +- **Lightning Network Node (lnd):** |
| 123 | +
|
| 124 | + - Connects to the Bitcoin Signet node. |
| 125 | + - Exposes gRPC, REST, and peer-to-peer ports for Lightning Network operations. |
| 126 | +
|
| 127 | +- **RTL (Ride the Lightning) Interface (rtl):** |
| 128 | +
|
| 129 | + - Provides a web-based interface for managing the LND node. |
| 130 | + - Accessible at http://localhost:3000 default password `sipsorcery`. |
| 131 | +
|
| 132 | +For advanced configuration, refer to the comments in the `docker-compose.yml` file. |
| 133 | +
|
| 134 | +### Troubleshooting |
| 135 | +
|
| 136 | +- **LND Node Not Syncing:** Ensure the Bitcoin Signet node is fully synced before using LND. Check the logs with: |
| 137 | +
|
| 138 | +```bash |
| 139 | +docker logs -f bitcoind |
| 140 | +``` |
| 141 | +
|
| 142 | + - **Connection Issues:** Verify that the `appSettings.json`, or `appSettings.Development.json`, file has the correct LND connection details. |
| 143 | +
|
| 144 | + - **Payment Not Triggering Video Updates:** Ensure the payment is confirmed and the demo application is correctly processing payment events. |
0 commit comments