52 votes
Accepted

My raw transaction destroyed 0.0284377 BTC. What did I do wrong?

Addresses that start with 3... are P2SH addresses, and they've been around for almost 6 years now. Historically they saw limited use - used by multisig wallets like Copay and GreenAddress. The ...
Pieter Wuille's user avatar
12 votes
Accepted

What does a segregated witness transaction look like?

From Bitcoin Core's primitive/transaction.h: /** * Basic transaction serialization format: * - int32_t nVersion * - std::vector<CTxIn> vin * - std::vector<CTxOut> vout * - uint32_t ...
Pieter Wuille's user avatar
11 votes

How does the variable length integer work?

From the Bitcoin forum: The way the variable length integer works is: Look at the first byte If that first byte is less than 253, use the byte literally If that first byte is 253, read ...
Sam Jones's user avatar
  • 191
9 votes
Accepted

How to tell which part of the previous tx I need to make the hash to sign for an old given tx?

Disclaimer: I am going to assume that you are not completely clueless and that you know what an array is, how to count from 0, and how to match brackets, quotes, and colons so that you can read JSON ...
Ava Chow's user avatar
  • 70.2k
8 votes
Accepted

Is it possible to combine two separate transactions into one transaction by only using their signatures?

The only possibility in Bitcoin today is the one described by kaykurokawa. Every signature specifies which inputs and outputs it signs for, so if you want independently-created signatures, it will be ...
Pieter Wuille's user avatar
8 votes
Accepted

What are the hex and asm field values in the JSON decoded from a raw transactions?

asm refers to the de-serialised form of the script, with well-known tokens parsed as script tokens. hex is just the serialised form of the script in hex encoding. If you compare them carefully, ...
rny's user avatar
  • 2,418
8 votes
Accepted

Breaking down a raw transaction:

The bolded byte in the following raw transaction is the number of outputs (two in this transaction): ...
David A. Harding's user avatar
8 votes
Accepted

What is the different between CompactSize and VarInt encoding?

There are two distinct variable-length integer encodings implemented in Bitcoin Core's serialization framework: The encoding used in the P2P protocol for the lengths of vectors (number of ...
Pieter Wuille's user avatar
7 votes
Accepted

How to sign raw transaction given a private key and SHA hash (in java)

This answer does not attempt to sign a transaction, but simply focuses on successfully calling the sign method of the ECKey class, i.e. making your code work. I am not yet familiar with the ...
Sven Williamson's user avatar
7 votes
Accepted

How do I spend bitcoins from multiple wallets in a single transaction?

There are currently three different ways to do this: raw transactions, PSBT in 0.17, and PSBT in 0.18. I recommend that you use PSBT in 0.18 as it is the least hassle, but I will describe all three ...
Ava Chow's user avatar
  • 70.2k
7 votes

what's the point of "n" in "vout"? getrawtransaction

The vout index (n) that you see after calling decoderawtransaction is added by bitcoind. It is not present in the raw transaction data. If you manually decode the serialized tx for your example, you ...
Raghav Sood's user avatar
7 votes
Accepted

what's the point of "n" in "vout"? getrawtransaction

Since it's an array, couldn't you just use the array index? Seems redundant, but i'm sure there's a reason. Thanks Yes, you could. In fact, that is how n is calculated since it isn't actually stored ...
Ava Chow's user avatar
  • 70.2k
7 votes
Accepted

Relation between transaction data and transaction id

Since BIP144, transaction data consists of two parts (normal data and witness data). There are also two distinct transaction serialization formats: The legacy serialization format, which stores ...
Pieter Wuille's user avatar
6 votes

Is it possible to combine two separate transactions into one transaction by only using their signatures?

Yes. But they require the transaction to be signed a certain way. OP_CHECKSIG has settable flags, which determines which of the inputs and outputs are signed. If SIGHASH_SINGLE and ...
k kurokawa's user avatar
  • 2,072
6 votes

How to decode raw tx hex programmatically

This is specified thoroughly on the Bitcoin Wiki. The first 4 bytes are the version number, the next 1-9 bytes are the number of inputs (almost never more than 1 byte) and so on. Programitically, ...
Jimmy Song's user avatar
  • 7,759
6 votes

How would this normal raw transaction appear if it was a raw segwit transaction?

wow, cool question, that's not very easy. Especially as there are different Segwit tx thinkable (native P2WPKH, P2SH-P2WPKH, Native P2WSH, P2SH-P2WSH or one with Bech32 address). Then there is the ...
pebwindkraft's user avatar
  • 5,086
6 votes

HTLC (Hash Time Lock Contract) using bitcoin-qt

The HTLC isn't really a specific type of bitcoin transaction, it is more a specific output script with the required spend conditions. Thus to make an HTLC, you really need to create a custom script ...
meshcollider's user avatar
  • 11.8k
6 votes

How to extract addresses from input in raw transaction

Addresses are associated with output scripts (scriptPubKeys). This information is not encoded in the transaction, the only information in the input is the txid and index of the output that is being ...
Mike D's user avatar
  • 3,569
6 votes
Accepted

Can I send almost 1MB transaction?

Can I send almost 1MB transaction? To be able to send a transaction that a miner will accept, that transaction has to be a standard transaction. As defined in policy.h /** The maximum weight for ...
MCCCS's user avatar
  • 10.2k
6 votes
Accepted

Why raw Bitcoin transaction are in hex format?

Because unlike addresses, hex raw transactions aren't meant to be seen or used by end-users. Hex is easy to encode and decode (every two character in hex represents one byte*, whereas in base64 one ...
MCCCS's user avatar
  • 10.2k
6 votes
Accepted

Function combinerawtransaction is not working

The issue here is that the two transactions are different, and combinerawtransaction does not operate on different transactions (it apparently just silently does nothing). It sounds like you expect ...
Ava Chow's user avatar
  • 70.2k
5 votes
Accepted

What is the "sequence" and its details as referenced for the segwit application?

Sequence is part of any input, before segwit as well. feffffff is the hexadecimal number 0xfffffffe because the bytes need to be reversed. This sequence number, as per BIP 125, is because: Wallets ...
meshcollider's user avatar
  • 11.8k
5 votes
Accepted

How to decode raw transaction which has 00 in '#TxIn' slot?

This is a SegWit transaction, serialized using the new format defined in BIP144. The format is only permitted when at least one of the transaction inputs has a witness, and works as follows: 4-byte ...
Pieter Wuille's user avatar
5 votes
Accepted

Raw transactions - SubtractFeeFromAmount flag

When you create a raw transaction, you must specify all inputs and outputs, and any leftover will go towards the fee (to the miner). The raw transaction does not do any fee calculation. Example ...
JBaczuk's user avatar
  • 7,388
5 votes

How do I sign and send a raw transaction using BitcoinJ?

I'm not an expert in this field by any means (and my error message was different), but I spent last week trying to make Bitcoinj sign a transaction and send in raw form (i.e. without using transport ...
Oleg Kuznetsov's user avatar
5 votes
Accepted

Can a node broadcast a valid signed raw transaction while still syncing?

You can only broadcast transactions if your node has synced to the point that it knows the outputs that were spent. This is because your node will always validate a transaction before it broadcasts it....
Ava Chow's user avatar
  • 70.2k
5 votes
Accepted

Why same output address is invalid in a transaction on Bitcoin Core?

It is not invalid. The code you are looking it is unrelated to validation and relay of actual transactions. You are looking at the code for RPCs which are just things for users. The RPC disallows ...
Ava Chow's user avatar
  • 70.2k
5 votes

Can I be rewarded for discovering, creating, and proving bugs on Bitcoin?

Yes, finding bugs in Bitcoin would be valuable. However this doesn't seem to be one. What's shown here is a series of supposed "signatures" with the hashes of messages they supposedly sign. ...
Murch's user avatar
  • 75k
5 votes
Accepted

Can a signed raw transaction's locktime be changed?

A transaction's locktime is part of the data committed to by the transaction's signatures. If you change it, the signatures become invalid, and so the transaction becomes invalid. If the locktime ...
Vojtěch Strnad's user avatar
5 votes
Accepted

Parsing blk.dat file fails, is this block legitimate?

A. Is this transaction and/or the block legitimate? Yes - assuming you accept the segwit soft fork and resulting option for BIP144 format transaction serialisation. B. If not, why is it in my blk.dat ...
Lee's user avatar
  • 534

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