比特币的交易消息到底长啥样?

资讯 2024-07-14 阅读:27 评论:0
比特币使用的是区块链技术,所以它的所有产生的区块(一个区块里面包含很多条交易)都是透明可查的,可进这个网站:https://btc.com/stats/pool/BTC.com 进行查询。Bitcoin uses block chai...
美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

APP下载   官网地址

比特币使用的是区块链技术,所以它的所有产生的区块(一个区块里面包含很多条交易)都是透明可查的,可进这个网站:https://btc.com/stats/pool/BTC.com 进行查询。

Bitcoin uses block chain technology, so all the blocks it produces (a block contains many transactions) are transparent and can be consulted on the website: .

binfun选取BTC历史区块里面的一条transaction:
https://btc.com/0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2

Binfun selects one in the BTC historical block:

该条transaction的编号为:0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2

This provision is numbered 0627052b6f28912f2703066a 912ea577f2ce4da4caa5a5fbd8a57286c345c2f2

该交易的内容如截图:

The contents of the transaction are transcribed:
loading=

从上图我们可以看到“输入”中的账户1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK把0.1个BTC分别转给了“输出”中的账户1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA(该账户收到了0.01500000个BTC)
1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK(该账户也就是原账户发送给了自己0.08450000个BTC)。

From the above figure we can see the account in the "Input" transferred 0.1 BTC accounts in the "output" )

所以这交易就是账户1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK转了0.015个BTC给1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA

So the transaction is the account 1Cdid9KFAaatwczBwBtbtQcwXYCpvK8FK transferred 0.015 BTCs to .

但是输出中的0.0845 + 0.015=0.0995,并不等于0.1啊,这是因为去掉的0.0005就是矿工费。

However, 0.0845 + 0.015 = 0.0995 in the output is not equal to 0.1 because the 0.0005 removed is the miner's fee.

上面的那张图片实际上把这条交易可视化了,这条交易的真实样子是长这样的:

The picture above actually visualizes this transaction. The true face of the deal is as follows:


是不是一脸懵逼,懵逼就对了。这条交易主要由vinvout两大块组成。看不懂我们就从似曾相识的数字看起:vout里面有个"value": 0.01500000和"value": 0.08450000,这两个数字我懂,这就是转账数字啊。

The deal is made up of two major pieces: vin and vout. I can't see that we've got a "value" : 0.01.5 million and `value' :0.084.5 million, which is the number of transfers.

就是刚才的比特币地址1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK发送给另一个比特币地址1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA的钱嘛。

The money just sent from Bitcoin address 1Cdid9KFAatwczBwBttQcwxYCpvK8h7FK to another Bitcoin address 1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA.

听说比特币地址是由Base58编码的,Base58编码是啥咱也不知道,咱也不敢问,反正估计和Base64大差不差。

I heard that the Bitcoin address was coded by Base58, and we don't know what the Base58 code is, and we're afraid to ask, it's not so different from Base64 anyway.

于是binfun毫不知情地从https://github.com/grondilu/bitcoin-bash-tools上下载了一个脚本bitcoin.sh,一顿猛操作对地址进行Base58解码:

As a result, binfun downloaded a script bitcoin.sh from https://github.com/grondulu/bitcoin-bash-tools without knowing it:


得到了:

Got it:


这串16进制数有点眼熟啊,这不就和上面看到的

It's kind of familiar, isn't it?


It's... it's... it's... it's... it's... it's... it's... it's... it's... it's... it's... it's... it's... it's... it's...


非常接近了,就是多出了头上的"00"和尾巴上的"01974ac6"

It's very close. It's "00" and "01974ac6" on the tail.

其中头上的"00"代表了主网版本号,而"01974ac6"代表了校验和,这个校验和可以由以下python命令生成:

The "00" on its head represents the main web version number, while "01974ac6" represents the checksum, which can be generated by the python command as follows:


可以看到该校验和由连续两次的sha256后的结果,取该结果的前四个字节,也就是01974ac6

You can see the check and the results of two consecutive shaw256s, the first four bytes of which are 01974 ac6.

以上过程就是类似比特币地址和比特币公钥的转换过程。

The process described above is a process of conversion similar to the Bitcoin address and the Bitcoin public key.

为了便于理解,我们可以认为在vout中,以上所述的两个比特币地址中分别获得了0.015和0.0845个BTC。

For ease of understanding, we can assume that in vout, 0.015 and 0.0845 BTCs were obtained in the two bitcoins referred to above.

换句话说vout就是把比特币“锁定”在上述两个比特币地址中,上面出现的scriptPubKey就是所谓的“锁定脚本”。

In other words, vout “locks” Bitcoin in the above two bitcoin addresses where the appearance of ScriptPubKey is the so-called “lock script”.

那么vin是干啥的,就是解锁呀,让我们再看一眼vin

So what's a strong vin / strong? Unlock it. Let's take another look at strong vin / strong :


以上的txid是transaction id的缩写,我们当前的txid是0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2
(下图中用txid0627052b简写)

The above txid is the acronym of the transposition id, and our current txid is 0627052b6f28912f273066a912ea577fce4da4caa5a5fbd8a57286c345c2f2
. (Summary of txid0627052b in the figure below)

但是vin中却引用了

But it's quoted in vin /strang >


(下图中用txid7957a35f简写)

(Txid7957a35f in the figure below)

这显得有点绕,具体意思如下图所示:

This appears to be somewhat intriguing, in the following figure:
loading=

所以scriptSig就是“解锁脚本”的意思,其中内容就是用户A使用他的私钥进行了一项签名,证明我是地址A的私钥拥有者,我有权对锁定到地址A内的余额进行使用。

So the scriptSig is the meaning of a “lacing script”, in which user A makes a signature using his private key to prove that I am the owner of the private key at address A and that I have the right to use the balance locked in address A.

那么问题又来了,用户A的钱又是哪里来的???实际上不断追溯源头的话,最终大家的比特币都来自于一种叫做币基交易(coinbase)的特殊交易,币基交易是没有vin的,币基交易是由挖到矿的矿工生成的,所以挖矿挖到的都是“新币”,平时用户转账的币追溯到最上面的话,都是矿工挖出来的。

So the question arises again, where does user A's money come from? In fact, in the end, everyone's bitcoin comes from a special transaction called coinbase, which does not have vin, which is made by miners who dig up the mines, so the digs are all “new coins” and the coins transferred by the users usually go back to the top.

现在我们知道,有用来解锁资金的解锁脚本,以及锁定资金的锁定脚本,解锁脚本是在"vin"中,锁定脚本是在"vout"中。

Now we know that there are unlocked scripts for unlocking funds, and locked scripts for locking funds in vin, and locked scripts in vout.

那么这些脚本长什么样呢?比特币交易脚本语言是一种逆波兰表达式的基于堆栈的执行语言。

So what do these scripts look like? Bitcoin-trading script language is a stack-based enforcement language that is anti-Polish expression.

在介绍解锁、锁定脚本之前,先介绍一下比特币的私钥、公钥、比特币地址之间的关系。

Before introducing unlocking and locking scripts, describe the relationship between Bitcoin's private key, public key, and Bitcoin address.
loading=

关于比特币公钥私钥的特性,只需要知道这两点:

With regard to the characteristics of the Bitcoin private key, just two things are needed:

  1. 私钥经过椭圆算法之后生成公钥,公钥经过哈希算法之后生成比特币地址(也就是公钥哈希)。这个过程是不可逆的,也就是说通过公钥不能倒推出私钥,但是私钥却可以生成公钥。

    The private key is generated by an elliptical algorithm, and the public key by a Hashi algorithm generates a bitcoin address (i.e. a public key by a public key). This process is irreversible, that is, a private key cannot be rolled out backwards through a public key, but a private key can generate a public key.

  2. 一段文本经过私钥加密之后只能由公钥进行解密,而由公钥加密之后的文本只能由私钥解密,这就是非对称加密算法。

    A text that is private key encrypted can only be decrypted by a public key, while a text that is subsequently encrypted by a public key can only be decrypted by a private key, which is the asymmetric encryption algorithm.

vout中的一种典型的锁定脚本如下:

A typical lock-in script in vot is as follows:


其中需要注意的是,是公钥哈希(可以通过它推出比特币地址),锁定脚本中指定了拥有该公钥哈希的私钥人,才能解锁该脚本。

Among other things, it should be noted that is the public key H.H.H. (which can be used to roll out a bitcoin address) and a private key with the public key is identified in the lock script to unlock the script.

vin中的一种典型的的解锁脚本如下:

A typical unlocked script in vin is as follows:


解锁脚本提供了签名以及公钥,该签名是私钥将交易加密后产生的。

Unlocking scripts provide the signature and the public key

The sigScript in the following graph is a unlocked script, and pkScript is a locked script.
loading=

参考资料:
https://github.com/tianmingyun/MasterBitcoin2CN/blob/master/ch06.md
http://www.infoq.com/cn/articles/deep-understanding-of-bitcoin-transaction-script
https://www.cnblogs.com/zhaoweiwei/p/address.html

References:

美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

APP下载   官网地址
文字格式和图片示例

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

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

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

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 美国可以使用什么加密货币交易所_前10名比特币交易平台名单

    美国可以使用什么加密货币交易所_前10名比特币交易平台名单
    美国可以使用什么加密货币交易所?What is an encrypted currency exchange that the United States can use?随着加密货币的普及,加密货币交易所也越来越多。对于美国的加密货币交易者而言,选择一个可靠、安全且易于使用的交易所是十分重要的事情。那么,美国可以使用哪些加密货币交易所呢?以下是前10名比特币交易平台名单:The choice of a reliable, secure, and easy-to-use...
  • 2017比特币已经挖出,比特币是什么?

    2017比特币已经挖出,比特币是什么?
    20 17比特币已经挖出了目录。20 17比特币被挖出来了。比特币是什么?比特币在20 17达到挖矿上限。在20 17中,比特币达到了挖矿上限,这意味着比特币的总数达到了2 1 100,000。比特币挖矿会越来越少。由于比特币挖矿的奖励每四年减半一次,未来比特币挖矿的数量将减少,比特币的价格可能会上涨。影响比特币市场的主要因素。除了挖矿上限和奖励减半之外,比特币市场还受到供需、投资者情绪和监管政策等因素的影响。比特币的未来前景。随着全球对比特币的认知度越来越高,比特币的前景仍...
  • 2015年宝马3系二手车价格多少钱

    2015年宝马3系二手车价格多少钱
    爱你一生不变心6558 2022-04-28 13:20:03 二手车能不能买主要看车况,如果车况好就可以考虑,车况不好价格再低也别考虑,像2015款宝马3系目前行情价是在18.32万这样,如果低...
  • Coinbase:财富100强企业过去一年的Web3采用率增长39%

    Coinbase:财富100强企业过去一年的Web3采用率增长39%
    随着比特币、以太坊等主流加密货币在web2世界的认可度变得越来越高,许多web2传统公司也积极拥抱web3,加速采用和开发区块链产品的速度和应用层面。With ˂a style= "max-width": 90%" href=https://m.php.cn/zt/21172.html" target="_blank" bitcoin, ˂a style="color:#f60; text-decoration: unde...
  • 区块链技术原理(转载)

    区块链技术原理(转载)
    转自:https://cloud.tencent.com/developer/article/1838661From: https://clud.tencent.com/development/article/1838661 本文主要是对区块链进行概念分析和组成技术解析,从哈希运算、数字签名、共识算法、智能合约、P2P网络等技术在区块链中的应用进行综合分析This paper focuses on conceptual analysis and technical com...
标签列表