科普:Taproot交易是什么

币圈资讯 阅读:45 2024-04-22 12:41:59 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

好久没有认真研究比特币的脚本了,最近想搞明白Taproot assets,发现绕不开Taproot交易,只好把Taproot的几个BIP都读完了。

P2PKH

最常见的比特币交易叫支付到公钥哈希,Pay-to-Publick-Key-Hash(P2PKH),它是将比特币锁定到公钥的哈希上,公钥哈希就是我们的比特币地址,即1开头的那种地址。

如果Alice想通过P2PKH交易向Bob支付1btc,这个过程可以按如下解释。

P2PKH交易的技术过程:

地址和公钥哈希:Bob给Alice提供了一个比特币地址,这个地址实际上是他的公钥的哈希值。

解锁和锁定:Alice要发送1 BTC给Bob,她需要从自己的钱包中解锁这笔资金。然后,她在创建交易时将这1 BTC锁定到Bob的公钥哈希上。

Bob的签名和解锁:当Bob想要花费这1 BTC时,他需要用自己的私钥签名来证明他是这个地址的拥有者。这样他就可以解锁这笔资金并将其用于新的交易。

通俗的解释:

Bob给Alice一个开着的带锁盒子(这里的锁就是Bob的比特币地址)。

Alice把1 BTC放进这个盒子,然后把盒子锁上,这样就只有拥有正确钥匙(即Bob的私钥)的人才能打开。

当Bob想使用这1 BTC时,他就用自己的钥匙(私钥)打开盒子,取出比特币,并可以选择将其放入另一个人的盒子(进行另一笔交易)。

P2SH

第二常见的比特币交易叫支付到脚本哈希,我们常用这种交易格式来实现多重签名。

如果Alice想通过P2SH交易格式向Bob发送1BTC,可以按如下来解释:

P2SH交易的技术过程:

脚本哈希而非公钥哈希:在P2SH交易中,资金被锁定到一个脚本哈希而不是一个公钥哈希。

这个脚本通常包含多个条件,比如需要多个签名(多重签名)或满足其他特定条件。

创建和发送交易:发送方(比如Alice)会将比特币发送到这个脚本哈希地址。这个地址是由接收方(比如Bob)提供的,而这个地址背后隐藏的脚本包含了解锁这些资金所需的条件。

即这个脚本哈希的原始脚本是Bob拥有的,但Bob不会将这个脚本公开,而只是公开这个脚本的哈希值。(这对应上面P2PKH的是公钥哈希)

解锁资金:当Bob(收款方)想要花费这些比特币时,他就会提供原始的脚本(这就是解锁脚本,或称赎回脚本),矿工拿到这个原始脚本就可以验证这笔交易。

通俗的解释:

其实P2SH和上面的P2PKH的差别就是在那个盒子上的锁不同,P2SH的锁是允许Bob自定义,可以构建非常复杂的锁。

比如最常见的多重签名,就是Bob自定义了多把解锁的钥匙,并定义了要多少把钥匙来解锁。

使用P2SH这种交易机制,把脚本哈希当成锁,把原始脚本当成是私钥,就可以自定义各种解锁条件。这让比特币的可编程性大大提高了。

现在来解释P2TR(Pay to Taproot

P2PKH是支付到公钥哈希,花费条件是提供公钥对应的私钥签名。

P2SH是支付到脚本哈希,花费条件是提供原始脚本。

P2TR是一种结合了支付到公钥哈希和支付到脚本哈希,因此它有两条花费路径,即可以是直接的私钥签名,也可以是提供原始脚本。

并且,P2TR的脚本是一颗包含了n个脚本的二叉树,花费时提供树的一个叶子节点脚本和树路径就可以花费。

这样,P2TR交易就可以定义出更复杂的花费条件,比特币的可编程性就更丰富了。


I haven't studied the script of Bitcoin seriously for a long time. Recently, I want to find out that I can't get around the transaction, so I have to read all of them. The most common bitcoin transaction is called paying to the public key hash, which is our bitcoin address, that is, the address at the beginning. If I want to pay through the transaction, I can explain the technical process of the transaction as follows. The address and the public key hash provide a bitcoin address, which is actually his public key. To unlock and lock the hash value, she needs to unlock the money from her purse, and then she will sign and unlock the locked public key hash when she creates a transaction. When she wants to spend it, she needs to sign with her private key to prove that he is the owner of this address, so that he can unlock the money and use it for a new transaction. Explain it to an open locked box, where the lock is the bitcoin address, and put it in this box and lock it, so that only. Only the person who has the right key, that is, the private key, can open it. When he wants to use it, he opens the box with his own key and private key, takes out the bitcoin and can choose to put it in another person's box for another transaction. The second common bitcoin transaction is called payment to script hash. We often use this transaction format to realize multi-signature. If we want to send it through the transaction format, we can explain the technical process of the transaction as follows: script hash instead of public key hash. In the transaction, funds are locked into a script. Hash is not a public key hash. This script usually contains multiple conditions, such as requiring multiple signatures, multiple signatures or meeting other specific conditions to create and send a transaction. For example, the sender will send bitcoin to this script hash address. This address is provided by the receiver, for example, and the script hidden behind this address contains the conditions needed to unlock these funds, that is, the original script of this script hash is owned, but the script will not be made public, but only the hash value of this script will be made public. This corresponds to the above public key hash unlocking funds. When the payee wants to spend these bitcoins, he will provide the original script, which is the unlocking script or redemption script. When the miner gets this original script, he can verify the transaction. In fact, the common explanation is that the lock on that box is different from the above, which allows customization and can build very complicated locks. For example, the most common multi-signature is to customize multiple unlocked keys and define how many keys to unlock. Using this transaction mechanism, we can customize various unlocking conditions by taking the script hash as a lock and the original script as a private key, which greatly improves the programmability of Bitcoin. Now it is explained that the cost condition of paying to the public key hash is to provide the private key signature corresponding to the public key, and the cost condition of providing the original script is a combination of paying to the public key hash and paying to the script hash, so it has two cost paths, that is, it can be a direct private key signature or it can be provided with the original. Script and the script is a binary tree containing a script. When it is spent, it provides a leaf node of the tree, and the script and tree path can be spent, so that the transaction can define more complicated spending conditions and the programmability of Bitcoin will be richer. 比特币今日价格行情网_okx交易所app_永续合约_比特币怎么买卖交易_虚拟币交易所平台

文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明 网址:https://netpsp.com/?id=63178

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
关注我们

若遇到问题,加微信客服---清歌

搜索
排行榜
扫一扫,加我为微信好友加我为微信好友