Bỏ qua tới nội dung chính

Exness hoàn 100% hoa hồng IB

Không khoản nào bị trừ trước khi về tài khoản bạn

EA và indicator miễn phí

XM hoàn 90%, nạp tối thiểu 5 USD

How does a Bitcoin transaction work?

A Bitcoin transaction spends earlier unspent outputs as its inputs, proves you may spend them with a signature, and creates new outputs: one for the person you pay and usually one returning change to you. Whatever the inputs hold beyond the outputs is the fee. Nodes check the transaction, and a miner adds it to a block.

Nội dung này hiện chỉ có bản tiếng Anh.

5 phút đọcAutoFXRebate

Your wallet shows a balance of 0.55 BTC. The Bitcoin network has no record of that number.

It records separate pieces, say one of 0.30 BTC and one of 0.25 BTC, each locked to a key you hold. Your wallet adds them up.

Every Bitcoin transaction spends pieces like these and creates new ones, and that one idea explains how fees and change work.

Coins are unspent outputs

Each piece is an unspent transaction output, or UTXO. It is an output of an earlier transaction that nobody has spent yet. Your balance is the total of the UTXOs your keys can spend.

Two unspent outputs of 0.30 BTC and 0.25 BTC sit on the blockchain, and the wallet adds them up to show a balance of 0.55 BTC.
The network stores separate pieces, and the wallet adds them up into a balance.

A UTXO is spent whole. You cannot spend half of the 0.30 piece and leave the rest behind. You spend all of it and send what you do not need back to yourself as change.

Worked example: paying 0.40 BTC

Suppose you pay someone 0.40 BTC. The numbers are round figures for illustration.

  1. Inputs: neither piece covers 0.40 alone, so the wallet uses both: 0.30 + 0.25 = 0.55 BTC.
  2. Output 1: 0.40 BTC to the recipient's address.
  3. Output 2: 0.1498 BTC back to a new address of yours, as change.
  4. Fee: 0.55 minus 0.40 minus 0.1498 = 0.0002 BTC.

No line in the transaction states the fee. The fee is the gap between what goes in and what comes out, and the miner who includes the transaction collects it.

A transaction takes inputs of 0.30 and 0.25 BTC and creates outputs of 0.40 BTC to the recipient and 0.1498 BTC change, leaving a 0.0002 BTC fee.
Whatever the inputs hold beyond the outputs goes to the miner as the fee.

Bitcoin amounts are often counted in satoshis, the smallest unit: 1 BTC is 100,000,000 satoshis. The 0.0002 BTC fee is 20,000 satoshis.

This design has a sharp edge. If the change output were left out, the whole 0.15 BTC gap would become the fee. Normal wallets add change automatically, but tools that build transactions by hand will not stop you.

Why the fee depends on transaction size

Blocks have limited space, so miners rank transactions by fee per unit of size. The unit is the virtual byte, or vbyte, and fee rates are quoted in satoshis per vbyte.

Continuing the example with an illustrative fee rate: a transaction with two inputs and two outputs, using a common modern address type, is roughly 200 vbytes.

At 100 satoshis per vbyte, the fee is 200 × 100 = 20,000 satoshis, the same 0.0002 BTC as above.

At a given fee rate, sending 0.001 BTC or 100 BTC in the same shape of transaction costs the same. More inputs make a bigger transaction, so paying from many small UTXOs costs more than paying from one large one.

Fee rates rise when many transactions are waiting. They wait in the mempool, and miners usually pick the highest fee rates first.

What a transaction contains

Strip away the wallet screen and a transaction holds two lists.

Each input points to an earlier output, by that transaction's ID and the output's number. It also carries a digital signature and, for most address types, a public key, which together prove you may spend it.

Each output holds an amount and a locking condition. Usually the condition says the output can be spent by whoever can sign for a given address.

The transaction data is then hashed twice with SHA-256 to give its transaction ID, the code you paste into a block explorer to track it. How hashing works covers that step.

Transactions that spend from addresses starting with bc1 use a format called SegWit. It moves the signatures into a separate witness section, which the ID leaves out, so nobody can change the ID by tweaking a signature.

From your wallet to a block

  1. Your wallet builds and signs the transaction on your device.
  2. It broadcasts the transaction to nodes. Each node checks the signatures, that the inputs exist and are unspent, and that the outputs do not add up to more than the inputs.
  3. Valid transactions wait in the mempool.
  4. A miner includes the transaction in a block. Blocks arrive about every 10 minutes on average, as Bitcoin mining explains.
  5. Every block added after that one counts as another confirmation.
A Bitcoin transaction is signed, broadcast to nodes, waits in the mempool, is mined into a block and then gains a confirmation with each new block.
Each block added after yours makes the transaction harder to undo.

Confirmations protect against a double spend, where someone tries to spend the same UTXO twice. Nodes accept only one of the two.

Many services wait for several confirmations before treating a large payment as final, and six is a common rule of thumb.

What a transaction cannot undo

Bitcoin has no chargeback. Once a transaction is confirmed, only the recipient can send the coins back, and coins sent to a wrong address are usually lost.

Check the first and last few characters of an address before you send. Some malware swaps a copied address for the attacker's when you paste it. How to send and receive crypto sets out a safe routine.

Not every crypto trade is a Bitcoin transaction. A transfer between two users of one exchange is often just an entry in its records, and a crypto CFD never touches the blockchain because you never own the coin.

Câu hỏi thường gặp

How long does a Bitcoin transaction take?

Blocks come about every 10 minutes on average, so a transaction with a competitive fee is often confirmed within one or a few blocks. A low fee can leave it waiting much longer when the network is busy.

Can I cancel a Bitcoin transaction?

Not once it is confirmed. Before that, some wallets let you replace it with a version that pays a higher fee, which can also send the coins back to your own address.

Why does my wallet send change to a new address?

A fresh address for change makes it harder for outsiders to link your payments together. The change still belongs to you, and the wallet counts it in your balance.

What is a satoshi?

It is the smallest unit of bitcoin, 0.00000001 BTC. There are 100 million satoshis in one bitcoin.

Học tiếp

Chương 3What is hashing?Hashing feeds data into a hash function, which returns a short code of fixed length called a hash. The same input always gives the same hash, a tiny change gives a completely different one, and there is no practical way to work back from the hash to the input. Bitcoin uses SHA-256 hashes to link blocks and name transactions.Chương 3How does hashing work, and what is it used for?A hash function pads its input, cuts it into blocks of equal size and mixes each block into a running state over many rounds of bit operations. The final state is the hash. Crypto uses this to check files, store passwords, chain blocks together, summarise transactions in a Merkle root, build addresses and set the puzzle that miners solve.Chương 3What is encryption?Encryption turns readable data into scrambled text using a key, and the right key turns it back. Symmetric encryption uses one shared key, while public key encryption uses a matched pair. Unlike hashing, encryption can be reversed. Bitcoin's ledger is not encrypted at all: encryption protects your connection to an exchange and the wallet files that hold your keys.Chương 3Public and private keys explained.A private key is a large random number that only you should know, and it signs your transactions. A public key is calculated from the private key and can be shared freely, so others can check your signatures and send you coins. The calculation only runs one way, so a public key never reveals the private key behind it.Chương 3How do digital signatures work?A digital signature is a number calculated from a message and a private key. Anyone with the matching public key can check it. If the check passes, the message came from whoever holds the private key and has not changed by a single bit. Bitcoin nodes run this check on every transaction before they accept it.
Góp ý

Tài khoản của bạn đang ở sàn nào?

Mỗi sàn một đường chuyển khác nhau, nên chúng tôi đưa bạn tới đúng phần của sàn đó.