Txid

*

A TXID (Transaction ID) is basically an identification number for a bitcoin transaction.

Bạn đang xem: Txid

Examples:

A TXID is always 32 bytes (64 characters) và hexadecimal.

Creating a TXID

You get a TXID by hashing transaction data through SHA256 twice.

Searching for TXIDs in the blockchain.

If you’ve sầu just hashed some transaction data and want khổng lồ tìm kiếm for a TXID in the blockchain, you have sầu khổng lồ search for it in reverse byte order.

txid (original): 169e1e83e930853391bc6f35f605c6754cfead57cf8387639d3b4096c54f18f4txid (searching): f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16Why?Because welcome khổng lồ Bitcoin.

Due to lớn historical accident, the tx & block hashes that bitcoin core uses are byte-reversed. I’m not entirely sure why. May be something like using openssl bignum to store hashes or something like that, then printing them as a number. – Wladimir van der Laan (Bitcoin Core developer)

In other words, this was a slight oversight in the early development of Bitcoin that has now become a standard.


Where are TXIDs used?

1. Searching the blockchain.

If you’ve sầu just made a transaction, you can use the TXID to find it in the blockchain. For example:


bitcoin-cli getrawtransaction 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098

*
The console window in the Bitcoin bộ vi xử lý Core WalletIf you have sầu been given a TXID by your bitcoin wallet, it’s probably already in its “searchable” format (reverse byte order).

2. Spending outputs.

Xem thêm: Year To Date ( Ytd Là Gì ? Định Nghĩa, Ví Dụ, Giải Thích Định Nghĩa,

You use a TXID when you want lớn use an existing output as an input đầu vào in a new transaction.

*
To refer to an existing output, you use the txid it was created in, along with the vout number for that transaction.

Because after all, a TXID is a unique identifier1 for a transaction.

Notes

Why hash twice? Why not once?

Things often get hashed twice in bitcoin for super-extra security.

SHA-256(SHA-256(x)) was proposed by Ferguson & Schneier in their excellent book “Practical Cryptography” (later updated by Ferguson, Schneier, & Kohno và renamed “Cryptography Engineering”) as a way to lớn make SHA-256 invulnerable to “length-extension” attack. They called it “SHA-256d”. – https://crypkhổng lồ.stackexchange.com/questions/779/hashing-or-encrypting-twice-to-increase-security/884#884

Hash functions like SHA256 are great for creating identification numbers, because they will take in any string of data và always spit out a short yet unique result.


Coinbase transactions having the same TXID.

There has been a situation where two “different” coinbase transactions had the same TXID.

These coinbase transactions used the same address when claiming the block reward from two different blocks. This meant that their transaction data was the same, & so the TXIDs were the same also. Here are the transactions và the blocks they were included in:

e3bf3d07d4b0375638d5f1db5255fe07ba2c4cb067cd81b84ee974b6585fb468d5d27987d2a3dfc724e359870c6644b40e497bdc0589a033220fe15429d88599The Fix.

Xem thêm: Cách Viết Phần Mềm Quản Lý Nhân Sự Miễn Phí Bằng Access : Miễn Phí

Initially, BIP. 30 introduced a rule that prevented blocks from containing a TXID that already exists. Later, BIPhường 34 required coinbase transactions lớn include the height of the block the were mining in to lớn their transaction data, so that coinbase transactions could be different.

Links
Chuyên mục: Công Nghệ 4.0