19 votes
Accepted

How do virtual size, stripped size and raw size compare between legacy address formats and native segwit?

Let's compare a 2-input and 2-output transaction for single-sig output types. I'll refer to the byte length of the transaction as "raw size" , the transaction without its witness data as &...
user avatar
  • 64.4k
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 ...
user avatar
  • 5,026
9 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 ...
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 ...
user avatar
7 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. ...
user avatar
  • 62.2k
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 ...
user avatar
  • 64.4k
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 ...
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 ...
user avatar
  • 28.7k
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) + ...
user avatar
  • 2,712
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 ...
user avatar
  • 6,978
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 ...
user avatar
  • 64.4k
5 votes

What order does Bitcoin Core place the inputs it spends in?

The inputs are chosen by the function SelectCoins() in CreateTransaction() and then added one by one (without shuffling) to the transaction. The order is defined by the coin selection (CWallet::...
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 ...
user avatar
5 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....
user avatar
  • 64.4k
5 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. ...
user avatar
  • 62.2k
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 ...
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 ...
user avatar
  • 2,927
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 ...
user avatar
  • 62.2k
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 ...
user avatar
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 ...
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 ...
user avatar
  • 64.4k
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 ...
user avatar
  • 11.4k
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 ...
user avatar
  • 64.4k
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 ...
user avatar
  • 16.5k
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 ...
user avatar
4 votes
Accepted

Reference an UTXO of a transaction that has not been yet mined

The UTXO is referenced as an outpoint(TXID, Index) in the input of your time-locked spending transaction. So, when creating your time-locked transaction, you need to know the TXID of the (unconfirmed)...
user avatar
  • 2,423
4 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 (...
user avatar
4 votes
Accepted

How to get input address and amount from vin using bitcoin core rpc

The address and amount of the sender can be gotten from the 'txid' and 'vout' by using getrawtransaction command. Let's see the example, the vin part of the block is as follows: "vin": [ { "...
user avatar
  • 155
4 votes
Accepted

Is sharing a signed input safe?

Is it possible to decode the private key from a signed input? No. Signatures and public keys are meant to be public. In typical use, using a correct implementation of the signing code, it is ...
user avatar
  • 62.2k
3 votes
Accepted

Processing multiple transactions very fast

I want to send one transaction with 5 BTC to one address and a transaction with 2 BTC to another. The fastest (and cheapest) way to do this is with a single transaction. Many transactions have 2 ...
user avatar
  • 421

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