Enabling Micro-payments on IoT Devices using Bitcoin Lightning Network
Abstract
Lightning Network (LN) addresses the scalability problem of Bitcoin by leveraging off-chain transactions. Nevertheless, it is not possible to run LN on resource-constrained IoT devices due to its storage, memory, and processing requirements. Therefore, in this paper, we propose an efficient and secure protocol that enables an IoT device to use LN’s functions through a gateway LN node. The idea is to involve the IoT device in LN operations with its digital signature by replacing original 2-of-2 multisignature channels with 3-of-3 multisignature channels. Our protocol enforces the LN gateway to request the IoT device’s cryptographic signature for all operations on the channel. We evaluated the proposed protocol by implementing it on a Raspberry Pi for a toll payment scenario and demonstrated its feasibility and security.
Index Terms:
Internet of things, cryptocurrency, bitcoin, lightning networkI Introduction
Internet of Things (IoT) has been adopted in various domains at a great pace in the last decade as it brings numerous opportunities and convenience [1]. We have been witnessing applications where an IoT device may need to do financial transactions. For instance, they may be used in commerce applications such as toll systems, where an on-board unit acting as an IoT device on a vehicle may need to do automatic payments as the vehicle passes through a toll gate [2]. Similarly, there are other cases such as automated vehicle charging, parking payment, sensor data selling, etc. where micro-payments need to be made [3, 4, 5]. In this context, cryptocurrencies have great potential to provide a smooth payment automation. Thus, successful merge of IoT [6] and cryptocurrency technologies such as Bitcoin [7] and Ethereum [8] may foster such applications.
However, despite their popularity, mainstream cryptocurrencies such as Bitcoin and Ethereum suffer from scalability issues [9] in terms of transaction confirmation times and throughput [10]. This increases the transaction fee and makes their adoption infeasible for micro-payments. Payment Channel Network (PCN) idea has emerged as a second layer solution to address this problem by utilizing off-chain transactions [11]. While LN is a successful solution that addresses the scalability issue, current LN protocol cannot be run on most of the IoT devices because of the computation, communication, and storage requirements [12].
To this end, in this paper, we propose an efficient and secure protocol where an IoT device can connect to an LN gateway that already hosts the full LN and Bitcoin nodes and can send payments on behalf of the IoT device when requested. First, a secure channel is established between IoT device and the LN gateway using lightweight cryptography. Second, we introduce the concept of 3-of-3 multisignature LN channels, which involve signatures of all parties (i.e., the IoT device, the LN gateway and a bridge LN node to which the gateway opens a channel) to conduct any operation on the channel as opposed to using LN’s original 2-of-2 multisignature channels [13]. More specifically, the LN gateway cannot spend channel funds without getting IoT device’s cryptographic signature.
In order to assess the effectiveness and overhead of the proposed protocol, we implemented it within a setup where a Raspberry Pi sends payments to a real LN node through a wireless connection. A toll payment scenario was considered for the evaluation. We demonstrated that the proposed protocol enables realization of timely payments without compromising the security of IoT device’s funds.
II System Model and Protocol
II-A System Model
There are five entities in our system which are IoT device, IoT gateway, LN gateway, bridge LN node, and destination LN node as shown in Fig. 1. IoT device wants to pay the destination LN node for the goods/services. The IoT gateway is responsible for connecting the IoT device to the Internet when the IoT device is within its range using wireless protocols such as WiFi, Bluetooth, 5G etc. Through this Internet connection, IoT device is able to reach the LN gateway, which manages the Bitcoin and LN nodes and can be hosted anywhere on the cloud. Bridge LN node is the node to which the LN gateway opens a channel when requested by the IoT device. This node could be any LN node on the Internet and is determined by the LN gateway. Through the bridge LN node, IoT device’s payments are routed to a destination LN node specified by the IoT device.

II-B Proposed Protocol
II-B1 Channel Opening Process
We authorize the IoT device to securely initiate the channel opening process through the LN gateway and co-sign the funding transaction along with the LN gateway and bridge LN node. This means that LN’s existing channel opening protocol is modified with the addition of another party (i.e., IoT device) to the channel. Since now three signatures are required to open a channel, the channel is no longer a 2-of-2 multisignature wallet but instead a 3-of-3 multisignature wallet. To create a secure channel between IoT and the LN gateway, we use public key cryptography and symmetric session keys to exchange messages. IoT sends a channel opening request message to the LN gateway. The LN gateway creates a Bitcoin transaction from the IoT device’s BTC wallet address to the 3-of-3 multisignature address. The LN gateway also creates the commitment transactions for itself and the bridge LN node. The LN gateway then sends the funding transaction to IoT to get it completely signed. Finally, the LN gateway broadcasts the signed funding transaction to the Bitcoin network which opens the channel.
II-B2 Sending a Payment
We incorporate the IoT device in the process for signature aggregation. In addition, the gateway needs to charge the IoT a service fee for its services. To start the payment sending, IoT device sends a payment sending request to the LN gateway. Upon receiving the request, the LN gateway adds an HTLC output to its commitment transaction. When preparing the HTLC, the LN gateway deducts a certain amount of fee from the real payment amount IoT device wants to send to the destination. Therefore, the remaining Bitcoin is sent with the HTLC. The new commitment transaction created at the LN gateway needs to be also signed by IoT device and thus we enforce the gateway to make a request to IoT device. Upon receiving this request, IoT device signs the commitment transaction and sends it back to the LN gateway. Next, the LN gateway and bridge LN node cross signs their new commitment transactions and revoke the old state. This finalizes the payment sending and IoT is notified of the successful payment.
II-B3 Channel Closing Process
All 3 parties of the channel namely; The IoT device, the LN gateway and the bridge LN node can close the channel. The IoT device can ask the LN gateway to close the channel by sending a channel closing request. The LN gateway can also close the channel by requesting from IoT device to sign its most recent commitment transaction then broadcasting the signed transaction to the blockchain.
III Evaluation
III-A Experiment Setup
To evaluate the proposed protocol, we created a setup where an IoT device connects to an LN gateway to send payments on LN. To mimic the IoT device, we used a Raspberry Pi 3 Model B v1.2 and the LN gateway was setup on a desktop computer with an Intel(R) Xeon(R) CPU E5-2630 v4 and 32 GB of RAM. This desktop computer was on a remote location different from the Pi. For the full Bitcoin node installation, we used bitcoind [14] and for the LN node, we used lnd v0.11.0-beta.rc1 from Lightning Labs [15] which is a complete implementation of the LN protocol. Python was used to implement the protocol. We used IEEE 802.11n (WiFi) to exchange protocol messages between the Raspberry Pi and the LN gateway.
III-B Toll Payment Use-Case Evaluation of the Protocol
When a car enters the communication range of the toll wireless system, it sends a request to the IoT gateway of the toll to initiate the payment. IoT gateway relays this request to the LN gateway which immediately creates an LN payment and sends it to the toll center’s LN node. Lastly, the car is notified of the successful payment. For this to work, whole payment sending process must be completed before the car gets out of the communication range of toll’s wireless system.
There are 4 protocol message exchanges between IoT device and the LN gateway in our payment sending protocol. In each protocol message exchange, there are 2 corresponding communication delays which are between the car and the IoT gateway and between the IoT gateway and the LN gateway running at the cloud. In addition to communication delays, we also measured the LN payment sending time which was 2 seconds over an average of 30 separate payments at different times throughout the day. Eventually, the total payment sending time for WiFi was 2.558 secs.
Vehicle Speed | Available Time | Satisfied? |
---|---|---|
50 mph | 11.2 s | Yes |
60 mph | 9.3 s | Yes |
80 mph | 7 s | Yes |
The advertised range of 802.11n is 250m [16]. If cars pass through the toll gate with a speed of 50mph, there is around 11 seconds with WiFi available for them to complete the protocol message exchanges with the LN gateway for a successful toll payment. The results for varying vehicle speeds are shown in Table I. As can be seen, our protocol meets the deadlines even under a high speed of 80mph.
IV Conclusion
In this paper, we proposed a secure and efficient protocol for enabling IoT devices to use Bitcoin’s LN for sending payments. By modifying LN’s peer protocol for channel management as well as LN’s Bitcoin transactions, a third peer (i.e. IoT device) was added to LN channels. IoT device’s interactions with LN is achieved through a gateway node which has access to LN and thus can provide LN services to it in return for a fee. Our evaluation results showed that the proposed protocol enables smooth payments for the IoT device with negligible delay/cost overheads while ensuring the security of the IoT device’s funds.
References
- [1] J. Gubbi, R. Buyya, S. Marusic, and M. Palaniswami, “Internet of things (IoT): A vision, architectural elements, and future directions,” Future generation computer systems, vol. 29, no. 7, pp. 1645–1660, 2013.
- [2] D. Pašalić, B. Cvijić, D. Bundalo, Z. Bundalo, and R. Stojanović, “Vehicle toll payment system based on internet of things concept,” in 2016 5th Mediterranean Conference on Embedded Computing (MECO). IEEE, 2016, pp. 485–488.
- [3] S. Mercan, A. Kurt, E. Erdin, and K. Akkaya, “Cryptocurrency solutions to enable micro-payments in consumer IoT,” IEEE Consumer Electronics Magazine, 2021.
- [4] J. Robert, S. Kubler, and S. Ghatpande, “Enhanced lightning network (off-chain)-based micropayment in IoT ecosystems,” Future Generation Computer Systems, 2020.
- [5] A. Kurt, E. Erdin, M. Cebe, K. Akkaya, and A. S. Uluagac, “LNBot: A covert hybrid botnet on bitcoin lightning network for fun and profit,” in European Symposium on Research in Computer Security. Springer, 2020, pp. 734–755.
- [6] S. Mercan, E. Erdin, and K. Akkaya, “Improving sustainability of cryptocurrency payment networks for IoT applications,” in 2020 IEEE International Conference on Communications Workshops (ICC Workshops), 2020, pp. 1–6.
- [7] S. Nakamoto, “Bitcoin: A peer-to-peer electronic cash system,” Tech. Rep., 2008.
- [8] G. Wood et al., “Ethereum: A secure decentralised generalised transaction ledger,” Ethereum project yellow paper, vol. 151, no. 2014, pp. 1–32, 2014.
- [9] J. Xie, F. R. Yu, T. Huang, R. Xie, J. Liu, and Y. Liu, “A survey on the scalability of blockchain systems,” IEEE Network, vol. 33, no. 5, pp. 166–173, 2019.
- [10] W. Charts, “Bitcoin throughput,” accessed 2021-03. [Online]. Available: https://charts.woobull.com/bitcoin-network-throughput/
- [11] C. Decker and R. Wattenhofer, “A fast and scalable payment network with bitcoin duplex micropayment channels,” in Symposium on Self-Stabilizing Systems. Springer, 2015, pp. 3–18.
- [12] K. Kurimoto, “Lightning network x IoT(LoT); potential, challenges and solutions,” accessed 2021-03. [Online]. Available: https://medium.com/nayuta-en/lightning-network-x-iot-lot-potential-challenges-and-solutions-6e4d8b4c252a
- [13] R. Pickhardt, “Introduction to the lightning network protocol,” accessed 2021-03. [Online]. Available: http://site.ieee.org/icbc-2019/files/2019/05/ICBC-2019-Tutorial-3-Lightning-Network-Protocol.pdf
- [14] bitcoin.org, “Running a full node,” accessed 2021-03. [Online]. Available: https://bitcoin.org/en/full-node
- [15] L. Labs, “Lightning network daemon,” accessed 2021-03. [Online]. Available: https://github.com/lightningnetwork/lnd
- [16] S. Fadilah, A. Shibghatullah, Z. Abas, M. H. Abd Wahab, M. Helmy, and W. Hashim, “Performance analysis for wireless G (IEEE 802.11 G) and wireless N (IEEE 802.11 N) in outdoor environment,” Journal of Engineering & Applied Sciences, vol. 9, pp. 850–854, 01 2014.