21
votes
Accepted
How do virtual size, stripped size and raw size compare between legacy address formats and native segwit?
Segwit introduced a new limit for blocks, the blockweight limit, superseding the previous blocksize limit. Under the segwit rules, witness data is counted at a lower weighting than non-witness data ...
15
votes
What is Bitcoin locking and unlocking script?
There are quite a lot of things going on there, so let's break it down bit by bit.
Transaction structure
A transaction can be seen as a collection of inputs and outputs. Inputs refer to previously ...
12
votes
Accepted
multiple input and output addresses in bitcoin transactions
why some of transactions have one input and one output?
A bitcoin transaction can have many inputs and many outputs. Bitcoin has a transaction oriented logic, where amounts are transferred from ...
11
votes
Accepted
How big is the input of a P2PKH transaction?
The first number does not include the prevout, sequence number, or the length byte for the scriptSig. It also uses 65 bytes for the public key (which is correct if it is uncompressed, but compressed ...
11
votes
Accepted
Why are transaction input and output indices called `vin` and `vout`?
The original Satoshi codebase used a programming style called "Hungarian notation", where variable names are prefixed with letters that indicate the data type they contain.
v in particular ...
8
votes
Accepted
How do transaction costs compare between Bech32 addresses and legacy Bitcoin addresses?
Transfer from Legacy ⟶ SegWit: pay full fee (doesn't benefit from SegWit discount)
Transfer from SegWit ⟶ Legacy or SegWit: discounted.
Note: SegWit addresses can be Bech32 bc1... or they can be ...
8
votes
Accepted
Maximum number of inputs per transaction
No, the number that can be represented by the varint has no effect on the maximum number of inputs. That number is far too large. Rather the maximum number of inputs is constrained by the block size.
...
8
votes
Accepted
Does the coinbase transaction have inputs?
Coinbase transactions must:
Have exactly 1 input.
That input must have prevout hash 0000...0000, and index 0xFFFFFFFF (an output which isn't actually spent).
The input's scriptSig must be between 2 ...
7
votes
Accepted
What are the sizes of single-sig and 2-of-3 multisig taproot inputs?
Taproot generally has two ways of spending. The default way is to spend the output using the key path: pay-to-taproot then behaves like a p2pk output except that it is using a schnorr signature and ...
7
votes
Accepted
Why is the locktime set at transaction level while the sequence is set at input level?
See @RedGrittyBrick's answer for historical context for why there is a per-input nSequence field. The evolution since includes:
nLockTime's meaning has been unchanged since the early days; it ...
6
votes
SegWit and previous hash: txid or wtxid, or either?
Inside transaction inputs, you have to refer to previous transactions using the txid. Allowing a wtxid there would be (1) a hard fork and (2) defeating the purpose, as it'd make transactions malleable ...
6
votes
Accepted
How to retrieve the from and to wallet addresses of a transaction?
Which part / field of the input refers to the hash of the output?
The outpoint contains a txid (32 bytes) and vout (4 bytes), which specify the output you're spending.
This is not the sending ...
6
votes
What is the maximum number of inputs/outputs a transaction can have?
These numbers are slightly different today after the segwit and taproot softforks got activated.
A standard transaction is limited to 400 000 weight units (WU). The smallest standard (single-sig ...
6
votes
Accepted
What are the standard formats of transaction outputs?
AFAIK there are 5 different standard non-SegWit transaction types, and 4 SegWit ones.
Non-SegWit:
Pay to public key (P2PK)
PUSH (1 byte) + <compressed/uncompressed_pk> (33/65 bytes) + ...
6
votes
Accepted
Can signature be re-used to cash out everything in the address?
When you sign the transaction with your private key, you include the hash of the entire transaction data as a message. This means the signature which is generated is specific to that transaction ...
6
votes
Accepted
How can the segwit witness data be "off-chain"? What does it really mean?
No, that's not accurate. Witness data is on-chain, inputs have a similar byte length as before (they are just weighed differently), and the transaction throughput is increased because segwit is a ...
6
votes
Accepted
What is the size and weight of a P2WPKH input?
TL;DR:
A P2WPKH input should be conservatively estimated with 68.0 vbytes. Standard P2WPKH inputs generally weigh 67.75 or 68.0 vbytes, depending on whether the r-value in the signature is low or high....
6
votes
Accepted
Segwit includes the input amount in the SignatureHash. What possible attack can this prevent?
Consider a transaction that has 2 inputs and 1 output. Let's say that the inputs are both 1 BTC and the output is 1.5 BTC. This would mean that the transaction pays a 0.5 BTC fee, which is ridiculous.
...
6
votes
Why is the locktime set at transaction level while the sequence is set at input level?
I'm not sure if you will have already seen this:
From: Satoshi Nakamoto <[email protected]
Date: Wed, Mar 9, 2011 at 5:15 PM
To: Mike Hearn [email protected]
Subject: Re: Open sourced my Java SPV ...
5
votes
If I reuse the same address can a previously used transaction be reused?
Can somebody take the transaction tx0 I signed and publish it in order to spend the new coins with the old transaction?
No.
Firstly, the transaction inputs are already known to have been used. Any ...
4
votes
Accepted
What is the point of including the scriptCode of the input in the transaction digest of segwit?
What problems could arise if the scriptCode of the input were not included in the digest?
Almost certainly nothing.
The reason for doing this is a very intentional design choice to limit the number ...
4
votes
How to retrieve the from and to wallet addresses of a transaction?
The scriptPubKey contains the public key used to synthesize the public address. Here are two pedantic approaches, not using bitcoinj, applying bx commands to synthesize the public address of interest ...
4
votes
Accepted
How to get address from CTxIn object
I suppose you are the same person who made this thread on bitcointalk: https://bitcointalk.org/index.php?topic=1969807.0
I'll answer you here too to help other people too.
You are treating the ...
4
votes
Accepted
Submitted a raw tx that was already on the blockchain, to test it. I got 'missing inputs' instead of 'already exists'. Why?
Bitcoin Core has no idea which transactions already exist in the chain. It does not maintain a full index, because... it doesn't need to. In fact, when running in pruning mode, it doesn't even have ...
4
votes
What happens when two transactions send to the same address?
It works just fine.
Bitcoin transactions can have multiple inputs and outputs; each input is a "pointer" to an output of a previous transaction (specifically, it consists of a transaction id and ...
4
votes
How come that there can be many transfers in a single Bitcoin transaction?
Ethereum is an account based system. It relies on the sender specifying the sequence of transactions to prevent double spending. The balance is associated with an address and when you spend from that ...
4
votes
Accepted
How are 'excessive' numbers of inputs and outputs handled in bitcoin transactions?
The number of inputs/outputs is encoded as a "var_int" or "variable length integer".
Start by looking at the first byte. If it's 252 or less, then that's it, that's your number (like you've been ...
4
votes
Accepted
How to read a transaction from a block? Who paid whom?
When you send a Bitcoin transaction, your wallet software will use one or more existing Unspent Transaction Outputs (UTXO) to fund the transaction. The transaction will then specify the new owners of ...
4
votes
Accepted
How does fee split between senders in a transaction?
There is no real concept of sender identities, as far as the blockchain is concerned. The fee split is entirely determined by the change output values, which are entirely determined by the signers of ...
4
votes
Accepted
Why are the inputs of Bitcoin transactions signed?
There may be multiple utxos that the same script would unlock. The most common example is two transactions that both pay the same address. If inputs weren't signed, an attacker could replace one input ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
transaction-input × 117transactions × 48
output × 18
utxo × 14
segregated-witness × 13
signature × 12
script × 9
bitcoinj × 9
transaction-weight × 9
address × 7
transaction-fees × 7
raw-transaction × 7
multi-signature × 5
bitcoin-core × 4
security × 4
signrawtransaction × 4
blockchain × 3
address-format × 3
witness-data × 3
sighash × 3
input-script × 3
bitcoind × 2
blockchain.info × 2
block × 2
bitcoin-core-development × 2