Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
22 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 ...
Murch's user avatar
  • 75.7k
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 ...
sr_gi's user avatar
  • 3,220
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 ...
pebwindkraft's user avatar
  • 5,096
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 ...
Pieter Wuille's user avatar
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 ...
Pieter Wuille's user avatar
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 ...
Jonathan Cross's user avatar
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. ...
Ava Chow's user avatar
  • 70.7k
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 ...
Pieter Wuille's user avatar
7 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 ...
Murch's user avatar
  • 75.7k
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 ...
Murch's user avatar
  • 75.7k
7 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 ...
Murch's user avatar
  • 75.7k
7 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. ...
Ava Chow's user avatar
  • 70.7k
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 ...
Pieter Wuille's user avatar
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 ...
Pieter Wuille's user avatar
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 ...
Nick ODell's user avatar
  • 29.4k
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) + ...
sr_gi's user avatar
  • 3,220
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 ...
Ugam Kamat's user avatar
  • 7,407
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....
Murch's user avatar
  • 75.7k
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 ...
RedGrittyBrick's user avatar
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 ...
RedGrittyBrick's user avatar
5 votes
Accepted

Are all UTXOs locked by an address spent in a transaction?

Transactions explicitly refer to which UTXOs they are spending. You can construct a transaction which only spends one of the two 5-BTC UTXOs, and sends 2 BTC to the destination and 3 BTC to a (...
Pieter Wuille's user avatar
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 ...
skaht's user avatar
  • 3,067
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 ...
Pieter Wuille's user avatar
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 ...
Ava Chow's user avatar
  • 70.7k
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 ...
Nate Eldredge's user avatar
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 ...
Murch's user avatar
  • 75.7k
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 ...
Pieter Wuille's user avatar
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 ...
meshcollider's user avatar
  • 11.8k
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 ...
Murch's user avatar
  • 75.7k
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 ...
Raghav Sood's user avatar
  • 17.1k

Only top scored, non community-wiki answers of a minimum length are eligible