Bitcoinjs-lib: Transaction has unexpected data

Created on 27 Feb 2017  路  8Comments  路  Source: bitcoinjs/bitcoinjs-lib

Hello, I get the following error sometimes decoding transactions when on testnet ... it never happened on mainnet.

Here is the output I get from the angularjs controller:

bundle.js:136 Error: Transaction has unexpected data
at Function.Transaction.fromBuffer (bundle.js:44947)
at Function.Transaction.fromHex (bundle.js:44953)
at Socket.rawtxListener (bundle.js:133)
at bundle.js:572
at bundle.js:25254
at completeOutstandingRequest (bundle.js:11449)
at bundle.js:11728
bundle.js:137 probably a non standard tx - here is the dump of data: 010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff23036da31000fe5536b458fe1b7c0a000963676d696e6572343208000000000000000000ffffffff024f527609000000001976a914c5670ac9cf3ef1b363813e90685b548fb58bd32488ac0000000000000000266a24aa21a9ed5a7bc0d23de922f1b0d15f44f5a73dd54b0fba66ce6da9ac04835d3840b1bcd20120000000000000000000000000000000000000000000000000000000000000000000000000

After investigating the data it is a segwit transaction. Am I using something wrong, or is it a bug?

my code:

var bjs = require("bitcoinjs-lib");

    function rawtxListener(data) {
        try {
            var tx = bjs.Transaction.fromHex(data.data);
        }
        catch (e) {
            console.log(e);
            console.log("probably a non standard tx - here is the dump of data: " + data.data);
            console.log('check agains bitcoind - this is a witness transaction')
            return;
        }
    ...
    }
how to / question / docs

All 8 comments

May be a bug, though I'll check it now

What version are you running? It's a segwit transaction and the version in master hasn't been officially released, you shouldn't be able to decode that yet.

Actually hoping to do some polishing so it can be released in the next few days.. but as of yet, it won't work with a segwit transaction.

installed it using npm

pi@raspbinode:~/raspinodemon $ cat package.json |grep bitcoinjs 
    "bitcoinjs-lib": "^2.3.0"

Ok, so it is an expected behavior then ...

Thanks for looking into it!

No probs. You can be more certain it's a segwit transaction if you check bytes 4 - 5 equals 01 00 when this error occurs, they're marker bytes that (probably) won't change anytime soon. If they match it's segwit, otherwise something else is wrong with your messages :)

cool, thanks for the info :)

Meanwhile I downloaded the master repo and checked if it decodes fine ... it did

@afk11 did we want to do an RC release now for beta testers?

Yeah that might be a nice idea, do we do a dev branch with it?

Anyone who wants to play segwit, the only change is the new output script, and then providing the witness value and witness script to TransactionBuilder.sign

Yeah that might be a nice idea, do we do a dev branch with it?

No need, master is fine for beta releases?
Tagged, obviously.

Anyone who wants to play segwit, the only change is the new output script, and then providing the witness value and witness script to TransactionBuilder.sign

:+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coingeek picture coingeek  路  4Comments

dakk picture dakk  路  3Comments

thrastarson picture thrastarson  路  3Comments

Beardcoding picture Beardcoding  路  3Comments

rbndg picture rbndg  路  3Comments