parseLegacyTx :: MonadGet m => m Tx
parseLegacyTx = do
    v <- getWord32le
    is <- replicateList =<< deserialize
    os <- replicateList =<< deserialize
    when (length is == 0x00 && length os == 0x01) $ fail "Witness transaction"
    l <- getWord32le
    return
        Tx
        { txVersion = v
        , txIn = is
        , txOut = os
        , txWitness = []
        , txLockTime = l
        }
  where
    replicateList (VarInt c) = replicateM (fromIntegral c) deserialize

-- | Witness transaction deserializer.
parseLegacyTx :: MonadGet m => m Tx
parseLegacyTx = do
    v <- getWord32le
    is <- replicateList =<< deserialize
    os <- replicateList =<< deserialize
    when (length is == 0x00 && length os == 0x01) $ fail "Witness transaction"
    l <- getWord32le
    return
        Tx
        { txVersion = v
        , txIn = is
        , txOut = os
        , txWitness = []
        , txLockTime = l
        }
  where
    replicateList (VarInt c) = replicateM (fromIntegral c) deserialize

-- | Witness transaction deserializer.
parseLegacyTx = do
    v <- getWord32le
    is <- replicateList =<< deserialize
    os <- replicateList =<< deserialize
    when (length is == 0x00 && length os == 0x01) $ fail "Witness transaction"
    l <- getWord32le
    return
        Tx
        { txVersion = v
        , txIn = is
        , txOut = os
        , txWitness = []
        , txLockTime = l
        }
  where
    replicateList (VarInt c) = replicateM (fromIntegral c) deserialize

-- | Witness transaction deserializer.