These are two raw transactions I got from Testnet, using bitcoind -testnet.



When I try to parse these transactions using new bitcore.Transaction(serialized) via Bitcore library, the return value either results in Buffer error or malformed Transaction.

When I refer the Bitcoin doc, the first 4 bytes are assigned to be version, and the following bytes are assigned to be the number of inputs, in the variable length integer format. Variable length integer has the value of uint8_t when its value is less than 0xFD, according to the doc.

Following the rule, above two raw transactions should indicate that these transactions have zero input because it has 01000000, thus 1 in little endian (so it means version 1), which is followed by 00, thus 0 (so it means 0 input) according to the doc.

But when I decode these raw transactions either at BlockCypher or by bitcoin-cli decoderawtransaction, it clearly shows that it has some input and the result seems to be valid. (By querying the tx id or addresses, I can get a valid result too.)

Is there any other way to decode these kind of raw transactions?

1 Answer 1


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 integer nVersion
  • 1-byte dummy (must be 0)
  • 1-byte flags (must be nonzero)
  • vector(transaction inputs)
  • vector(transaction outputs)
  • if (flags & 1): vector(input witnesses) (excluding the length, which is implied by the number of transaction inputs)
  • 4-byte integer nLockTime

The dummy byte is required to be 0, guaranteeing that the transaction cannot be misinterpreted by old software (as by consensus rules, a transaction with 0 inputs is invalid).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.