2

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

01000000000101dc82cf0b892b325413ec7b3237e1a122c3114002ccd6e0f0157c8851144c00200100000017160014a530e459b62406b99aa75091bd9eb833a20698a3ffffffff0290f4f700000000001976a9143eabc5342434987e43e5c49f42462689d969c56288ac67baa26f2e00000017a9144d62bfc7376858c8d601c50dc08d8dc8491b27a8870247304402206998883f24133677c46a70e01e70cd9f69ee9059a4d5d82e891b82e797f125000220760a3af0836a9068de63ca0a4cedbb68bc8ea2d067f5cdaf92f2cd4d31703e18012103d8421b44b3d21151a5a2660662bc6ef69a0ef2266bf68b8c56eea715b23a596500000000

0100000000010151df0e2bb6bd3ffa19ae03330b7f89a4a8d6ad93bc204ec7d8cd367e58a10b580100000017160014a03506f19e6851264f21f373bae14023d247d760ffffffff02bc733400000000001976a9143d19e810138ebcb0033c462cf2b5e62a9d7af24588acc4ecca632e00000017a9142f877141344c0202e2f6eb979025d9e3f4f38c6a87024730440220342f74d49243d342a8cd3818e48d8aaf94c71fa41a96863dd986057992650bc202202a7cbe1541941e55abf06fee496c890cce9a2d2fcbb0710fb24342f3b513cd0a0121029e3868ce4a192e0b47f29090c243764e68b4c2c18aa0476272a61b62e3a3804c00000000

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?

4

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, privacy policy and cookie policy

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