Skip to content

Commit

Permalink
Merge pull request #7 from rohenaz/test/parse-tx
Browse files Browse the repository at this point in the history
segwit stuff
  • Loading branch information
jadwahab authored Dec 4, 2020
2 parents 7ff5471 + c2a912f commit adc5870
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 0 additions & 5 deletions tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ func NewTxFromStream(b []byte) (*Tx, int, error) {
}
offset += 4

// There is an optional Flag of 2 bytes after the version. It is always "0001" and represent that this is a SegWit tx.
if b[offset] == 0x00 && b[offset+1] == 0x01 {
offset += 2
}

inputCount, size := DecodeVarInt(b[offset:])
offset += size

Expand Down
6 changes: 6 additions & 0 deletions tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ func TestNewTx(t *testing.T) {
func TestNewTxFromString(t *testing.T) {
t.Parallel()

t.Run("valid tx no inputs", func(t *testing.T) {
tx, err := bt.NewTxFromString("01000000000100000000000000001a006a07707265666978310c6578616d706c65206461746102133700000000")
assert.NoError(t, err)
assert.NotNil(t, tx)
})

t.Run("invalid tx", func(t *testing.T) {
tx, err := bt.NewTxFromString("0")
assert.Error(t, err)
Expand Down

0 comments on commit adc5870

Please sign in to comment.