Bitcoin principle - transactions with UTXO

UTXO

UTXO (Unspent Transaction Output) unspent transaction output

Traditional payment systems are based on the account (account based), that is:
if A transfer B to 20 yuan

  1. Analyzing A's account balance is greater than or equal to 20 million;
  2. Applied to the B account $ 20;
  3. By 20. At the same time on the A account.

Encryption currency UTXO model, one "account" in the balance is not represented by a number, but the current block chain network with all components of current "account" relevant UTXO. That is, bitcoin address accounts "balance" is not really Bitcoin, but "UTXO".

Personal feeling is not very good understanding of the concept of direct see, for example child better.

Transaction 1001: Zhang bits obtained by mining 12.5 credits (or called 12.5 UTXO), the address output to the seating
transaction 2001: Zhang transfer credits to John Doe 2.5 bits, the input address from the transaction 1001 Zhang UTXO of 12.5, a 2.5-bit output includes credits John Doe further comprising a back seating 10 UTXO address
transaction 3001: Zhang and Li were transfected credits to 2.5 king five bits, the input from the transaction 2001 the two outputs, the output from the transaction are obtained Wang Wu and seating 5 UTXO remaining 7.5 UTXO.

Each block of the first transactions are obtained Bitcoin mining, only the output not input, called Coinbase.

{
   "addr":"14uhqGYDEhqwfdoP59QdLWdt4ha5CHttwQ",
   "n":1,
   "script":"76a9142ae017a5bd24a3f935897085253e503fbfd66f4e88ac",
   "spent":false,
   "tx_index":335926477,
   "type":0,
   "value":21680000
}

Json data above shows a UTXO, which contains the current transaction index tx_index UTXO belongs, the recipient address addr transaction amount and the transaction value.

transaction

UTXO part of the transaction, the transaction by the input and output of two parts. Transaction data format is as follows:

{
   "txid":"5be7a9e47f56c98e5297a44df52da0475f448ece98bb51489103cdf70653092f",
   "hash":"5be7a9e47f56c98e5297a44df52da0475f448ece98bb51489103cdf70653092f",
   "version":1,
   "size":224,
   "vsize":224,
   "locktime":0,
   "vin": [...],
   "vout": [...],
   "hex":"0100000001a90b4101e6cbb75e1ff885b6358264627581e9f96db9ae609acec98d72422067000000006b483045022100c42c89eb2b10aeefe27caea63f562837b20290f0a095bda39bec37f2651af56b02204ee4260e81e31947d9297e7e9e027a231f5a7ae5e21015aabfdbdb9c6bbcc76e0121025e6e9ba5111117d49cfca477b9a0a5fba1dfcd18ef91724bc963f709c52128c4ffffffff02a037a0000000000017a91477df4f8c95e3d35a414d7946362460d3844c2c3187e6f6030b000000001976a914aba7915d5964406e8a02c3202f1f8a4a63e95c1388ac00000000",
   "blockhash":"0000000000000000000c23ca00756364067ce5e815deb5982969df476bfc0b5c",
   "confirmations":5,
   "time":1521981077,
   "blocktime":1521981077
}

Where "vin" and "vout" is to represent the input and output.
Every legal transaction, the sum of all inputs must be greater than the sum of all output, which is the difference between the transaction fee.

sum(inputs.vlaue) = sum(outputs.value) + fee

Entry

Enter the following:

{
   "vin":[
      {
         "txid":"672042728dc9ce9a60aeb96df9e9817562648235b685f81f5eb7cbe601410ba9",
         "vout":0,
         "scriptSig":{
            "asm":"3045022100c42c89eb2b10aeefe27caea63f562837b20290f0a095bda39bec37f2651af56b02204ee4260e81e31947d9297e7e9e027a231f5a7ae5e21015aabfdbdb9c6bbcc76e[ALL] 025e6e9ba5111117d49cfca477b9a0a5fba1dfcd18ef91724bc963f709c52128c4",
            "hex":"483045022100c42c89eb2b10aeefe27caea63f562837b20290f0a095bda39bec37f2651af56b02204ee4260e81e31947d9297e7e9e027a231f5a7ae5e21015aabfdbdb9c6bbcc76e0121025e6e9ba5111117d49cfca477b9a0a5fba1dfcd18ef91724bc963f709c52128c4"
         },
         "sequence":4294967295
      }
   ]
}

Hash txid input data contains references UTXO where the transactions cited UTXO index (starting at 0) vout. Txid and vout by two fields, can be positioned on the unique UTXO block chain.

Export

Output is as follows:

{
   "vout":[
      {
         "value":0.10500000,
         "n":0,
         "scriptPubKey":{
            "asm":"OP_HASH160 77df4f8c95e3d35a414d7946362460d3844c2c31 OP_EQUAL",
            "hex":"a91477df4f8c95e3d35a414d7946362460d3844c2c3187",
            "reqSigs":1,
            "type":"scripthash",
            "addresses":[
               "3CcqrGq4oQcfx3u75ijj4tDiqf4HJvhoeP"
            ]
         }
      },
      {
         "value":1.84809190,
         "n":1,
         "scriptPubKey":{
            "asm":"OP_DUP OP_HASH160 aba7915d5964406e8a02c3202f1f8a4a63e95c13 OP_EQUALVERIFY OP_CHECKSIG",
            "hex":"76a914aba7915d5964406e8a02c3202f1f8a4a63e95c1388ac",
            "reqSigs":1,
            "type":"pubkeyhash",
            "addresses":[
               "1GedHcxdxq2tab98hqAmREUK9BBYHKznof"
            ]
         }
      }
   ]
}

Each unused vout is a UTXO, vout contains the output limit value, and the arrival of the corresponding address.

In each transaction, there may be a plurality of inputs and multiple outputs, such as a token bit address is composed of a plurality of addresses from the transfer. Each UTXO integral denomination of the coin corresponds to one, and A has a 5-bit UTXO UTXO a currency coin 1 bit, 2 bits when transfer credits to B, will take off from the 5-bit UTXO coins A, wherein 2 bits to UTXO credits to B, 3-bit additional credits UTXO change due to their return.

Guess you like

Origin www.cnblogs.com/KRDecad3/p/11025768.html