03 Feb Bitcoin: What if someone locks some bitcoin with a script which only requires a user to know a preimage, but it matches the p2sh template? [duplicate]
Potential Lightning Network HTLC Vulnerability
As more people enter the world of Bitcoin and Lightning Network (LN) transactions, the security and reliability of these systems are becoming increasingly important topics of discussion. One aspect that has sparked curiosity is how to create a trusted environment for Lightning Network transactions using the Hash-Address-Pubkey Script Template (p2sh), also known as HTLC.
However, there is a potential weakness in this setup that could compromise the security of these transactions. In this article, we will explore what happens when someone locks some Bitcoin with a script that only requires the user to know the preimage, but matches the p2sh template.
Hash-Address-Pubkey (p2sh) Script Template Basics
Before we dive into the potential vulnerability, let’s take a quick look at how HTLCs work. In a Lightning Network transaction, multiple users can “lock” a Bitcoin by creating a script that includes a public key and a hash of a certain value. This public key is used to validate the lock, and when a user attempts to spend the locked funds, they must know the preimage (i.e., the original value) associated with their public key.
The HTLC output uses the p2sh template, which provides a secure way to transfer Bitcoin from one wallet to another. The basic syntax of the p2sh template is as follows: