简体   繁体   English

区块链中的交易验证

[英]Transaction verification in Blockchain

Lets consider that we have an AltCoin named ABCCoin,ABC. 让我们假设我们有一个名为ABCCoin,ABC的AltCoin。 I will be referred as X, mined a block and got a freshly minted 25 ABC as a mining reward. 我将被称为X,开采了一个街区并获得了新鲜铸造的25 ABC作为采矿奖励。 Now, I want to gift this coin a friend Y. So, 现在,我想将此硬币送给朋友Y。

Tx: X -> Y : 25ABC

And lets assume that this was stored in block B100. 并假设它存储在块B100中。 Now after some months, Ms. Y wants to transfer it to Z for any reason. 现在几个月后,Y女士出于任何原因都希望将其转移到Z。 So, 所以,

Tx: Y -> Z : 25ABC

Now, after few months later. 现在,几个月后。 Mr. Z wanted to buy a coffee in starbucks while going on a date with his girlfriend. Z先生想和女友约会时用星巴克买咖啡。

Now the chain of transcation will be as below: 现在,交易链如下:

|Tx|Minted -> X |
   --> "Tx: X -> Y : 25ABC" 
   --> "Tx: Y -> Z : 25ABC"
   --> "Tx: Z -> Starbucks : 25ABC"

So, in this situation. 因此,在这种情况下。 When we need to verify "Tx: Z -> Starbucks : 25ABC" do we have to trace it back the origin, ie to the point when this coin was minted OR can it be just verified just by check its immediate source. 当我们需要验证“ Tx:Z-> Starbucks:25ABC”时,我们必须追溯到其起源,即该硬币铸造的时间点,或者仅通过检查其直接来源就可以对其进行验证。 ie "Tx: X -> Y : 25ABC" and dont care about other previous. 即“ Tx:X-> Y:25ABC”,并且不关心其他先前版本。

Assuming You are asking about UTXO transaction based blockchains like bitcoin. 假设您正在询问基于UTXO交易的区块链(如比特币)。

There are 2 types of verification 验证有2种类型

  1. FullNode Verification 全节点验证

  2. SPV Verification SPV验证

Full node 全节点

Full node is a program that fully validates transactions and blocks such as bitcoind , litecoind or geth . 全节点程序是一种完全验证交易和区块(例如bitcoindlitecoindgeth So every time a full node receives new block from other peer, It does validate all transactions in the block and adds to its blockchain and update a list of UTXOs only if the block is fully valid. 因此,每当一个完整的节点从其他对等方接收到新的块时,它都会验证该块中的所有交易,并仅在该块完全有效时才将其添加到其区块链中并更新UTXO列表。

to validate transactions, full node checks something like 为了验证交易,全节点检查类似

  • Transaction format 交易格式
  • Transaction signature(s) 交易签名
  • find Previous transactions from its blockchain 从其区块链中查找先前的交易
  • double spending transaction existence 双重支出交易的存在

Because a full node has a list of UTXOs that it believes correct, checking transaction format/signatures and the list of UTXOs are enough to validate new transaction. 因为完整节点具有它认为正确的UTXO列表,所以检查事务格式/签名和UTXO列表足以验证新事务。

SPV SPV

SPV client doesn't have full blockchain data nor a list of UTXOs, SPV checks only if a transaction is in a block using MarkleTree and block which contains the transaction satisfies block difficulty or not. SPV客户端没有完整的区块链数据或UTXO列表,SPV仅使用MarkleTree检查交易是否在区块中,并且包含该交易的区块是否满足区块难度。 And this is all SPV can check because It has to check all blockheader and blockbody one by one to create UTXOs list. 这就是SPV可以检查的所有内容,因为它必须逐个检查所有块头和块体以创建UTXO列表。 So SPV cannot check if it's double spending transaction or not. 因此,SPV无法检查是否是双重消费交易。 But still, Because It costs a lot to create a fake block as long as a blockchain has enough difficulty, It's usable validation. 但是,因为只要区块链具有足够的难度,创建一个假块的成本很高,所以它是可用的验证。 like @Haardik mentioned in the comment, obntaining trustable UTXOs list without downloading all blockchain data using markle tree might be coming in the future update 就像评论中提到的@Haardik一样,在将来的更新中可能会获得可信任的UTXO列表而不使用标记树下载所有区块链数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM